feat(browser): Add environment variable support for Spotlight configuration
Implements full Spotlight spec with support for multiple framework-specific environment variable prefixes. Adds defensive environment variable access for both process.env and import.meta.env to support various bundlers.
Supported environment variables (in priority order):
PUBLIC_SENTRY_SPOTLIGHT(SvelteKit, Astro, Qwik)NEXT_PUBLIC_SENTRY_SPOTLIGHT(Next.js)VITE_SENTRY_SPOTLIGHT(Vite)NUXT_PUBLIC_SENTRY_SPOTLIGHT(Nuxt)REACT_APP_SENTRY_SPOTLIGHT(Create React App)VUE_APP_SENTRY_SPOTLIGHT(Vue CLI)GATSBY_SENTRY_SPOTLIGHT(Gatsby)SENTRY_SPOTLIGHT(base/official)
SENTRY_SPOTLIGHT is last as in environments like Docker Compose, we actually make the front-end env variable different than the base SENTRY_SPOTLIGHT one -- the backends need to reach docker.host.internal whereas front-ends always need localhost as we assume the browser runs on the same host with Spotlight.
Refactors envToBool utility from node-core to core package for shared usage. Adds resolveSpotlightOptions utility to ensure consistent precedence rules across Browser and Node SDKs.
Includes comprehensive test coverage for all new utilities and integration tests for environment variable precedence behavior.
Closes #18404
size-limit report 📦
| Path | Size | % Change | Change |
|---|---|---|---|
| @sentry/browser | 24.81 kB | - | - |
| @sentry/browser - with treeshaking flags | 23.3 kB | - | - |
| @sentry/browser (incl. Tracing) | 41.55 kB | - | - |
| @sentry/browser (incl. Tracing, Profiling) | 46.14 kB | - | - |
| @sentry/browser (incl. Tracing, Replay) | 79.97 kB | - | - |
| @sentry/browser (incl. Tracing, Replay) - with treeshaking flags | 69.7 kB | - | - |
| @sentry/browser (incl. Tracing, Replay with Canvas) | 84.64 kB | - | - |
| @sentry/browser (incl. Tracing, Replay, Feedback) | 96.89 kB | - | - |
| @sentry/browser (incl. Feedback) | 41.52 kB | - | - |
| @sentry/browser (incl. sendFeedback) | 29.49 kB | - | - |
| @sentry/browser (incl. FeedbackAsync) | 34.48 kB | - | - |
| @sentry/react | 26.52 kB | - | - |
| @sentry/react (incl. Tracing) | 43.75 kB | - | - |
| @sentry/vue | 29.27 kB | - | - |
| @sentry/vue (incl. Tracing) | 43.36 kB | - | - |
| @sentry/svelte | 24.82 kB | - | - |
| CDN Bundle | 27.28 kB | +0.17% | +45 B 🔺 |
| CDN Bundle (incl. Tracing) | 42.28 kB | +0.12% | +50 B 🔺 |
| CDN Bundle (incl. Tracing, Replay) | 78.81 kB | +0.07% | +53 B 🔺 |
| CDN Bundle (incl. Tracing, Replay, Feedback) | 84.25 kB | +0.05% | +41 B 🔺 |
| CDN Bundle - uncompressed | 80.12 kB | +0.11% | +83 B 🔺 |
| CDN Bundle (incl. Tracing) - uncompressed | 125.47 kB | +0.07% | +83 B 🔺 |
| CDN Bundle (incl. Tracing, Replay) - uncompressed | 241.5 kB | +0.04% | +83 B 🔺 |
| CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed | 254.27 kB | +0.04% | +83 B 🔺 |
| @sentry/nextjs (client) | 46.58 kB | +1.32% | +606 B 🔺 |
| @sentry/sveltekit (client) | 41.92 kB | - | - |
| @sentry/node-core | 51.52 kB | +0.05% | +24 B 🔺 |
| @sentry/node | 160.33 kB | +0.02% | +23 B 🔺 |
| @sentry/node - without tracing | 92.92 kB | +0.01% | +9 B 🔺 |
| @sentry/aws-serverless | 108.46 kB | +0.03% | +27 B 🔺 |
node-overhead report 🧳
Note: This is a synthetic benchmark with a minimal express app and does not necessarily reflect the real-world performance impact in an application.
| Scenario | Requests/s | % of Baseline | Prev. Requests/s | Change % |
|---|---|---|---|---|
| GET Baseline | 11,682 | - | 11,232 | +4% |
| GET With Sentry | 1,927 | 16% | 2,005 | -4% |
| GET With Sentry (error only) | 7,710 | 66% | 7,743 | -0% |
| POST Baseline | 1,171 | - | 1,134 | +3% |
| POST With Sentry | 568 | 49% | 596 | -5% |
| POST With Sentry (error only) | 1,024 | 87% | 1,036 | -1% |
| MYSQL Baseline | 3,907 | - | 3,992 | -2% |
| MYSQL With Sentry | 472 | 12% | 520 | -9% |
| MYSQL With Sentry (error only) | 3,238 | 83% | 3,320 | -2% |