Skip to content
Advertisement

How to process tracked information in Application Insights

I am using Application Insights to track events in my web pages:

appInsights.trackEvent("my-event", { test: true });

However I can see that each entry in the log, collects some info regarding several other things like:

  • User Id
  • Session Id
  • Operation name

The last one is sensitive as I can get the name of the computer or some other stuff. In order to comply to the GDPR, I wanna strip out those info from my log.

How do I tell Application Insights, to process the data before logging them? In my case, I would like to get access to the object which will be sent out by trackEvent and modify it before it is transmitted.

Advertisement

Answer

You can use TelemetryInitializers for that. They allow you to modify items before they are send to Application Insights

In your case it could be as simple as

appInsights.queue.push(function () {
    appInsights.context.addTelemetryInitializer(function (envelope) {
        envelope.tags['ai.operation.name'] = 'xxx';
});
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement