【发布时间】:2020-07-31 03:51:45
【问题描述】:
我正在尝试在我的 Angular 8 应用程序中设置 Pendo。但是,他们的文档似乎已关闭。示例脚本与我的 Pendo 控制面板中提供给我的实际脚本不匹配。此外,他们的 YouTube 演练已有 4 年历史,看起来像是为 Angular JS 编写的。
我遵循了位于https://support.pendo.io/hc/en-us/articles/360031862272-Installation-for-Single-Page-Frameworks的文档
我将脚本的第一部分放在 index.html 页面上,就在结束 <body> 标记之前。
然后我将pendo.initialize 放在我的授权组件中。
然而,这并没有奏效。我在浏览器控制台中收到 ERROR TypeError: "pendo.initialize(...) is not a function"。
所以我联系了支持人员,他们建议我使用 ngZone 在 Angular 之外运行 pendo.initialize。
有谁知道需要修改什么来初始化 pendo 而不会出现未定义的错误?
这就是我的结局。
index.html
...
<script>
(function (apiKey) {
(function (p, e, n, d, o) {
var v, w, x, y, z; o = p[d] = p[d] || {}; o._q = [];
v = ['initialize', 'identify', 'updateOptions', 'pageLoad']; for (w = 0, x = v.length; w < x; ++w)(function (m) {
o[m] = o[m] || function () { o._q[m === v[0] ? 'unshift' : 'push']([m].concat([].slice.call(arguments, 0))); };
})(v[w]);
y = e.createElement(n); y.async = !0; y.src = 'https://cdn.pendo.io/agent/static/' + apiKey + '/pendo.js';
z = e.getElementsByTagName(n)[0]; z.parentNode.insertBefore(y, z);
})(window, document, 'script', 'pendo');
})('xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
</script>
</body>
在我的登录组件中
declare let pendo: any;
...
constructor(
private ngZone: NgZone
) {
...
}
...
private onAuthorizationResultComplete(authorizationResult: AuthorizationResult) {
if (authorizationResult.authorizationState === AuthorizationState.unauthorized) {
...
} else {
this.httpClient.post(this.apiUrl, {}).subscribe(r => {
this.ngZone.runOutsideAngular(function () {
pendo.initialize({
visitor: {
id: 'VISITOR-UNIQUE-ID-test'
},
account: {
id: 'ACCOUNT-UNIQUE-ID-test'
}
})('xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx');
});
this.router.navigate(['/dashboard']);
});
}
}
```
【问题讨论】:
-
您是如何解决 IE 无法运行箭头功能的问题的?如果你在 IE 中启动它,它只会出错。我很好奇你是否测试过这个
标签: angular typescript angular8 pendo