microsoft / microsoft/ApplicationInsights-JS

[BUG] Since release 3.2.0 there are CSP violations attempting to connect to js.monitor.azure.com (using npm not snippet)

Open
#2,341 15 comments 3 reactions 0 assignees View on GitHub
documentation
Dominant language
TypeScript
Stars
685
Forks
261
Avg merge
21h 33m
Merged PRs (30d)
5

Description

**Description/Screenshot**

Since updating to 3.2.0 we are now getting CSP violations connecting to js.monitor.azure.com. This was not happening in 3.1.2. We are using npm and the javascript initialization, not the snippet because we have a policy of not loading scripts from external domains.

image

**Steps to Reproduce**

- OS/Browser: Windows 11/Chrome 124
- SDK Version [e.g. 22]: 3.2.0
- How you initialized the SDK:

using npm package

const appInsights = new ApplicationInsights({
config: { instrumentationKey: appInsightsKey, disableCookiesUsage: true },
})
appInsights.addTelemetryInitializer((envelope) => {
if (envelope.tags) {
envelope.tags['ai.cloud.role'] = 'ui'
}
})
appInsights.loadAppInsights()

**Expected behavior**

applicationinsights-web implemented via npm will not load javascript from an external site

**Additional context**
We have a very strict CSP that blocks loading of scripts from external sites.
This cause a production showstopper for us since it was not listed as a breaking change that external scripts would now be loaded

Contributor guide

Open the contributing guide

Research direction

Start with the npm initialization shown in the issue and compare the 3.1.2 and 3.2.0 browser behavior in Chrome. Trace the request to js.monitor.azure.com and verify that the npm-based SDK no longer attempts to load external JavaScript, while preserving the documented initialization path.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, javascript, typescript
Domain
frontend, observability, security
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
40/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.