-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Chrome Extension using @sentry/browser
gets rejected
#14010
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
Comments
Hey @SpaceK33z, how are you exactly bundling your application? The |
@chargome I am bundling the application with Vite and following the official docs which has this line in it:
Because of that, it will always import all integrations. The docs should be changed to not teach this, but instead do this:
This is shorter, more readable, doesn't use "magic" strings, and most importantly enables tree-shaking which fixes this issue. |
@SpaceK33z The snippet you provided does the exact opposite (not filtering out the integrations that use global state). So in your case this might work because it get's rid of all integrations but these three. In the docs there is also a line that states:
We could update the docs in this regard by adding a comment directly in the code snippet, wdyt? |
This was definitely a "problem exists between chair and computer" situation; the whole experience was just very confusing because we suddenly got rejected from the Chrome Webstore; In the end the real issue was that I was doing To prevent other users from having this issue, it could be helpful to add a warning about that to the docs; that importing |
Bundlers should still be able to tree-shake this. Did you check the emitted build output? There should not be a place that uses |
Yes I checked the build output and it's there when using It also makes sense because that's the whole reason we got rejected from the store, because that piece of code is in our bundle output. We got approved again by the store after switching to specific imports. For me it's fine if this ticket gets closed, but potentially a warning to the docs like I mention above could be helpful for others. |
I just set up a Vite project with the vanilla preset and TS, bundled it and could not find Can you please share a minimal reproduction example of your setup so we can confirm this? It's useful to warn in the docs, but I want to make sure that this is not a problem within a specific setup or Vite preset. |
Can you also not find any reference of |
The only occurrences I found with |
For us it worked fine with
or
❌ Unfortunately, this approach did not work with
|
I have a feeling this is mostly related to bundler and tree-shaking setup. All modern bundlers are able to tree-shake out unused APIs, like Likewise, I can't see a reason as to why We'd still need a minimal reproduction to investigate this further. Thanks! |
I've faced this same issue when importing from the In my project we're using the Rollup bundler, so I've bounced of the input plugin rollup-plugin-modify to strip the Sentry CDN URL: const rollup = require('rollup');
const modify = require('rollup-plugin-modify');
rollup
.rollup({
input: 'src/main/background/index.ts',
plugins: modify({
find: 'https://browser.sentry-cdn.com',
replace: '',
}),
})
.then((bundle) => {
return bundle.write({
// ...
});
}) |
Glad you found a workaround! However, in general I'd still argue that there must be a tree-shaking related problem in build setups where My comment from above still stands:
|
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/browser
SDK Version
8.34.0
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
Use this in a Chrome Extension in the service worker.
In the content script we setup Sentry as outlined in these official docs — but just using it in a service worker is enough to trigger this.
Steps to Reproduce
Expected Result
Actual Result
The given reason:
When looking up this code, it's coming from
@sentry/browser
and it looks like it's being used twice;We use neither of these, yet still get rejected.
Probably not coincidentally, Chrome now is finally actually phasing out MV2 extensions (source), and only with MV3 remote code is not allowed to be executed. My guess is that they only started checking now.
It might be debatable that this is a bug, but I consider it as such because browser extensions seem to be officially supported.
The current work-around that I am using is to use
patch-package
to remove the code that injects a script tag in thelazyLoadIntegration
andshowReportDialog
functions.The text was updated successfully, but these errors were encountered: