getsentry / getsentry/sentry-javascript

feat(browser): Add environment variable support for Spotlight configuration

Đang mở
#18,404 1 bình luận 0 reaction 1 người được giao Được @BYK nhận Xem trên GitHub
Feature
Ngôn ngữ chính
TypeScript
Star
8.7k
Fork
1.8k
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
515

Mô tả

> \[!NOTE\]
The pull request "[feat(browser): Add environment variable support for Spotlight configuration]()" was created by @BYK but did not reference an issue. Therefore this issue was created for better visibility in external tools like Linear.

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.

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.