microsoft / microsoft/ApplicationInsights-JS

Is there a way to detect if AI tracking is blocked by browser extension?

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

Description

**Is your feature request related to a problem? Please describe.**

There is evidence that Application Insights tracking is being blocked by a 3rd party browser extension such as Ad Blocker or Privacy Badger. Is there a method to detect when this is happening?

**Describe the solution you'd like**

When I reproduce the blocking with Privacy Badger I get the following in my JS console --

POST https://dc.services.visualstudio.com/v2/track net::ERR_BLOCKED_BY_CLIENT

I'd like to be able to implement a listener that will fire when this happens in order to give instructions to the user to disable their blocker. This would be ideal to implement on the NotificationManager like so:

const notificationManager = new NotificationManager();
notificationManager.addNotificationListener({
trackingBlocked: events => {
console.log('Tracking is blocked by your browser or browser extension. Events not tracked.. ', events);
},
});
appInsights.loadAppInsights(false, undefined, notificationManager);

**Describe alternatives you've considered**

Intercepting calls to XMLHttpRequest.send. The custom onerror handler is called but the event object does not contain any info about the error --

const savedSend = XMLHttpRequest.prototype.send;
XMLHttpRequest.prototype.send = function (data) {
this.onerror = event => {
console.log('ERROR!..', event, this);
};
savedSend.call(this, data);
};

**Additional context**
Add any other context or screenshots about the feature request here.

Contributor guide

Open the contributing guide

Research direction

Start by reviewing NotificationManager and the XMLHttpRequest.send/onerror path described in the issue, including requests to dc.services.visualstudio.com/v2/track. Determine whether blocked requests can be distinguished reliably; done means defining and implementing the requested tracking-blocked notification behavior, or documenting the browser limitations if detection is not possible.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
analytics, observability
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.