getsentry / sentry-javascript

Official Sentry SDKs for JavaScript
https://sentry.io
MIT License
7.86k stars 1.55k forks source link

Local Variables Integration shows Minified Variable Names #12863

Closed scefali closed 1 month ago

scefali commented 1 month ago

Is there an existing issue for this?

How do you use Sentry?

Sentry Saas (sentry.io)

Which SDK are you using?

@sentry/nextjs

SDK Version

8.9.2

Framework Version

14.2.4

Link to Sentry event

https://builtrightco.sentry.io/issues/5588390641/events/55a977f056554ebfa66ca6002b02d000/?project=4507092307148800

SDK Setup/Reproduction Example

Sentry.init({
  dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
  enabled:
    process.env.NODE_ENV === "production" ||
    process.env.VERCEL_ENV === "preview" ||
    process.env.NEXT_PUBLIC_FORCE_ENABLE_SENTRY === "true",

  // Adjust this value in production, or use tracesSampler for greater control
  tracesSampleRate: 0.1,
  includeLocalVariables: true,

  // Setting this option to true will print useful information to the console while you're setting up Sentry.
  debug: false,

  // uncomment the line below to enable Spotlight (https://spotlightjs.com)
  // spotlight: process.env.NODE_ENV === 'development',
  integrations: [
    Sentry.captureConsoleIntegration({
      levels: ["error"],
    }),
    Sentry.prismaIntegration(),
  ],
});

Steps to Reproduce

Happens on a generic backend error. Don't think there is anything in particular I can share that helps reproduce.

Expected Result

I would expect the the variables shown to use their actual variable names instead of the shortened variable names if source maps are available.

Actual Result

Screenshot 2024-07-11 at 7 02 24 AM
lforst commented 1 month ago

Hi, as of today, minified variables cannot be unminified (unless you have runtime information and even then it is still just heuristics).

There is a sourcemaps proposal that is making good progress about encoding information about bindings in sourcemaps: https://github.com/tc39/source-map/blob/main/proposals/scopes.md

Until that lands, we're stuck with the status quo.

AbhiPrasad commented 1 month ago

I opened https://github.com/getsentry/sentry-docs/pull/10662 to document this. Let's close this after the docs changes because I don't think we'll solve this for a while. We can re-visit after the sourcemap changes come through!

scefali commented 1 month ago

Thank @lforst @AbhiPrasad, makes sense. Hope things are going well on your end!