Expo Router: wrap push, replace, navigate, back, dismiss in addition to prefetch#6221
Expo Router: wrap push, replace, navigate, back, dismiss in addition to prefetch#6221alwx wants to merge 1 commit into
push, replace, navigate, back, dismiss in addition to prefetch#6221Conversation
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog.
🤖 This preview updates automatically when you update the PR. |
Instructions and example for changelogPlease add an entry to 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 |
| 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 { |
There was a problem hiding this comment.
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–566checkssendDefaultPiibefore includingroute.urlor anyroute.params.*attributes in spans.reactnavigation.ts:578–584breadcrumb omits params entirely (from/toroute names only).wrapNavigationMethod(lines 63–80 of the new file) spreadsparsed.paramsdirectly into theaddBreadcrumbdata object and setsroute.href(which may encode params) as a span attribute with nosendDefaultPiicheck.- 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
📢 Type of change
📜 Description
Fixes #6158
💡 Motivation and Context
💚 How did you test it?
📝 Checklist
sendDefaultPIIis enabled🔮 Next steps