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

2

7

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?

Dispend answered 15/6, 2017 at 10:13 Comment(0)
D
4

If you are using the @microsoft/applicationinsights-web SDK (for client-side Javascript), you can set the application version in this way:

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

This way, you'll be able to drill down into metrics by application version in the dashboards.

Datnow answered 2/6, 2020 at 21:32 Comment(0)
M
0

You can formulate the App version/Tags and send it in custom property or metrics via trackpageview.

Config file is not possible, but enum or some key/value pair can be maintained for each release in webpages & slice the custom param in Azure portal AI blade or API calls.

Moonmoonbeam answered 16/6, 2017 at 4:55 Comment(1)
There's a standard way of sending the Application Version. It shows "undefined" in Azure unless you set it yourself. That way you can segment by Application Version. The poster wants to know how to configure this setting in JavaScript client-side.Girardi

© 2022 - 2024 — McMap. All rights reserved.