diff --git a/README.md b/README.md index a135b5294..235410abf 100644 --- a/README.md +++ b/README.md @@ -376,7 +376,6 @@ Most configuration fields are named such that they can be defaulted to falsey. A | enableAutoRouteTracking | boolean | false | Automatically track route changes in Single Page Applications (SPA). If true, each route change will send a new Pageview to Application Insights. Hash route changes changes (`example.com/foo#bar`) are also recorded as new page views. | enableRequestHeaderTracking | boolean | false | If true, AJAX & Fetch request headers is tracked, default is false. If ignoreHeaders is not configured, Authorization and X-API-Key headers are not logged. | enableResponseHeaderTracking | boolean | false | If true, AJAX & Fetch request's response headers is tracked, default is false. If ignoreHeaders is not configured, WWW-Authenticate header is not logged. -| ignoreHeaders | string[] | ["Authorization", "X-API-Key", "WWW-Authenticate"] | AJAX & Fetch request and response headers to be ignored in log data. To override or discard the default, add an array with all headers to be excluded or an empty array to the configuration. | enableAjaxErrorStatusText | boolean | false | Default false. If true, include response error data text | boolean in dependency event on failed AJAX requests. | enableAjaxPerfTracking | boolean | false | Default false. Flag to enable looking up and including additional browser window.performance timings in the reported ajax (XHR and fetch) reported metrics. | maxAjaxPerfLookupAttempts | numeric | 3 | Defaults to 3. The maximum number of times to look for the window.performance timings (if available), this is required as not all browsers populate the window.performance before reporting the end of the XHR request and for fetch requests this is added after its complete. @@ -398,6 +397,29 @@ Most configuration fields are named such that they can be defaulted to falsey. A | throttleMgrCfg
since 3.0.3 | `{[key: number]: IThrottleMgrConfig}` | undefined | [Optional] Set throttle mgr configuration by key. | | retryCodes | number[] | undefined | Identifies the status codes that will cause event batches to be resent, when `null` or `undefined` the SDK will use it's defaults `[401, 408, 429, 500, 502, 503, 504]`. `403` was removed in version 3.1.1. | +### ExtensionConfig + +`extensionConfig` should be initialized under the specific extension rather than being defined in the root configuration. This allows for more granular configuration tailored to each extension's needs. + +For instance, to configure the dependencies plugin, you would initialize it as follows: + +```js +const appInsights = new ApplicationInsights({ + config: { + connectionString: 'InstrumentationKey=YOUR_INSTRUMENTATION_KEY_GOES_HERE', + extensionConfig: { + [DependenciesPlugin.identifier]: { + ignoreHeaders: [] + } + } + } +}); +``` + +| Name | Type | Default | Extenstion | Description | +|------|------|---------|---------|-------------| +| ignoreHeaders | string[] | ["Authorization", "X-API-Key", "WWW-Authenticate"] | DependenciesPlugin | AJAX & Fetch request and response headers to be ignored in log data. To override or discard the default, add an array with all headers to be excluded or an empty array to the configuration. Need to be defined in depenedency plugin extension config, see more [here](./extensions/applicationinsights-dependencies-js/README.md) + ### ICookieMgrConfig Cookie Configuration for instance based cookie management added in version 2.6.0. diff --git a/extensions/applicationinsights-dependencies-js/README.md b/extensions/applicationinsights-dependencies-js/README.md index 098eaae17..d4cf04586 100644 --- a/extensions/applicationinsights-dependencies-js/README.md +++ b/extensions/applicationinsights-dependencies-js/README.md @@ -20,6 +20,34 @@ npm run build --silent npm run test ``` +## Basic Usage + +### NPM Setup (ignore if using Snippet Setup) + +```js +import { ApplicationInsights } from '@microsoft/applicationinsights-web'; +import { AjaxPlugin } from '@microsoft/applicationinsights-dependencies-js'; + +const dependencyPlugin = new AjaxPlugin(); +const appInsights = new ApplicationInsights({ + config: { + connectionString: 'InstrumentationKey=YOUR_INSTRUMENTATION_KEY_GOES_HERE', + extensions: [dependencyPlugin], + extensionConfig: { + [dependencyPlugin.identifier]: { + ignoreHeaders:[ + "Authorization", + "X-API-Key", + "WWW-Authenticate" + ] + } + } + } +}); +appInsights.loadAppInsights(); +appInsights.trackPageView(); // Manually call trackPageView to establish the current user/session/pageview +``` + ## Contributing This project welcomes contributions and suggestions. Most contributions require you to diff --git a/shared/AppInsightsCommon/src/Interfaces/ICorrelationConfig.ts b/shared/AppInsightsCommon/src/Interfaces/ICorrelationConfig.ts index 05f168e9d..ea1331f97 100644 --- a/shared/AppInsightsCommon/src/Interfaces/ICorrelationConfig.ts +++ b/shared/AppInsightsCommon/src/Interfaces/ICorrelationConfig.ts @@ -44,7 +44,36 @@ export interface ICorrelationConfig { correlationHeaderDomains?: string[]; /** - * Response and request headers to be excluded from ajax tracking data. + * [Optional] Response and request headers to be excluded from AJAX & Fetch tracking data. + * To override or discard the default, add an array with all headers to be excluded or + * an empty array to the configuration. + * + * For example: `["Authorization", "X-API-Key", "WWW-Authenticate"]` + * + * @example + * ```js + * import { ApplicationInsights } from '@microsoft/applicationinsights-web'; + * import { AjaxPlugin } from '@microsoft/applicationinsights-dependencies-js'; + * + * const dependencyPlugin = new AjaxPlugin(); + * const appInsights = new ApplicationInsights({ + * config: { + * connectionString: 'InstrumentationKey=YOUR_INSTRUMENTATION_KEY_GOES_HERE', + * extensions: [dependencyPlugin], + * extensionConfig: { + * [dependencyPlugin.identifier]: { + * ignoreHeaders: [ + * "Authorization", + * "X-API-Key", + * "WWW-Authenticate" + * ] + * } + * } + * } + * }); + * appInsights.loadAppInsights(); + * appInsights.trackPageView(); // Manually call trackPageView to establish the current user/session/pageview + * ``` */ ignoreHeaders?: string[];