Skip to content

Commit 90328f1

Browse files
Lms24coolguyzone
andauthored
feat(browser): Document unregisterOriginalCallbacks option in browserApiErrors integration page (#13859)
Documents a new option added via getsentry/sentry-javascript#16412. Also added a troubleshooting section as adding this option was the result of investigating a user-reported SDK issue (getsentry/sentry-javascript#16398) Co-authored-by: Alex Krawiec <alex.krawiec@sentry.io>
1 parent b366299 commit 90328f1

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

docs/platforms/javascript/common/configuration/integrations/browserapierrors.mdx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Sentry.init({
4040
requestAnimationFrame: true,
4141
XMLHttpRequest: true,
4242
eventTarget: true,
43+
unregisterOriginalCallbacks: true,
4344
}),
4445
],
4546
});
@@ -110,3 +111,12 @@ List of default event targets:
110111
- `XMLHttpRequest`
111112
- `XMLHttpRequestEventTarget`
112113
- `XMLHttpRequestUpload`
114+
115+
### `unregisterOriginalCallbacks`
116+
117+
_Type: `boolean`_
118+
119+
Unregister the original `EventTarget.addEventListener` callbacks.
120+
If you experience issues with this integration (or the SDK) causing double invocations of an `addEventListener` callback, set this option to `true`.
121+
This is usually a sign of the SDK being initialized too late in the lifecycle of the page.
122+
If this is the case, you might want to consider initializing the SDK as early as possible to avoid this issue.

docs/platforms/javascript/common/troubleshooting/index.mdx

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,18 @@ Remember to pass in `true` as the second parameter to `addEventListener()`. With
389389
</Expandable>
390390
</PlatformCategorySection>
391391
392+
<PlatformCategorySection supported={['browser']}>
393+
394+
<Expandable permalink title="SDK causes double invocations of `addEventListener` (e.g. duplicated click events)">
395+
396+
In very rare cases, the SDK can cause callbacks added via `addEventListener` to an event target (such as a button) to be invoked twice.
397+
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.
398+
399+
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`.
400+
401+
</Expandable>
402+
</PlatformCategorySection>
403+
392404
<Expandable permalink title="Build errors with vite">
393405
394406
If you're using the [Vite Bundler](https://vitejs.dev/) and a Sentry NPM package, and you see the following error:

0 commit comments

Comments
 (0)