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
notcustomProperties
. 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
1 Answer
Reset to default 4As 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' } } });