【问题标题】:Azure Application Insights - trackEvent with custom properties in JavascriptAzure Application Insights - 在 Javascript 中具有自定义属性的 trackEvent
【发布时间】:2021-03-11 12:58:10
【问题描述】:

我们正在使用客户端 javascript SDK(通过 snippet-based 集成)将 Application Insights 用于 track custom events

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

如何向其中添加自定义属性?像这样?!

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

【问题讨论】:

  • 不,该属性是properties 而不是customProperties。这一切都在documentation if you read it
  • 你的意思不是“如果你读过它”,而是“如果你找到它”......无论如何,谢谢
  • @Liam...为什么这里不一样:docs.microsoft.com/en-us/azure/azure-monitor/app/…?
  • 我不知道@GauravMantri,问 MS,他们的文档总是很粗略,尤其是在 Azure 周围。他们似乎很难跟上自己的变化,而文档往往是事后才想到的。许多 Azure 函数文档仍然显示 v1 屏幕,尽管函数 SDK 现在与该版本完全不同。它是开源的,所以如果你对它有强烈的感觉,你可以随时打开 PR

标签: javascript azure azure-application-insights


【解决方案1】:

JS Azure appinsights github page上所见:

自定义属性可以通过 属性命名参数。这可以通过任何 Track 来完成 API。

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2016-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-18
    • 1970-01-01
    相关资源
    最近更新 更多