Feat new events#20
Open
jakub-roch wants to merge 2 commits into
Open
Conversation
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.
Overview
Converts the package to TypeScript and substantially expands analytics instrumentation — startup, rebuffering, quality, engagement, and consumer-defined custom events — with payload flood-protection and a documented event model. 43 files changed.
1. TypeScript migration
All src/ (and dev/main) converted .js → .ts, full strict mode.
Added tsconfig.json + tsconfig.types.json; build now bundles via ts-loader and emits .d.ts declarations. package.json gains a types entry so consumers get full typings.
Shared domain types in src/types.ts; ambient globals in types/globals.d.ts.
Removed Babel toolchain.
2. Tooling: yarn → pnpm
All yarn usage replaced with pnpm (scripts, .github/workflows/publish.yml via pnpm/action-setup, ignore files). CI Node bumped 16 → 20. Added packageManager field.
3. Player adapter contract
Expanded PlayerAdapter to cover the full HTML5 media event surface + QoE/engagement hooks and interpretation getters (volume, muted, dimensions, buffered, error, fullscreen, PiP). Removed the dead onComplete hook. iOS-webkit fullscreen handled.
4. New collected events
startup — join time (play → first frame); its absence = startup failure.
buffering — single per-view summary: count, totalDuration, maxDuration, byCause (seek/rebuffer), bounded occurrences[] (atTime, duration, cause, endedBy). Flapping bursts merged, sub-300ms jitter dropped, pre-playback stalls excluded, pause-during-stall handled.
qualityChange — resolution (debounced/deduped). error, ended, fullscreenChange, pictureInPictureChange.
5. Custom events
New reportCustomEvent(name, data?) — records a namespaced custom event into the active view (no-op when idle), correlatable by time with built-in events (e.g. viewability). Validated (name, object, ≤2KB).
6. Flood protection
Global 250-event/view cap with a truncated marker; per-view finalize hook for authoritative end-of-view summaries.
7. Bug fixes (from E2E audit)
Fullscreen cross-talk across multiple videos on a page (dedupe per element).
destroy() made idempotent (mobile background-then-stop no longer throws).
Stopped unbounded growth of listener/event maps across re-views.
Added stopAutoTracking / stopTracking aliases.
8. Docs
README rewritten with full API reference and a definition of every collected event + payload shape.
PlayerAdapter is a breaking contract change — custom adapters must implement the new required members. Suggest a major version bump.
Backend must handle new event types (startup, ended, buffering summary shape, qualityChange, error, fullscreenChange, pictureInPictureChange, custom, truncated) and use buffering.byCause.rebuffer for rebuffer ratio.