I have an Angular application which I have configured to use the Application Insights JS SDK. I want to modify the session ID at certain times, which is important to the way I log sessions in my application.
The documentation suggests I add Telemetry initializers as follows; https://github.com/microsoft/ApplicationInsights-JS#telemetry-initializers
var telemetryInitializer = (envelope) => {
envelope.tags["ai.cloud.role"] = "your role name";
envelope.tags["ai.cloud.roleInstance"] = "your role instance";
}
appInsights.addTelemetryInitializer(telemetryInitializer);
How could this be done to change the session ID?
I went through the docs to see if there are any keys to access to overwrite the session ID, I couldn't find anything there.
So I figured out how to do it, I was able to look at the request payloads and get the key to edit the session ID for telemetry.
var telemetryInitializer = (envelope) => {
envelope.tags["ai.session.id"] = "my session id";
}
appInsights.addTelemetryInitializer(telemetryInitializer);