-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
fix(browser): Improve browser extension error message check #12146
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
23e966a
to
ed286fd
Compare
return !!isInsideBrowserExtension || !!isInsideChromeExtension; | ||
const windowWithMaybeExtension = WINDOW as typeof WINDOW & ExtensionProperties; | ||
|
||
const extensionKey = windowWithMaybeExtension.chrome ? 'chrome' : 'browser'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to clarify, when would you have window.browser.xxx
, and would that mean this is an extension??
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, we introduced this in the original browser extension check (https://github.com/getsentry/sentry-javascript/pull/10844/files)
size-limit report 📦
|
This PR makes our check for when we abort and log an error due to
Sentry.init
being used in a browser extension a bit more fine-gained. In particular, we now do not abort the SDK initialization if we detect that the SDK is running in a browser-extension dedicated window (e.g. a URL starting withchrome-extension://
).This was raised in #12025. h/t @Thomas101 for providing the initial idea how to check for the dedicated pages. I expanded on the check a bit to add other browsers. This list is not complete but probably good enough for start.
Also rewrote the function a bit to hopefully save a few bytes 🤞