Closed
Description
Problem Statement
From time to time we get reports about browser extensions using Sentry with global handler integrations installed. The consequences are that the extension SDK collides with an SDK being used in the page, producing unwanted side effects like:
- event leakage from page to extension or vice versa
- SDK version discrepancies leading to type errors
Solution Brainstorm
There is a way to detect if code is being executed within a Chrome extension. Let's add this check in the browser SDK's init
function and, in case of detecting usage in an extension, stop initialization with a warning that extension authors should only directly use the SDK client instead of the global init.
Additional Considerations:
- Up for discussion: We could export a dedicated init function (e.g.
Sentry.initForExtension()
) that only sets up a minimal SDK setup without global handlers, etc. This, however, is out of scope for the initial task.