Skip to content

feat(core): Add environment option to Expo config plugin#5796

Merged
antonis merged 8 commits intomainfrom
antonis/sentry-options-env
Mar 11, 2026
Merged

feat(core): Add environment option to Expo config plugin#5796
antonis merged 8 commits intomainfrom
antonis/sentry-options-env

Conversation

@antonis
Copy link
Contributor

@antonis antonis commented Mar 10, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Adds environment configuration in the Expo config plugin. The environment can be set via:

  1. The environment plugin prop in app.json:
    ["@sentry/react-native/expo", {
      "useNativeInit": true,
      "environment": "staging"
    }]
  2. The SENTRY_ENVIRONMENT environment variable (e.g. per EAS Build profile in eas.json):
    {
      "build": {
        "production": { "env": { "SENTRY_ENVIRONMENT": "production" } },
        "staging": { "env": { "SENTRY_ENVIRONMENT": "staging" } }
      }
    }

The plugin prop takes precedence over the env variable. The value is written into sentry.options.json during expo prebuild, so that native init (useNativeInit: true) tags pre-JS crashes with the correct environment.

💡 Motivation and Context

Closes #5779

There is currently no way to dynamically specify the environment field in sentry.options.json. Users building for multiple environments need different values, but the file is static. While Sentry.init() in JS can override environment, pre-JS crashes would still be tagged with the wrong environment.

💚 How did you test it?

  • Unit tests for writeSentryOptionsEnvironment covering:
    • Creates sentry.options.json when file does not exist
    • Overrides environment in existing file
    • Adds environment to file that doesn't have it, preserving other options
  • All existing expo-plugin tests pass
  • ESLint passes
  • Build passes

📝 Checklist

🔮 Next steps

  • Documentation update

Closes #5779

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2026

Semver Impact of This PR

None (no version bump detected)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


  • feat(core): Add environment option to Expo config plugin by antonis in #5796
  • chore(deps): update CLI to v3.3.2 by github-actions in #5799
  • chore(deps): update Maestro to v2.3.0 by github-actions in #5790
  • chore(deps): update JavaScript SDK to v10.43.0 by github-actions in #5791
  • chore(deps): update CLI to v3.3.1 by github-actions in #5793
  • fix(core): Defer initial navigation span creation until navigation container is registered by antonis in #5789
  • Ref(Sample): Add existing bundled playgroundscreen into sample app by lucas-zimerman in #5778
  • Auto tracing for expo-image and expo-asset by alwx in #5718
  • Expo Updates: add tags with Expo Updates context vars to make them searchable/filterable by alwx in #5788
  • chore(deps): bump actions/setup-node from 6.2.0 to 6.3.0 by dependabot in #5784
  • chore(deps): bump github/codeql-action from 4.32.4 to 4.32.6 by dependabot in #5781
  • chore(deps): bump getsentry/craft/.github/workflows/changelog-preview.yml from 2.23.1 to 2.23.2 by dependabot in #5782
  • chore(deps): bump getsentry/craft from 2.21.7 to 2.23.2 by dependabot in #5783
  • chore(deps): bump tar to ^7.5.10 by antonis in #5777

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 10, 2026

Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against caeb51e

antonis and others added 4 commits March 10, 2026 15:52
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ugin

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link
Contributor

@alwx alwx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@antonis antonis added the ready-to-merge Triggers the full CI test suite label Mar 11, 2026
- Use `??` instead of `||` so explicit empty string is not ignored
- Add try-catch for JSON.parse in writeSentryOptionsEnvironment
- Add test for invalid JSON handling

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 11, 2026

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1217.86 ms 1220.09 ms 2.23 ms
Size 3.38 MiB 4.81 MiB 1.43 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
ea3e26e+dirty 1229.13 ms 1228.46 ms -0.67 ms
80e4616+dirty 1221.32 ms 1225.64 ms 4.32 ms
818a608+dirty 1205.76 ms 1208.00 ms 2.24 ms
77061ed+dirty 1233.16 ms 1234.88 ms 1.71 ms
bef3709+dirty 1222.07 ms 1220.24 ms -1.83 ms
a206511+dirty 1185.00 ms 1186.35 ms 1.35 ms
74979ac+dirty 1210.49 ms 1213.31 ms 2.82 ms
a2bb688+dirty 1223.53 ms 1232.90 ms 9.37 ms
8a868fe+dirty 1221.50 ms 1230.78 ms 9.28 ms
d590428+dirty 1211.77 ms 1220.51 ms 8.75 ms

App size

Revision Plain With Sentry Diff
ea3e26e+dirty 3.41 MiB 4.58 MiB 1.17 MiB
80e4616+dirty 3.38 MiB 4.60 MiB 1.22 MiB
818a608+dirty 2.63 MiB 3.91 MiB 1.28 MiB
77061ed+dirty 2.63 MiB 3.98 MiB 1.34 MiB
bef3709+dirty 3.38 MiB 4.78 MiB 1.40 MiB
a206511+dirty 3.41 MiB 4.67 MiB 1.25 MiB
74979ac+dirty 3.38 MiB 4.60 MiB 1.22 MiB
a2bb688+dirty 2.63 MiB 3.99 MiB 1.36 MiB
8a868fe+dirty 3.38 MiB 4.60 MiB 1.22 MiB
d590428+dirty 3.38 MiB 4.78 MiB 1.39 MiB

@github-actions
Copy link
Contributor

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 409.74 ms 428.48 ms 18.74 ms
Size 43.75 MiB 48.50 MiB 4.75 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
86584b7+dirty 463.83 ms 500.31 ms 36.48 ms
9a81842+dirty 412.23 ms 416.56 ms 4.33 ms
c637fc7+dirty 433.70 ms 467.76 ms 34.06 ms
d73150f+dirty 411.21 ms 465.86 ms 54.65 ms
fa7bb7e+dirty 350.37 ms 377.02 ms 26.65 ms
3bd3f0d+dirty 447.21 ms 472.31 ms 25.10 ms
88890fe+dirty 350.94 ms 365.74 ms 14.80 ms
95aaf8a 437.89 ms 419.45 ms -18.44 ms
c0842e7+dirty 527.76 ms 566.69 ms 38.93 ms
1e7a472+dirty 348.80 ms 362.55 ms 13.75 ms

App size

Revision Plain With Sentry Diff
86584b7+dirty 43.75 MiB 48.08 MiB 4.33 MiB
9a81842+dirty 43.75 MiB 48.08 MiB 4.33 MiB
c637fc7+dirty 43.75 MiB 48.40 MiB 4.64 MiB
d73150f+dirty 43.75 MiB 48.55 MiB 4.80 MiB
fa7bb7e+dirty 17.75 MiB 19.75 MiB 2.00 MiB
3bd3f0d+dirty 17.75 MiB 19.70 MiB 1.95 MiB
88890fe+dirty 17.75 MiB 19.71 MiB 1.96 MiB
95aaf8a 17.75 MiB 19.68 MiB 1.93 MiB
c0842e7+dirty 43.75 MiB 48.41 MiB 4.66 MiB
1e7a472+dirty 17.75 MiB 19.70 MiB 1.96 MiB

@github-actions
Copy link
Contributor

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1227.42 ms 1227.46 ms 0.04 ms
Size 3.38 MiB 4.81 MiB 1.43 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
ea3e26e+dirty 1216.61 ms 1214.15 ms -2.47 ms
80e4616+dirty 1206.90 ms 1205.94 ms -0.96 ms
818a608+dirty 1218.84 ms 1223.18 ms 4.34 ms
77061ed+dirty 1210.77 ms 1218.45 ms 7.68 ms
bef3709+dirty 1217.79 ms 1225.33 ms 7.54 ms
a206511+dirty 1225.02 ms 1223.74 ms -1.28 ms
74979ac+dirty 1212.33 ms 1212.54 ms 0.21 ms
a2bb688+dirty 1244.82 ms 1238.60 ms -6.22 ms
8a868fe+dirty 1206.85 ms 1215.04 ms 8.19 ms
d590428+dirty 1221.23 ms 1225.27 ms 4.03 ms

App size

Revision Plain With Sentry Diff
ea3e26e+dirty 3.41 MiB 4.58 MiB 1.17 MiB
80e4616+dirty 3.38 MiB 4.60 MiB 1.22 MiB
818a608+dirty 3.19 MiB 4.48 MiB 1.29 MiB
77061ed+dirty 3.19 MiB 4.54 MiB 1.36 MiB
bef3709+dirty 3.38 MiB 4.78 MiB 1.40 MiB
a206511+dirty 3.41 MiB 4.67 MiB 1.25 MiB
74979ac+dirty 3.38 MiB 4.60 MiB 1.22 MiB
a2bb688+dirty 3.19 MiB 4.56 MiB 1.37 MiB
8a868fe+dirty 3.38 MiB 4.60 MiB 1.22 MiB
d590428+dirty 3.38 MiB 4.78 MiB 1.39 MiB

@github-actions
Copy link
Contributor

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 474.08 ms 489.84 ms 15.76 ms
Size 43.94 MiB 49.36 MiB 5.42 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
7480abe+dirty 363.80 ms 431.34 ms 67.54 ms
2b89ce9+dirty 372.22 ms 417.06 ms 44.84 ms
170d5ea+dirty 348.79 ms 406.94 ms 58.15 ms
b1579bc+dirty 391.87 ms 456.26 ms 64.39 ms
73f2455+dirty 369.33 ms 398.90 ms 29.57 ms
0b64753+dirty 358.55 ms 429.16 ms 70.61 ms
6a70a7e+dirty 382.45 ms 424.54 ms 42.09 ms
2adbd1e+dirty 366.13 ms 419.49 ms 53.36 ms
f8d19f8+dirty 374.17 ms 383.40 ms 9.23 ms
7be1f99+dirty 369.02 ms 399.60 ms 30.58 ms

App size

Revision Plain With Sentry Diff
7480abe+dirty 7.15 MiB 8.41 MiB 1.26 MiB
2b89ce9+dirty 7.15 MiB 8.41 MiB 1.26 MiB
170d5ea+dirty 7.15 MiB 8.42 MiB 1.27 MiB
b1579bc+dirty 43.94 MiB 49.27 MiB 5.33 MiB
73f2455+dirty 43.94 MiB 48.82 MiB 4.88 MiB
0b64753+dirty 7.15 MiB 8.42 MiB 1.27 MiB
6a70a7e+dirty 7.15 MiB 8.42 MiB 1.26 MiB
2adbd1e+dirty 7.15 MiB 8.43 MiB 1.28 MiB
f8d19f8+dirty 43.94 MiB 48.91 MiB 4.97 MiB
7be1f99+dirty 7.15 MiB 8.42 MiB 1.27 MiB

@antonis antonis merged commit 06d4e24 into main Mar 11, 2026
125 of 133 checks passed
@antonis antonis deleted the antonis/sentry-options-env branch March 11, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Triggers the full CI test suite

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dynamic environments & native init (sentry.options.json)

2 participants