EMBR-12558 feat: roll over session part on soft navigation#1398
Merged
joaquin-diaz merged 7 commits intoJul 2, 2026
Conversation
Contributor
Chrome DevTools Protocol Tracing (Script: 120.63ms, Heap: 13.01MB)
Lighthouse (Script Eval: 123.86ms)
Platform Tests (vite-7 es2015 gzip: 68.46KB)vite-6 Platform Tests
vite-7 Platform Tests
webpack-5 Platform Tests
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1398 +/- ##
==========================================
+ Coverage 96.41% 96.64% +0.23%
==========================================
Files 230 230
Lines 9718 9759 +41
Branches 1353 1360 +7
==========================================
+ Hits 9370 9432 +62
+ Misses 346 325 -21
Partials 2 2
🚀 New features to boost your workflow:
|
overbalance
reviewed
Jun 30, 2026
overbalance
approved these changes
Jul 1, 2026
overbalance
left a comment
Member
There was a problem hiding this comment.
I recommend expanding the reason value. Otherwise looks great!
Co-authored-by: Jared Freeze <overbalance@users.noreply.github.com> Signed-off-by: Joaquin Diaz <32420835+joaquin-diaz@users.noreply.github.com>
joaquin-diaz
force-pushed
the
joaquin-diaz/feat/EMBR-12558-session-part-soft-nav
branch
from
July 2, 2026 14:55
214cd1d to
d3341b0
Compare
joaquin-diaz
deleted the
joaquin-diaz/feat/EMBR-12558-session-part-soft-nav
branch
July 2, 2026 15:02
jpmunz
reviewed
Jul 6, 2026
| private readonly _onSoftNavigation = ( | ||
| event: NavigationCurrentEntryChangeEvent, | ||
| ): void => { | ||
| // Skip same-URL replacements (e.g. framework hydration via history.replaceState). |
Contributor
There was a problem hiding this comment.
Won't we also need to ignore fragment and query string changes here?
Contributor
Author
There was a problem hiding this comment.
event.from.url and this._navigationHost.location.href include the entire query string so navigating to the same URL (including qs) would be ignored
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What problem is this solving?
SPA soft navigations (React Router link clicks, browser back/forward) were not triggering session part rollovers. The Navigation API's
currententrychangeevent is the right hook but was unwired.Short description of changes
_rolloverSessionParttonavigation.currententrychangevia a newonSoftNavigationactivity listener inactivity.tsNavigationandSoftNavigationEventinterfaces incommon/types.tsto type the Navigation API without casting;NavigationHostnow typesnavigationasNavigationinstead ofEventTargetlocation: { href: string }toNavigationHostso the handler can detect same-URL replacements without accessingwindow.locationdirectlyevent.from.url === navigationHost.location.hrefto avoid spurious rollovers from framework hydration (e.g. Next.js App Router firescurrententrychangeviahistory.replaceStateduring hydration with the same URL)navigationHost?: NavigationHosttoEmbraceUserSessionManagerArgs; defaults towindowReceivedSpansfromRecord<string, boolean>toRecord<string, Record<string, { endReason }>>, keyed by session part ID — enables server-side count validationvalidateThatSessionPartEnded/validateThatSessionPartsEndedinto a singlevalidateThatSessionPartsEnded(expectedCount = 1, userSessionId?)that polls/received-spansfor accuracytest.skipfrom all three Vite React Router SPA navigation e2e testsHow has this been tested?
EmbraceSessionPartActivity.test.tspass (22 existing + 5 new)vite-react-router-tests.spec.tsare unskipped and exercise forward links, browser back, and browser forward scenarios; Next.js integration tests all pass (same-URL skip fix prevents spurious rollovers during hydration)Checklist