gpt4 book ai didi

angular - 如何将 AppInsights 与 Angular 结合使用?

转载 作者:行者123 更新时间:2023-12-02 08:32:29 25 4
gpt4 key购买 nike

我正在尝试将 AppInsights 与 Angular 结合使用:

import { AppInsights } from 'applicationinsights-js';

....

if (!AppInsights.config) {
var config: Microsoft.ApplicationInsights.IConfig = {
instrumentationKey: environment.appInsightsInstrumentationKey
};

AppInsights.downloadAndSetup(config);
}

// code for logging exception:
AppInsights.trackException(errorMessage, "GlobalErrorHandler", {
UserName: userName,
ViewName: url
}, { }, AI.SeverityLevel.Error);

// code for logging page views
AppInsights.trackPageView(name, url, {
UserName: userName,
ViewName: url
}, { });

我在使用这段代码时遇到了两个问题:

  1. 使用此代码在应用洞察中根本不会跟踪异常,并且
  2. 跟踪页面 View ,但它不包含自定义属性。

我尝试查看 AppInsights (applicationinsights-js) 模块的源代码,但找不到解决方案。

感谢您的建议。

最佳答案

an exception is not tracked at all in app insights using this code

请检查是否disableExceptionTracking设置为 true 或 false。

a page view is tracked, but it does not contain the custom properties

您应该尝试添加 properties如下所示:

AppInsights.trackPageView(name, url, properties:{
UserName: userName,
ViewName: url
}, { });

并且请尝试使用@microsoft/applicationinsights-web包。

关于angular - 如何将 AppInsights 与 Angular 结合使用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59611787/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com