Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 950
Akila Avatar asked Jun 15 '17 10:06

Akila


1 Answers

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.

like image 154
Andrea Spadaccini Avatar answered Oct 12 '22 12:10

Andrea Spadaccini