Skip to content

Commit 1e4276a

Browse files
antonisclaude
andcommitted
feat(core): Support SENTRY_ENVIRONMENT env variable in Expo config plugin
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 0f2c0a8 commit 1e4276a

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,14 @@
2424
- Adds tags with Expo Updates context variables to make them searchable and filterable ([#5788](https://github.com/getsentry/sentry-react-native/pull/5788))
2525
- Add `environment` option to the Expo config plugin for native init ([#5796](https://github.com/getsentry/sentry-react-native/pull/5796))
2626
- Sets the environment in `sentry.options.json` during `expo prebuild`, so pre-JS crashes are tagged correctly
27+
- Reads from the `environment` plugin prop or the `SENTRY_ENVIRONMENT` environment variable
2728
```json
2829
["@sentry/react-native/expo", {
2930
"useNativeInit": true,
3031
"environment": "staging"
3132
}]
3233
```
34+
- Or via `SENTRY_ENVIRONMENT` env variable (e.g. per EAS Build profile in `eas.json`)
3335

3436
### Fixes
3537

packages/core/plugin/src/withSentry.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ const withSentryPlugin: ConfigPlugin<PluginProps | void> = (config, props) => {
2828
}
2929

3030
let cfg = config;
31-
if (props?.environment) {
32-
cfg = withSentryOptionsEnvironment(cfg, props.environment);
31+
const environment = props?.environment || process.env.SENTRY_ENVIRONMENT;
32+
if (environment) {
33+
cfg = withSentryOptionsEnvironment(cfg, environment);
3334
}
3435
if (sentryProperties !== null) {
3536
try {

0 commit comments

Comments
 (0)