Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[main] update ignoreHeaders doc for #2336 #2345

Merged
merged 8 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -398,6 +397,29 @@ Most configuration fields are named such that they can be defaulted to falsey. A
| throttleMgrCfg <br/><sub>since 3.0.3</sub> | `{[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 debug plugin, you would initialize it as follows:
siyuniu-ms marked this conversation as resolved.
Show resolved Hide resolved

```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.
Expand Down
28 changes: 28 additions & 0 deletions extensions/applicationinsights-dependencies-js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
31 changes: 30 additions & 1 deletion shared/AppInsightsCommon/src/Interfaces/ICorrelationConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];

Expand Down
Loading