# Add Crash Reporting to a React Native App

Yes. An agent adds Sentry to your Expo React Native app the way your own setup guide describes, adapted to today's config files, and opens a PR with checks run.

[Run this on Rush](https://cloud.getrush.ai/run/add-crash-reporting/react-native/). Opens the console with this prompt ready to send, in a Project that has your repository.

## What the agent does

The agent reads the app's configuration and, when the repository has one, its own guide. In an app shaped like obytes/react-native-template-obytes, `app.config.ts` builds the Expo config from `env.ts`, with plugins for `expo-splash-screen`, `expo-font`, `expo-localization`, `expo-router`, `app-icon-badge` and `react-native-edge-to-edge`, and bundle ids per environment. `env.ts` holds one zod `envSchema` for `EXPO_PUBLIC_APP_ENV`, `EXPO_PUBLIC_API_URL` and the rest, plus a build-only `APP_BUILD_ONLY_VAR`, and `.env` keeps `SECRET_KEY` and `APP_BUILD_ONLY_VAR` without the `EXPO_PUBLIC_` prefix so they never reach the client. `metro.config.js` wraps `getDefaultConfig` in `withUniwindConfig` with `cssEntryFile: './src/global.css'`, `src/app/_layout.tsx` re-exports `ErrorBoundary` from `expo-router`, calls `hydrateAuth()` and `loadSelectedTheme()` at module load and renders the `Stack` inside a `Providers` tree, and `jest.config.js` already lists `@sentry/.*` in `transformIgnorePatterns`. `package.json` is on `expo ~54`, `expo-router ~6`, `react-native 0.81.5` and `pnpm@10.12.3`, with no Sentry package. `sentry-setup.mdx` under `docs/src/content/docs/` is a ten-step guide that says the starter does not ship Sentry and shows how to add it.

The agent follows that guide and corrects it where the code has moved on. The guide's `env.ts` snippet uses separate `client` and `buildTime` schemas and a `ClientEnv` export that no longer exist; the agent adds `SENTRY_ORG` and `SENTRY_PROJECT` as optional build-time entries and the DSN as `EXPO_PUBLIC_SENTRY_DSN` in the single `envSchema`, because only `EXPO_PUBLIC_` values are inlined into the client bundle. The guide's metro snippet calls `withUniwind(config, { input })`; the current file uses `withUniwindConfig(config, { cssEntryFile })`, so the agent swaps `getDefaultConfig` for `getSentryExpoConfig(__dirname)` and keeps the Uniwind wrapper exactly as it is. It installs with `pnpm expo install @sentry/react-native`, adds the `@sentry/react-native/expo` plugin to `app.config.ts` with `organization` and `project` read from `Env`, and adds the `apple-privacy-manifest.json` the guide lists, wired through `ios.privacyManifests`. `SENTRY_AUTH_TOKEN` is not written to `.env`; the pull request says it belongs in EAS as a secret environment variable, as the guide does.

For the runtime it creates `src/lib/sentry.ts` as the guide shows, `initSentry()` guarded by `!__DEV__` with `reactNavigationIntegration`, and `useSentryNavigationConfig()` registering the router's navigation container. In `_layout.tsx` it calls `initSentry()` next to `hydrateAuth()`, calls the hook inside `RootLayout`, and exports `Sentry.wrap(RootLayout)` as the default while keeping the `ErrorBoundary` re-export so expo-router's error screen still renders. It adds a Jest test for `sentry.ts` with `@sentry/react-native` mocked, asserting `init` is not called when `__DEV__` is true and is called with the DSN when it is false.

Then it runs what the repository's workflows run: `pnpm type-check`, `pnpm lint`, `pnpm test:ci`, `pnpm exec expo config --type public` to show the plugin resolves without an auth token, and `npx expo-doctor`. It does not run `expo prebuild` or an EAS build, since neither is needed to show the change compiles and the native projects are generated at build time. The pull request pastes those outputs and lists the three values the maintainers add in EAS: the org, the project and the auth token.

## Start it with one API call

`POST https://api.phoenix.so/o/{org}/sessions`

```json
{
  "agent": "claude",
  "input": "Add Sentry crash reporting to this Expo app and open a pull request. Read app.config.ts, env.ts, .env, metro.config.js, babel.config.js, tsconfig.json, jest.config.js, package.json, src/app/_layout.tsx and the repository's own Sentry setup guide, sentry-setup.mdx under docs/src/content/docs/, first, and follow the guide, adapting its snippets to how the files look now: env.ts has a single envSchema, so add SENTRY_ORG and SENTRY_PROJECT as optional build-time entries and the DSN as EXPO_PUBLIC_SENTRY_DSN; metro.config.js uses withUniwindConfig with cssEntryFile, so replace getDefaultConfig with getSentryExpoConfig and keep that wrapper unchanged. Install @sentry/react-native with pnpm expo install, add the @sentry/react-native/expo plugin to app.config.ts reading organization and project from Env, add the apple privacy manifest the guide lists via ios.privacyManifests, create src/lib/sentry.ts with initSentry guarded by !__DEV__ and the navigation integration hook, and wire both into src/app/_layout.tsx with Sentry.wrap as the default export while keeping the ErrorBoundary re-export. Do not put SENTRY_AUTH_TOKEN anywhere in the repository; say in the pull request that it is set in EAS. Add a Jest test for src/lib/sentry.ts with @sentry/react-native mocked. Run pnpm type-check, pnpm lint, pnpm test:ci, pnpm exec expo config --type public and npx expo-doctor, and paste their output in the pull request description. Do not run prebuild or an EAS build, and change nothing else.",
  "resources": [
    {
      "url": "https://github.com/your-org/your-app"
    }
  ]
}
```

1. **Get an API key.** In the console, open Settings, then API keys, and create a key for your org. Send it in the Authorization header as a Bearer token.
2. **Send the request.** POST the body in request.json to https://api.phoenix.so/o/{org}/sessions, with your repository as the resources URL. The run starts in its own cloud sandbox.
3. **Read what came back.** Follow the run on its live stream or wait for the run.completed webhook, then read the result and its trajectory.

## What comes back

What comes back is a pull request with `@sentry/react-native` in `package.json` and `pnpm-lock.yaml`, the plugin and privacy manifest in `app.config.ts`, three new entries in `env.ts`, `getSentryExpoConfig` in `metro.config.js`, a new `src/lib/sentry.ts` with its test, `apple-privacy-manifest.json`, and `src/app/_layout.tsx` wrapped with `Sentry.wrap`. The description quotes the type-check, lint and Jest output, the resolved public config showing the plugin, the `expo-doctor` result, and the three values to set in EAS.

The repository's `Tests (jest)`, `lint-ts`, `type-check` and `expo-doctor` workflows run on the pull request, so the change is checked the same way every other change is before merge. The first EAS build after the org, project and auth token are set in EAS uploads source maps through the plugin, and the first `!__DEV__` build sends its errors.

A reviewer checks that `initSentry()` runs before the first render but after nothing that could throw, that `ErrorBoundary` is still re-exported so route errors keep their screen, that no token or DSN for production is committed, and that the DSN env entry carries the `EXPO_PUBLIC_` prefix the client needs.

## Run it on every app release without crash reports

This is a change a mobile team wants in before the next store release and keeps deferring: a `POST /o/{org}/sessions` with this prompt and the repository in `resources`, sent from the terminal, lets the branch be ready while the team is on other work. The run continues in its own sandbox after the laptop closes. The sandbox parks with its disk when the turn ends, so a follow-up such as `add a Report a problem button in settings that calls Sentry.captureFeedback` wakes it with `node_modules` installed and the branch in place.

With a `webhook_url` on the API key, Rush posts `run.completed` or `run.failed` with the `session_url` when the turn ends. A studio that starts every app from the same template can send the same prompt to each repository, one run per repository, and each run reads that app's own `env.ts` and plugins.

## Why run it on Rush?

The guide exists and is still wrong in three places, because the template moved on after it was written: the env schema is one object now, the Metro wrapper has a different name and argument, and client values need a prefix the guide's `SENTRY_DSN` lacks. Following it line by line produces a build that silently has no DSN. The agent reads the guide and the current files together, applies the intent of each step to the code as it is, and runs the type-check, lint and tests in its own sandbox so the mismatches show up before review rather than on a device.

The run's record keeps the resolved Expo config and the test output beside the diff, so the reviewer sees the plugin in the config and `Sentry.init` behaving under both `__DEV__` values, not a description of the setup.

## Frequently asked questions

### Where does the Sentry auth token go?

Not in the repository. The token only uploads source maps during a build, so it is set in EAS as a secret environment variable, as the repository's own guide says. The agent leaves `SENTRY_AUTH_TOKEN` out of `.env` and `env.ts` and lists it in the pull request as a value to set in EAS.

### Why EXPO_PUBLIC_SENTRY_DSN rather than SENTRY_DSN?

Expo inlines only variables with the `EXPO_PUBLIC_` prefix into the JavaScript bundle. The guide names it `SENTRY_DSN`, which in the current `env.ts` would be a build-time value the client never sees, so `Sentry.init` would get nothing. The prefix is the one correction that matters most.

### Does it break the expo-router error screen?

No. `_layout.tsx` keeps `export { ErrorBoundary } from 'expo-router'`, and `Sentry.wrap` wraps the root component rather than replacing the router's boundary, so route errors still render the existing screen and are also reported.

### Will it run an EAS build to prove it works?

No. An EAS build needs the Expo token and takes a build slot; the change is shown to compile with `pnpm type-check`, to pass `pnpm lint` and `pnpm test:ci`, and to resolve the plugin with `expo config --type public`. The first real build after the EAS values are set is when source maps upload.

### Does Sentry report in development too?

Not by default. `initSentry()` is guarded by `!__DEV__`, as the guide shows, so local runs and the Jest suite never send events. The new test asserts that guard in both directions.

## More React Native jobs

- [Add Deep Links to a React Native App](https://getrush.ai/run/add-deep-links/react-native/)
- [Set Up GitHub Actions CI for a React Native App](https://getrush.ai/run/add-github-actions-ci/react-native/)
- [Add Offline Support to a React Native App](https://getrush.ai/run/add-offline-support/react-native/)

## The same job on other stacks

- [Add Crash Reporting to a Tauri App](https://getrush.ai/run/add-crash-reporting/tauri/)
- [Add Sentry Crash Reporting to a Vite React App](https://getrush.ai/run/add-crash-reporting/vite-react/)
- [Add Crash Reporting to an Electron App](https://getrush.ai/run/add-crash-reporting/electron/)

## Keep reading

- [How a Rush run works on your repository, from request to pull request](https://getrush.ai/cloud/)
- [Compare cloud agents, agent sandboxes and AI code review](https://getrush.ai/compare/)
- [Rush pricing: Free, Pro and Max](https://getrush.ai/pricing/)
