github microsoft/ApplicationInsights-JS 2.0.1

latest releases: 3.2.0, nightly-240412-01, nightly-240410-01...
4 years ago

trackException Change

This update has a couple of non-breaking API changes. Namely, trackException is now consistent with the Node.js SDK. The only change here is the named argument is renamed from error to exception. A shim is in place so any existing usages of trackException will still work, and the old field is marked as optional, so any type-checked files will still "compile". There are no breaking changes with this change, but you are encouraged to use exception as your named argument field as error will be deprecated in a future major version.

Old

appInsights.trackException({ error: new Error() });

New

appInsights.trackException({ exception: new Error() });

Correlation Header Domain Whitelisting #869

Second, the ability to only send correlation headers to specific, whitelisted domains is now available as a configuration option , correlationHeaderDomains. It accepts an array of domain strings. Wildcards ("*") are okay. By populating this array, all other domains which your application makes requests to will not have correlation headers included. This setting makes it easy to avoid OPTIONS requests to services outside of your control.

You can use the inclusion list and the exclusion list in conjunction with each other to add correlation headers to a particular domain, example.com, and at the same time exclude headers from a prefixed version of it, no-headers.example.com.

Tag Override Change #903

Performing custom tag overrides is now more consistent with all of the other Application Insights SDKs, in that it is modified via a simple key-value dictionary. There are no breaking changes with this update, and if you are setting any tags via the old way, they will still work as they do now. You are encouraged to update them since the old way will be deprecated in a future major version release.

Old

var telemetryInitializer = (item) => {
  item.tags.push({ "ai.cloud.role": "My Web App" });
};
appInsights.addTelemetryInitializer(telemetryInitializer);

New

var telemetryInitializer = (item) => {
  item.tags["ai.cloud.role"] = "My Web App";
};
appInsights.addTelemetryInitializer(telemetryInitializer);

Changelog

#869 - config: add ability to whitelist specific domains for adding correlation headers
#893 - docs: fix sample configuration settings
#899 - common: replace Array.some with Array.forEach to simplify polyfill story, add tests
#902 - snippet: add missing methods to lazy loaders
#903 - tags can now be set with same API as other AI SDKs
#904 - rename IExceptionTelemetry.error --> IExceptionTelemetry.exception
#905 - react: fix plugin causing jest tests to fail
#907 - docs: add mention of how to update current context's operation
#908 - react: remove analytics package dependency
#910 - docs: update context refresh information
#913 - Remove code from adding libVer from extensions
#918 - automatically add ai.operation.name tag, add id to pageview telemetry
#919 - fix issue with namePrefix not affecting send buffers

Don't miss a new ApplicationInsights-JS release

NewReleases is sending notifications on new releases.