The shape of the player's customData on the request that
triggered the event. Defaults to Record<string, unknown>.
OptionalbatchSize?: numberThe number of events to batch before sending the report.
Optionalevents?: CmcdEventType[]The events to report. If no events are provided, the event target will be effectively disabled.
Optionalinterval?: numberWhen the time interval event is sent, the interval at which the events should be reported as a number of seconds.
Optionaltransform?: CmcdEventReportTransform<C>Transform applied to each of this target's event reports before
it is queued. Return the data to continue, or null to cancel
the report for this target.
Scoped to this target only: targets that share a collector URL each run their own transform, and a report cancelled here is still sent to other targets that accept the event.
const { requester } = createMockRequester()
const reporter = new CmcdReporter({
sid: 'session-id',
cid: 'content-id',
enabledKeys: ['br', 'sid', 'cid', 'v', 'sn'],
// Request mode: never decorate license requests with CMCD
transform: (data, request) => request.url.includes('/license') ? null : data,
eventTargets: [
{
url: 'https://collector.example.com/cmcd',
events: [CmcdEventType.RESPONSE_RECEIVED],
enabledKeys: ['url', 'rc', 'sid', 'v', 'e', 'ts', 'sn'],
batchSize: 1,
// Event mode, this target only: segment responses only
transform: (data, request) =>
request?.customData?.['requestType'] === 'segment' ? data : null,
},
],
}, requester)
const license = reporter.createRequestReport({ url: 'https://drm.example.com/license' })
ok(!license.url.includes('CMCD='))
const segment = reporter.createRequestReport({ url: 'https://cdn.example.com/segment.mp4' })
ok(segment.url.includes('CMCD='))
The URL to which the CMCD event should be sent.
Optionalversion?: typeof CMCD_V2The version of the CMCD protocol to use. Must be version 2 or higher for event reporting.
Configuration for a CMCD event report.