Type Alias: CmcdEventReportConfig<C>
type CmcdEventReportConfig<C> = CmcdReportConfig & object;Defined in: CmcdEventReportConfig.ts:14
Configuration for a CMCD event report.
Type Parameters
C
C = Record<string, unknown>
The type of the player's customData on the request that triggered the event. Defaults to Record<string, unknown>.
Type Declaration
batchSize?
batchSize?: number;The number of events to batch before sending the report.
Default Value
1
events?
events?: CmcdEventType[];The events to report. If the caller provides no events, the event target is effectively disabled.
Default Value
undefined
interval?
interval?: number;When the time interval event is sent, the interval in seconds at which the reporter sends it.
Default Value
CMCD_DEFAULT_TIME_INTERVAL
See
transform?
transform?: 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.
Default Value
undefined
Example
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='))url
url: string;The URL where the reporter sends CMCD event reports.
version?
version?: typeof CMCD_V2;The version of the CMCD protocol to use. Event reporting requires version 2.
Default Value
CMCD_V2