Reputation: 141
I have installed the front-end for azure application insights to track events on my application. My application uses web-pack for its front end. I cant see any event being tracked when I use the NPM setup but everything works fine when I use the Snippet Setup. The error I am getting in the browser is:
AI (Internal): 24 message:"Missing required field specification. The field is required but not present on source" props:"{field:exceptions,name:baseData}"
this is described in the documentation https://github.com/microsoft/ApplicationInsights-JS#configuration
I am missing something ?
Upvotes: 5
Views: 1339
Reputation: 93
One place this can happen is when calling trackException with an exception variable that isn't an instanceof an Error, see: https://github.com/microsoft/ApplicationInsights-JS/blob/d3abfe4138d0cfd624f72288c14e73b0b4849f3b/shared/AppInsightsCommon/src/Telemetry/Exception.ts#L39
The documentation infers to do exception: new Error(...) and doing that fixes this issue.
One way you can reproduce this is if you do:
trackException({
exception: error
})
where error could be something like:
{
message: 'some error',
stack: 'some stack'
}
Which is an object and not an instanceof an Error.
Upvotes: 2
Reputation: 141
it turned out that adding trackPageView method was the answer
import { ApplicationInsights } from '@microsoft/applicationinsights-web';
const appInsights = new ApplicationInsights({
config: {
instrumentationKey: 'key',
},
});
appInsights.loadAppInsights();
appInsights.trackPageView({});
Upvotes: 1