Skip to content

fix: gate Sentry init on EXPO_PUBLIC_SENTRY_ENABLED instead of isDev#747

Merged
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
collinsezedike:fix/issue-639-sentry-env-var-gating
Jun 30, 2026
Merged

fix: gate Sentry init on EXPO_PUBLIC_SENTRY_ENABLED instead of isDev#747
RUKAYAT-CODER merged 1 commit into
rinafcode:mainfrom
collinsezedike:fix/issue-639-sentry-env-var-gating

Conversation

@collinsezedike

Copy link
Copy Markdown
Contributor

What this does

Closes #639.

initializeLogging() previously called Sentry.init() only when !isDev. Because isDev is derived from __DEV__ at module load time, staging and internal testing builds compiled with __DEV__ === true (e.g. EAS preview distributed internally) would silently discard all exceptions - never reaching the QA team's Sentry project.

This PR decouples Sentry initialization from the dev/prod binary and puts it under an explicit EXPO_PUBLIC_SENTRY_ENABLED env var:

isSentryEnabled = (EXPO_PUBLIC_SENTRY_ENABLED === 'true') OR (not a dev build)
  • Dev builds, no env var set: Sentry stays off (unchanged behaviour for local development)
  • Dev/staging builds with EXPO_PUBLIC_SENTRY_ENABLED=true: Sentry initializes, environment tag set to 'staging' so events are filtered correctly in the Sentry dashboard
  • Production builds: Sentry always initializes regardless of the env var, environment tag set to 'production'

isDev is left in place - it still controls log level and verbosity. Only the Sentry init decision is moved to isSentryEnabled.

Changes

File What changed
src/config/logging.ts Added isSentryEnabled constant; replaced if (!isDev) guard with if (isSentryEnabled); Sentry environment now reflects 'staging' vs 'production'
src/config/env.ts Added EXPO_PUBLIC_SENTRY_ENABLED to EnvConfig type and validation
eas.json development profile sets EXPO_PUBLIC_SENTRY_ENABLED=false; preview and production profiles set it to true
docs/environments.md New file documenting all env vars, build profiles, and the Sentry opt-in logic
src/__tests__/config/logging.test.ts Five tests covering: dev without var (off), dev with true (on, staging env), production without var (on, production env), production with false (still on), dev with false (off)

@collinsezedike collinsezedike force-pushed the fix/issue-639-sentry-env-var-gating branch from d874262 to f6c1613 Compare June 30, 2026 06:52
@drips-wave

drips-wave Bot commented Jun 30, 2026

Copy link
Copy Markdown

@collinsezedike Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@RUKAYAT-CODER

Copy link
Copy Markdown
Contributor

Thank you for contributing to the project.

@RUKAYAT-CODER RUKAYAT-CODER merged commit 52158f0 into rinafcode:main Jun 30, 2026
1 of 11 checks passed
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.

[Bug] Sentry DSN initialized conditionally — exceptions thrown before isDev check are never captured

2 participants