Skip to content

Commit df539cf

Browse files
committed
debug: Add logging to show globalThis vs process.env in spotlight test
1 parent 43572cf commit df539cf

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

dev-packages/e2e-tests/test-applications/nextjs-15-spotlight/app/page.tsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ import * as Sentry from '@sentry/nextjs';
66
// Next.js replaces process.env.NEXT_PUBLIC_* at BUILD TIME with literal values
77
const NEXT_PUBLIC_SPOTLIGHT_VALUE = process.env.NEXT_PUBLIC_SENTRY_SPOTLIGHT;
88

9+
// Check globalThis which is where the valueInjectionLoader should put the value
10+
const GLOBALTHIS_SPOTLIGHT_VALUE =
11+
typeof globalThis !== 'undefined'
12+
? (globalThis as Record<string, unknown>)['NEXT_PUBLIC_SENTRY_SPOTLIGHT']
13+
: undefined;
14+
915
export default function SpotlightTestPage() {
1016
const [spotlightEnabled, setSpotlightEnabled] = useState<boolean | null>(null);
1117
const [integrationNames, setIntegrationNames] = useState<string[]>([]);
@@ -23,7 +29,8 @@ export default function SpotlightTestPage() {
2329

2430
// Log for debugging
2531
console.log('Spotlight test results:', {
26-
envValue: NEXT_PUBLIC_SPOTLIGHT_VALUE,
32+
processEnvValue: NEXT_PUBLIC_SPOTLIGHT_VALUE,
33+
globalThisValue: GLOBALTHIS_SPOTLIGHT_VALUE,
2734
integrationFound: !!integration,
2835
clientExists: !!client,
2936
integrationNames: intNames,
@@ -36,7 +43,8 @@ export default function SpotlightTestPage() {
3643

3744
<div data-testid="env-value">
3845
<h2>Environment Variable</h2>
39-
<p>NEXT_PUBLIC_SENTRY_SPOTLIGHT: {NEXT_PUBLIC_SPOTLIGHT_VALUE || 'undefined'}</p>
46+
<p>process.env: {NEXT_PUBLIC_SPOTLIGHT_VALUE || 'undefined'}</p>
47+
<p data-testid="globalthis-value">globalThis: {String(GLOBALTHIS_SPOTLIGHT_VALUE) || 'undefined'}</p>
4048
</div>
4149

4250
<div data-testid="spotlight-status">
Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,16 @@
11
import * as Sentry from '@sentry/nextjs';
22

3+
// Debug: Log what the valueInjectionLoader injected (if anything)
4+
// The loader should inject globalThis["NEXT_PUBLIC_SENTRY_SPOTLIGHT"] = "true" before this code
5+
console.log('[Sentry Debug] globalThis.NEXT_PUBLIC_SENTRY_SPOTLIGHT:', (globalThis as Record<string, unknown>)['NEXT_PUBLIC_SENTRY_SPOTLIGHT']);
6+
console.log('[Sentry Debug] process.env.NEXT_PUBLIC_SENTRY_SPOTLIGHT:', process.env.NEXT_PUBLIC_SENTRY_SPOTLIGHT);
7+
38
Sentry.init({
49
environment: 'qa',
510
dsn: process.env.NEXT_PUBLIC_E2E_TEST_DSN,
611
tunnel: `http://localhost:3031/`,
712
tracesSampleRate: 1.0,
813
// Note: We don't explicitly set spotlight here - it should be auto-enabled
914
// from NEXT_PUBLIC_SENTRY_SPOTLIGHT env var which is injected by the SDK's
10-
// webpack DefinePlugin and Turbopack valueInjectionLoader
15+
// valueInjectionLoader to globalThis
1116
});

0 commit comments

Comments
 (0)