[BUG]: Getting Error `AI (Internal): 24 message:"Missing required field specification. The field is required but not present on source" props:"{field:id,name:baseData}"`
Description/Screenshot On logging custom messages on Application Insights, I am getting below error
AI (Internal): 24 message:"Missing required field specification. The field is required but not present on source" props:"{field:id,name:baseData}"
Steps to Reproduce
- How you initialized the SDK: Application Insights JavaScript (Web) SDK
Expected behavior
it should not log this error on Application Insights.
How are you using the SDK, the baseData is a required field by the back end, if we didn't log the error here it would cause the telemetry to fail to send...
Here is the only location where we report this critical error https://github.com/microsoft/ApplicationInsights-JS/blob/4bb6caa1d5acf5eb945ee83ac280fa0cdc31a9cd/channels/applicationinsights-channel-js/src/Serializer.ts#L74-L78
Can you provide a JSON dump of the telemetry you are trying to report so that we can check if this is a special case that we need to handle?
We are using the Snippet Setup to initialise the it which is mentioned in link
https://github.com/Microsoft/ApplicationInsights-JS?tab=readme-ov-file#snippet-setup-ignore-if-using-npm-setup
we are calling below function to add telemetry and we are able to see this in Application insights with error.
appInsights.trackPageView({ name: "Landing page" })
Also we are using click analytics plugin in our application
below request is seen in the network tab from the javascript SDK.
{ "time": "2025-01-28T05:22:48.959Z", "iKey": "****-1cea-****-bfe2-cfdb689937f6", "name": "Microsoft.ApplicationInsights.666216d21cea473fbfe2cfdb689937f6.Message", "tags": { "ai.user.id": "***************", "ai.session.id": "***********", "ai.device.id": "browser", "ai.device.type": "Browser", "ai.operation.name": "/", "ai.operation.id": "***************", "ai.internal.sdkVersion": "javascript:3.3.4_ClickPlugin2.6.2", "ai.internal.snippet": "8", "ai.internal.sdkSrc": "https://js.monitor.azure.com/scripts/b/ai.3.gbl.min.js" }, "data": { "baseType": "MessageData", "baseData": { "ver": 2, "message": "AI (Internal): 24 message:\"Missing required field specification. The field is required but not present on source\" props:\"{field:id,name:baseData}\"", "properties": {} } } }
@kishor-dabi do you mind sharing your config and when do you call the trackPageview? Based on the code, baseData.id is required for pageview events, and it is set when we create data envelop https://github.com/microsoft/ApplicationInsights-JS/blob/9a1e749ab578e82ff18747facd9c0243e48141aa/channels/applicationinsights-channel-js/src/EnvelopeCreator.ts#L280-L285 so if none id can be retrieved from the original telemetry item, it will be default to trace id. So I assume your pageview might be called before the sdk is fully initialized.
@Karlie-777 please find below configuration object
{
connectionString: window.connectionString,
enableAutoRouteTracking: true,
extensions: [
clickPluginInstance
],
extensionConfig: {
[clickPluginInstance.identifier] : {
autoCapture: true,
dataTags: {
useDefaultContentNameOrId: true
}
}
},
}
@kishor-dabi I am curious why the {...autocaputure : true} is at the extensions sections? and dataTags config is duplicated inside extensionConfig? (i assume it might the formatting issue)
one example of config:
{
connectionString: ...,
...
extensions: [clickAnalyticsInstance],
extensionConfig: {
[clickAnalyticsInstance.identifier]: {
dataTags: {
useDefaultContentNameOrId : ...
....
}
}
}
}
Yes, it was formatting issue. I have updated the config