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

[BUG] disableCorrelationHeaders does not work as expected

Open krystofmatejka opened this issue 1 year ago • 2 comments

Description/Screenshot

Documentation for disableCorrelationHeaders attribute says

If false, the SDK adds two headers ('Request-Id' and 'Request-Context') to all dependency requests to correlate them with corresponding requests on the server side. Default is false.

But the mentioned header Request-Id is sent only if attribute enableCorsCorrelation is set to true and Request-Context is sent only if enableCorsCorrelation is set to true and appId is not undefined.

Steps to Reproduce

  • OS/Browser: win 11, edge
  • SDK Version [e.g. 22]: "@microsoft/applicationinsights-clickanalytics-js": "^3.2.1"
  • How you initialized the SDK: npm

Expected behavior

I expect that Request-Id and Request-Context will be sent when disableCorrelationHeaders is false.

krystofmatejka avatar May 15 '24 18:05 krystofmatejka

The current logic (by design) for the two configs is:

  1. if disableCorrelationHeaders is set to true, regardless of other settings, correlation headers will not be added.
  2. if disableCorrelationHeaders is set to false and enableCorsCorrelation is set to false, correlation headers will not be added.
  3. if disableCorrelationHeaders is set to false and enableCorsCorrelation is set to true, correlation headers will be added based on correlationHeaderExcludePatterns, correlationHeaderDomains and correlationHeaderExcludedDomains

Karlie-777 avatar May 16 '24 20:05 Karlie-777

thank you for clarification

krystofmatejka avatar May 17 '24 07:05 krystofmatejka