The type 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 the caller provides no events, the event target is effectively disabled.
Optionalinterval?: numberWhen the time interval event is sent, the interval in seconds at which the reporter sends it.
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.
The transform is scoped to this target only. Targets that share a collector URL each run their own transform. Other targets that accept the event still receive a report cancelled by this transform.
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 where the reporter sends CMCD event reports.
Optionalversion?: typeof CMCD_V2The version of the CMCD protocol to use. Event reporting requires version 2.
Configuration for a CMCD event report.