-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Expo integration docs #16923
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
Merged
Merged
Expo integration docs #16923
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
docs/platforms/react-native/manual-setup/expo/eas-build-hooks.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| --- | ||
| title: EAS Build Hooks | ||
| description: "Capture EAS build failures and lifecycle events in Sentry." | ||
| sidebar_order: 10 | ||
| --- | ||
|
|
||
| EAS Build runs your app builds on Expo's infrastructure. When a build fails, the error can be hard to diagnose — it happens outside your local environment and outside your app. EAS Build Hooks let you send build lifecycle events directly to Sentry so you can track failures, correlate them with releases, and get notified when production builds break. | ||
|
|
||
| ## Setup | ||
|
|
||
| Add the Sentry EAS build hook scripts to your `package.json`: | ||
|
|
||
| ```json {filename:package.json} | ||
| { | ||
| "scripts": { | ||
| "eas-build-on-error": "sentry-eas-build-on-error", | ||
| "eas-build-on-success": "sentry-eas-build-on-success", | ||
| "eas-build-on-complete": "sentry-eas-build-on-complete" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| EAS Build automatically runs `package.json` scripts with these names at the corresponding lifecycle events. See the [Expo npm hooks documentation](https://docs.expo.dev/build-reference/npm-hooks/) for more details. | ||
|
|
||
| Set your DSN as an EAS secret or environment variable so it's available during builds: | ||
|
|
||
| ```bash | ||
| eas secret:create --scope project --name SENTRY_DSN --value <your-dsn> | ||
| ``` | ||
|
|
||
| ## What Gets Captured | ||
|
|
||
| **`eas-build-on-error`** — Sends an `EASBuildError` event to Sentry when a build fails. The event includes: | ||
|
|
||
| - Build platform (`ios` / `android`) | ||
| - Build profile (for example, `production`, `preview`) | ||
| - Build ID, project ID, git commit hash | ||
| - Whether the build ran on CI | ||
|
|
||
| **`eas-build-on-success`** — Optionally sends an info event when a build succeeds. Disabled by default; enable it with `SENTRY_EAS_BUILD_CAPTURE_SUCCESS=true`. | ||
|
|
||
| **`eas-build-on-complete`** — A single hook that captures either a failure or success event depending on the build outcome. Use this instead of `on-error` + `on-success` if you prefer a single hook entry point. | ||
|
|
||
| All events are tagged with `eas.*` tags so you can filter and group them in Sentry. | ||
|
|
||
| ## Environment Variables | ||
|
|
||
| | Variable | Required | Description | | ||
| |---|---|---| | ||
| | `SENTRY_DSN` | Yes | Your project's DSN | | ||
| | `SENTRY_EAS_BUILD_CAPTURE_SUCCESS` | No | Set to `true` to capture successful builds | | ||
| | `SENTRY_EAS_BUILD_TAGS` | No | JSON object of additional tags, for example `{"team":"mobile"}` | | ||
| | `SENTRY_EAS_BUILD_ERROR_MESSAGE` | No | Custom error message for failed builds | | ||
| | `SENTRY_EAS_BUILD_SUCCESS_MESSAGE` | No | Custom message for successful builds | | ||
| | `SENTRY_RELEASE` | No | Override the release name (defaults to `{appVersion}+{buildNumber}`) | | ||
|
|
||
| ## Environment Files | ||
|
|
||
| The hook automatically loads environment variables from the following sources (without overwriting values already set by EAS): | ||
|
|
||
| 1. `@expo/env` (if available) | ||
| 2. `.env` file in the project root (via `dotenv`, if available) | ||
| 3. `.env.sentry-build-plugin` file in the project root | ||
|
|
||
| This means you can store the DSN in `.env.sentry-build-plugin` locally, and use an EAS secret in CI — the hook will use whichever value is already set. | ||
|
|
||
| ## Using `on-complete` Instead of Separate Hooks | ||
|
|
||
| If you only need to track failures but want the option to add success tracking later, `eas-build-on-complete` is the most flexible option. It reads `EAS_BUILD_STATUS` (set by EAS) to determine the outcome and captures the appropriate event: | ||
|
|
||
| ```json {filename:package.json} | ||
| { | ||
| "scripts": { | ||
| "eas-build-on-complete": "sentry-eas-build-on-complete" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| To also capture successful builds, set `SENTRY_EAS_BUILD_CAPTURE_SUCCESS=true` in your build environment. | ||
74 changes: 74 additions & 0 deletions
74
docs/platforms/react-native/manual-setup/expo/expo-updates.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,74 @@ | ||
| --- | ||
| title: Expo Updates | ||
| description: "Automatic context and alerts for Expo OTA updates." | ||
| sidebar_order: 20 | ||
| --- | ||
|
|
||
| When you ship OTA updates with Expo Updates, events captured by Sentry are automatically enriched with information about which update is running. This lets you filter issues by update channel, runtime version, or update ID — and get alerted when an emergency launch occurs. | ||
|
|
||
| These integrations are enabled by default in Expo projects. No additional setup is required. | ||
|
|
||
| ## Expo Updates Context | ||
|
|
||
| Every Sentry event includes an `ota_updates` context with the current update state: | ||
|
|
||
| | Field | Description | | ||
| |---|---| | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit/q: Are is_enabled, is_using_embedded_assets, and emergency_launch_reason omitted for simplicity? |
||
| | `update_id` | UUID of the currently running OTA update | | ||
| | `channel` | Expo Updates channel (for example, `production`, `staging`) | | ||
| | `runtime_version` | Runtime version of the update | | ||
| | `is_enabled` | Whether Expo Updates is enabled | | ||
| | `is_embedded_launch` | Whether the app launched from the embedded bundle | | ||
| | `is_using_embedded_assets` | Whether the app is using embedded assets | | ||
| | `is_emergency_launch` | Whether this was an emergency launch (fallback to embedded) | | ||
| | `emergency_launch_reason` | Reason for the emergency launch (if applicable) | | ||
| | `check_automatically` | Automatic update check policy | | ||
| | `launch_duration` | How long the update launch took (ms) | | ||
| | `created_at` | When the update was created | | ||
|
|
||
| ## Searchable Tags | ||
|
|
||
| The SDK also sets the following tags on every event so you can filter and group issues in Sentry: | ||
|
|
||
| | Tag | Value | | ||
| |---|---| | ||
| | `expo.updates.update_id` | UUID of the running update | | ||
| | `expo.updates.channel` | Update channel name | | ||
| | `expo.updates.runtime_version` | Runtime version string | | ||
|
|
||
| To find all issues from a specific update channel, use `expo.updates.channel:production` in the Sentry issue search. | ||
|
|
||
| ## Emergency Launch Warnings | ||
|
|
||
| Expo Updates performs an _emergency launch_ when it fails to load the latest OTA update and falls back to the embedded bundle. This can silently degrade user experience. | ||
|
|
||
| When the SDK detects an emergency launch at startup, it automatically sends a `warning`-level event to Sentry with: | ||
|
|
||
| - Message: `Expo Updates emergency launch: <reason>` (or `Expo Updates emergency launch` if no reason is available) | ||
| - Tag: `expo.updates.emergency_launch: true` | ||
|
|
||
| You can set up a Sentry alert on this tag to get notified whenever an emergency launch happens in production. | ||
|
|
||
| <Alert> | ||
|
|
||
| Emergency launch detection only runs in native builds, not in Expo Go. | ||
|
|
||
| </Alert> | ||
|
|
||
| ## Expo Constants Context | ||
|
|
||
| The SDK automatically captures Expo Constants as an `expo_constants` context on every event. This provides metadata about the execution environment and app configuration: | ||
|
|
||
| | Field | Description | | ||
| |---|---| | ||
| | `execution_environment` | Where the app is running (`storeClient`, `standalone`, `bare`) | | ||
| | `app_ownership` | Whether the app runs in Expo Go or standalone | | ||
| | `debug_mode` | Whether debug mode is enabled | | ||
| | `expo_version` | Expo client version | | ||
| | `expo_runtime_version` | Runtime version from app config | | ||
| | `session_id` | Current session ID | | ||
| | `app_name` | App name from `app.json` | | ||
| | `app_slug` | App slug from `app.json` | | ||
| | `app_version` | App version from `app.json` | | ||
| | `expo_sdk_version` | Expo SDK version | | ||
| | `eas_project_id` | EAS project ID | | ||
44 changes: 44 additions & 0 deletions
44
docs/platforms/react-native/tracing/instrumentation/expo-resources.mdx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| --- | ||
| title: Expo Image and Asset Instrumentation | ||
| description: "Automatic performance spans for expo-image and expo-asset." | ||
| sidebar_order: 70 | ||
| --- | ||
|
|
||
| Image and asset loading times directly affect how quickly your app feels responsive. The SDK can automatically create performance spans for `expo-image` and `expo-asset` operations so you can see exactly how long prefetching and loading takes within your existing traces. | ||
|
|
||
| ## Expo Image | ||
|
|
||
| Wrap the `Image` class from `expo-image` once at app startup to instrument `Image.prefetch()` and `Image.loadAsync()`: | ||
|
|
||
| ```javascript {filename:App.js} | ||
| import { Image } from 'expo-image'; | ||
| import * as Sentry from '@sentry/react-native'; | ||
|
|
||
| Sentry.wrapExpoImage(Image); | ||
| ``` | ||
|
|
||
| After wrapping, every call to `Image.prefetch()` creates a `resource.image.prefetch` span, and every call to `Image.loadAsync()` creates a `resource.image.load` span. The spans are automatically linked to the active trace. | ||
|
|
||
| Span attributes include: | ||
|
|
||
| - `image.url` — the image URL (for single-image operations) | ||
| - `image.url_count` — number of URLs (for batch prefetch) | ||
|
|
||
| ## Expo Asset | ||
|
|
||
| Wrap the `Asset` class from `expo-asset` once at app startup to instrument `Asset.loadAsync()`: | ||
|
|
||
| ```javascript {filename:App.js} | ||
| import { Asset } from 'expo-asset'; | ||
| import * as Sentry from '@sentry/react-native'; | ||
|
|
||
| Sentry.wrapExpoAsset(Asset); | ||
| ``` | ||
|
|
||
| After wrapping, every call to `Asset.loadAsync()` creates a `resource.asset` span with an `asset.count` attribute. | ||
|
|
||
| ## Notes | ||
|
|
||
| - Both `wrapExpoImage` and `wrapExpoAsset` are safe to call multiple times — the SDK guards against double-wrapping. | ||
| - Spans are only created when a trace is active. If you're not using [tracing](/platforms/react-native/tracing/), no spans are created and there's no overhead. | ||
| - `expo-image` and `expo-asset` are peer dependencies — the SDK does not require them to be installed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Sorry I'm not super familiar with expo builds, is this the same thing as the build environment?
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.
Very similar, yes: https://docs.expo.dev/build/eas-json/#build-profiles