Reputation: 9490
I am trying to use AppInsights with 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
}, { });
I ran into two issues with this code:
I tried to look into the source code of the module for AppInsights (applicationinsights-js), but could not find a solution.
Thank you for any advice.
Upvotes: 1
Views: 871
Reputation: 29985
an exception is not tracked at all in app insights using this code
Please check if disableExceptionTracking is set to true or false.
a page view is tracked, but it does not contain the custom properties
you should try to add properties like below:
AppInsights.trackPageView(name, url, properties:{
UserName: userName,
ViewName: url
}, { });
And also please try to use @microsoft/applicationinsights-web packages.
Upvotes: 2