Skip to content

Feat new events#20

Open
jakub-roch wants to merge 2 commits into
masterfrom
feat-new-events
Open

Feat new events#20
jakub-roch wants to merge 2 commits into
masterfrom
feat-new-events

Conversation

@jakub-roch

Copy link
Copy Markdown
Collaborator

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.

⚠️ Breaking changes / coordination
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.

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.

1 participant