Skip to content

Feat zoning 010526#1514

Draft
jxiwang wants to merge 18 commits intomainfrom
feat-zoning-010526
Draft

Feat zoning 010526#1514
jxiwang wants to merge 18 commits intomainfrom
feat-zoning-010526

Conversation

@jxiwang
Copy link
Collaborator

@jxiwang jxiwang commented Feb 3, 2026

Summary

Checklist

  • Does your PR title have the correct title format?
  • Does your PR have a breaking change?:

Dogfalo and others added 18 commits January 5, 2026 09:04
 - @amplitude/analytics-browser@2.33.2-feat-zoning-010526.0
 - @amplitude/analytics-client-common@2.4.20-feat-zoning-010526.0
 - @amplitude/analytics-core@2.35.1-feat-zoning-010526.0
 - @amplitude/analytics-node@1.5.30-feat-zoning-010526.0
 - @amplitude/analytics-react-native@1.5.33-feat-zoning-010526.0
 - @amplitude/gtm-snippet@2.33.2-feat-zoning-010526.0
 - @amplitude/plugin-autocapture-browser@1.19.0-feat-zoning-010526.0
 - @amplitude/plugin-global-user-properties@1.2.111-feat-zoning-010526.0
 - @amplitude/plugin-network-capture-browser@1.7.4-feat-zoning-010526.0
 - @amplitude/plugin-page-url-enrichment-browser@0.5.10-feat-zoning-010526.0
 - @amplitude/plugin-page-view-tracking-browser@2.7.0-feat-zoning-010526.0
 - @amplitude/plugin-session-replay-browser@1.25.6-feat-zoning-010526.0
 - @amplitude/plugin-web-attribution-browser@2.1.104-feat-zoning-010526.0
 - @amplitude/plugin-web-vitals-browser@1.1.5-feat-zoning-010526.0
 - @amplitude/segment-session-replay-plugin@0.0.0-feat-zoning-010526.0
 - @amplitude/session-replay-browser@1.30.5-feat-zoning-010526.0
 - @amplitude/unified@1.0.0-feat-zoning-010526.0
@macroscopeapp
Copy link
Contributor

macroscopeapp bot commented Feb 3, 2026

Add zoning feature by upgrading snippets to analytics-browser 2.33.2-feat-zoning-010526.0 and implement 150ms exposure tracking with plugin-autocapture-browser viewport content updates

Upgrade browser and GTM snippets to 2.33.2-feat-zoning-010526.0 with new SRI, add scroll and exposure observables, track exposures after 150ms, batch and emit [Amplitude] Viewport Content Updated, and include [Amplitude] Page View ID in page view events with sessionStorage persistence.

📍Where to Start

Start with autocapturePlugin in autocapture-plugin.ts, then review trackExposure in track-exposure.ts and fireViewportContentUpdated in track-viewport-content-updated.ts.


📊 Macroscope summarized 3a8470e. 32 files reviewed, 14 issues evaluated, 0 issues filtered, 3 comments posted. View details

elementExposedForPage,
exposureTracker: trackers.exposure,
isPageEnd,
lastScroll,
Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 Medium

packages/plugin-autocapture-browser/src/autocapture-plugin.ts:346

The lastScroll parameter is reassigned locally (lastScroll = { ... }), so the caller's object never updates. Consider mutating the object's properties directly (lastScroll.maxX = ...; lastScroll.maxY = ...) instead of reassigning.

🚀 Want me to fix this? Reply ex: "fix it for me".

Comment on lines +114 to +115
// init session storage
sessionStorage = new BrowserStorage<PageViewSessionStorage>(globalScope.sessionStorage);
Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 Medium

packages/plugin-page-view-tracking-browser/src/page-view-tracking.ts:114

Accessing globalScope.sessionStorage can throw a SecurityError in restricted environments (e.g., cross-origin iframes). Consider wrapping the BrowserStorage initialization in a try/catch to gracefully degrade.

-        // init session storage
-        sessionStorage = new BrowserStorage<PageViewSessionStorage>(globalScope.sessionStorage);
+        // init session storage
+        try {
+          sessionStorage = new BrowserStorage<PageViewSessionStorage>(globalScope.sessionStorage);
+        } catch {
+          // Storage may be restricted in some environments
+        }

🚀 Want me to fix this? Reply ex: "fix it for me".


/* istanbul ignore next */
amplitude?.track('[Amplitude] Viewport Content Updated', eventProperties);
lastScroll = { maxX: pageScrollMaxState.maxX, maxY: pageScrollMaxState.maxY };
Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 Medium

packages/plugin-autocapture-browser/src/autocapture/track-viewport-content-updated.ts:66

Reassigning the local lastScroll parameter (line 66) doesn't update the caller's state, so deduplication will fail after the first scroll. Consider mutating the object properties directly (lastScroll.maxX = ...; lastScroll.maxY = ...) instead of reassigning.

Suggested change
lastScroll = { maxX: pageScrollMaxState.maxX, maxY: pageScrollMaxState.maxY };
lastScroll.maxX = pageScrollMaxState.maxX;
lastScroll.maxY = pageScrollMaxState.maxY;

🚀 Want me to fix this? Reply ex: "fix it for me".

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