首页 > 解决方案 > Application Insights 在 trackException 方法中重复记录异常

问题描述

我有 Angular 5 Web App,我在其中配置了 1.0.20 版(applicationinsights-js)的 Application Insights js。[ https://www.npmjs.com/package/applicationinsights-js]

由于大量用户受到影响,我们的 Production Application Insights 中持续记录了以下异常。

Application Insights 在其自己的程序集“ https://az416426.vo.msecnd.net/scripts/a/ai.0.js ”中重复记录trackException方法中的异常

在此处输入图像描述

//This is my ApplicationInsightsService Angular service. 

export class ApplicationInsightsService {
ikey: string;

constructor(private http: HttpClient) {
this.initializeApplicationInsights();
}

public initializeApplicationInsights() {
if (sessionStorage.getItem('ikey')) {
AppInsights.downloadAndSetup({ instrumentationKey: sessionStorage.getItem('ikey') });
}
}

//Track an exception in Appinsights
public logException(e: Error, handledAt?: string, properties?: any, measurements?: any) {
AppInsights.trackException(e, handledAt, properties, measurements);
}

}
`

//And In Angular, I have Global Error Handler,
//where we logged the Exceptions.


const applicationInsightsService = this.injector.get(ApplicationInsightsService);
applicationInsightsService.logException(error);

标签: angularazure-application-insightsazure-application-insights-profiler

解决方案


推荐阅读