feat(tracing): Wrap Expo Router push, replace, navigate, back, dismiss in addition to prefetch
#6221
3 issues
code-review: Found 3 issues (3 low)
Low
Pending Expo Router navigation consumed and applied to app-restart span - `packages/core/src/js/tracing/reactnavigation.ts:358`
When Android triggers an Activity restart (isAppRestart = true), consumePendingExpoRouterNavigation() is called unconditionally, and because the downstream if (pendingExpoRouter && latestNavigationSpan) guard has no !isAppRestart check, a restart span can be incorrectly attributed navigation.method from an unrelated prior Expo Router call.
Test 'returns the router unchanged if prefetch method does not exist' no longer matches behavior after push is wrapped - `packages/core/test/tracing/expoRouter.test.ts:51-54`
The test at line 51 passes { push: jest.fn() } and asserts expect(wrapped).toBe(router), with a name implying the router is left untouched when prefetch is absent. After this PR, wrapExpoRouter unconditionally wraps push (as well as replace, navigate, back, dismiss) in place, so router.push IS now a different function reference than what was passed in. The assertion still passes only because wrapExpoRouter mutates and returns the same object โ reference equality is preserved while the contract implied by the test name (push unchanged) is not. Consider renaming the test and asserting on the method reference (e.g. expect(wrapped.push).toBe(originalPush) โ which will fail and reveal the new behavior), or replace this case with one that uses a router lacking any known method (similar to the existing 'returns the router unchanged if no known methods exist' test).
dismiss test omits pending navigation assertion, leaving the hand-off feature untested for that method - `packages/core/test/tracing/expoRouter.test.ts:440`
The dismiss test verifies the span and breadcrumb but never asserts consumePendingExpoRouterNavigation(), so the key setPendingExpoRouterNavigation hand-off (the main new mechanism described in the PR) is not verified for dismiss, unlike the equivalent back test which does assert it.
โฑ 7m 24s ยท 1.1M in / 72.9k out ยท $2.44