Creates a new CMCD reporter.
The configuration for the CMCD reporter.
The function to use to send the request.
The default is a simple wrapper around the
native fetch API.
Applies the CMCD request report data to the request. Called by the player before sending the request.
The request to apply the CMCD request report to.
The request with the CMCD request report applied.
Use CmcdReporter.createRequestReport instead.
Creates a new request with the CMCD request report data applied. Called by the player before sending the request.
The request with the CMCD request report applied.
Forces the sending of all event reports, regardless of the batch size or interval. Useful for sending outstanding reports when the player is destroyed or a playback session ends.
Checks if the request reporting is enabled.
true if the request reporting is enabled, false otherwise.
Records an event. Called by the player when an event occurs.
For state-change events (PLAY_STATE, PLAYBACK_RATE, CONTENT_ID,
BACKGROUNDED_MODE, BITRATE_CHANGE), this method:
data (if present) into the reporter's
persistent data store — equivalent to a write-through update().update({ field: undefined })).
State-change events without their required field would violate CTA-5004-B.For all other event types, the event is always emitted.
For state-change events, prefer CmcdReporter.update — including
for snapshot enrichment via a combined call like
update({ sta: 'p', bl: [3000], mtp: [8500] }). Calling recordEvent()
for a state-change event after update() has already auto-fired it
silently drops the second call's data, because dedup suppresses the
second emission.
Use recordEvent() directly for events whose payload is intrinsic to
the event call — CUSTOM_EVENT with cen, ERROR with ec,
ad-lifecycle events, MUTE/UNMUTE, PLAYER_EXPAND/PLAYER_COLLAPSE,
SKIP. For RESPONSE_RECEIVED, prefer
CmcdReporter.recordResponseReceived, which derives the
per-response fields automatically.
The type of event to record.
Additional data to record with the event. This data only applies to this event report, except for the dedup field of a state-change event, which is also persisted into the reporter's data store.
Records a response-received event. Called by the player when a media request response has been fully received.
This method automatically derives the rr event keys from the
url - the original requested URL (before any redirects)rc - the HTTP response status codets - the request initiation time (from resourceTiming.startTime)ttfb - time to first byte (from resourceTiming.responseStart)ttlb - time to last byte (from resourceTiming.duration)Additional keys like ttfbb, cmsdd, cmsds, and smrt can be
supplied via the data parameter if the player has access to them.
The HTTP response received.
Additional CMCD data to include with the event. Values provided here override any auto-derived values.
Starts the CMCD reporter. Called by the player when the reporter is enabled.
Note: This fires an initial time-interval event immediately (synchronously) before the first interval elapses. Ensure CMCD data (sid, cid, etc.) is populated before calling start().
Stops the CMCD reporter. Called by the player when the reporter is disabled.
Whether to flush the event targets.
Updates the CMCD data.
Called by the player when data changes. For tracked state fields
(sta, pr, cid, bg, br), if the new value differs from the
last-reported value (the value most recently emitted on the wire for
that field), the corresponding state-change event is automatically
fired. Comparing against the last-reported value (rather than the
previous persisted value) ensures the first state-change event in a
new session always emits, even when the persisted value didn't change
across the sid boundary.
Multi-field updates fire multiple events in the order: sta → pr →
cid → bg → br. The order of keys in the input object does not
affect the firing order.
To attach snapshot context (e.g., bl, mtp, pt, ltc) to a
state-change event, ensure those fields are in the reporter's data
before the state field changes. Either include them alongside the
state field in the same update() call, or persist them via earlier
update() calls — auto-fired events emit whatever is currently in
the persistent data store. This is also how to keep TIME_INTERVAL
reports useful — those events draw from the persistent data store
with no caller hook for per-event data, so fields the player wants
in periodic reports must be kept fresh here.
A sid change resets the dedup baseline.
The CMCD reporter.
See
CTA-5004-B Reporting Modes