Skip to content

Commit 1642e35

Browse files
committed
debug: Add logging to verify valueInjectionLoader in Spotlight test
1 parent 40c4967 commit 1642e35

File tree

2 files changed

+25
-1
lines changed

2 files changed

+25
-1
lines changed
Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
import * as Sentry from '@sentry/nextjs';
22

3+
// Debug: Log what values the valueInjectionLoader should have set
4+
// This runs AFTER imports are processed but BEFORE Sentry.init()
5+
console.log('[Sentry Debug] After imports - globalThis._sentrySpotlight:', (globalThis as Record<string, unknown>)['_sentrySpotlight']);
6+
console.log(
7+
'[Sentry Debug] After imports - globalThis.NEXT_PUBLIC_SENTRY_SPOTLIGHT:',
8+
(globalThis as Record<string, unknown>)['NEXT_PUBLIC_SENTRY_SPOTLIGHT'],
9+
);
10+
311
Sentry.init({
412
environment: 'qa',
513
dsn: process.env.NEXT_PUBLIC_E2E_TEST_DSN,
614
tunnel: `http://localhost:3031/`,
715
tracesSampleRate: 1.0,
816
// Note: We don't explicitly set spotlight here - it should be auto-enabled
9-
// from NEXT_PUBLIC_SENTRY_SPOTLIGHT env var (replaced by Next.js at build time)
17+
// via the valueInjectionLoader which sets globalThis._sentrySpotlight
1018
});

dev-packages/e2e-tests/test-applications/nextjs-15-spotlight/tests/spotlight.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,33 @@ import { expect, test } from '@playwright/test';
22

33
test.describe('Spotlight auto-enablement in Next.js development mode', () => {
44
test('Spotlight is automatically enabled when NEXT_PUBLIC_SENTRY_SPOTLIGHT=true', async ({ page }) => {
5+
// Capture console output for debugging
6+
const consoleLogs: string[] = [];
7+
page.on('console', msg => {
8+
const text = msg.text();
9+
consoleLogs.push(`[${msg.type()}] ${text}`);
10+
// Print Sentry debug messages immediately
11+
if (text.includes('Sentry Debug')) {
12+
console.log(`[Browser Console] ${text}`);
13+
}
14+
});
15+
516
await page.goto('/');
617

718
// Wait for client-side hydration and Sentry initialization
819
await page.waitForTimeout(3000);
920

21+
// Print all console logs for debugging
22+
console.log('All browser console logs:');
23+
consoleLogs.forEach(log => console.log(log));
24+
1025
// Check environment variable is accessible (injected at build time by Next.js)
1126
const envValue = await page.getByTestId('env-value').textContent();
1227
expect(envValue).toContain('true');
1328

1429
// Check Spotlight integration is enabled
1530
const spotlightStatus = await page.getByTestId('spotlight-enabled').textContent();
31+
console.log('Spotlight status:', spotlightStatus);
1632
expect(spotlightStatus).toBe('ENABLED');
1733
});
1834

0 commit comments

Comments
 (0)