-
Notifications
You must be signed in to change notification settings - Fork 13
Add conditional Sentry initialization based on environment (production only) #154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the Comment |
Deploying wallet-signet with
|
| Latest commit: |
12e0515
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://f11fb835.wallet-23u.pages.dev |
| Branch Preview URL: | https://copilot-add-sentry-dsn-env-s.wallet-23u.pages.dev |
Deploying wallet-mutinynet with
|
| Latest commit: |
12e0515
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://b17a83a6.arkade-wallet.pages.dev |
| Branch Preview URL: | https://copilot-add-sentry-dsn-env-s.arkade-wallet.pages.dev |
Deploying wallet-bitcoin-v8 with
|
| Latest commit: |
12e0515
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://2d921f1b.wallet-v8.pages.dev |
| Branch Preview URL: | https://copilot-add-sentry-dsn-env-s.wallet-v8.pages.dev |
Co-authored-by: tiero <3596602+tiero@users.noreply.github.com>
Co-authored-by: tiero <3596602+tiero@users.noreply.github.com>
|
@copilot merge master, solve conflicts and remove VITE_IS_RIGA as in master we have cleaned up |
Co-authored-by: tiero <3596602+tiero@users.noreply.github.com>
Done! Successfully merged master branch and removed VITE_IS_RIGA from TypeScript definitions. All conflicts resolved automatically, tests pass, and build succeeds. Commit: ea4ae40 → (merge commit will be created) |
Deploying wallet-bitcoin with
|
| Latest commit: |
8ee174a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://9ace442a.wallet-bitcoin.pages.dev |
| Branch Preview URL: | https://copilot-add-sentry-dsn-env-s.wallet-bitcoin.pages.dev |
Signed-off-by: Marco Argentieri <3596602+tiero@users.noreply.github.com>
bordalix
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
Overview
This PR implements conditional Sentry initialization that ensures error tracking is only active in production environments, preventing development errors from being sent to Sentry when running on localhost.
Problem
Previously, Sentry was initialized unconditionally whenever the
VITE_SENTRY_DSNenvironment variable was set:This meant that:
Solution
Implemented environment-aware Sentry initialization that checks the hostname before initializing:
New Utility Functions (
src/lib/sentry.ts)Behavior
Sentry will initialize only when:
VITE_SENTRY_DSNenvironment variable is setChanges
src/lib/sentry.ts(NEW): Added utility functions for environment detection and Sentry initialization logicsrc/index.tsx: Updated Sentry initialization to be conditional based on environmentsrc/vite-env.d.ts: Added TypeScript type definitions for environment variables (VITE_SENTRY_DSN, VITE_ARK_SERVER, VITE_BOLTZ_URL); removed deprecated VITE_IS_RIGAsrc/test/lib/sentry.test.ts(NEW): Added 11 comprehensive test cases covering all scenariosREADME.md: Updated documentation to clarify that Sentry only works in productionMerge with Master
This PR includes a merge with the latest master branch (commit fce53cf - "Cleanup #156"), which includes:
isRigaconstant fromsrc/lib/constants.tssrc/components/Minimal.tsx,src/lib/alerts.ts,src/providers/iframe.tsxTesting
✅ 111 tests pass (including 11 new Sentry-specific tests)
isProduction()with various hostnames (localhost, 127.0.0.1, production domains)shouldInitializeSentry()with different DSN and hostname combinations✅ All quality checks pass:
Usage
Development
# Sentry will NOT initialize on localhost pnpm run startProduction
Benefits
Original prompt
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.