@@ -7,22 +7,35 @@ import * as Sentry from '@sentry/nextjs';
77const NEXT_PUBLIC_SPOTLIGHT_VALUE = process . env . NEXT_PUBLIC_SENTRY_SPOTLIGHT ;
88// Check internal values (these may or may not be replaced depending on bundler)
99const INTERNAL_SPOTLIGHT_PROCESS_ENV = process . env . _sentrySpotlight ;
10- // @ts -expect-error - accessing globalThis for debugging
11- const INTERNAL_SPOTLIGHT_GLOBAL = typeof globalThis !== 'undefined' ? globalThis . _sentrySpotlight : 'globalThis undefined' ;
12- // @ts -expect-error - accessing manual global set in instrumentation-client.ts
13- const MANUAL_SPOTLIGHT_GLOBAL = typeof globalThis !== 'undefined' ? globalThis . _sentrySpotlightManual : 'globalThis undefined' ;
14- // @ts -expect-error - accessing SDK debug info
15- const SDK_DEBUG_INFO = typeof globalThis !== 'undefined' ? globalThis . _sentrySpotlightDebug : undefined ;
16- // @ts -expect-error - accessing init marker
17- const INIT_CALLED = typeof globalThis !== 'undefined' ? globalThis . _sentryNextjsInitCalled : undefined ;
18- // @ts -expect-error - accessing init timestamp
19- const INIT_TIMESTAMP = typeof globalThis !== 'undefined' ? globalThis . _sentryNextjsInitTimestamp : undefined ;
2010
2111export default function SpotlightTestPage ( ) {
2212 const [ spotlightEnabled , setSpotlightEnabled ] = useState < boolean | null > ( null ) ;
2313 const [ integrationNames , setIntegrationNames ] = useState < string [ ] > ( [ ] ) ;
14+ const [ debugInfo , setDebugInfo ] = useState < {
15+ internalGlobal : string ;
16+ manualGlobal : string ;
17+ sdkDebug : unknown ;
18+ initCalled : unknown ;
19+ } | null > ( null ) ;
2420
2521 useEffect ( ( ) => {
22+ // Read globals at runtime (after init has run)
23+ // @ts -expect-error - accessing globalThis for debugging
24+ const internalGlobal = globalThis . _sentrySpotlight ;
25+ // @ts -expect-error - accessing manual global
26+ const manualGlobal = globalThis . _sentrySpotlightManual ;
27+ // @ts -expect-error - accessing SDK debug info
28+ const sdkDebug = globalThis . _sentrySpotlightDebug ;
29+ // @ts -expect-error - accessing init marker
30+ const initCalled = globalThis . _sentryNextjsInitCalled ;
31+
32+ setDebugInfo ( {
33+ internalGlobal : String ( internalGlobal ?? 'undefined' ) ,
34+ manualGlobal : String ( manualGlobal ?? 'undefined' ) ,
35+ sdkDebug,
36+ initCalled,
37+ } ) ;
38+
2639 // Check if Spotlight integration is registered
2740 const client = Sentry . getClient ( ) ;
2841 const integration = client ?. getIntegrationByName ?.( 'SpotlightBrowser' ) ;
@@ -37,9 +50,10 @@ export default function SpotlightTestPage() {
3750 console . log ( 'Spotlight test results:' , {
3851 envValue : NEXT_PUBLIC_SPOTLIGHT_VALUE ,
3952 internalProcessEnv : INTERNAL_SPOTLIGHT_PROCESS_ENV ,
40- internalGlobal : INTERNAL_SPOTLIGHT_GLOBAL ,
41- manualGlobal : MANUAL_SPOTLIGHT_GLOBAL ,
42- sdkDebugInfo : SDK_DEBUG_INFO ,
53+ internalGlobal,
54+ manualGlobal,
55+ sdkDebugInfo : sdkDebug ,
56+ initCalled,
4357 integrationFound : ! ! integration ,
4458 clientExists : ! ! client ,
4559 integrationNames : intNames ,
@@ -54,15 +68,14 @@ export default function SpotlightTestPage() {
5468 < h2 > Environment Variable</ h2 >
5569 < p > NEXT_PUBLIC_SENTRY_SPOTLIGHT: { NEXT_PUBLIC_SPOTLIGHT_VALUE || 'undefined' } </ p >
5670 < p > process.env._sentrySpotlight: { String ( INTERNAL_SPOTLIGHT_PROCESS_ENV ) || 'undefined' } </ p >
57- < p > globalThis._sentrySpotlight: { String ( INTERNAL_SPOTLIGHT_GLOBAL ) || 'undefined ' } </ p >
58- < p > globalThis._sentrySpotlightManual: { String ( MANUAL_SPOTLIGHT_GLOBAL ) || 'undefined ' } </ p >
71+ < p > globalThis._sentrySpotlight: { debugInfo ?. internalGlobal || 'loading... ' } </ p >
72+ < p > globalThis._sentrySpotlightManual: { debugInfo ?. manualGlobal || 'loading... ' } </ p >
5973 </ div >
6074
6175 < div data-testid = "sdk-debug" >
6276 < h2 > SDK Debug Info (what SDK saw during init)</ h2 >
63- < p > init() called: { String ( INIT_CALLED ) } </ p >
64- < p > init() timestamp: { String ( INIT_TIMESTAMP ) } </ p >
65- < pre > { SDK_DEBUG_INFO ? JSON . stringify ( SDK_DEBUG_INFO , null , 2 ) : 'No debug info' } </ pre >
77+ < p > init() called: { String ( debugInfo ?. initCalled ?? 'loading...' ) } </ p >
78+ < pre > { debugInfo ?. sdkDebug ? JSON . stringify ( debugInfo . sdkDebug , null , 2 ) : 'No debug info' } </ pre >
6679 </ div >
6780
6881 < div data-testid = "spotlight-status" >
0 commit comments