Skip to content

Expo Router: wrap push, replace, navigate, back, dismiss in addition to prefetch#6221

Draft
alwx wants to merge 1 commit into
mainfrom
alwx/feature/wrap-expo-router-methods
Draft

Expo Router: wrap push, replace, navigate, back, dismiss in addition to prefetch#6221
alwx wants to merge 1 commit into
mainfrom
alwx/feature/wrap-expo-router-methods

Conversation

@alwx
Copy link
Copy Markdown
Contributor

@alwx alwx commented May 27, 2026

📢 Type of change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring

📜 Description

Fixes #6158

💡 Motivation and Context

💚 How did you test it?

📝 Checklist

  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • All tests passing
  • No breaking changes

🔮 Next steps

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


  • Expo Router: wrap push, replace, navigate, back, dismiss in addition to prefetch by alwx in #6221
  • feat(tracing): Add breadcrumbs for dispatched React Navigation events by antonis in #6218
  • feat(tracing): Add Sentry.NavigationContainer wrapper for React Navigation by antonis in #6199
  • chore(e2e): Update Expo sample to SDK 56 by antonis in #6216
  • feat(ios): opt-in consumption of sentry-cocoa via Swift Package Manager by alwx in #6182
  • 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

Fails
🚫 Pull request is not ready for merge, please add the "ready-to-merge" label to the pull request
🚫 Please consider adding a changelog entry for the next release.

Instructions and example for changelog

Please add an entry to CHANGELOG.md to the "Unreleased" section. Make sure the entry includes this PR's number.

Example:

## Unreleased

### Features

- wrap `push`, `replace`, `navigate`, `back`, `dismiss` in addition to `prefetch` ([#6221](https://github.com/getsentry/sentry-react-native/pull/6221))

If none of the above apply, you can opt out of this check by adding #skip-changelog to the PR description or adding a skip-changelog label.

Generated by 🚫 dangerJS against f88ba2d

Comment on lines +63 to +80
router.replace = wrapNavigationMethod(router, 'replace', router.replace.bind(router));
}
if (router.navigate) {
router.navigate = wrapNavigationMethod(router, 'navigate', router.navigate.bind(router));
}
if (router.back) {
router.back = wrapNavigationMethod(router, 'back', router.back.bind(router)) as NonNullable<T['back']>;
}
if (router.dismiss) {
const originalDismiss = router.dismiss.bind(router) as (...args: unknown[]) => unknown;
router.dismiss = wrapNavigationMethod(router, 'dismiss', originalDismiss) as NonNullable<T['dismiss']>;
}

wrappedRouter.__sentryWrapped = true;
return router;
}

function wrapPrefetch<T extends ExpoRouter>(router: T): void {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Navigation params added to breadcrumbs and spans without sendDefaultPii guard

Route params (which can contain user IDs and other PII) are unconditionally included in breadcrumb data and span attributes, but the existing reactnavigation.ts explicitly checks getClient()?.getOptions()?.sendDefaultPii before including any params — this new code bypasses that guard entirely.

Evidence
  • reactnavigation.ts:560–566 checks sendDefaultPii before including route.url or any route.params.* attributes in spans.
  • reactnavigation.ts:578–584 breadcrumb omits params entirely (from/to route names only).
  • wrapNavigationMethod (lines 63–80 of the new file) spreads parsed.params directly into the addBreadcrumb data object and sets route.href (which may encode params) as a span attribute with no sendDefaultPii check.
  • The PR checklist item "No new PII added" is unchecked.
Also found at 1 additional location
  • packages/core/src/js/tracing/expoRouter.ts:143-143

Identified by Warden code-review · 4TC-USJ

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.

Wrap push, replace, navigate, back, dismiss in addition to prefetch

1 participant