diff --git a/README.md b/README.md index be700bc50..9ae5d7c54 100644 --- a/README.md +++ b/README.md @@ -121,7 +121,13 @@ The current version of the snippet is version 8, the version is identified by th // onInit: null, // Once the application insights instance has loaded and initialized this callback function will be called with 1 argument -- the sdk instance (DO NOT ADD anything to the sdk.queue -- As they won't get called) // sri: false, // Custom optional value to specify whether fetching the snippet from integrity file and do integrity check cfg: { // Application Insights Configuration - connectionString: "YOUR_CONNECTION_STRING" + connectionString: "YOUR_CONNECTION_STRING", + extensionConfig: { + ApplicationInsightsAnalytics: { + autoExceptionInstrumented: true // Workaround for older SDK versions to prevent duplicate hooking of window.onerror. + // Fixed in v3.3.5; recommended for versions prior to this. + } + }, } }); diff --git a/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/AnalyticsPlugin.ts b/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/AnalyticsPlugin.ts index fc32ed1b6..b51873cac 100644 --- a/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/AnalyticsPlugin.ts +++ b/extensions/applicationinsights-analytics-js/src/JavaScriptSDK/AnalyticsPlugin.ts @@ -700,7 +700,7 @@ export class AnalyticsPlugin extends BaseTelemetryPlugin implements IAppInsights _self._addHook(onConfigChange(_extConfig, () => { _disableExceptionTracking = _extConfig.disableExceptionTracking; - if (!_disableExceptionTracking && !_autoExceptionInstrumented && !_extConfig.autoExceptionInstrumented) { + if (!_disableExceptionTracking && !_autoExceptionInstrumented && !_extConfig.autoExceptionInstrumented && !_self.core.config["autoExceptionInstrumented"]) { // We want to enable exception auto collection and it has not been done so yet _addHook(InstrumentEvent(_window, "onerror", { ns: _evtNamespace,