Skip to content

feat: expose Sentry DSN as a runtime env (Closes #920) - #1041

Open
waterWang wants to merge 1 commit into
CredenceOrg:mainfrom
waterWang:feat/expose-sentry-dsn-as-runtime-env
Open

feat: expose Sentry DSN as a runtime env (Closes #920)#1041
waterWang wants to merge 1 commit into
CredenceOrg:mainfrom
waterWang:feat/expose-sentry-dsn-as-runtime-env

Conversation

@waterWang

Copy link
Copy Markdown
Contributor

Summary

Expose the Sentry DSN as a runtime environment variable, so it can be configured at deployment time without rebuilding the application.

Changes

  • src/config/sentry.ts: Added resolveDsn() function that checks window.__RUNTIME_CONFIG__?.VITE_SENTRY_DSN first, then falls back to import.meta.env.VITE_SENTRY_DSN (build-time), then to empty string.
  • src/vite-env.d.ts: Added VITE_SENTRY_DSN to ImportMetaEnv, added RuntimeConfig interface, and extended Window with __RUNTIME_CONFIG__.
  • src/config/sentry.test.ts: Added 4 new tests covering runtime config resolution (priority, fallback, absent, empty).
  • index.html: Added <script> placeholder for server-side runtime config injection.

Testing

All 8 tests pass (4 existing + 4 new):

✓ src/config/sentry.test.ts (8 tests) 37ms

Closes #920

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Config: expose the Sentry DSN as a runtime env

1 participant