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

Azure Application Insights - trackEvent with custom properties in Javascript - Stack Overflow

programmeradmin0浏览0评论

We are using the client-side javascript SDK (via the snippet-based integration) for Application Insights to track custom events

appInsights.trackEvent({name:"WinGame"});

How can I add custom properties to this? Something like this?!

appInsights.trackEvent({name:"WinGame", customProperties:{gameName:"Game 1", player:"my player 1"}});

We are using the client-side javascript SDK (via the snippet-based integration) for Application Insights to track custom events

appInsights.trackEvent({name:"WinGame"});

How can I add custom properties to this? Something like this?!

appInsights.trackEvent({name:"WinGame", customProperties:{gameName:"Game 1", player:"my player 1"}});
Share Improve this question asked Mar 11, 2021 at 12:58 silentsilent 16.3k7 gold badges57 silver badges112 bronze badges 6
  • No, the property is properties not customProperties. This is all in the documentation if you read it – Liam Commented Mar 11, 2021 at 13:09
  • you dont mean "if you read it" but "if you find it"...thanks anyway – silent Commented Mar 11, 2021 at 13:15
  • @Liam...Why it is different here: learn.microsoft./en-us/azure/azure-monitor/app/…? – Gaurav Mantri Commented Mar 11, 2021 at 13:22
  • I don't know @GauravMantri , ask MS, their docs are always sketchy, especially around Azure. They seem to struggle to keep up with their own changes and documentation is often an after thought. A lot of the Azure function docs are still showing v1 screens despite the function SDK now being totally different since that incarnation. It's open source so you can always open a PR if you feel that strongly about it – Liam Commented Mar 11, 2021 at 13:38
  • 1 I've submitted an issue on that document – Liam Commented Mar 11, 2021 at 14:10
 |  Show 1 more ment

1 Answer 1

Reset to default 4

As seen on the JS Azure appinsights github page:

Custom properties can be included in your telemetry through the properties named argument. This can be done with any of the Track APIs.

appInsights.trackEvent({   
    name: 'some event',  
    properties: { // accepts any type
       prop1: 'string',
       prop2: 123.45,
       prop3: { nested: 'objects are okay too' }   
    } 
}); 
发布评论

评论列表(0)

  1. 暂无评论