我有 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);