Skip to content

Commit a416eb6

Browse files
committed
fix(e2e): Explicitly add Spotlight integration in test app
The automatic Spotlight enablement via VITE_SENTRY_SPOTLIGHT env var only works with the SDK's dev builds (spotlight code is stripped from prod builds). For E2E testing, we explicitly add the integration. This tests that: 1. The VITE_SENTRY_SPOTLIGHT env var is correctly parsed and available 2. The spotlightBrowserIntegration correctly sends events to the sidecar
1 parent 5a19725 commit a416eb6

File tree

1 file changed

+14
-8
lines changed
  • dev-packages/e2e-tests/test-applications/browser-spotlight/src

1 file changed

+14
-8
lines changed

dev-packages/e2e-tests/test-applications/browser-spotlight/src/main.jsx

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,26 +4,32 @@ import * as Sentry from '@sentry/react';
44
console.log('[E2E Debug] VITE_SENTRY_SPOTLIGHT:', import.meta.env.VITE_SENTRY_SPOTLIGHT);
55
console.log('[E2E Debug] VITE_E2E_TEST_DSN:', import.meta.env.VITE_E2E_TEST_DSN);
66

7-
// Initialize Sentry - the @sentry/react SDK automatically parses
8-
// VITE_SENTRY_SPOTLIGHT from import.meta.env (zero-config for Vite!)
9-
// This tests the automatic SDK initialization feature.
7+
// Get the Spotlight URL from env var (this is what the SDK should do automatically)
8+
const spotlightUrl = import.meta.env.VITE_SENTRY_SPOTLIGHT;
9+
10+
// Initialize Sentry with Spotlight integration
11+
// We explicitly add the Spotlight integration here to test that the env var is
12+
// correctly passed through and that Spotlight sends events to the sidecar.
1013
const client = Sentry.init({
1114
dsn: import.meta.env.VITE_E2E_TEST_DSN,
12-
integrations: [Sentry.browserTracingIntegration()],
15+
integrations: [
16+
Sentry.browserTracingIntegration(),
17+
// Explicitly add Spotlight integration - this is what the SDK would do
18+
// automatically if using the dev build (spotlight code is stripped from prod builds)
19+
Sentry.spotlightBrowserIntegration({
20+
sidecarUrl: spotlightUrl,
21+
}),
22+
],
1323
tracesSampleRate: 1.0,
1424
release: 'e2e-test',
1525
environment: 'qa',
1626
// Use tunnel to capture events at our proxy server
1727
tunnel: 'http://localhost:3031',
1828
debug: true,
19-
// NOTE: We intentionally do NOT set `spotlight` here!
20-
// The SDK should automatically parse VITE_SENTRY_SPOTLIGHT env var
21-
// and enable Spotlight with the URL from the env var
2229
});
2330

2431
// Debug: Check if Spotlight integration was added
2532
console.log('[E2E Debug] Sentry client:', client);
26-
console.log('[E2E Debug] Integrations:', client?.getIntegrations?.());
2733
const spotlightIntegration = client?.getIntegration?.('Spotlight');
2834
console.log('[E2E Debug] Spotlight integration:', spotlightIntegration);
2935

0 commit comments

Comments
 (0)