Skip to content

feat(analytics-browser): add page context and SDK initialization offset - #2067

Open
jxiwang wants to merge 3 commits into
mainfrom
cursor/page-viewed-min-page-y-6fe0
Open

jxiwang wants to merge 3 commits into
mainfrom
cursor/page-viewed-min-page-y-6fe0

Conversation

@jxiwang

@jxiwang jxiwang commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds [Amplitude] Min Page Y and [Amplitude] Viewport Width to [Amplitude] Page Viewed.

[Amplitude] Min Page Y matches the property on [Amplitude] Viewport Content Updated. The value is the floored vertical scroll offset (window.scrollY, or pageYOffset when scrollY is missing) at the moment the page view event is created. It is the top of the viewport, not the offset plus viewport height. A non-zero value means the page view started below the top of the page (late script injection, consent gating, or scroll restoration).

[Amplitude] Viewport Width is window.innerWidth at that same moment, the same property already sent on click and viewport content updated events.

Both values are read before campaign parsing so a scroll or resize during that wait does not change the event.

Adds [Amplitude] SDK Initialization Offset to [Amplitude] Page Viewed and [Amplitude] Viewport Content Updated. Linear: ZON-119.

The value is milliseconds from the current document's navigation time origin (performance.now()) until the SDK first initializes for that project. It is sampled when the page view plugin or autocapture plugin is installed, whichever runs first. Later page views in the same document, including single-page navigations, and every viewport content updated event reuse that sample. It stays 0 when the performance clock is missing, not finite, negative, or throws. A deferred init therefore reports how long after navigation the SDK actually started, not how long the init function itself ran.

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?: No
Open in Web Open in Cursor 

Note

Medium Risk
Adds new default properties on high-volume automatic events (page views and viewport updates), which can affect dashboards and pipelines that assume a fixed schema, though behavior is additive and non-breaking.

Reviewed by Cursor Bugbot for commit b5a6342. Bugbot is set up for automated code reviews on this repo. Configure here.

Record the viewport top scroll offset on [Amplitude] Page Viewed.
It uses the same units as Min Page Y on Viewport Content Updated.
@jxiwang
jxiwang marked this pull request as ready for review October 19, 2026 16:00
@jxiwang
jxiwang requested a review from a team as a code owner October 19, 2026 16:00
@github-actions

github-actions Bot commented Oct 19, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Path Size
packages/analytics-browser/lib/scripts/amplitude-min.js.gz 67.73 KB (+0.39% 🔺)
packages/session-replay-browser/lib/scripts/session-replay-browser-min.js.gz 136.37 KB (0%)
packages/unified/lib/scripts/amplitude-min.umd.js.gz 221.85 KB (+0.13% 🔺)
@amplitude/element-selector (gzipped esm) 3.48 KB (0%)

…iewed

Record window.innerWidth on [Amplitude] Page Viewed as
[Amplitude] Viewport Width, sampled with Min Page Y.
@cursor cursor Bot changed the title feat(plugin-page-view-tracking-browser): add Min Page Y to page viewed feat(plugin-page-view-tracking-browser): add Min Page Y and viewport width to page viewed Oct 19, 2026
Sample milliseconds from document navigation until the SDK first
starts, and attach that value to Page Viewed and Viewport Content
Updated. Later events in the same document reuse the sample.
@linear-code

linear-code Bot commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

ZON-119

@cursor cursor Bot changed the title feat(plugin-page-view-tracking-browser): add Min Page Y and viewport width to page viewed feat(browser): add page context and SDK initialization offset Oct 19, 2026
@jxiwang

jxiwang commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit b5a6342. Configure here.

@jxiwang jxiwang changed the title feat(browser): add page context and SDK initialization offset feat(analytics-browser): add page context and SDK initialization offset Oct 19, 2026

This branch has not been deployed

No deployments
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.

3 participants