Sdki 26/end video on pagehide - #2025
daniel-graham-amplitude wants to merge 7 commits into
Conversation
- @amplitude/analytics-browser@2.47.1 - @amplitude/analytics-core@2.58.1 - @amplitude/analytics-node@1.5.75 - @amplitude/analytics-react-native@1.10.2 - @amplitude/element-selector@0.3.1 - @amplitude/plugin-autocapture-browser@1.29.4 - @amplitude/plugin-event-property-attribution-browser@0.2.18 - @amplitude/plugin-experiment-browser@1.0.0-beta.45 - @amplitude/plugin-experiment-react-native@1.0.0-beta.5 - @amplitude/plugin-network-capture-browser@1.10.18 - @amplitude/plugin-page-url-enrichment-browser@0.7.28 - @amplitude/plugin-page-view-tracking-browser@2.11.18 - @amplitude/plugin-session-replay-browser@1.35.4 - @amplitude/plugin-session-replay-react-native@0.5.5 - @amplitude/plugin-web-attribution-browser@2.2.28 - @amplitude/plugin-web-vitals-browser@1.2.1 - @amplitude/segment-session-replay-plugin@0.0.47 - @amplitude/session-replay-browser@1.50.4 - @amplitude/unified@1.1.37 - @amplitude/unified-react-native@1.0.0-beta.4
…plugin-session-replay-react-native/example (#1897) Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Session Replay Browser E2E ResultsDetails
|
size-limit report 📦
|
1ef63e5 to
699bc03
Compare
f483515 to
33871de
Compare
|
@codex review |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 33871de018
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| expect(trackNoDelay).toHaveBeenCalledWith( | ||
| expect.objectContaining({ | ||
| event_type: '[Amplitude] Stream Stopped', | ||
| event_properties: expect.objectContaining({ stop_reason: 'ended' }), | ||
| }), | ||
| true, | ||
| ); |
There was a problem hiding this comment.
Match the trackNoDelay call signature in the assertion
flushStopEvent invokes trackNoDelay(stopEvent) with one argument, but this assertion requires an additional true argument, so the new pagehide test fails even after the heartbeat mock is corrected. Assert the actual one-argument call, or change the production API consistently if the boolean is intended.
AGENTS.md reference: AGENTS.md:L19-L23
Useful? React with 👍 / 👎.
8736baf to
82c34f2
Compare
82c34f2 to
b912e0d
Compare
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b912e0dabc
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…Script into SDKI-26/end-video-on-pagehide
b912e0d to
9321979
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
❌ 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 9321979. Configure here.
| const onPageHide = (evt: PageTransitionEvent) => { | ||
| if (!evt.persisted) { | ||
| void this.heartbeat(true); | ||
| } |
There was a problem hiding this comment.
Stop reason lost on pagehide
Medium Severity
Heartbeat and VideoCapture each handle pagehide independently. heartbeat(true) snapshots the queue as soon as it runs, so a capture registered after the shared heartbeat already has listeners still has stop_reason timeout when that snapshot is sent.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 9321979. Configure here.


Summary
Checklist
Note
Medium Risk
Changes delayed-event delivery and flush timing on tab/page lifecycle, which can affect analytics completeness and ordering but avoids false stops for bfcache (
persisted) pages.Overview
Improves video stream analytics when users leave a page or start tracking late in playback.
Page lifecycle:
Heartbeatregisterspagehideandvisibilitychangelisteners (browser-only viagetGlobalScope). On a non–back/forward-cachepagehide, it re-sends queued delayed events and callsclient.flush(); when the document becomes hidden, it resets the heartbeat so the latest delayed stop payload is sent sooner.VideoCapturealso listens forpagehideand ends an in-progress session withstop_reason: 'ended', skipping teardown whenevent.persistedis true.Already-playing media: HTML and embedded player tracking now synthesize a play when capture starts while playback is already active (embedded players use optional
getPausedonready).API / behavior tweaks:
VideoCapture.stopaccepts an optional stop reason; heartbeatstop(flush)and publicheartbeat(flushClient)support optional flush; heartbeat error handlers callstop()without binding so rejections do not pass stray arguments.Reviewed by Cursor Bugbot for commit 9321979. Bugbot is set up for automated code reviews on this repo. Configure here.