SDK事件(Node.js)
最近更新: 2024年7月20日
创建对象:
- undefined
描述
在初始化SDK时,options.events
对象是可选对象,具有事件名称键和回调函数值。 它可用于订阅SDK内发生的各种事件。 例如,clientReady
事件可与回调函数一起使用,在SDK准备好进行方法调用时将调用该回调函数。
调用回调函数时,将传入一个事件对象。 每个事件都有一个与事件名称对应的type
。 某些事件包含其他属性及相关信息。
事件
事件名称(类型) | 描述 | 其他事件属性 |
---|---|---|
clientready | 在下载工件并且SDK准备好进行getOffers 调用时发出。 建议在使用设备上决策方法时使用该选项。 | |
artifactDownloadSucceeded | 每次下载新工件时发出。 | artifactPayload, artifactLocation |
artifactDownloadFailed | 每次未能下载工件时发出。 | artifactLocation,错误 |
示例
Node.js
const targetClient = TargetClient.create({
client: "acmeclient",
organizationId: "1234567890@AdobeOrg",
decisioningMethod: "on-device",
events: {
clientReady: onTargetClientReady,
artifactDownloadSucceeded: onArtifactDownloadSucceeded,
artifactDownloadFailed: onArtifactDownloadFailed
}
});
function onTargetClientReady() {
// make getOffers requests
targetClient.getOffers({...})
}
function onArtifactDownloadSucceeded(event) {
console.log(`The artifact was successfully downloaded from '${event.artifactLocation}'`);
// optionally do something with event.artifactPayload, like persist it
}
function onArtifactDownloadFailed(event) {
console.log(`The artifact failed to download from '${event.artifactLocation}' with the following error message: ${event.error.message}`);
}
Target
- Adobe Target开发人员指南
- 快速入门
- 客户端实施
- 概述:为客户端 Web 实施 Target
- Adobe Experience Platform Web SDK实施概述
- at.js 实施
- at.js概述
- at.js 的工作原理
- 如何部署 at.js
- 设备上决策
- at.js 函数
- at.js 函数概述
- adobe.target.getOffer()
- adobe.target.getOffers() - at.js 2.x
- adobe.target.applyOffer()
- adobe.target.applyOffers() - at.js 2.x
- adobe.target.triggerView() - at.js 2.x
- adobe.target.trackEvent()
- mboxCreate() - at.js 1.x
- targetGlobalSettings()
- mboxDefine() 和 mboxUpdate() - at.js 1.x
- targetPageParams()
- targetPageParamsAll()
- registerExtension() - at.js 1.x
- sendNotifications() - at.js 2.1
- at.js 自定义事件
- 使用 Adobe Experience Cloud Debugger 调试 at.js
- 结合使用基于云的实例和 Target
- at.js 常见问题解答
- at.js 版本详细信息
- 从 at.js 1.x 升级到 at.js 2.x
- at.js Cookie
- 用户代理和客户端提示
- 了解全局 mbox
- 服务器端实现
- 混合实施
- Recommendations实施
- 移动应用实施
- 电子邮件实施
- API指南
- 实施模式