ApplicationInsights-JS icon indicating copy to clipboard operation
ApplicationInsights-JS copied to clipboard

[BUG] excludeRequestFromAutoTrackingPatterns values are not properly excluding dependencies

Open vanpyrzericj opened this issue 4 years ago • 1 comments

Description/Screenshot It is my understanding that excludeRequestFromAutoTrackingPatterns can be used to exclude certain AJAX/XHR/Fetch requests (which show up as Dependencies in App Insights dashboards) from being tracked. I have several third-party analytics platforms that regularly send telemetry every few seconds, and are cluttering things up.

image

Steps to Reproduce Using the following configuration:

{
        instrumentationKey: '123123',
        autoTrackPageVisitTime: true,
        distributedTracingMode: DistributedTracingModes.W3C,
        correlationHeaderDomains: ['*.myappdomain.com'],
        disableFetchTracking: false,
        enableCorsCorrelation: true,
        enableAjaxPerfTracking: true,
        enableAjaxErrorStatusText: true,
        enableRequestHeaderTracking: true,
        enableResponseHeaderTracking: true,
        excludeRequestFromAutoTrackingPatterns: [/^((?!myappdomain).)*$/gm],
        correlationHeaderExcludePatterns: [/^((?!myappdomain).)*$/gm],
}
  • OS/Browser: All
  • SDK Version [e.g. 22]: 2.7.2
  • How you initialized the SDK: pulling from npm, initializing in VueJS app

Expected behavior All requests that do NOT go to api.mydomain.com would be excluded in AI telemetry and do not show up as dependencies (being matched by the pattern of /^((?!stagehub).)*$/gm

Additional context Examples of calls that are being tracked (see screenshot above):

app.posthog.com
bam.nr-data.com
pub.highlight.run

I may be misunderstanding the difference between correlationHeaderDomains and correlationHeaderExcludePatterns

vanpyrzericj avatar Jan 08 '22 03:01 vanpyrzericj

Looking at your regex and the code that "excludes" the dependencies, I believe that this is correct. i.e. excludeRequestFromAutoTrackingPatterns means do not report matching entries as dependencies.

Are you using fetch or XHR requests?

This is where the code processes the provided config https://github.com/microsoft/ApplicationInsights-JS/blob/master/extensions/applicationinsights-dependencies-js/src/ajax.ts#L567-L576

Can you try debugging an unminified version of your VueJS App? as that would be useful to determine

  • Is the config being initialized correctly (i.e. isit being passed down to this code)
  • Is there something about how the request is being called that is causing the theUrl to not be the expected value.

MSNev avatar Jan 11 '22 22:01 MSNev

This Issue will be closed in 30 days. Please remove the "Stale" label or comment to avoid closure with no action.

github-actions[bot] avatar Nov 08 '22 07:11 github-actions[bot]

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

github-actions[bot] avatar Dec 10 '23 00:12 github-actions[bot]