microsoft / microsoft/ApplicationInsights-JS
[BUG] Unable to use telemetry initializer to filter calls to retrieve config from js.monitor.azure.com
@siyuniu-ms is already working on this.
Since Feb 11, 2025.
- Dominant language
- TypeScript
- Stars
- 685
- Forks
- 261
- Avg merge
- 21h 33m
- Merged PRs (30d)
- 5
Description
Trying to cut down on the # of 3rd party dependency calls that get logged from our app to keep log volumes down, but ran into difficulties suppressing App Insights' calls to load its own config.
We wind up with at least one dependency call logged per page load for the following URL:
GET https://js.monitor.azure.com/scripts/b/ai.config.1.cfg.json
I tried adding a telemetry initializer to filter dependencies based on hostname, but it looks like the call to fetch the config is made & logged as soon as the ApplicationInsights object is created.
Since addTelemetryInitializer isn't called until after that, there's nothing to prevent the SDK from logging that initial request.
Steps to Reproduce
- OS/Browser: Windows / Edge
- SDK Version: 3.3.4
- How you initialized the SDK:
const config: IConfiguration & IConfig = {
connectionString: connectionString,
enableAutoRouteTracking: true,
enableAjaxPerfTracking: true,
enableAjaxErrorStatusText: true,
enableCorsCorrelation: true,
// Monitor all AJAX calls
maxAjaxCallsPerView: -1,
// Whether or not to disable telemetry
disableTelemetry: disableTelemetry,
};
// This triggers a fetch that gets logged as a dependency
const appInsights = new ApplicationInsights({
config: config,
});
// Filter to exclude traffic is here
appInsights.addTelemetryInitializer(filterDependencyTracking);
const reactPlugin = new ReactPlugin();
appInsights.addPlugin(reactPlugin);
appInsights.loadAppInsights();
Expected behavior
All telemetry events get processed via the telemetry initializer as long as it's registered before calling loadAppInsights.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.