Conversation
…updated Record the highest viewport top seen since tracking started, including the scroll offset at attach time, so a late SDK load is visible on [Amplitude] Viewport Content Updated.
Contributor
size-limit report 📦
|
… harness Scroll the viewport exposure page before the SDK starts, then check that the sent Min and Max Page Y match the scroll range the browser actually reached.
…ontent updated The Min Page Y checks scrolled again after the SDK attached, so a tracker that ignored the position at attach still passed. Lock the late-load cases: the attach offset is the range when nothing moves afterward, movement from before init is not reconstructed, and popstate re-seeds from the restored scroll position.
jxiwang
marked this pull request as ready for review
October 1, 2026 23:03
…toration The navigate event fires before a back/forward traversal restores scroll. Sampling there copied the previous page's offset into the new page's Min and Max Page Y. Sample on navigatesuccess, after that restoration.
…ion scroll is restored An exposure snapshot that finishes during an intercepted navigation waits for navigatesuccess, so Min and Max Page Y use the restored offset.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit caa6f69. Configure here.
…ion fails navigateerror and an aborted navigate signal sample the current offset and send a snapshot that was waiting on navigatesuccess.
This branch has not been deployed
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.

Summary
Adds
[Amplitude] Min Page Yto[Amplitude] Viewport Content Updatedso we can see where viewport tracking started. Linear: ZON-101.[Amplitude] Max Page Yis the bottom of the furthest viewport (max scrollY + viewport height). Min Page Y is the top of the highest viewport seen since tracking began for the current page view: the smallestwindow.scrollY, including the offset at the moment the scroll tracker attaches. A non-zero value on the first event of a page view means the SDK started below the top of the page (late script injection, consent gating, scroll restoration, or a hash navigation).The tracker also seeds max scroll from that same initial sample. Previously max stayed
0until the nextscrollevent, so a late load under-reported[Amplitude] Max Page Yas only the viewport height.On a new page view the range resets, then re-seeds once history has been applied (
pushState/replaceState) or afterpopstate. Navigation API traversals wait fornavigatesuccess, which runs after the browser restores scroll. Sampling inside thenavigatehandler copied the previous page's offset into the new page's Min and Max Page Y. An exposure snapshot that finishes beforenavigatesuccesswaits for that sample, so a long intercept does not flush Min and Max Page Y as 0. If the navigation fails or is cancelled,navigateerroror the navigate event's abort signal releases that wait and samples the offset the page is still at. A change in the minimum flushes on the next Viewport Content Updated trigger, including page end.The viewport exposure harness (
test-server/autocapture/viewport-exposure.html) can defer SDK startup with?deferInit=1. The Playwright spec scrolls beforestart(), then down and back up, and checks the sent Min Page Y and Max Page Y against those scroll positions. The same range is shown on the page.Later checks lock the late-load cases the first spec did not:
[Amplitude] Element Exposed.popstatere-seeds from the scroll position the browser has already restored, instead of carrying the previous page's max forward.navigatesuccess. A scroll event that arrives before that success is the new page's baseline, not an extension of the previous page's max. A snapshot that finishes first waits for that success instead of sending 0. A failed or aborted navigation releases the same wait.Checklist