0
votes

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!

1

1 Answers

1
votes

The 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);

enter image description here