Skip to content

feat(tracing): Add Sentry.NavigationContainer wrapper for React Navigation#6199

Open
antonis wants to merge 13 commits into
mainfrom
feat/sentry-navigation-container
Open

feat(tracing): Add Sentry.NavigationContainer wrapper for React Navigation#6199
antonis wants to merge 13 commits into
mainfrom
feat/sentry-navigation-container

Conversation

@antonis
Copy link
Copy Markdown
Contributor

@antonis antonis commented May 21, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Adds a Sentry.NavigationContainer component — a drop-in replacement for
NavigationContainer from @react-navigation/native that automatically
registers the navigation container with reactNavigationIntegration.

Before:

const ref = useRef(null);

<NavigationContainer
  ref={ref}
  onReady={() => navigationIntegration.registerNavigationContainer(ref)}
>
  ...
</NavigationContainer>

After:

<Sentry.NavigationContainer>
  ...
</Sentry.NavigationContainer>

The component:

  • Internally creates a ref and calls registerNavigationContainer on ready
  • Forwards refs via forwardRef so users keep imperative navigation access
  • Passes through all NavigationContainer props
  • Chains user-provided onReady callbacks (Sentry registers first)
  • Resolves the integration from the current client; no-ops if not registered
  • Gracefully falls back to rendering children if @react-navigation/native is not installed
  • Caches the require() result and warns only once to avoid noise

💡 Motivation and Context

reactNavigationIntegration requires manual ref + onReady wiring that is a
recurring source of misconfiguration — when users forget onReady, navigation
spans silently don't work. This is the biggest friction point for React Native
tracing adoption compared to iOS/Android where navigation auto-instruments via
OS lifecycle hooks.

Fixes #6065

💚 How did you test it?

CI, Manual, Unit tests

📝 Checklist

🔮 Next steps

…ation

Drop-in replacement for NavigationContainer that automatically wires up
reactNavigationIntegration, removing the manual ref/onReady boilerplate
that is a recurring source of misconfiguration.

Closes #6065

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

github-actions Bot commented May 21, 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(tracing): Add Sentry.NavigationContainer wrapper for React Navigation by antonis in #6199
  • chore(deps): bump getsentry/craft from 2.26.5 to 2.26.6 by dependabot in #6213
  • chore(deps): bump getsentry/craft/.github/workflows/changelog-preview.yml from 2.26.5 to 2.26.6 by dependabot in #6214
  • chore(deps): bump github/codeql-action from 4.35.5 to 4.36.0 by dependabot in #6215
  • fix(ios): Return NO from requiresMainQueueSetup by antonis in #6202
  • fix(tracing): Bound TTID/TTFD to prevent inflated transactions by antonis in #6210
  • feat(core): Add disableAutoUpload option to Expo plugin by antonis in #6195
  • chore(deps): Remove unused @sentry/types dependency by antonis in #6207
  • Correct route and dynamic param extraction for Expo Router (Correct route and dynamic param extraction for Expo Router #6157) by alwx in #6197
  • chore(deps): update CLI to v3.4.3 by github-actions in #6205
  • chore(deps): update Cocoa SDK to v9.14.0 by github-actions in #6204
  • chore(deps): update Maestro to v2.6.0 by github-actions in #6198
  • chore(deps): bump js-cookie from 3.0.5 to 3.0.7 by dependabot in #6203
  • chore(deps): bump @tootallnate/once from 2.0.0 to 2.0.1 by dependabot in #6206
  • chore(deps): update Sentry Android Gradle Plugin to v6.8.1 by github-actions in #6196
  • feat(core): Expose pauseAppHangTracking and resumeAppHangTracking APIs by antonis in #6192

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

Fails
🚫 Pull request is not ready for merge, please add the "ready-to-merge" label to the pull request
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against 04d17af

antonis and others added 2 commits May 21, 2026 17:20
…nContainer

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@antonis antonis added the ready-to-merge Triggers the full CI test suite label May 21, 2026
@sentry
Copy link
Copy Markdown

sentry Bot commented May 21, 2026

📲 Install Builds

Android

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

⚙️ sentry-react-native Build Distribution Settings

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

Android (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 408.12 ms 447.94 ms 39.82 ms
Size 48.30 MiB 53.58 MiB 5.28 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
3ce5254+dirty 410.57 ms 448.48 ms 37.91 ms
3b6e9f9+dirty 442.70 ms 486.44 ms 43.74 ms
4e0ba9c+dirty 452.84 ms 473.36 ms 20.52 ms
4966363+dirty 400.04 ms 431.08 ms 31.04 ms
5125c43+dirty 497.18 ms 543.78 ms 46.60 ms
a5d243c+dirty 424.52 ms 485.18 ms 60.66 ms
3817909+dirty 406.67 ms 416.58 ms 9.91 ms
71abba0+dirty 496.54 ms 525.16 ms 28.63 ms
5fe1c6c+dirty 401.62 ms 445.28 ms 43.66 ms
c823bb5+dirty 409.87 ms 478.57 ms 68.70 ms

App size

Revision Plain With Sentry Diff
3ce5254+dirty 43.75 MiB 48.12 MiB 4.37 MiB
3b6e9f9+dirty 48.30 MiB 53.54 MiB 5.23 MiB
4e0ba9c+dirty 48.30 MiB 53.49 MiB 5.19 MiB
4966363+dirty 48.30 MiB 53.54 MiB 5.24 MiB
5125c43+dirty 48.30 MiB 53.54 MiB 5.24 MiB
a5d243c+dirty 48.30 MiB 53.54 MiB 5.23 MiB
3817909+dirty 43.75 MiB 48.08 MiB 4.33 MiB
71abba0+dirty 48.30 MiB 53.49 MiB 5.19 MiB
5fe1c6c+dirty 43.75 MiB 48.14 MiB 4.39 MiB
c823bb5+dirty 48.30 MiB 53.58 MiB 5.28 MiB

Previous results on branch: feat/sentry-navigation-container

Startup times

Revision Plain With Sentry Diff
b941fc4+dirty 458.94 ms 503.52 ms 44.58 ms
161ef26+dirty 419.96 ms 463.76 ms 43.80 ms

App size

Revision Plain With Sentry Diff
b941fc4+dirty 48.30 MiB 53.58 MiB 5.28 MiB
161ef26+dirty 48.30 MiB 53.58 MiB 5.28 MiB

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

iOS (legacy) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 3843.36 ms 1219.31 ms -2624.05 ms
Size 5.15 MiB 6.69 MiB 1.54 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
7d8c8bd+dirty 3837.24 ms 1215.51 ms -2621.73 ms
bc0d8cf+dirty 3830.33 ms 1220.52 ms -2609.81 ms
df5d108+dirty 1225.90 ms 1220.14 ms -5.76 ms
7d6fd3a+dirty 1223.29 ms 1229.57 ms 6.28 ms
0d9949d+dirty 1211.38 ms 1219.67 ms 8.29 ms
5c1e987+dirty 1204.30 ms 1222.15 ms 17.85 ms
b0d3373+dirty 3831.75 ms 1227.29 ms -2604.46 ms
3817909+dirty 1183.90 ms 1187.50 ms 3.60 ms
3ce5254+dirty 1219.93 ms 1221.90 ms 1.96 ms
04207c4+dirty 1191.27 ms 1189.78 ms -1.48 ms

App size

Revision Plain With Sentry Diff
7d8c8bd+dirty 5.15 MiB 6.68 MiB 1.53 MiB
bc0d8cf+dirty 5.15 MiB 6.67 MiB 1.51 MiB
df5d108+dirty 3.38 MiB 4.73 MiB 1.35 MiB
7d6fd3a+dirty 3.38 MiB 4.77 MiB 1.39 MiB
0d9949d+dirty 3.38 MiB 4.76 MiB 1.38 MiB
5c1e987+dirty 3.38 MiB 4.73 MiB 1.35 MiB
b0d3373+dirty 5.15 MiB 6.68 MiB 1.53 MiB
3817909+dirty 3.38 MiB 4.73 MiB 1.35 MiB
3ce5254+dirty 3.38 MiB 4.76 MiB 1.38 MiB
04207c4+dirty 3.38 MiB 4.76 MiB 1.38 MiB

Previous results on branch: feat/sentry-navigation-container

Startup times

Revision Plain With Sentry Diff
b941fc4+dirty 3842.59 ms 1224.66 ms -2617.93 ms
161ef26+dirty 3833.45 ms 1215.96 ms -2617.49 ms

App size

Revision Plain With Sentry Diff
b941fc4+dirty 5.15 MiB 6.68 MiB 1.53 MiB
161ef26+dirty 5.15 MiB 6.68 MiB 1.53 MiB

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

iOS (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 3825.11 ms 1220.32 ms -2604.79 ms
Size 5.15 MiB 6.69 MiB 1.54 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
7d8c8bd+dirty 3847.98 ms 1230.77 ms -2617.21 ms
bc0d8cf+dirty 3834.64 ms 1223.91 ms -2610.73 ms
df5d108+dirty 1207.34 ms 1210.50 ms 3.16 ms
7d6fd3a+dirty 1210.89 ms 1217.63 ms 6.74 ms
0d9949d+dirty 1203.94 ms 1202.27 ms -1.67 ms
5c1e987+dirty 1208.43 ms 1220.72 ms 12.29 ms
b0d3373+dirty 3842.49 ms 1218.49 ms -2624.00 ms
3817909+dirty 1210.76 ms 1215.64 ms 4.89 ms
3ce5254+dirty 1217.70 ms 1224.69 ms 6.99 ms
04207c4+dirty 1228.55 ms 1226.04 ms -2.51 ms

App size

Revision Plain With Sentry Diff
7d8c8bd+dirty 5.15 MiB 6.68 MiB 1.53 MiB
bc0d8cf+dirty 5.15 MiB 6.67 MiB 1.51 MiB
df5d108+dirty 3.38 MiB 4.73 MiB 1.35 MiB
7d6fd3a+dirty 3.38 MiB 4.77 MiB 1.39 MiB
0d9949d+dirty 3.38 MiB 4.76 MiB 1.38 MiB
5c1e987+dirty 3.38 MiB 4.73 MiB 1.35 MiB
b0d3373+dirty 5.15 MiB 6.68 MiB 1.53 MiB
3817909+dirty 3.38 MiB 4.73 MiB 1.35 MiB
3ce5254+dirty 3.38 MiB 4.76 MiB 1.38 MiB
04207c4+dirty 3.38 MiB 4.76 MiB 1.38 MiB

Previous results on branch: feat/sentry-navigation-container

Startup times

Revision Plain With Sentry Diff
b941fc4+dirty 3845.29 ms 1222.18 ms -2623.11 ms
161ef26+dirty 3844.87 ms 1227.50 ms -2617.37 ms

App size

Revision Plain With Sentry Diff
b941fc4+dirty 5.15 MiB 6.68 MiB 1.53 MiB
161ef26+dirty 5.15 MiB 6.68 MiB 1.53 MiB

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 21, 2026

Android (new) Performance metrics 🚀

  Plain With Sentry Diff
Startup time 476.05 ms 543.68 ms 67.63 ms
Size 48.30 MiB 53.58 MiB 5.28 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
5c1e987+dirty 444.71 ms 475.13 ms 30.42 ms
a736b76+dirty 405.78 ms 458.74 ms 52.96 ms
3b6e9f9+dirty 442.39 ms 486.44 ms 44.05 ms
4e0ba9c+dirty 421.39 ms 455.80 ms 34.41 ms
4966363+dirty 415.67 ms 448.60 ms 32.93 ms
3d377b5+dirty 425.38 ms 440.67 ms 15.30 ms
23598c3+dirty 371.92 ms 420.65 ms 48.74 ms
5125c43+dirty 409.52 ms 451.00 ms 41.48 ms
7ac3378+dirty 410.67 ms 442.60 ms 31.92 ms
a5d243c+dirty 499.20 ms 525.62 ms 26.42 ms

App size

Revision Plain With Sentry Diff
5c1e987+dirty 43.94 MiB 48.94 MiB 5.00 MiB
a736b76+dirty 48.30 MiB 53.48 MiB 5.18 MiB
3b6e9f9+dirty 48.30 MiB 53.54 MiB 5.23 MiB
4e0ba9c+dirty 48.30 MiB 53.49 MiB 5.19 MiB
4966363+dirty 48.30 MiB 53.54 MiB 5.24 MiB
3d377b5+dirty 43.94 MiB 49.00 MiB 5.06 MiB
23598c3+dirty 43.94 MiB 49.02 MiB 5.08 MiB
5125c43+dirty 48.30 MiB 53.54 MiB 5.24 MiB
7ac3378+dirty 43.94 MiB 48.99 MiB 5.05 MiB
a5d243c+dirty 48.30 MiB 53.54 MiB 5.23 MiB

Previous results on branch: feat/sentry-navigation-container

Startup times

Revision Plain With Sentry Diff
b941fc4+dirty 477.42 ms 547.94 ms 70.52 ms
161ef26+dirty 426.07 ms 473.14 ms 47.07 ms

App size

Revision Plain With Sentry Diff
b941fc4+dirty 48.30 MiB 53.58 MiB 5.28 MiB
161ef26+dirty 48.30 MiB 53.58 MiB 5.28 MiB

antonis and others added 2 commits May 21, 2026 18:37
… NavigationContainer

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Comment thread packages/core/src/js/NavigationContainer.tsx
Comment thread packages/core/src/js/NavigationContainer.tsx Outdated
antonis and others added 2 commits May 21, 2026 22:04
…ck behavior

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

antonis commented May 21, 2026

@sentry review

Copy link
Copy Markdown

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

✅ 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 134cc57. Configure here.

@antonis
Copy link
Copy Markdown
Contributor Author

antonis commented May 21, 2026

Re: Warden findings — 3 low-severity issues about module-level _warned* flags not being reset between tests.

This is expected: the warn-once flags are intentional for production, and jest.resetModules() isn't viable here because it causes React instance mismatches between the test renderer and the component under test. Each warning branch is covered by exactly one test, so there's no actual flakiness. No changes needed.

@antonis antonis marked this pull request as ready for review May 22, 2026 06:38
@lucas-zimerman
Copy link
Copy Markdown
Collaborator

Thank you for the PR!
Everything looks good!

I only have one small concern:
Sentry NavigationContainer:
image

vs normal NavigationContainer:
image

with Sentry implementation, we lose most of the autocomplete fields. Is it possible to also include them?

@lucas-zimerman
Copy link
Copy Markdown
Collaborator

The props haven't changed since 2020 so it might be worth just adding the types manually.

Copy link
Copy Markdown
Collaborator

@lucas-zimerman lucas-zimerman left a comment

Choose a reason for hiding this comment

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

see comments above

antonis and others added 2 commits May 26, 2026 09:51
…n-container

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

@antonis antonis left a comment

Choose a reason for hiding this comment

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

Good catch @lucas-zimerman 👍
Adding the missing types with 254298f

@antonis antonis requested a review from lucas-zimerman May 26, 2026 08:47
antonis and others added 2 commits May 26, 2026 11:11
@antonis antonis removed the ready-to-merge Triggers the full CI test suite label May 26, 2026
Copy link
Copy Markdown

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

Fix All in Cursor

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

Reviewed by Cursor Bugbot for commit 8746805. Configure here.

Comment thread packages/core/src/js/NavigationContainer.tsx
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

feat(tracing): Add <Sentry.NavigationContainer> wrapper to auto-register React Navigation

2 participants