I have a single page application written with JavaScript. I am currently logging events to Azure Application Insights using the JavaScript API. At this time, I am logging events using code that looks like this:
let eventLog = {
name: 'Custom Event Name',
customDimensions: {
target: 'app'
},
customMeasurements: {
totalTime: '00:00:01.1234'
}
};
appInsights.trackEvent(eventLog);
When I run my code, I notice that custom events are being written to my Application Insights instance. While the correct event name is shown in Application Insights, I do not see any custom dimensions or custom measurements.
How do I log custom dimensions and custom measurements with custom events to Azure Application Insights via the JavaScript API?
Thank you!
I have a single page application written with JavaScript. I am currently logging events to Azure Application Insights using the JavaScript API. At this time, I am logging events using code that looks like this:
let eventLog = {
name: 'Custom Event Name',
customDimensions: {
target: 'app'
},
customMeasurements: {
totalTime: '00:00:01.1234'
}
};
appInsights.trackEvent(eventLog);
When I run my code, I notice that custom events are being written to my Application Insights instance. While the correct event name is shown in Application Insights, I do not see any custom dimensions or custom measurements.
How do I log custom dimensions and custom measurements with custom events to Azure Application Insights via the JavaScript API?
Thank you!
Share Improve this question asked Nov 25, 2020 at 13:23 DevDev 1,2234 gold badges19 silver badges40 bronze badges1 Answer
Reset to default 5The field names of the telemetry object should be properties
and measurements
respectively in code as below. Also, value of measurements items should be number.
let eventLog = {
name: 'Custom Event Name',
properties: {
target: 'app'
},
measurements: {
totalTime: 0.34567
}
};
appInsights.trackEvent(eventLog);