From d643fccfc11f3ed1cc5d3317dadcf78ae7e1a4bd Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Tue, 10 Mar 2026 16:16:42 +0100 Subject: [PATCH 1/2] feat(react-native): Add environment option to Expo config plugin --- .../manual-setup/app-start-error-capture.mdx | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/docs/platforms/react-native/manual-setup/app-start-error-capture.mdx b/docs/platforms/react-native/manual-setup/app-start-error-capture.mdx index 0b7004aad70c84..9c63a9a519cc51 100644 --- a/docs/platforms/react-native/manual-setup/app-start-error-capture.mdx +++ b/docs/platforms/react-native/manual-setup/app-start-error-capture.mdx @@ -139,3 +139,40 @@ export default withSentry(config, { When `useNativeInit` is set to `true`, the Expo plugin automatically: - Adds `RNSentrySDK.init()` to your Android `MainApplication` - Adds `RNSentrySDK.start()` to your iOS `AppDelegate` + +### Setting the Environment + +You can set the `environment` for native initialization using the Expo plugin prop or the `SENTRY_ENVIRONMENT` environment variable. The plugin writes the value into `sentry.options.json` during `expo prebuild`. + +```json {filename:app.json} +{ + "expo": { + "plugins": [ + [ + "@sentry/react-native/expo", + { + "useNativeInit": true, + "environment": "staging" + } + ] + ] + } +} +``` + +For per-environment builds with EAS Build, set `SENTRY_ENVIRONMENT` in your build profiles instead: + +```json {filename:eas.json} +{ + "build": { + "production": { + "env": { "SENTRY_ENVIRONMENT": "production" } + }, + "staging": { + "env": { "SENTRY_ENVIRONMENT": "staging" } + } + } +} +``` + +The plugin prop takes precedence over the environment variable. From 3653a3f4dbb92e5dca11de8ae2820bb7dddb4d65 Mon Sep 17 00:00:00 2001 From: Antonis Lilis Date: Wed, 11 Mar 2026 14:44:55 +0100 Subject: [PATCH 2/2] feat(react-native): Document Expo plugin options for sentry.options.json generation Co-Authored-By: Claude Opus 4.6 --- .../manual-setup/app-start-error-capture.mdx | 40 ++++++++----------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/docs/platforms/react-native/manual-setup/app-start-error-capture.mdx b/docs/platforms/react-native/manual-setup/app-start-error-capture.mdx index 9c63a9a519cc51..5d134de7f5fb71 100644 --- a/docs/platforms/react-native/manual-setup/app-start-error-capture.mdx +++ b/docs/platforms/react-native/manual-setup/app-start-error-capture.mdx @@ -107,9 +107,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ## Expo Setup -If you're using Expo, you can enable native initialization using the Expo plugin. First, create a `sentry.options.json` file in your project root (same location as your `app.json`) [as above](#configuration-file). - -Add the `useNativeInit` option to your Expo plugin configuration: +If you're using Expo, you can enable native initialization using the Expo plugin. Add the `useNativeInit` option and your SDK options to the plugin configuration: ```json {filename:app.json} { @@ -118,7 +116,12 @@ Add the `useNativeInit` option to your Expo plugin configuration: [ "@sentry/react-native/expo", { - "useNativeInit": true + "useNativeInit": true, + "options": { + "dsn": "https://key@example.io/value", + "environment": "production", + "tracesSampleRate": 1.0 + } } ] ] @@ -126,6 +129,8 @@ Add the `useNativeInit` option to your Expo plugin configuration: } ``` +The plugin generates a `sentry.options.json` file from the `options` property during `expo prebuild`. If a `sentry.options.json` file already exists in your project root, the plugin options are merged into it (plugin options take precedence). + If you need to use environment variables or dynamic configuration, you can use `app.config.js` with the `withSentry()` wrapper instead of the array form in `app.json`: ```javascript {filename:app.config.js} @@ -133,6 +138,11 @@ import { withSentry } from "@sentry/react-native/expo"; export default withSentry(config, { useNativeInit: true, + options: { + dsn: "https://key@example.io/value", + environment: "production", + tracesSampleRate: 1.0, + }, }); ``` @@ -142,25 +152,9 @@ When `useNativeInit` is set to `true`, the Expo plugin automatically: ### Setting the Environment -You can set the `environment` for native initialization using the Expo plugin prop or the `SENTRY_ENVIRONMENT` environment variable. The plugin writes the value into `sentry.options.json` during `expo prebuild`. +You can set the `environment` using the plugin `options` property as shown above, or using the `SENTRY_ENVIRONMENT` environment variable. The environment variable takes precedence over the plugin option. -```json {filename:app.json} -{ - "expo": { - "plugins": [ - [ - "@sentry/react-native/expo", - { - "useNativeInit": true, - "environment": "staging" - } - ] - ] - } -} -``` - -For per-environment builds with EAS Build, set `SENTRY_ENVIRONMENT` in your build profiles instead: +For per-environment builds with EAS Build, set `SENTRY_ENVIRONMENT` in your build profiles: ```json {filename:eas.json} { @@ -174,5 +168,3 @@ For per-environment builds with EAS Build, set `SENTRY_ENVIRONMENT` in your buil } } ``` - -The plugin prop takes precedence over the environment variable.