> Note: ES3/IE8 compatibility will be removed in the future v3.x.x releases (scheduled for mid-late 2022), so if you need to retain ES3 compatibility you will need to remain on the 2.x.x versions of the SDK or your runtime will need install polyfill's to your ES3 environment before loading / initializing the SDK.
This release fixes an issue with the `sendBeacon` usage during page unload, where the SDK was not correctly splitting the payload into multiple requests when the payload size exceeded the maximum allowed size for a single request. This issue was introduced in the 3.0.4 release and only affects the `sendBeacon` usage during page unload, it does not affect the `fetch` usage during page unload.
### Changelog
-#2195 [BUG] Beacon sender causes flood of thousands of requests on page unload
-#2201 [BUG] applicationinsights.azure.com/v2/track making hundreds of thousands of requests when third party cookies are disabled
-#2205 [BUG] Duplicate customEvent entries
-#2204 [BUG] Beacon sender reports error for success when diagnostics are enabled
#### Major release with breaking changes from v2.x see [v3.x Breaking Changes](https://microsoft.github.io/ApplicationInsights-JS/upgrade/v3_BreakingChanges.html) for details.
Maintained from the `main` branch, v2.x is in maintenance mode on the `master` branch
### Changelog
- All code from 2.8.12 has been merged into the `main` branch and therefore this release
#### Major Changes
- Removed ES3 (IE8) Support
- Enabled dynamic config changes after initialization
-#1427 Dynamically updating config (for extensions in my case)
- Too many individual commits to include as most revolve around the breaking changes and enabling dynamic configuration support for each extension
- All Extensions now **share** the same configuration object `core.config` in previous releases each component maintained their own copy with their own default values, now all defaults and configuration values are exposed on the shared config.
- By default the config object passed in during initialization is NOT the same object as that used as the shared config. Any previous assumptions around this being the same object will now be broken as this was a previously unsupported scenario.
- All properties of the config object are now using get/set functions (via Object.defineProperty) to allow listeners to be registered (`core.onCfgChange` and internally `onConfigChange`) so that the callback function will be called if any referenced config property is changed. Yes, this means you can register your own configuration listener via `core.onCfgChange` see the [AISku Manual Test](./AISKU/Tests/Manual//HelloWorld.html) for an example.
- All properties present during initialization are converted into dynamic properties and may be monitored, properties added "after" creation (initialization) are not. This is to continue to support IE which does not support `Proxy` implementation which also means we are not using the `Proxy` class.
- Extensions are now responsible for listening and responding to the configuration changes that they want to support
- Updating the config `extensions` and `channels` is NOT supported, you must use the individual plugin add / remove functions if you want to dynamically add / remove extensions / channels
- Support for parallel channels was removed from the Core and SKU's and extracted to the new `TeeChannel`, if you require this support you will need to use npm and include this module.
- v2.x Extension support.
- While the basic API and support for Backward compatibility for the v2.x extension (plugin) API was maintained, due to the breaking changes (specifically the removal of the namespaced helpers) this will only support self contained components (without recompiling). Any npm module that attempts to import and use a removed helper function will potentially break and will need to be updated to use the newer or replacement helper functions (see the v3.x Breaking Changes for details), if you find an issue and are not able to work around please [raise an issue](https://github.com/microsoft/ApplicationInsights-JS/issues).
- Updates React Plugin to v3.3.5 (with v2.8.5 as dependency) -- using React 17
- Updates React Native Plugin to 2.5.5 (with v2.8.5 as dependency)
- Updates Chrome Debug Extension to 0.3.5
### Changelog
-#1636 [BUG] measurements not being sent when using stopTrackEvent(name, properties, measurements);
-#1857 [BUG] CDN Packaging is not exposing the internal tools (CoreUtils / Telemetry / etc)
- This was caused by the updated tree-shaking component that we used, fixing this has increased the CDN payload but it provides backward compatibility again
-#1852 [BUG] Snippet initialization with IE8 fails with minified code (works with un-minified code)
- This was specific to IE8 usages
-#1076 Refactor code to provide better tree shaking and minification of generated code
- Final stage which provides automatic name crunching, however, because of the fix for #1857 the CDN package size does not show the full effect of this improvement
This release has been manually validated to work with IE8 both directly and by extending the provided classes. While the previous version 2.8.2 also fully supported IE8 it did not handle classes extending the all of Core classes correctly in multiple cases. If you need to support IE8 it is strongly advised that you upgrade to, validate and use this version.
### Changelog
-#1831 Updates to dynamicProto() v1.1.6 which provides a final edge case fix for IE8
- [#50](https://github.com/microsoft/DynamicProto-JS/issues/50) [IE8] Fix in 1.1.5 only handles 2 levels of dynamically nested classes
-#1828 Update README.md to redirect to Node.JS
-#1829 Extracting HOC tracked component class base for re-use
-#1804 [BUG] Error type in AppInsightsErrorBoundary after upgrading to react 18
-`fetch` Ajax tracking was also been change to be on by default from this version moving forward, if you are running in an environment without `fetch` support and you are using an incompatible polyfill (that doesn't identify itself as a polyfill) or the SDK you start seeing recursive or duplicate (`fetch` and `XHR` requests) being reported you WILL need to add `disableFetchTracking` with a value of `true` to your configuration to disable this functionality.
- TelemetryInitializers have been moved to `BaseCore` so they are now available as part of all Sku's and not just those using the `analytics` plugin (@microsoft/applicationinsights-analytics-js) using the `appInsights.addTelemetryInitializer(...)`
- Web Events (addEventHandler) now support "event namespaces" (similar to jQuery) to enable the removing of events by just specifying the namespace and new specific `eventOn(...)` and `eventOff(...)` API's.
- Fully unload, removing all internal event handlers (may be re-initialized) via the `appInsights.unload(...)` function.
- Dynamically add a plugin to an already initialized SDK (optionally replacing an existing) via new `appInsights.addPlugin(...)` function
- New helper to get any plugin from an initialized SDK via `appInsights.getPlugin("...identifier...")`
- Dynamically remove a plugin via the `appInsights.getPlugin("...identifier..").remove()`
- Enable / Disable any plugin (even if the plugin doesn't support disabling itself) via `appInsights.getPlugin("...identifier...").setEnabled(true/false)`
- The standard name fro the `analytics` plugin @microsoft/applicationinsights-analytics-js has been renamed and is now exported as `AnalyticsPlugin`, for backward compatibility it is also exported as it's previous name `ApplicationInsights`, if you are using it directly it is recommended that you update to use the new exported name.
While this release contains a substantial amount of additional functionality and code, there has also been significant minification efforts (which also drove some of the SDK naming) to keep the minified code around the same size. We intend to keep working on additional improvements to attempt to bring the size changes down further. However, the minification improvements do generally cause a lower level of GZip compression most because of the removal of duplicate names. The main readme for the [AISKU](https://github.com/microsoft/ApplicationInsights-JS/tree/master/AISKU) has a table of the CDN base SKU sizes, as the CDN version includes all public API's (older versions for backward compatibility and newer smaller versions) when using NPM you should see smaller sizes than those shown.
> Note:
> Due to the above changes required to support the above, there may be some minor TypeScript Type compatibility warnings when you attempt to use components from v2.8.0 with older SDK's (forward compatibility), backward compatibility, using Core v2.8.0 with older components is supported and v2.8.0 is completely backward compatible. This is due to some API's now support both older (for back compat) and new enhanced arguments, we have attempted to keep these changes to a minimum.
> If you are getting typing errors such as "Argument of type 'XXXXX' os not assignable to parameter of type 'YYYY'", please ensure that you are using all v2.8.0 components and raise an issue if this does not resolve you issue. As a work around casting to work around this warning should not cause any issues.
> Due the the size of this change, the above date is the NPM release date and CDN deployment will be over an extended period.
### Changelog
- Task 13064945: Enable the option to remove all "added" SDK event listeners as part of calling teardown()
- Partial, foundational support for #1427 Dynamically updating config (for extensions in my case)
-#1773 [BUG] IConfig and IConfiguration define different configuration "names" for the cookie manager config
-#1779 Allow including custom properties in useTrackMetric
-#1791 Merge remote-tracking branch `upstream/beta` into `master`
* Update version update script to support default "next" release version (major/minor) not just patch (#1756)
* Additional Performance enhancements to use provided functions rather than internal polyfill's (#1758)
* Enable GitHub Actions on [beta] branch
* Beta Part 1: Part of Mega Dynamic Load/Unload support (#1766)
- Refactor TelemetryPluginChain ready to start supporting load/unload
- Move TelemetryInitializer to BaseCore
- add getPlugin (will be used for remove)
- Address Channel flush issue
* Additional Performance enhancements to use provided functions rather than internal polyfill's (#1758)
* Beta Part 2: Part of Mega Dynamic Load/Unload support (#1768)
- Add Event Namespace support
- Minification of constant values
- Add part of the unload functionality (required for unified `teardown()` functionality)
* Beta Part 3: Part of Mega Dynamic Load/Unload support (#1780)
- Add Core SDK Unload support
* Fix telemetry chain for null and undefined
* Beta Part 4: Part of Mega Dynamic Load/Unload support (#1781)
-#1268 Investigate and add a sender that uses fetch when XMLHttpRequest is not available
-#1545 Cannot modify the request headers and cookies when using a custom endpoint
-#1546 [Typings] Update the TypeScript typings to identify the readonly properties/fields and dynamic values of the snippet
-#1541 ITelemetryContext.user is sometimes null - setAuthenticatedUserContext throws
-#1569 [BUG] Authorization header included when enableRequestHeaderTracking is enabled
- As part of this change the ["Authorization", "X-API-Key", "WWW-Authenticate"] headers will NO longer be logged when ```enableRequestHeaderTracking``` is enabled, if you want these headers to be sent to AzureMonitor you will need to override the default ```ignoreHeaders``` config which excludes them (See the [Configuration settings](https://github.com/Microsoft/ApplicationInsights-JS#configuration)).
-#1558 [BUG] Durations reported as zero (00:00:00.000) in Angular SPA for router changes
-#363 Script error: Browser exception message not providing information type and method
-#1536 Update DynamicProto version 1.1.2 (Fixes IE7 mode issue originally reported in #1534)
-#1280 Investigate removing the globals __extends() and __assign() populated by applicationinsights-shims
-#1523 Remove exposing global instances of __extends() and __assign() and update sideEffects usage (by removing globals)
-#1538 [BUG] Telemetry Buffer Getting Cleared in Offline Mode - Online Status Incorrectly Initialized in Offline Listener
-#1528 [BUG] correlationHeaderExcludePatterns is not honored in Ajax calls
-#1516 [BUG] App insight library will flush telemetry using beforeUnload event but this event is cancellable
-#1509 [BUG] Investigate changing the sideEffects: false to list only the files that include the shims module from the all AI modules so that webpack can evaluate correctly
-#1517 [BUG] addHousekeepingBeforeUnload should also be listening to the 'unload' event
-#1524 [BUG] Config items are not functional for current snippet disableFlushOnBeforeUnload, disableFlushOnBeforeUnload and maybe others
-#1440 [BUG] PageViewPerformanceManager.populatePageViewPerformanceEvent() is always returning zero for the network time
-#1393 [BUG] enableAutoRouteTracking should also update the Operation Name with the hashroute
- [BUG] Add test coverage for #1518
-#1510 Update PageView operation name to include the hash
### Version bump is due to the following major changes
A large amount of [Tree-Shaking improvements](https://github.com/microsoft/ApplicationInsights-JS#tree-shaking-support-and-enhancements) have been included in this version, please [see the recommendations](TreeShakingRecommendations.md) you may need to apply to your code to take complete advantage of these changes to reduce the overall module sizes (when using NPM packages)
Also includes major changes to the cookie management, please [see the readme cookie configuration section](https://github.com/microsoft/ApplicationInsights-JS#icookiemgrconfig) and [cookie handling changes](https://github.com/microsoft/ApplicationInsights-JS#cookie-handling).
-#1276 [BUG] Does not work with Closure Compiler (possible fix, now generates `applicationinsights-web.d.ts` (This version is namespaced) and `applicationinsights-web.rollup.d.ts` in the dist folder
### New (Beta) extension applicationinsights-debugplugin-js
- Created the initial extension to help developers understand, track, visualize and fix issues with events
- This extension injects a UI onto your page details for the component is available at https://github.com/microsoft/ApplicationInsights-JS/tree/master/extensions/applicationinsights-debugplugin-js
- This is a beta release so the UI, config etc are not yet complete, feedback for features, suggestions or changes are welcome -- please create an Issue
- The detailed view is still under construction and contains known bugs, these will be address in the next few months (releases) as we build out the module. We had not originally planed to have any detailed view as part of this initial beta release.
### Changelog
-#1311 Allow the generated modules to extend the namespace defined by "name" in rollup config -- rather than always replace.
- Changes the way the "Microsoft.ApplicationInsights" is defined for each module to all modules to be added to the same namespace
-#1309 When using prototype js the SessionStorage become corrupted causing requests internal exceptions
-#1303 Task 7027291: Investigate CDN Configuration to support custom domain (automate CDN deployment scripts)
-#1299 Releasing core queue as soon as possible (fixes lost events from page load immediate unload with no additional events)
-#1297 Created initial applicationinsights-debugplugin-js
-#1289 [Documentation] doc: SPO set up instruction
-#1286 [Documentation] Update JS SDK Snippet documentation with bug fixes (new v4 snippet)
-#1283 [BUG] (Snippet v3) AppInsights stub methods captured incorrect method names in the closure
-#1262 [BUG] Custom properties added with addTelemetryInitializer are ignored for exceptions
-#1245 React Native - AI (Internal): 19 message: "Could not add handler for beforeunload and pagehide"
- Add isReactNative() function for detecting the runtime environment
-#1095 Add an Error Boundary to the React plugin
-#1089 Blocking certain URIs/Patterns from fetch tracking (patch included)
- Added new config 'correlationHeaderExcludePatterns' to allow disabling correlation headers using regular expressions
### Updated React plugin to v3.0.1
-#1311 Allow the generated modules to extend the namespace defined by "name" in rollup config -- rather than always replace.
- Changes the way the "Microsoft.ApplicationInsights" is defined for each module to all modules to be added to the same namespace
### Update applicationinsights-rollup-es3 to v1.1.2
-#1311 Allow the generated modules to extend the namespace defined by "name" in rollup config -- rather than always replace.
-#1204 When a fetch polyfill is installed there reporting endpoint is also causing events to be sent
-#1202 ai_user and ai_session cookies not set #1203
-#1201 add to auto track exceptions in react native plugin
-#1199 Build is breaking when you do a "rush update --full --purge --recheck" due to tslib v1.11.0 update
-#1194 XHR/Fetch enhancement - add additional telemetry from window.performance #1195
-#1193 add sanitizer for operationName
-#1189 Add the option to specify the refUri with stopTrackPage #1190
-#1186 App Insights initialization setting 'enableAjaxErrorStatusText' is not working #1187
#### XHR/Fetch enhancement
Adds additional performance data derived from the window.performance.getEntries() for the fetch or XHR request.
Configuration options
| Name | Default | Description |
|------|---------|-------------|
| enableAjaxPerfTracking | 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 | 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.
| ajaxPerfLookupDelay | 25 | Defaults to 25ms. The amount of time to wait before re-attempting to find the windows.performance timings for an ajax request, time is in milliseconds and is passed directly to setTimeout().
#### Auto track exception React Native Plugin
This has been enabled by default in the updated version.
It can be disabled by adding the ```disableExceptionCollection``` config value with a value of true.
With this release the source files can be loaded in an ES3 environment (IE7/8) and send requests to the server. As part of this change you will now receive requests from users using an older browser, prior to this version users using an ES3 base browser will (most likely) have been getting a javascript error, which would have caused no data to be sent.
### Enable support for reusing plugins in multiple instances of AppInsights #1132
We have added upport to enable reusing the same plugin in different instances of AppInsights, owned by the same application (but using different Instrumentation keys) is required so that they can reuse a single Plugin instance for all instances.
This changes introduces a new [`IProcessTelemetryContext`](https://microsoft.github.io/ApplicationInsights-JS/webSdk/applicationinsights-core-js/interfaces/IProcessTelemetryContext.html) interface that is passed to the processTelemetry() method so that the plugins can use the current request context for the event rather than the context during initialization.
To assist with creating plugins we have also introduced a base class that you can use for creating new plugins [BaseTelemetryPlugin](https://github.com/microsoft/ApplicationInsights-JS/blob/master/shared/AppInsightsCore/src/JavaScriptSDK/BaseTelemetryPlugin.ts), details are included on the [Readme](https://github.com/microsoft/ApplicationInsights-JS/blob/master/README.md)
### Changelog
-#1175 [BUG] Typescript build with 2.4.0 breaks #1173
> *You do not need to upgrade for drag and drop to work. It will work on all previous and future versions of the javascript (and Node.js) SDK
https://i.imgur.com/Efue9nU.gif
You can now drag and drop your source maps onto your Exception Telemetry in the Azure Portal to unminify your callstack. Please open an issue or use the Feedback button in the Portal if a source map you've uploaded is not working as intended. This is a first iteration and in a future update, your source maps will be automatically unminified.
#### SPA Route Change Tracking
You can set `enableAutoRouteTracking: true` to enable state based route tracking for your Single Page Application (React, Angular, Vue, etc). You do not need to install a separate plugin to use this configuration option.
This setting will cause a new Page View telemetry item to be sent each time your app's route changes (**including** Hash route changes).
### Changelog
-#920 Resolve jest testing issues when using React plugin
-#928 Make analytics plugin have last priority
-#936 Fallback to XHR Sender when beacon sender tries to send >64 KB
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
```js
appInsights.trackException({ error: new Error() });
```
#### New
```js
appInsights.trackException({ exception: new Error() });
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`.
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
```js
var telemetryInitializer = (item) => {
item.tags.push({ "ai.cloud.role": "My Web App" });