Observability — Sentry
Once an app is installed on someone else's device, you lose your terminal. Without crash/error reporting, a broken release is invisible until a tester happens to mention it. Sentry closes that gap for React Native / Expo apps: crash capture, error tracking, and (optionally) performance spans, wired into the CI/CD pipeline so every release is traceable back to the commits that shipped in it.
Key Concepts
| Term | What it is |
|---|---|
| Event | One captured crash, exception, or manually reported error |
| Issue | A group of events Sentry considers the same underlying bug (by stack trace fingerprint) |
| Release | A named version of the app — events and deploys attach to it |
| Deploy | A marker on a release saying "this build actually reached an environment" (distinct from the build itself) |
| Environment | Free-text tag (development, production) to separate dev noise from real user crashes |
| Source maps | Map minified/bundled JS back to original source — required for readable stack traces |
| Suspect commit | Sentry's guess at which commit introduced an issue, computed from the commits attached to each release |
| Crash-free rate | % of sessions/users without a crash, tracked per release — needs deploys to be marked to compute per-version |
Setup (React Native / Expo)
npx @sentry/wizard@latest -i reactNative
The wizard wires most of this automatically, but the manual pieces worth knowing:
- Init + wrap the root component:
// app/_layout.tsx Sentry.init({ dsn: '...', environment: __DEV__ ? 'development' : 'production' }); export default Sentry.wrap(RootLayout); - Expo config plugin — adds native instrumentation and auto-uploads
source maps + creates a release during
eas build. This is a native change — it changes the build fingerprint, so an OTA update won't reach devices until the next full build+submit.// app.config.js plugins: [['@sentry/react-native', { organization: '...', project: '...' }]] SENTRY_AUTH_TOKENneeds to exist in two separate places, and this is not redundant:- As an EAS environment variable — used by the config plugin during
eas build(native infra) to upload source maps. - As a GitHub Actions secret of the same name — used by
sentry-clirunning on the GitHub runner (separate infra) for the CI/CD steps below.
Release naming convention
The config plugin names releases automatically at build time as:
<applicationId>@<version>+<buildNumber>
# e.g. com.example.myapp@2.0.0+7
(bundleIdentifier+CFBundleVersion on iOS instead of applicationId.)
Confirm this against the actual project with sentry-cli releases list
rather than assuming — the release already exists (with source maps
attached) as soon as a native build finishes, even before anything below is
wired up; it just sits (unreleased) with no commits attached.
CI/CD Integration Pattern
Two things a release needs beyond what the native build already provides:
-
Commit association (suspect-commit detection) — run once the build finishes, in the build workflow:
sentry-cli releases set-commits "$RELEASE" --auto sentry-cli releases finalize "$RELEASE"--autoreads local git history to diff against the previous release.actions/checkout@v4defaults tofetch-depth: 1(shallow clone) — this silently starves--autoof history. Usefetch-depth: 0. -
Deploy marker (crash-free rate per version) — run once the build is actually distributed, in the submit workflow:
If the submit step doesn't tell you which build it submitted (e.g.sentry-cli releases deploys new "$RELEASE" --env productioneas submit --latest), re-derive the same release name by re-querying the latest finished build (eas build:list --profile <p> --status finished --limit 1 --json).
Lessons Learned
1. Metro must be instrumented, or capture silently never arrives
Symptom: SDK initialized, plugin installed, auth token set — everything looks correct, but no event ever shows up in the dashboard, and there's no error telling you why.
Root cause: Expo's default getDefaultConfig doesn't instrument the JS
bundle. Sentry ships its own wrapper for this.
Fix:
// metro.config.js
const { getSentryExpoConfig } = require('@sentry/react-native/metro');
module.exports = getSentryExpoConfig(__dirname);
// not: const { getDefaultConfig } = require('expo/metro-config');
npx @sentry/wizard (interactive) catches this automatically if run — but
it needs a real TTY, so it can fail silently in a non-interactive shell.
2. React Native DevTools console is broken under WSL2
Symptom: pressing j in the Metro terminal to open React Native
DevTools does nothing useful — the console never executes anything typed
into it, with no visible error (just [debugger-shell stderr] Exiting GPU
process due to errors during initialization buried in the Metro log).
Consequence: any ad hoc JS testing that relies on that console (e.g. a
globalThis.__testCrash() helper to verify Sentry capture) looks like it's
failing when it's actually never running at all. Also easy to mistake for a
different failure: typing into the Metro terminal itself (rather than the
DevTools console) triggers Metro's own keyboard shortcuts instead (e.g. r
reloads the app).
Workaround: don't depend on the DevTools console under WSL2 for ad hoc JS triggers. Add a dev-only UI button that calls the helper directly:
{__DEV__ && (
<Button title="🧪 Test crash" onPress={() => globalThis.__testCrash?.()} />
)}
3. A build's own release starts (unreleased) with zero commits
Not a bug — just the default state before the CI/CD steps above run. If
you configure Sentry alerting/regression detection and it looks like
nothing is tracked, check sentry-cli releases list first: the release
usually already exists, it's just missing commit/deploy metadata.
Checklist
- [ ] SDK installed,
Sentry.init+Sentry.wrap(RootComponent)in place - [ ] Config plugin added (
organization/project) — remember this is a native change (fingerprint bump, needs a full rebuild) - [ ]
metro.config.jsusesgetSentryExpoConfig, not Expo's default - [ ]
SENTRY_AUTH_TOKENset both as an EAS env var (native build) and a GitHub Actions secret (CIsentry-cli) - [ ] Capture verified end-to-end — a real event visible in the dashboard, not just "no errors thrown locally"
- [ ]
actions/checkoutusesfetch-depth: 0before anyset-commits --auto - [ ] Build workflow:
set-commits --auto+finalize - [ ] Submit/deploy workflow:
releases deploys new --env <env>