【问题标题】:Azure Application Insights - Using Custom Dimensions and Custom Measurements in Custom Events from JavaScriptAzure Application Insights - 在来自 JavaScript 的自定义事件中使用自定义维度和自定义度量
【发布时间】:2020-11-25 13:23:50
【问题描述】:

我有一个用 JavaScript 编写的单页应用程序。我目前正在使用 JavaScript API 将事件记录到 Azure Application Insights。目前,我正在使用如下代码记录事件:

let eventLog = {
  name: 'Custom Event Name',
  customDimensions: {
    target: 'app'
  },
  customMeasurements: {
    totalTime: '00:00:01.1234'
  }
};

appInsights.trackEvent(eventLog);

当我运行我的代码时,我注意到自定义事件正在写入我的 Application Insights 实例。虽然 Application Insights 中显示了正确的事件名称,但我没有看到任何自定义维度或自定义度量。

如何通过 JavaScript API 将带有自定义事件的自定义维度和自定义度量记录到 Azure Application Insights?

谢谢!

【问题讨论】:

    标签: javascript azure azure-application-insights


    【解决方案1】:

    遥测对象的字段名称应分别为propertiesmeasurements,代码如下。另外,测量项目的值应该是数字。

    let eventLog = {
      name: 'Custom Event Name',
      properties: {
        target: 'app'
      },
      measurements: {
        totalTime: 0.34567
      }
    };
    
    appInsights.trackEvent(eventLog);
    

    【讨论】:

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