Skip to content

fix(analytics-core): track video playback on playing (SDK-723) - #2177

Merged
daniel-graham-amplitude merged 3 commits into
video-analyticsfrom
SDK-723-switch-play-to-playing
Nov 23, 2026
Merged

daniel-graham-amplitude merged 3 commits into
video-analyticsfrom
SDK-723-switch-play-to-playing

Conversation

@daniel-graham-amplitude

@daniel-graham-amplitude daniel-graham-amplitude commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Report HTML and Mux video playback when playing fires, so a play request does not emit a start event before playback begins. When attaching to an unpaused element, require HAVE_FUTURE_DATA before emitting the initial play event. Update listener cleanup, the media mock, and regression coverage for delayed playback and attachment at all five readiness states.

Validation

  • Passed pnpm install.
  • Passed pnpm test --concurrency 2 -- --runInBand --forceExit for all 32 test projects. Explicit exit was needed because existing Jest runs retained open handles after reporting passing results.
  • Analytics-core: 1,027 tests passed with 100% coverage. Analytics-browser: 614 tests passed with 100% coverage.
  • Passed pnpm lint, pnpm docs:check, and pnpm lint:deps.
  • Follow-up validation: analytics-core and analytics-browser builds and full package tests passed, along with core lint, typechecking, and all five size-limit checks. The new tests reproduced premature play callbacks at readiness states 1 and 2 before the fix.
  • Commit hooks passed ESLint and Prettier.
  • Full pnpm build could not finish: the targeting Rollup process remained idle after writing its bundles on both attempts and was stopped.
  • pnpm test:examples is blocked by its reference to the missing jest.setup.examples.js file.

Checklist

  • PR title follows the conventional commit format.
  • Breaking change: No.

Note

Medium Risk
Changes when video start events are emitted in analytics, which can shift reported metrics and timing for existing integrations but stays confined to video lifecycle tracking.

Overview
Video start analytics now fire on the HTML media playing event instead of play, so a play request no longer emits a stream-started event before playback actually begins.

When tracking attaches to an element that is already unpaused, an initial play is reported only if readyState is at least HAVE_FUTURE_DATA; otherwise tracking waits until playing. Listener teardown, the test video mock, and browser teardown tests were aligned with playing, with added coverage for all readiness states and delayed playback.

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

@daniel-graham-amplitude
daniel-graham-amplitude requested a review from a team as a code owner November 13, 2026 19:33
@linear-code

linear-code Bot commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

SDK-723

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

size-limit report 📦

Path Size
packages/analytics-browser/lib/scripts/amplitude-min.js.gz 74.07 KB (+0.05% 🔺)
packages/session-replay-browser/lib/scripts/session-replay-browser-min.js.gz 139.19 KB (0%)
packages/unified/lib/scripts/amplitude-min.umd.js.gz 229.29 KB (0%)
@amplitude/element-selector (gzipped esm) 3.48 KB (0%)
@amplitude/analytics-browser/lite (gzipped CDN bundle) 22.06 KB (0%)

@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.

Stale Bugbot comment from a previous run.

@daniel-graham-amplitude
daniel-graham-amplitude force-pushed the SDK-723-switch-play-to-playing branch from 683fd69 to 09c3a1e Compare November 13, 2026 21:10
@daniel-graham-amplitude

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 09c3a1e. Configure here.

@Mercy811 Mercy811 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lgtm!

@daniel-graham-amplitude
daniel-graham-amplitude force-pushed the SDK-723-switch-play-to-playing branch from 8a055a6 to 2993a11 Compare November 23, 2026 22:52
@daniel-graham-amplitude
daniel-graham-amplitude force-pushed the SDK-723-switch-play-to-playing branch from 2993a11 to 412031d Compare November 23, 2026 22:54
@daniel-graham-amplitude
daniel-graham-amplitude merged commit faed380 into video-analytics Nov 23, 2026
22 checks passed
@daniel-graham-amplitude
daniel-graham-amplitude deleted the SDK-723-switch-play-to-playing branch November 23, 2026 23:39
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.

2 participants