最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Azure Application Insights - Using Custom Dimensions and Custom Measurements in Custom Events from JavaScript - Stack Overflow

programmeradmin8浏览0评论

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 badges
Add a ment  | 

1 Answer 1

Reset to default 5

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

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论