From ab4997b39dc245f8a5d794b727070deaf00f9b35 Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Wed, 28 May 2025 16:21:25 +0200 Subject: [PATCH 1/2] feat(browser): Document `unregisterOriginalCallbacks` option in `browserApiErrors` integration page --- .../configuration/integrations/browserapierrors.mdx | 10 ++++++++++ .../javascript/common/troubleshooting/index.mdx | 12 ++++++++++++ 2 files changed, 22 insertions(+) diff --git a/docs/platforms/javascript/common/configuration/integrations/browserapierrors.mdx b/docs/platforms/javascript/common/configuration/integrations/browserapierrors.mdx index 784a9c8370a8c3..2801827d438dd4 100644 --- a/docs/platforms/javascript/common/configuration/integrations/browserapierrors.mdx +++ b/docs/platforms/javascript/common/configuration/integrations/browserapierrors.mdx @@ -40,6 +40,7 @@ Sentry.init({ requestAnimationFrame: true, XMLHttpRequest: true, eventTarget: true, + unregisterOriginalCallbacks: true, }), ], }); @@ -110,3 +111,12 @@ List of default event targets: - `XMLHttpRequest` - `XMLHttpRequestEventTarget` - `XMLHttpRequestUpload` + +### `unregisterOriginalCallbacks` + +_Type: `boolean`_ + +Unregister the original callbacks of `EventTarget.addEventListener` callbacks. +If you experience issues with this integration (or the SDK) causing double invocations of an `addEventListener` callback, set this option to `true`. +This is usually a sign of the SDK being initialized too late in the lifecycle of the page. +If this is the case, you might want to consider initializing the SDK as early as possible to avoid this issue. \ No newline at end of file diff --git a/docs/platforms/javascript/common/troubleshooting/index.mdx b/docs/platforms/javascript/common/troubleshooting/index.mdx index 1a38638b34e523..185ed1cd292aa8 100644 --- a/docs/platforms/javascript/common/troubleshooting/index.mdx +++ b/docs/platforms/javascript/common/troubleshooting/index.mdx @@ -389,6 +389,18 @@ Remember to pass in `true` as the second parameter to `addEventListener()`. With + + + + +In very rare cases, the SDK can cause callbacks added via `addEventListener` to an event target (e.g. a button) to be invoked twice. +This is usually a sign of the SDK being intialized too late in the lifecycle of the page. If you can, try initializing the SDK as earlier. + +If this is not possible or doesn't apply to your use case, set the `unregisterOriginalCallbacks` option in the [`browserApiErrors` integration](../configuration/integrations/browserapierrors) to `true`. + + + + If you're using the [Vite Bundler](https://vitejs.dev/) and a Sentry NPM package, and you see the following error: From a2185d4a0dd9229992e460fcb592d621ac76933d Mon Sep 17 00:00:00 2001 From: Lukas Stracke Date: Fri, 30 May 2025 11:04:57 +0200 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Alex Krawiec --- .../common/configuration/integrations/browserapierrors.mdx | 2 +- docs/platforms/javascript/common/troubleshooting/index.mdx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/platforms/javascript/common/configuration/integrations/browserapierrors.mdx b/docs/platforms/javascript/common/configuration/integrations/browserapierrors.mdx index 2801827d438dd4..1232e96ff1ae57 100644 --- a/docs/platforms/javascript/common/configuration/integrations/browserapierrors.mdx +++ b/docs/platforms/javascript/common/configuration/integrations/browserapierrors.mdx @@ -116,7 +116,7 @@ List of default event targets: _Type: `boolean`_ -Unregister the original callbacks of `EventTarget.addEventListener` callbacks. +Unregister the original `EventTarget.addEventListener` callbacks. If you experience issues with this integration (or the SDK) causing double invocations of an `addEventListener` callback, set this option to `true`. This is usually a sign of the SDK being initialized too late in the lifecycle of the page. If this is the case, you might want to consider initializing the SDK as early as possible to avoid this issue. \ No newline at end of file diff --git a/docs/platforms/javascript/common/troubleshooting/index.mdx b/docs/platforms/javascript/common/troubleshooting/index.mdx index 185ed1cd292aa8..69ca25fec96b58 100644 --- a/docs/platforms/javascript/common/troubleshooting/index.mdx +++ b/docs/platforms/javascript/common/troubleshooting/index.mdx @@ -393,8 +393,8 @@ Remember to pass in `true` as the second parameter to `addEventListener()`. With -In very rare cases, the SDK can cause callbacks added via `addEventListener` to an event target (e.g. a button) to be invoked twice. -This is usually a sign of the SDK being intialized too late in the lifecycle of the page. If you can, try initializing the SDK as earlier. +In very rare cases, the SDK can cause callbacks added via `addEventListener` to an event target (such as a button) to be invoked twice. +This is usually a sign of the SDK being intialized too late in the lifecycle of the page. If you can, try initializing the SDK earlier in your application. If this is not possible or doesn't apply to your use case, set the `unregisterOriginalCallbacks` option in the [`browserApiErrors` integration](../configuration/integrations/browserapierrors) to `true`.