How to send 'Application Version' with client side application insights using javascript?

时间:2017-06-15 10:13:53

标签: javascript webforms azure-application-insights telemetry

We can send 'application version' property with every insight in c# like in this tutorial by adding a initializer.

    class AppVersionTelemetryInitializer : Microsoft.ApplicationInsights.Extensibility.ITelemetryInitializer
{
    public void Initialize(Microsoft.ApplicationInsights.Channel.ITelemetry telemetry)
    {
        telemetry.Context.Component.Version = ApplicationInsightsHelper.ApplicationVersion;
    }
}

https://blogs.msdn.microsoft.com/visualstudioalm/2015/01/07/application-insights-support-for-multiple-environments-stamps-and-app-versions/

How can I do this with javascript?

2 个答案:

答案 0 :(得分:0)

您可以制定应用版本/代码,并通过trackpageview以自定义属性或指标发送。

无法使用配置文件,但可以为网页中的每个版本维护枚举或某些键/值对。在Azure门户AI刀片或API调用中切割自定义参数。

答案 1 :(得分:0)

如果您使用@microsoft/applicationinsights-web SDK(用于客户端Javascript),则可以通过以下方式设置应用程序版本:

const appInsights = new ApplicationInsights(...);
appInsights.loadAppInsights();  // important, otherwise the `application` object is missing
appInsights.context.application.ver = "YOUR_VERSION_HERE";

通过这种方式,您将能够在仪表板中按应用程序版本深入分析指标。