7
votes

The Application Insights extensions in Visual Studio and Azure appear to inject the javascript snippet for page view tracking automatically, even though the docs say you enable this with an Application Setting key "APPINSIGHTS_JAVASCRIPT_ENABLED" = true.

Other docs show how to add the same javascript in my layout view, which I did. As a result I'm now seeing the AI javascript twice, once from my view, once from the AI magic. I'd prefer to control this myself -- how can I prevent the tooling from modifying the pages to inject the script? Setting APPINSIGHTS_JAVASCRIPT_ENABLED to false doesn't seem to work.

I'm working in an ASP.NET Core 2.0 web application.

1
so you're saying that with the setting set to false, you're still seeing the AI javascript twice? once from you and once auto generated? any docs having you add it yourself are probably for cases where you're deploying somewhere other than azure, so the setting won't work, or are for a previous version of asp.net where support for the setting didn't exist.John Gardner
i see other discussion here: azure.microsoft.com/en-us/blog/… about this setting. maybe the existance of the setting is enough to get injection? it looks like the setting adds rewrite rules to webconfig, possibly turning it "off" doesn't remove those rules?John Gardner
I can confirm the auto-injection still happens if the setting value is "false".Noah Stahl
what happens if you remove the setting completely instead of switching it to false?John Gardner
I'm seeing this behaviour as well. I have upgraded to ApplicationInsights 2.2.1 and still seeing it manifest.Sam

1 Answers

2
votes

Try upgrading to the lastest version of Microsoft.ApplicationInsights.AspNetCore. They released a new version (2.2.0) today, which resolved the problem for me! The javascript part is not added automatically anymore!