File tree Expand file tree Collapse file tree 2 files changed +8
-10
lines changed
Expand file tree Collapse file tree 2 files changed +8
-10
lines changed Original file line number Diff line number Diff line change @@ -43,7 +43,6 @@ const globalWithInjectedValues = GLOBAL_OBJ as typeof GLOBAL_OBJ & {
4343 _sentryBasePath ?: string ;
4444 _sentryRelease ?: string ;
4545 _experimentalThirdPartyOriginStackFrames ?: string ;
46- _sentrySpotlight ?: string ;
4746} ;
4847
4948// Treeshakable guard to remove all code related to tracing
@@ -144,9 +143,11 @@ function getDefaultIntegrations(options: BrowserOptions): Integration[] {
144143 ) ;
145144
146145 // Auto-enable Spotlight from NEXT_PUBLIC_SENTRY_SPOTLIGHT env var
147- // The value is injected at build time via buildTimeVariables in withSentryConfig
148- // following the same pattern as _sentryRelease
149- const spotlightEnvValue = process . env . _sentrySpotlight || globalWithInjectedValues . _sentrySpotlight ;
146+ // We read NEXT_PUBLIC_SENTRY_SPOTLIGHT directly because Next.js guarantees that
147+ // NEXT_PUBLIC_* variables are exposed to the browser via webpack DefinePlugin replacement.
148+ // Using a custom _sentrySpotlight variable doesn't work reliably because Next.js doesn't
149+ // always replace arbitrary env vars in node_modules code.
150+ const spotlightEnvValue = process . env . NEXT_PUBLIC_SENTRY_SPOTLIGHT ;
150151 if ( spotlightEnvValue !== undefined && options . spotlight === undefined ) {
151152 const boolValue = envToBool ( spotlightEnvValue , { strict : true } ) ;
152153 const spotlightConfig = boolValue !== null ? boolValue : spotlightEnvValue ;
Original file line number Diff line number Diff line change @@ -610,12 +610,9 @@ function setUpBuildTimeVariables(
610610 buildTimeVariables . _sentryRelease = releaseName ;
611611 }
612612
613- // Inject Spotlight config from NEXT_PUBLIC_SENTRY_SPOTLIGHT env var
614- // We check both userNextConfig.env (from next.config.js) and process.env (from .env files or shell)
615- const spotlightValue = userNextConfig . env ?. NEXT_PUBLIC_SENTRY_SPOTLIGHT ?? process . env . NEXT_PUBLIC_SENTRY_SPOTLIGHT ;
616- if ( spotlightValue ) {
617- buildTimeVariables . _sentrySpotlight = spotlightValue ;
618- }
613+ // Note: NEXT_PUBLIC_SENTRY_SPOTLIGHT is read directly in the client code because
614+ // Next.js guarantees that NEXT_PUBLIC_* variables are exposed to the browser.
615+ // No need to inject it as a build-time variable here.
619616
620617 if ( typeof userNextConfig . env === 'object' ) {
621618 userNextConfig . env = { ...buildTimeVariables , ...userNextConfig . env } ;
You can’t perform that action at this time.
0 commit comments