Skip to content

fix(core): Align SENTRY_ENVIRONMENT/RELEASE/DIST in JS bundled options with native SDKs#6330

Merged
antonis merged 2 commits into
mainfrom
fix/options-env-overrides-js
Jun 24, 2026
Merged

fix(core): Align SENTRY_ENVIRONMENT/RELEASE/DIST in JS bundled options with native SDKs#6330
antonis merged 2 commits into
mainfrom
fix/options-env-overrides-js

Conversation

@antonis

@antonis antonis commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

📢 Type of change

  • Bugfix

📜 Description

The native build steps apply the SENTRY_ENVIRONMENT, SENTRY_RELEASE and SENTRY_DIST build-time overrides to the native copy of sentry.options.json (sentry-xcode.sh, sentry.gradle.kts), but the Metro serializer that produces the __SENTRY_OPTIONS__ blob bundled into JS read the raw source file and applied no overrides.

This change mirrors those three overrides in createSentryOptionsModule (sentryOptionsSerializer.ts), so the JS-bundled options match the native SDKs.

💡 Motivation and Context

This came up while investigating #6329

💚 How did you test it?

  • Unit tests for the serializer: each override, all-three, empty-string is skipped (matches sentry-xcode.sh truthy semantics), unset keeps the file value, and a guard so a non-object options file doesn't throw.
  • Integration test in sdk.test.ts: an environment from __SENTRY_OPTIONS__ is used instead of the default.
  • End-to-end with a real Metro bundle of samples/react-native (file has environment: "dev"):
    • SENTRY_ENVIRONMENT=staging -> __SENTRY_OPTIONS__.environment === "staging"
    • no env vars -> stays "dev"
    • SENTRY_RELEASE/SENTRY_DIST -> injected; environment unchanged

📝 Checklist

🔮 Next steps

…s with native SDKs

The native build steps (sentry-xcode.sh, sentry.gradle.kts) apply the
SENTRY_ENVIRONMENT, SENTRY_RELEASE and SENTRY_DIST build-time overrides to the
native copy of sentry.options.json, but the Metro serializer that bundles
__SENTRY_OPTIONS__ for JS did not. With Capture App Start Errors, native sessions
and JS events could end up on different environments/releases, splitting release
health (e.g. Failure Rate instead of Crash Free Session Rate).

Mirror the same overrides in the Metro serializer so __SENTRY_OPTIONS__ stays in
sync with the native SDKs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

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).


  • fix(core): Align SENTRY_ENVIRONMENT/RELEASE/DIST in JS bundled options with native SDKs by antonis in #6330
  • chore(core): Bump react-native and metro devDependencies to 0.86.0 by antonis in #6316
  • chore: Bump macOS sample to react-native-macos 0.81.7 by antonis in #6315
  • chore(e2e): Bump react-native devDependency to 0.86.0 by antonis in #6313
  • fix(core): Forward user geo as an object so the native scope keeps it by antonis in #6309
  • fix(ios): Remove manual geo handling, use sentry-cocoa native support by antonis in #6289
  • fix(deps): bump js-yaml from ^4.1.1 to ^4.2.0 by antonis in #6298
  • fix: update React Native repo URL to new GitHub org by antonis in #6290
  • chore(deps): update JavaScript SDK to v10.59.0 by github-actions in #6321
  • chore(deps): bump concurrent-ruby from 1.3.6 to 1.3.7 in /samples/react-native-macos by dependabot in #6327
  • chore(deps): bump undici from 6.24.1 to 6.27.0 by dependabot in #6328
  • chore(deps): bump actions/checkout from 6.0.3 to 7.0.0 by dependabot in #6324
  • fix(ios): [RN 0.87] remove unused React/RCTTextView.h import by cortinico in #6322
  • chore(deps): bump actions/setup-java from 5.2.0 to 5.3.0 by dependabot in #6326
  • chore(deps): bump ruby/setup-ruby from 1.313.0 to 1.314.0 by dependabot in #6325
  • chore(deps): update Android SDK to v8.44.1 by github-actions in #6323

🤖 This preview updates automatically when you update the PR.

Comment thread CHANGELOG.md Outdated
@antonis

antonis commented Jun 23, 2026

Copy link
Copy Markdown
Contributor Author

@sentry review

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit e440234. Configure here.

@sentry

sentry Bot commented Jun 23, 2026

Copy link
Copy Markdown

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
Sentry RN io.sentry.reactnative.sample 8.15.1 (93) Release

⚙️ sentry-react-native Build Distribution Settings

@github-actions

Copy link
Copy Markdown
Contributor

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 3844.70 ms 1224.00 ms -2620.70 ms
Size 4.98 MiB 6.46 MiB 1.49 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
0bd8916+dirty 3842.33 ms 1230.76 ms -2611.58 ms
4e0ba9c+dirty 3839.22 ms 1221.06 ms -2618.16 ms
1122a96+dirty 3823.10 ms 1218.64 ms -2604.46 ms
04207c4+dirty 1191.27 ms 1189.78 ms -1.48 ms
acd838e+dirty 3849.78 ms 1230.00 ms -2619.78 ms
23598c3+dirty 1207.00 ms 1209.90 ms 2.90 ms
5748023+dirty 3840.49 ms 1227.43 ms -2613.05 ms
b0d3373+dirty 3831.75 ms 1227.29 ms -2604.46 ms
6177334+dirty 3834.85 ms 1217.58 ms -2617.28 ms
038a6d7+dirty 3849.69 ms 1228.40 ms -2621.28 ms

App size

Revision Plain With Sentry Diff
0bd8916+dirty 5.15 MiB 6.69 MiB 1.53 MiB
4e0ba9c+dirty 5.15 MiB 6.67 MiB 1.51 MiB
1122a96+dirty 5.15 MiB 6.68 MiB 1.53 MiB
04207c4+dirty 3.38 MiB 4.76 MiB 1.38 MiB
acd838e+dirty 5.15 MiB 6.70 MiB 1.55 MiB
23598c3+dirty 3.38 MiB 4.80 MiB 1.42 MiB
5748023+dirty 5.15 MiB 6.68 MiB 1.53 MiB
b0d3373+dirty 5.15 MiB 6.68 MiB 1.53 MiB
6177334+dirty 5.15 MiB 6.68 MiB 1.53 MiB
038a6d7+dirty 5.15 MiB 6.70 MiB 1.55 MiB

@antonis antonis marked this pull request as ready for review June 23, 2026 09:58
@github-actions

Copy link
Copy Markdown
Contributor

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 3844.60 ms 1222.72 ms -2621.87 ms
Size 4.98 MiB 6.46 MiB 1.49 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
0bd8916+dirty 3816.17 ms 1215.05 ms -2601.12 ms
4e0ba9c+dirty 3856.39 ms 1234.44 ms -2621.95 ms
1122a96+dirty 3839.17 ms 1219.23 ms -2619.93 ms
04207c4+dirty 1228.55 ms 1226.04 ms -2.51 ms
acd838e+dirty 3835.94 ms 1215.87 ms -2620.07 ms
23598c3+dirty 1223.59 ms 1229.13 ms 5.53 ms
5748023+dirty 3844.74 ms 1225.49 ms -2619.26 ms
b0d3373+dirty 3842.49 ms 1218.49 ms -2624.00 ms
6177334+dirty 3851.52 ms 1226.23 ms -2625.29 ms
038a6d7+dirty 3838.96 ms 1218.86 ms -2620.10 ms

App size

Revision Plain With Sentry Diff
0bd8916+dirty 5.15 MiB 6.69 MiB 1.53 MiB
4e0ba9c+dirty 5.15 MiB 6.67 MiB 1.51 MiB
1122a96+dirty 5.15 MiB 6.68 MiB 1.53 MiB
04207c4+dirty 3.38 MiB 4.76 MiB 1.38 MiB
acd838e+dirty 5.15 MiB 6.70 MiB 1.55 MiB
23598c3+dirty 3.38 MiB 4.80 MiB 1.42 MiB
5748023+dirty 5.15 MiB 6.68 MiB 1.53 MiB
b0d3373+dirty 5.15 MiB 6.68 MiB 1.53 MiB
6177334+dirty 5.15 MiB 6.68 MiB 1.53 MiB
038a6d7+dirty 5.15 MiB 6.70 MiB 1.55 MiB

@github-actions

Copy link
Copy Markdown
Contributor

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 470.16 ms 537.44 ms 67.28 ms
Size 49.74 MiB 54.82 MiB 5.07 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
c823bb5+dirty 468.26 ms 516.16 ms 47.90 ms
3ce5254+dirty 373.90 ms 427.84 ms 53.94 ms
3d377b5+dirty 425.38 ms 440.67 ms 15.30 ms
a50b33d+dirty 353.21 ms 398.48 ms 45.27 ms
580fb5c+dirty 515.72 ms 585.38 ms 69.66 ms
c004dae+dirty 404.60 ms 430.67 ms 26.07 ms
038a6d7+dirty 499.02 ms 527.68 ms 28.66 ms
0d9949d+dirty 414.88 ms 428.68 ms 13.81 ms
7d6fd3a+dirty 435.06 ms 458.78 ms 23.72 ms
68ae91b+dirty 515.04 ms 578.08 ms 63.04 ms

App size

Revision Plain With Sentry Diff
c823bb5+dirty 48.30 MiB 53.58 MiB 5.28 MiB
3ce5254+dirty 43.94 MiB 48.98 MiB 5.04 MiB
3d377b5+dirty 43.94 MiB 49.00 MiB 5.06 MiB
a50b33d+dirty 43.94 MiB 48.94 MiB 5.00 MiB
580fb5c+dirty 49.74 MiB 54.79 MiB 5.05 MiB
c004dae+dirty 48.30 MiB 53.49 MiB 5.19 MiB
038a6d7+dirty 48.30 MiB 53.60 MiB 5.30 MiB
0d9949d+dirty 43.94 MiB 48.99 MiB 5.05 MiB
7d6fd3a+dirty 43.94 MiB 49.00 MiB 5.06 MiB
68ae91b+dirty 49.74 MiB 54.79 MiB 5.05 MiB

@github-actions

Copy link
Copy Markdown
Contributor

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 425.49 ms 479.06 ms 53.57 ms
Size 49.74 MiB 54.82 MiB 5.07 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
c823bb5+dirty 409.87 ms 478.57 ms 68.70 ms
5c1e987+dirty 423.52 ms 471.64 ms 48.12 ms
580fb5c+dirty 436.34 ms 471.63 ms 35.28 ms
c004dae+dirty 412.86 ms 481.50 ms 68.64 ms
038a6d7+dirty 524.82 ms 531.92 ms 7.10 ms
bc0d8cf+dirty 412.37 ms 466.26 ms 53.89 ms
44c8b3f+dirty 414.20 ms 457.28 ms 43.08 ms
68ae91b+dirty 416.44 ms 477.56 ms 61.12 ms
64630e5+dirty 419.18 ms 464.58 ms 45.40 ms
7887847+dirty 416.61 ms 462.04 ms 45.43 ms

App size

Revision Plain With Sentry Diff
c823bb5+dirty 48.30 MiB 53.58 MiB 5.28 MiB
5c1e987+dirty 43.75 MiB 48.08 MiB 4.33 MiB
580fb5c+dirty 49.74 MiB 54.79 MiB 5.05 MiB
c004dae+dirty 48.30 MiB 53.49 MiB 5.19 MiB
038a6d7+dirty 48.30 MiB 53.60 MiB 5.30 MiB
bc0d8cf+dirty 48.30 MiB 53.48 MiB 5.18 MiB
44c8b3f+dirty 48.30 MiB 53.46 MiB 5.15 MiB
68ae91b+dirty 49.74 MiB 54.79 MiB 5.05 MiB
64630e5+dirty 49.74 MiB 54.82 MiB 5.07 MiB
7887847+dirty 49.74 MiB 54.81 MiB 5.07 MiB

@antonis antonis removed the ready-to-merge Triggers the full CI test suite label Jun 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor
Fails
🚫 Pull request is not ready for merge, please add the "ready-to-merge" label to the pull request

Generated by 🚫 dangerJS against e440234

@antonis antonis merged commit ecf47a2 into main Jun 24, 2026
136 of 144 checks passed
@antonis antonis deleted the fix/options-env-overrides-js branch June 24, 2026 07:56
antonis added a commit to getsentry/sentry-docs that referenced this pull request Jun 25, 2026
…pp start errors (#18508)

## DESCRIBE YOUR PR

Updates the **Capture App Start Errors** guide to explain how
`environment`, `release`, and `dist` must stay aligned between the
native SDK and JavaScript when using early native initialization.

Context: corresponds to SDK fix getsentry/sentry-react-native#6330 and
the report in getsentry/sentry-react-native#6329.

## IS YOUR CHANGE URGENT?

- [ ] Urgent deadline (GA date, etc.): <!-- ENTER DATE HERE -->
- [ ] Other deadline: <!-- ENTER DATE HERE -->
- [x] None: Not urgent, can wait up to 1 week+

⚠️ Should be merged after getsentry/sentry-react-native#6330 is released

## PRE-MERGE CHECKLIST

*Make sure you've checked the following before merging your changes:*

- [ ] Checked Vercel preview for correctness, including links
- [ ] PR was reviewed and approved by any necessary SMEs (subject matter
experts)
- [ ] PR was reviewed and approved by a member of the [Sentry docs
team](https://github.com/orgs/getsentry/teams/docs)

## EXTRA RESOURCES

- [Sentry Docs contributor guide](https://docs.sentry.io/contributing/)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants