getsentry / sentry-javascript-bundler-plugins

JavaScript Bundler Plugins for Sentry
https://sentry.io
BSD 3-Clause "New" or "Revised" License
135 stars 35 forks source link

How to prevent @sentry/vite-plugin from injecting Sentry to every file? #591

Open lilouartz opened 2 months ago

lilouartz commented 2 months ago

Looks like Sentry injects this to every file:

(function() {
    try {
        var r = typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {}
          , t = new Error().stack;
        t && (r._sentryDebugIds = r._sentryDebugIds || {},
        r._sentryDebugIds[t] = "6af1d399-83b0-4d2d-8d81-2b50af19ad83",
        r._sentryDebugIdIdentifier = "sentry-dbid-6af1d399-83b0-4d2d-8d81-2b50af19ad83")
    } catch {}
}
)();

How do I disable this?

Lms24 commented 2 months ago

Hey @lilouartz would you mind letting us know why you want to disable debug id injection? This snippet is injected so that we can better associate the minified stack frames with the correct source maps to show you the unminified stack frames in the Sentry UI.

How do I disable this?

You can give our legacy source maps uploading strategy a try. This won't inject debug id snippets into your code but you'll need to more carefully set up source maps upload

lilouartz commented 2 months ago

Feels lame that I have to use something named "legacy" for what seems like a basic ask.

Lms24 commented 2 months ago

I gave you an alternative. Without having more context as to why you want to achieve this, we cannot prioritize further work.

Hey @lilouartz would you mind letting us know why you want to disable debug id injection?

At this time, we don't understand why this is a "basic ask".

getsantry[bot] commented 1 month ago

This issue has gone three weeks without activity. In another week, I will close it.

But! If you comment or otherwise update it, I will reset the clock, and if you remove the label Waiting for: Community, I will leave it alone ... forever!


"A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀

chadgauth commented 1 month ago

I am having the same issue, the issue is Sentry config on vite is injecting an import to my web worker. We should have an ignore list or a way to prevent Sentry from importing on specified files.

Lms24 commented 1 month ago

@chadgauth you can use the sourcemaps.ignore option to disable injecting the debugId snippet into specific files. Vice verca, you can also specify assets to limit the injection of debugIds and source map upload to specific file paths (glob patterns work for both).

Note that once you do this, errors ocurring in the excluded files will not be source-mapped correctly.