简体   繁体   English

如何在 mPulse Boomerang 中为 Angular 应用程序注册软导航更改?

[英]How to register soft-navigation changes in mPulse Boomerang for an Angular app?

The BOOMR.plugins.Angular plugin seems to be used for AngularJS 1.x and so far I failed to find a Angular example or plugin I could use. BOOMR.plugins.Angular 插件似乎用于AngularJS 1.x ,到目前为止我找不到Angular示例或我可以使用的插件。 Based on the docs I came up with the following solution:根据文档,我提出了以下解决方案:

@Injectable()
export class BoomerangBootstrapService implements OnAppInit {
    constructor(private router: Router) {}

    onAppInit() {
        const boomr = window['BOOMR'];
        const callbacks = {};

        this.router.events.subscribe((e) => {
            if (!boomr) {
                return;
            }
            if (e instanceof NavigationStart) {
                boomr.plugins.SPA.last_location(e.url);
                const callback = () => {
                    boomr.plugins.SPA.markNavigationComplete();
                };
                callbacks[e.url] = callback;
                boomr.plugins.SPA.route_change(callback, []);
            } else if (e instanceof NavigationEnd || e instanceof NavigationCancel || e instanceof NavigationError) {
                const callback = callbacks[e.url];
                if (callback) {
                    callback();
                    delete callbacks[e.url];
                }
            }
        });
    }
}

When I insert a helper diagnostics script using the browser console to debug the calls I can see that the registration is correct but I don't see any data being submitted on navigation.当我使用浏览器控制台插入帮助diagnostics script来调试调用时,我可以看到注册是正确的,但我没有看到在导航中提交的任何数据。

diagnostics script:诊断脚本:

(function(spa) {
  'use strict';
  var rc = spa.route_change;
  var ll = spa.last_location;
  var cm = spa.markNavigationComplete;

  spa.last_location = function(url) {
    console.log('last route url was ' + url);
    ll(url);
  };

  spa.route_change = function(c, o) {
    console.log('route_change start');
    rc(c, o);
  };

  spa.markNavigationComplete = function() {
    console.log('route_change completed');
    cm();
  };
})(window.BOOMR.plugins.SPA);

Am I doing something wrong?难道我做错了什么? Do I need to create a custom plugin or call additional methods?我需要创建自定义插件或调用其他方法吗? Could you point me to a working code example or plugin git project?你能给我指出一个工作代码示例或插件 git 项目吗?

There is no need now to instrument anything in your Angular app.现在无需在您的 Angular 应用程序中检测任何内容。 From Boomerang version 1.632 all SPAs are supported with simply checking the从 Boomerang 版本 1.632 开始,只需检查

Enable Single Page App (SPA) monitoring启用单页应用程序 (SPA) 监控

Docs available here此处提供的文档

https://developer.akamai.com/tools/boomerang/?language=en_US?language=en_US#single-page-apps https://developer.akamai.com/tools/boomerang/?language=en_US?language=en_US#single-page-apps

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM