@svta/cml-cmcd 2.6.1 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +594 -572
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +482 -361
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -4,109 +4,109 @@ import { DeepReadonly, ExclusiveRecord, HttpRequest, HttpResponse, ValueOf, Valu
|
|
|
4
4
|
//#region src/CmcdEventType.d.ts
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
|
-
* CMCD event type
|
|
7
|
+
* CMCD event type 'bc' (bitrate change).
|
|
8
8
|
*
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
11
11
|
declare const CMCD_EVENT_BITRATE_CHANGE: "bc";
|
|
12
12
|
/**
|
|
13
|
-
* CMCD event type
|
|
13
|
+
* CMCD event type 'ps' (play state change).
|
|
14
14
|
*
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
17
|
declare const CMCD_EVENT_PLAY_STATE: "ps";
|
|
18
18
|
/**
|
|
19
|
-
* CMCD event type
|
|
19
|
+
* CMCD event type 'pr' (playback rate change).
|
|
20
20
|
*
|
|
21
21
|
* @public
|
|
22
22
|
*/
|
|
23
23
|
declare const CMCD_EVENT_PLAYBACK_RATE: "pr";
|
|
24
24
|
/**
|
|
25
|
-
* CMCD event type
|
|
25
|
+
* CMCD event type 'e' (error).
|
|
26
26
|
*
|
|
27
27
|
* @public
|
|
28
28
|
*/
|
|
29
29
|
declare const CMCD_EVENT_ERROR: "e";
|
|
30
30
|
/**
|
|
31
|
-
* CMCD event type
|
|
31
|
+
* CMCD event type 't' (time interval).
|
|
32
32
|
*
|
|
33
33
|
* @public
|
|
34
34
|
*/
|
|
35
35
|
declare const CMCD_EVENT_TIME_INTERVAL: "t";
|
|
36
36
|
/**
|
|
37
|
-
* CMCD event type
|
|
37
|
+
* CMCD event type 'c' (content ID).
|
|
38
38
|
*
|
|
39
39
|
* @public
|
|
40
40
|
*/
|
|
41
41
|
declare const CMCD_EVENT_CONTENT_ID: "c";
|
|
42
42
|
/**
|
|
43
|
-
* CMCD event type
|
|
43
|
+
* CMCD event type 'b' (backgrounded mode).
|
|
44
44
|
*
|
|
45
45
|
* @public
|
|
46
46
|
*/
|
|
47
47
|
declare const CMCD_EVENT_BACKGROUNDED_MODE: "b";
|
|
48
48
|
/**
|
|
49
|
-
* CMCD event type
|
|
49
|
+
* CMCD event type 'm' (mute).
|
|
50
50
|
*
|
|
51
51
|
* @public
|
|
52
52
|
*/
|
|
53
53
|
declare const CMCD_EVENT_MUTE: "m";
|
|
54
54
|
/**
|
|
55
|
-
* CMCD event type
|
|
55
|
+
* CMCD event type 'um' (unmute).
|
|
56
56
|
*
|
|
57
57
|
* @public
|
|
58
58
|
*/
|
|
59
59
|
declare const CMCD_EVENT_UNMUTE: "um";
|
|
60
60
|
/**
|
|
61
|
-
* CMCD event type
|
|
61
|
+
* CMCD event type 'pe' (player expand).
|
|
62
62
|
*
|
|
63
63
|
* @public
|
|
64
64
|
*/
|
|
65
65
|
declare const CMCD_EVENT_PLAYER_EXPAND: "pe";
|
|
66
66
|
/**
|
|
67
|
-
* CMCD event type
|
|
67
|
+
* CMCD event type 'pc' (player collapse).
|
|
68
68
|
*
|
|
69
69
|
* @public
|
|
70
70
|
*/
|
|
71
71
|
declare const CMCD_EVENT_PLAYER_COLLAPSE: "pc";
|
|
72
72
|
/**
|
|
73
|
-
* CMCD event type
|
|
73
|
+
* CMCD event type 'rr' (response received).
|
|
74
74
|
*
|
|
75
75
|
* @public
|
|
76
76
|
*/
|
|
77
77
|
declare const CMCD_EVENT_RESPONSE_RECEIVED: "rr";
|
|
78
78
|
/**
|
|
79
|
-
* CMCD event type
|
|
79
|
+
* CMCD event type 'as' (ad start).
|
|
80
80
|
*
|
|
81
81
|
* @public
|
|
82
82
|
*/
|
|
83
83
|
declare const CMCD_EVENT_AD_START: "as";
|
|
84
84
|
/**
|
|
85
|
-
* CMCD event type
|
|
85
|
+
* CMCD event type 'ae' (ad end).
|
|
86
86
|
*
|
|
87
87
|
* @public
|
|
88
88
|
*/
|
|
89
89
|
declare const CMCD_EVENT_AD_END: "ae";
|
|
90
90
|
/**
|
|
91
|
-
* CMCD event type
|
|
91
|
+
* CMCD event type 'abs' (ad break start).
|
|
92
92
|
*
|
|
93
93
|
* @public
|
|
94
94
|
*/
|
|
95
95
|
declare const CMCD_EVENT_AD_BREAK_START: "abs";
|
|
96
96
|
/**
|
|
97
|
-
* CMCD event type
|
|
97
|
+
* CMCD event type 'abe' (ad break end).
|
|
98
98
|
*
|
|
99
99
|
* @public
|
|
100
100
|
*/
|
|
101
101
|
declare const CMCD_EVENT_AD_BREAK_END: "abe";
|
|
102
102
|
/**
|
|
103
|
-
* CMCD event type
|
|
103
|
+
* CMCD event type 'sk' (skip).
|
|
104
104
|
*
|
|
105
105
|
* @public
|
|
106
106
|
*/
|
|
107
107
|
declare const CMCD_EVENT_SKIP: "sk";
|
|
108
108
|
/**
|
|
109
|
-
* CMCD event type
|
|
109
|
+
* CMCD event type 'ce' (custom event).
|
|
110
110
|
*
|
|
111
111
|
* @public
|
|
112
112
|
*/
|
|
@@ -146,7 +146,7 @@ declare const CmcdEventType: {
|
|
|
146
146
|
*/
|
|
147
147
|
readonly CONTENT_ID: typeof CMCD_EVENT_CONTENT_ID;
|
|
148
148
|
/**
|
|
149
|
-
* A change in the
|
|
149
|
+
* A change in the player's backgrounded state.
|
|
150
150
|
*/
|
|
151
151
|
readonly BACKGROUNDED_MODE: typeof CMCD_EVENT_BACKGROUNDED_MODE;
|
|
152
152
|
/**
|
|
@@ -154,7 +154,7 @@ declare const CmcdEventType: {
|
|
|
154
154
|
*/
|
|
155
155
|
readonly MUTE: typeof CMCD_EVENT_MUTE;
|
|
156
156
|
/**
|
|
157
|
-
*
|
|
157
|
+
* The player was unmuted.
|
|
158
158
|
*/
|
|
159
159
|
readonly UNMUTE: typeof CMCD_EVENT_UNMUTE;
|
|
160
160
|
/**
|
|
@@ -201,17 +201,17 @@ type CmcdEventType = ValueOf<typeof CmcdEventType>;
|
|
|
201
201
|
//#endregion
|
|
202
202
|
//#region src/CmcdCustomKey.d.ts
|
|
203
203
|
/**
|
|
204
|
-
* A custom key for CMCD. Custom keys MUST
|
|
204
|
+
* A custom key for CMCD. Custom keys MUST have a hyphenated prefix
|
|
205
205
|
* to ensure that there will not be a namespace collision with future
|
|
206
206
|
* revisions to this specification. Clients SHOULD use a reverse-DNS
|
|
207
207
|
* syntax when defining their own prefix.
|
|
208
208
|
*
|
|
209
209
|
* The type requires a lowercase hyphenated string. At runtime a key
|
|
210
|
-
* must also satisfy {@link isCmcdCustomKey}
|
|
211
|
-
* letter, then characters from `a-z 0-9 .
|
|
212
|
-
* neither
|
|
213
|
-
* custom-key grammar that
|
|
214
|
-
*
|
|
210
|
+
* must also satisfy {@link isCmcdCustomKey}: a lowercase first
|
|
211
|
+
* letter, then characters from `a-z 0-9 . -`. The key needs a hyphen
|
|
212
|
+
* that is neither first nor last. The check restricts the CMCD
|
|
213
|
+
* custom-key grammar to names that RFC 8941 key serialization accepts.
|
|
214
|
+
* Preparation drops keys that fail the check. Lowercase reverse-DNS
|
|
215
215
|
* names satisfy all constraints.
|
|
216
216
|
*
|
|
217
217
|
* @public
|
|
@@ -289,7 +289,7 @@ type CmcdObjectTypeList = (number | SfItem<number, ExclusiveRecord<CmcdObjectTyp
|
|
|
289
289
|
//#endregion
|
|
290
290
|
//#region src/CmcdPlayerState.d.ts
|
|
291
291
|
/**
|
|
292
|
-
* CMCD
|
|
292
|
+
* CMCD version 2 player states for the 'sta' key.
|
|
293
293
|
*
|
|
294
294
|
*
|
|
295
295
|
* @enum
|
|
@@ -336,7 +336,7 @@ declare const CmcdPlayerState: {
|
|
|
336
336
|
*/
|
|
337
337
|
readonly QUIT: "q";
|
|
338
338
|
/**
|
|
339
|
-
* Preloading: The player is loading assets ahead of starting
|
|
339
|
+
* Preloading: The player is loading assets ahead of starting to provide a fast startup. The expectation is that playback will commence at a future time.
|
|
340
340
|
*/
|
|
341
341
|
readonly PRELOADING: "d";
|
|
342
342
|
};
|
|
@@ -357,11 +357,11 @@ type CmcdPlayerState = ValueOf<typeof CmcdPlayerState>;
|
|
|
357
357
|
*/
|
|
358
358
|
declare const CmcdStreamType: {
|
|
359
359
|
/**
|
|
360
|
-
*
|
|
360
|
+
* All segments are available, for example VOD
|
|
361
361
|
*/
|
|
362
362
|
readonly VOD: "v";
|
|
363
363
|
/**
|
|
364
|
-
* Segments become available over time
|
|
364
|
+
* Segments become available over time, for example LIVE
|
|
365
365
|
*/
|
|
366
366
|
readonly LIVE: "l";
|
|
367
367
|
/**
|
|
@@ -420,17 +420,18 @@ type CmcdStreamingFormat = ValueOf<typeof CmcdStreamingFormat>;
|
|
|
420
420
|
*/
|
|
421
421
|
type CmcdRequest = {
|
|
422
422
|
/**
|
|
423
|
-
* Custom key names may be used, but they MUST
|
|
424
|
-
* with future revisions
|
|
423
|
+
* Custom key names may be used, but they MUST have a hyphenated prefix. The prefix ensures that there is no
|
|
424
|
+
* namespace collision with future CMCD revisions. Clients SHOULD use a reverse-DNS syntax when defining their own
|
|
425
|
+
* prefix.
|
|
425
426
|
*/
|
|
426
427
|
[index: CmcdCustomKey]: CmcdCustomValue | undefined;
|
|
427
428
|
/**
|
|
428
429
|
* Aggregate encoded bitrate
|
|
429
430
|
*
|
|
430
|
-
* The aggregate encoded bitrate across a playable combination of tracks. This
|
|
431
|
-
* of the tracks are known.
|
|
432
|
-
* If the playlist declares both peak and average bitrate values, the peak value
|
|
433
|
-
* the encoded bitrate is known.
|
|
431
|
+
* The aggregate encoded bitrate across a playable combination of tracks. This key SHOULD NOT be used when the
|
|
432
|
+
* individual bitrates of the tracks are known. The player SHOULD derive this value from a playlist/manifest
|
|
433
|
+
* declaration, or MAY estimate it. If the playlist declares both peak and average bitrate values, the peak value
|
|
434
|
+
* MUST be transmitted. This value MUST NOT be sent if the encoded bitrate is known.
|
|
434
435
|
*
|
|
435
436
|
* Inner list of integer kbps with token identifiers
|
|
436
437
|
*
|
|
@@ -441,7 +442,7 @@ type CmcdRequest = {
|
|
|
441
442
|
* Backgrounded
|
|
442
443
|
*
|
|
443
444
|
* All players in a session are currently in a state that is not visible to the user due to a user interaction. This key SHOULD only
|
|
444
|
-
* be sent if it is TRUE. If the visibility state of the player is not known this key SHOULD NOT be reported.
|
|
445
|
+
* be sent if it is TRUE. If the visibility state of the player is not known, this key SHOULD NOT be reported.
|
|
445
446
|
*
|
|
446
447
|
* Boolean
|
|
447
448
|
*
|
|
@@ -461,10 +462,10 @@ type CmcdRequest = {
|
|
|
461
462
|
/**
|
|
462
463
|
* Encoded bitrate
|
|
463
464
|
*
|
|
464
|
-
* The encoded bitrate. In request mode, this
|
|
465
|
-
*
|
|
466
|
-
*
|
|
467
|
-
*
|
|
465
|
+
* The encoded bitrate. In request mode, this value is the encoded bitrate of the requested representation. In event
|
|
466
|
+
* mode, this value is the encoded bitrate of the currently selected representation. The player SHOULD derive this
|
|
467
|
+
* value from playlist/manifest declarations, or MAY estimate it. If the playlist declares both peak and average
|
|
468
|
+
* bitrate values, the peak value MUST be transmitted.
|
|
468
469
|
*
|
|
469
470
|
* Inner list of integer kbps with token identifiers
|
|
470
471
|
*
|
|
@@ -474,9 +475,10 @@ type CmcdRequest = {
|
|
|
474
475
|
/**
|
|
475
476
|
* Buffer starvation
|
|
476
477
|
*
|
|
477
|
-
* TRUE if the player buffer was starved at some point between the prior report and this report per reporting
|
|
478
|
-
* the player entering a rebuffering state or remaining in a rebuffering state.
|
|
479
|
-
* new CDN,
|
|
478
|
+
* TRUE if the player buffer was starved at some point between the prior report and this report, per reporting
|
|
479
|
+
* destination. Starvation results in the player entering a rebuffering state or remaining in a rebuffering state.
|
|
480
|
+
* If the player begins requesting data from a new CDN, this key might initially report buffering caused by the
|
|
481
|
+
* prior CDN. This key SHOULD NOT be reported if it is FALSE.
|
|
480
482
|
*
|
|
481
483
|
* Boolean
|
|
482
484
|
*
|
|
@@ -498,7 +500,7 @@ type CmcdRequest = {
|
|
|
498
500
|
* Buffer Starvation Duration
|
|
499
501
|
*
|
|
500
502
|
* A list of durations of each buffer starvation period reported once the rebuffering has completed. This value MUST only be reported
|
|
501
|
-
* once per reporting mode and
|
|
503
|
+
* once per reporting mode and reporting destination. Token identifier MAY be omitted if the cause of the rebuffering is unknown.
|
|
502
504
|
*
|
|
503
505
|
* Inner list of integer milliseconds with optional token identifiers
|
|
504
506
|
*
|
|
@@ -529,8 +531,8 @@ type CmcdRequest = {
|
|
|
529
531
|
/**
|
|
530
532
|
* Content ID
|
|
531
533
|
*
|
|
532
|
-
* A unique string identifying the current content. The maximum length is 128 characters. This value is consistent
|
|
533
|
-
* sessions and devices
|
|
534
|
+
* A unique string identifying the current content. The maximum length is 128 characters. This value is consistent
|
|
535
|
+
* across different sessions and devices. The service provider defines and updates this value at its discretion.
|
|
534
536
|
*
|
|
535
537
|
* String
|
|
536
538
|
*
|
|
@@ -540,8 +542,9 @@ type CmcdRequest = {
|
|
|
540
542
|
/**
|
|
541
543
|
* Content Signature
|
|
542
544
|
*
|
|
543
|
-
* A string representing a signature of the content being played. This
|
|
544
|
-
* to the content. For example, this
|
|
545
|
+
* A string representing a signature of the content being played. This key SHOULD vary with content ID and be bound
|
|
546
|
+
* by some mechanism to the content. For example, this key may transmit the C2PA signature associated with the
|
|
547
|
+
* content being viewed.
|
|
545
548
|
*
|
|
546
549
|
* String
|
|
547
550
|
*
|
|
@@ -552,7 +555,7 @@ type CmcdRequest = {
|
|
|
552
555
|
* Object duration
|
|
553
556
|
*
|
|
554
557
|
* The playback duration in milliseconds of the object being requested. If a partial segment is being requested,
|
|
555
|
-
*
|
|
558
|
+
* this value MUST indicate the playback duration of that part and not that of its parent segment.
|
|
556
559
|
* This value can be an approximation of the estimated duration if the explicit value is not known.
|
|
557
560
|
* This value MUST NOT be sent for objects which do not have an object type of 'a', 'v', 'av', 'tt', 'c', or 'o'.
|
|
558
561
|
*
|
|
@@ -564,9 +567,10 @@ type CmcdRequest = {
|
|
|
564
567
|
/**
|
|
565
568
|
* Dropped Frames Absolute
|
|
566
569
|
*
|
|
567
|
-
* An absolute count of dropped frames since session initiation. This key SHOULD only be sent for content types of
|
|
568
|
-
*
|
|
569
|
-
*
|
|
570
|
+
* An absolute count of dropped frames since session initiation. This key SHOULD only be sent for content types of
|
|
571
|
+
* 'v', 'av' or 'o'. This value depends on the content being rendered, not on the content being retrieved.
|
|
572
|
+
* Therefore, sending the playhead time 'pt' key with this key is beneficial. The 'pt' key allows correct
|
|
573
|
+
* interpretation of this value.
|
|
570
574
|
*
|
|
571
575
|
* Integer
|
|
572
576
|
*
|
|
@@ -576,9 +580,9 @@ type CmcdRequest = {
|
|
|
576
580
|
/**
|
|
577
581
|
* Deadline
|
|
578
582
|
*
|
|
579
|
-
* Deadline from the request time until the first sample of this Segment/Object needs to be available
|
|
580
|
-
* or any other playback problems. This value MUST be rounded to the
|
|
581
|
-
* player's remaining buffer length.
|
|
583
|
+
* Deadline from the request time until the first sample of this Segment/Object needs to be available. Availability
|
|
584
|
+
* by the deadline avoids a buffer underrun or any other playback problems. This value MUST be rounded to the
|
|
585
|
+
* nearest 100ms. For a playback rate of 1, this value may be equivalent to the player's remaining buffer length.
|
|
582
586
|
*
|
|
583
587
|
* Integer milliseconds
|
|
584
588
|
*
|
|
@@ -588,7 +592,7 @@ type CmcdRequest = {
|
|
|
588
592
|
/**
|
|
589
593
|
* Player Error Code
|
|
590
594
|
*
|
|
591
|
-
* A string defining an error code produced by the player. The namespace and formatting of this error code
|
|
595
|
+
* A string defining an error code produced by the player. The namespace and formatting of this error code are left to the application.
|
|
592
596
|
*
|
|
593
597
|
* Even if only one error code is being specified, the list notation MUST still be used.
|
|
594
598
|
*
|
|
@@ -600,10 +604,10 @@ type CmcdRequest = {
|
|
|
600
604
|
/**
|
|
601
605
|
* Lowest aggregated encoded bitrate
|
|
602
606
|
*
|
|
603
|
-
* The lowest aggregated bitrate rendition in the manifest or playlist.
|
|
604
|
-
* or
|
|
605
|
-
* transmitted. The aggregate encoded bitrate is of the complete media object
|
|
606
|
-
* sent if the lowest encoded bitrate is known.
|
|
607
|
+
* The lowest aggregated bitrate rendition in the manifest or playlist. The player SHOULD derive this value from
|
|
608
|
+
* playlist/manifest declarations, or MAY estimate it. If the playlist declares both peak and average bitrate
|
|
609
|
+
* values, the peak value MUST be transmitted. The aggregate encoded bitrate is that of the complete media object,
|
|
610
|
+
* including all object types. This value MUST NOT be sent if the lowest encoded bitrate is known.
|
|
607
611
|
*
|
|
608
612
|
* Inner list of integer kbps with token identifiers
|
|
609
613
|
*
|
|
@@ -613,10 +617,11 @@ type CmcdRequest = {
|
|
|
613
617
|
/**
|
|
614
618
|
* Lowest encoded bitrate
|
|
615
619
|
*
|
|
616
|
-
* The lowest bitrate rendition in the manifest or playlist.
|
|
617
|
-
*
|
|
618
|
-
* lowest bitrate MUST apply to the object type being requested.
|
|
619
|
-
*
|
|
620
|
+
* The lowest bitrate rendition in the manifest or playlist. The player SHOULD derive this value from
|
|
621
|
+
* playlist/manifest declarations, or MAY estimate it. If the playlist declares both peak and average bitrate
|
|
622
|
+
* values, the peak value MUST be transmitted. This lowest bitrate MUST apply to the object type being requested.
|
|
623
|
+
* Requests for video objects MUST specify the lowest video bitrate. Requests for audio objects MUST specify the
|
|
624
|
+
* lowest audio bitrate.
|
|
620
625
|
*
|
|
621
626
|
* Inner list of integer kbps with token identifiers
|
|
622
627
|
*
|
|
@@ -626,8 +631,8 @@ type CmcdRequest = {
|
|
|
626
631
|
/**
|
|
627
632
|
* Live stream latency
|
|
628
633
|
*
|
|
629
|
-
* The time delta between when a given media timestamp
|
|
630
|
-
* accuracy of this estimate
|
|
634
|
+
* The time delta between when a given media timestamp became available at the origin and when the player rendered
|
|
635
|
+
* it. The accuracy of this estimate depends on synchronization between the packager and the player clocks.
|
|
631
636
|
*
|
|
632
637
|
* Integer milliseconds
|
|
633
638
|
*
|
|
@@ -637,11 +642,12 @@ type CmcdRequest = {
|
|
|
637
642
|
/**
|
|
638
643
|
* Media Start Delay
|
|
639
644
|
*
|
|
640
|
-
*
|
|
641
|
-
* begins playback
|
|
642
|
-
* "starting" and "playing" states.
|
|
645
|
+
* The initial delay, in wall-clock time, from when the player is instructed to play media for a given session until
|
|
646
|
+
* any media begins playback. The media can be primary content or interstitial content. This value SHOULD be the
|
|
647
|
+
* time difference between the "starting" and "playing" states.
|
|
643
648
|
*
|
|
644
|
-
* This key MUST only be sent once per Session ID
|
|
649
|
+
* This key MUST only be sent once per Session ID. This key MUST be sent for each reporting mode active within the
|
|
650
|
+
* player.
|
|
645
651
|
*
|
|
646
652
|
* Integer milliseconds
|
|
647
653
|
*
|
|
@@ -651,14 +657,15 @@ type CmcdRequest = {
|
|
|
651
657
|
/**
|
|
652
658
|
* Measured throughput
|
|
653
659
|
*
|
|
654
|
-
* The throughput between player and server, as measured by the player. Throughput MUST be rounded to the nearest
|
|
655
|
-
* derived, SHOULD be the value that the player
|
|
656
|
-
* different object types from different providers
|
|
657
|
-
* object type request
|
|
658
|
-
*
|
|
659
|
-
*
|
|
660
|
-
*
|
|
661
|
-
*
|
|
660
|
+
* The throughput between player and server, as measured by the player. Throughput MUST be rounded to the nearest
|
|
661
|
+
* 100 kbps. This value, however derived, SHOULD be the value that the player uses for its next Adaptive Bitrate
|
|
662
|
+
* switching decision. If the player requests different object types from different providers, it SHOULD match each
|
|
663
|
+
* object type request with the throughput measured against that provider. Reporting aggregate information is
|
|
664
|
+
* acceptable if objects of the same type are requested from different providers. If the player has multiple
|
|
665
|
+
* concurrent connections to the provider, this value is intended to communicate the player's aggregate throughput
|
|
666
|
+
* across all those connections. If this key is sent on an interval report, the value should be the last throughput
|
|
667
|
+
* estimate that the player made before the report. The player is not required to calculate the average measured
|
|
668
|
+
* throughput since the prior interval report.
|
|
662
669
|
*
|
|
663
670
|
* Inner list of integer kbps with token identifiers
|
|
664
671
|
*
|
|
@@ -668,24 +675,25 @@ type CmcdRequest = {
|
|
|
668
675
|
/**
|
|
669
676
|
* Next object request
|
|
670
677
|
*
|
|
671
|
-
* The relative path, as defined by RFC 3986, to one or more objects
|
|
672
|
-
*
|
|
673
|
-
* only one object is being specified, the list notation MUST still be
|
|
674
|
-
* the range is communicated as the parameter 'r' with a String value. The
|
|
675
|
-
*
|
|
676
|
-
* only valid combinations are:
|
|
678
|
+
* The relative path, as defined by RFC 3986, to one or more objects. The player making the current request can
|
|
679
|
+
* reasonably be expected to request these objects. Each object SHOULD be fetched in its entirety unless the future
|
|
680
|
+
* request has an associated range. Even if only one object is being specified, the list notation MUST still be
|
|
681
|
+
* used. If the future request has a range, the range is communicated as the parameter 'r' with a String value. The
|
|
682
|
+
* String value has a format similar to the HTTP Range header, with these exceptions. The unit MUST be 'byte'. The
|
|
683
|
+
* 'Range:' prefix is NOT permitted. Multiple ranges are NOT allowed. The only valid combinations are:
|
|
677
684
|
*
|
|
678
685
|
* - `"<range-start>-"`
|
|
679
686
|
* - `"<range-start>-<range-end>"`
|
|
680
687
|
* - `"-<suffix-length>"`
|
|
681
688
|
*
|
|
682
|
-
* The player SHOULD NOT depend upon any pre-fetch action being taken
|
|
689
|
+
* The player SHOULD NOT depend upon any pre-fetch action being taken. The key is only a request for such a
|
|
690
|
+
* pre-fetch.
|
|
683
691
|
*
|
|
684
692
|
* Inner list of strings
|
|
685
693
|
*
|
|
686
694
|
* @remarks
|
|
687
|
-
* Values may be provided as absolute URLs for convenience
|
|
688
|
-
*
|
|
695
|
+
* Values may be provided as absolute URLs for convenience. If {@link CmcdEncodeOptions.baseUrl} is set, same-origin
|
|
696
|
+
* URLs are converted to paths relative to that base. Already-relative values are emitted unchanged.
|
|
689
697
|
*
|
|
690
698
|
* @see {@link https://cta-wave.github.io/Resources/common-media-client-data--cta-5004-b.html#next-object-request | CTA-5004-B Next Object Request}
|
|
691
699
|
*/
|
|
@@ -716,7 +724,7 @@ type CmcdRequest = {
|
|
|
716
724
|
* - `k` = cryptographic key, license or certificate.
|
|
717
725
|
* - `o` = other
|
|
718
726
|
*
|
|
719
|
-
* If the object type being requested is unknown,
|
|
727
|
+
* If the object type being requested is unknown, this key MUST NOT be used.
|
|
720
728
|
*
|
|
721
729
|
* This key is also used as a token parameter for other keys.
|
|
722
730
|
*
|
|
@@ -738,7 +746,7 @@ type CmcdRequest = {
|
|
|
738
746
|
/**
|
|
739
747
|
* Playback rate
|
|
740
748
|
*
|
|
741
|
-
* 1.0 if real-time, 2.0 if double speed, 0 if not playing. SHOULD only be sent if not equal to 1.0.
|
|
749
|
+
* 1.0 if real-time, 2.0 if double speed, 0 if not playing. This value SHOULD only be sent if not equal to 1.0.
|
|
742
750
|
*
|
|
743
751
|
* Decimal
|
|
744
752
|
*
|
|
@@ -785,10 +793,10 @@ type CmcdRequest = {
|
|
|
785
793
|
/**
|
|
786
794
|
* Session ID
|
|
787
795
|
*
|
|
788
|
-
* A GUID identifying the current playback session. A playback session typically consists of the playback of a
|
|
789
|
-
* with accompanying content such as advertisements. This session may comprise the playback of
|
|
790
|
-
* content. This session is being played on a single device. The maximum
|
|
791
|
-
* UUID specification.
|
|
796
|
+
* A GUID identifying the current playback session. A playback session typically consists of the playback of a
|
|
797
|
+
* single media asset with accompanying content such as advertisements. This session may comprise the playback of
|
|
798
|
+
* primary content combined with interstitial content. This session is being played on a single device. The maximum
|
|
799
|
+
* length is 64 characters. Conformance to the UUID specification is RECOMMENDED.
|
|
792
800
|
*
|
|
793
801
|
* String
|
|
794
802
|
*
|
|
@@ -798,8 +806,9 @@ type CmcdRequest = {
|
|
|
798
806
|
/**
|
|
799
807
|
* Sequence Number
|
|
800
808
|
*
|
|
801
|
-
* A monotonically increasing integer to identify the sequence of a CMCD report to a target within a session. This
|
|
802
|
-
* zero on the start of a new session-id. Sequence numbers increase independently
|
|
809
|
+
* A monotonically increasing integer to identify the sequence of a CMCD report to a target within a session. This
|
|
810
|
+
* value MUST be reset to zero on the start of a new session-id. Sequence numbers increase independently for each
|
|
811
|
+
* combination of mode and target.
|
|
803
812
|
*
|
|
804
813
|
* Integer
|
|
805
814
|
*
|
|
@@ -809,8 +818,8 @@ type CmcdRequest = {
|
|
|
809
818
|
/**
|
|
810
819
|
* Stream type
|
|
811
820
|
*
|
|
812
|
-
* - `v` = all segments are available
|
|
813
|
-
* - `l` = segments become available over time
|
|
821
|
+
* - `v` = all segments are available, for example VOD
|
|
822
|
+
* - `l` = segments become available over time, for example LIVE
|
|
814
823
|
* - `ll` = low latency LIVE
|
|
815
824
|
*
|
|
816
825
|
* Token
|
|
@@ -831,7 +840,7 @@ type CmcdRequest = {
|
|
|
831
840
|
* - `e` - ended: Rendering has ended due to completion of the media asset playback.
|
|
832
841
|
* - `f` - fatal error: Rendering has ended due to an irrecoverable error.
|
|
833
842
|
* - `q` - quit: User initiated end of playback before media asset completion.
|
|
834
|
-
* - `d` - preloading: the player is loading, or has loaded, assets ahead of starting
|
|
843
|
+
* - `d` - preloading: the player is loading, or has loaded, assets ahead of starting to provide a fast startup. The expectation is that playback will commence at a future time.
|
|
835
844
|
*
|
|
836
845
|
* Token - one of [s,p,k,r,a,e,f,q,d]
|
|
837
846
|
*
|
|
@@ -841,8 +850,9 @@ type CmcdRequest = {
|
|
|
841
850
|
/**
|
|
842
851
|
* Startup
|
|
843
852
|
*
|
|
844
|
-
*
|
|
845
|
-
* reports this key as true until its buffer first reaches the target buffer for
|
|
853
|
+
* The key is included without a value if the object is needed urgently due to startup, seeking or recovery after a
|
|
854
|
+
* buffer-empty event. The player reports this key as true until its buffer first reaches the target buffer for
|
|
855
|
+
* stable playback.
|
|
846
856
|
*
|
|
847
857
|
* Boolean
|
|
848
858
|
*
|
|
@@ -852,10 +862,10 @@ type CmcdRequest = {
|
|
|
852
862
|
/**
|
|
853
863
|
* Top aggregated encoded bitrate
|
|
854
864
|
*
|
|
855
|
-
* The highest aggregated bitrate rendition in the manifest or playlist.
|
|
856
|
-
* or
|
|
857
|
-
* transmitted. The aggregate encoded bitrate is of the complete media object
|
|
858
|
-
* sent if the top encoded bitrate is known.
|
|
865
|
+
* The highest aggregated bitrate rendition in the manifest or playlist. The player SHOULD derive this value from
|
|
866
|
+
* playlist/manifest declarations, or MAY estimate it. If the playlist declares both peak and average bitrate
|
|
867
|
+
* values, the peak value MUST be transmitted. The aggregate encoded bitrate is that of the complete media object,
|
|
868
|
+
* including all object types. This value MUST NOT be sent if the top encoded bitrate is known.
|
|
859
869
|
*
|
|
860
870
|
* Inner list of integer kbps with token identifiers
|
|
861
871
|
*
|
|
@@ -865,10 +875,11 @@ type CmcdRequest = {
|
|
|
865
875
|
/**
|
|
866
876
|
* Top encoded bitrate
|
|
867
877
|
*
|
|
868
|
-
* The highest bitrate rendition in the manifest or playlist.
|
|
869
|
-
* or
|
|
870
|
-
* MUST be transmitted. This top bitrate MUST apply to the object type being requested.
|
|
871
|
-
* specify the top video bitrate
|
|
878
|
+
* The highest bitrate rendition in the manifest or playlist. The player SHOULD derive this value from
|
|
879
|
+
* playlist/manifest declarations, or MAY estimate it. If the playlist declares both peak and average bitrate
|
|
880
|
+
* values, the peak value MUST be transmitted. This top bitrate MUST apply to the object type being requested.
|
|
881
|
+
* Requests for video objects MUST specify the top video bitrate. Requests for audio objects MUST specify the top
|
|
882
|
+
* audio bitrate.
|
|
872
883
|
*
|
|
873
884
|
* Inner list of integer kbps with token identifiers
|
|
874
885
|
*
|
|
@@ -889,17 +900,17 @@ type CmcdRequest = {
|
|
|
889
900
|
/**
|
|
890
901
|
* Top playable bitrate
|
|
891
902
|
*
|
|
892
|
-
* The highest bitrate rendition that the player is currently capable of playing for reasons other than bandwidth
|
|
893
|
-
* key
|
|
894
|
-
* of bitrate. These constraints are intentionally obfuscated for privacy reasons.
|
|
903
|
+
* The highest bitrate rendition that the player is currently capable of playing for reasons other than bandwidth
|
|
904
|
+
* limitations. This key applies to cases in which, for example, screen resolution, DRM, or performance constraints
|
|
905
|
+
* limit the player's topmost choice of bitrate. These constraints are intentionally obfuscated for privacy reasons.
|
|
895
906
|
*
|
|
896
|
-
* This key can increase the fingerprinting surface exposed by CMCD transmission
|
|
897
|
-
* configuration.
|
|
907
|
+
* This key can increase the fingerprinting surface exposed by CMCD transmission. This key SHOULD NOT be transmitted
|
|
908
|
+
* in a default player configuration.
|
|
898
909
|
*
|
|
899
|
-
* If the playlist declares both peak and average bitrate values, the peak value MUST be transmitted. This top
|
|
900
|
-
* apply to the object type being requested. Requests for video objects MUST specify the top
|
|
901
|
-
* audio objects MUST specify the top playable audio bitrate. This value MUST
|
|
902
|
-
* of 'a', 'v', 'av' or 'c'.
|
|
910
|
+
* If the playlist declares both peak and average bitrate values, the peak value MUST be transmitted. This top
|
|
911
|
+
* playable bitrate MUST apply to the object type being requested. Requests for video objects MUST specify the top
|
|
912
|
+
* playable video bitrate. Requests for audio objects MUST specify the top playable audio bitrate. This value MUST
|
|
913
|
+
* NOT be sent for objects which do not have an object type of 'a', 'v', 'av' or 'c'.
|
|
903
914
|
*
|
|
904
915
|
* Inner list of integer kbps with token identifiers
|
|
905
916
|
*
|
|
@@ -909,9 +920,9 @@ type CmcdRequest = {
|
|
|
909
920
|
/**
|
|
910
921
|
* Version
|
|
911
922
|
*
|
|
912
|
-
* The version
|
|
913
|
-
* MUST interpret the values as
|
|
914
|
-
* if the version is not 1.
|
|
923
|
+
* The CMCD version used to interpret the defined key names and values. If this key is omitted, the player and
|
|
924
|
+
* server MUST interpret the values as defined by version 1. The player SHOULD omit this key if the version is 1.
|
|
925
|
+
* The player MUST include this key if the version is not 1.
|
|
915
926
|
*
|
|
916
927
|
* Integer
|
|
917
928
|
*
|
|
@@ -935,9 +946,10 @@ type CmcdEvent = CmcdRequest & {
|
|
|
935
946
|
/**
|
|
936
947
|
* Custom Event Name
|
|
937
948
|
*
|
|
938
|
-
*
|
|
939
|
-
*
|
|
940
|
-
* a custom value associated with this event. The names chosen SHOULD associate the custom event name with the custom
|
|
949
|
+
* Defines a custom event name. Maximum length is 64 characters. This key MUST be sent when the event type is 'ce'
|
|
950
|
+
* (custom event). This key MUST NOT be sent when the event type is any other value. A custom key-value pair MAY be used to
|
|
951
|
+
* transfer a custom value associated with this event. The names chosen SHOULD associate the custom event name with the custom
|
|
952
|
+
* key name.
|
|
941
953
|
*
|
|
942
954
|
* String
|
|
943
955
|
*
|
|
@@ -947,7 +959,7 @@ type CmcdEvent = CmcdRequest & {
|
|
|
947
959
|
/**
|
|
948
960
|
* Event
|
|
949
961
|
*
|
|
950
|
-
* This key MUST only be used in Event mode
|
|
962
|
+
* This key MUST only be used in Event mode. It MUST be present on all reports. The minimum recommended set of supported events
|
|
951
963
|
* are: `ps`, `e`, `t`, and `rr`.
|
|
952
964
|
*
|
|
953
965
|
* - `abs` - ad break start
|
|
@@ -988,8 +1000,8 @@ type CmcdEvent = CmcdRequest & {
|
|
|
988
1000
|
/**
|
|
989
1001
|
* Timestamp
|
|
990
1002
|
*
|
|
991
|
-
* The timestamp at which the associated event occurred
|
|
992
|
-
*
|
|
1003
|
+
* The timestamp at which the associated event occurred. The value is the number of milliseconds elapsed since the Unix Epoch
|
|
1004
|
+
* (January 1, 1970, at 00:00:00 UTC), excluding leap seconds. When the event is a request for a media object, the time SHOULD
|
|
993
1005
|
* reference when the request was first initiated.
|
|
994
1006
|
*
|
|
995
1007
|
* This key MUST be included with all Event reports.
|
|
@@ -1016,7 +1028,7 @@ type CmcdResponse = CmcdRequest & {
|
|
|
1016
1028
|
/**
|
|
1017
1029
|
* CMSD Dynamic Header
|
|
1018
1030
|
*
|
|
1019
|
-
*
|
|
1031
|
+
* A Base64 encoded copy of the CMSD data received on the CMSD-Dynamic response header. This key MUST only be reported on
|
|
1020
1032
|
* events of type `rr` (response received).
|
|
1021
1033
|
*
|
|
1022
1034
|
* String
|
|
@@ -1027,7 +1039,7 @@ type CmcdResponse = CmcdRequest & {
|
|
|
1027
1039
|
/**
|
|
1028
1040
|
* CMSD Static Header
|
|
1029
1041
|
*
|
|
1030
|
-
*
|
|
1042
|
+
* A Base64 encoded copy of the CMSD data received on the CMSD-Static response header. This key MUST only be reported on
|
|
1031
1043
|
* events of type `rr` (response received).
|
|
1032
1044
|
*
|
|
1033
1045
|
* String
|
|
@@ -1038,7 +1050,7 @@ type CmcdResponse = CmcdRequest & {
|
|
|
1038
1050
|
/**
|
|
1039
1051
|
* Response code
|
|
1040
1052
|
*
|
|
1041
|
-
* The response code received when requesting a media object. In a redirect scenario,
|
|
1053
|
+
* The response code received when requesting a media object. In a redirect scenario, the value is the final response code received.
|
|
1042
1054
|
* A value of 0 SHOULD be used to indicate that a response was not received.
|
|
1043
1055
|
*
|
|
1044
1056
|
* This key MUST only be reported on events of type `rr` (response received).
|
|
@@ -1051,7 +1063,7 @@ type CmcdResponse = CmcdRequest & {
|
|
|
1051
1063
|
/**
|
|
1052
1064
|
* SMRT-Data Header
|
|
1053
1065
|
*
|
|
1054
|
-
*
|
|
1066
|
+
* A Base64 encoded copy of the streaming media response tracing data received on the Request Tracing header. This key MUST
|
|
1055
1067
|
* only be reported on events of type `rr` (response received).
|
|
1056
1068
|
*
|
|
1057
1069
|
* String
|
|
@@ -1115,7 +1127,8 @@ type CmcdResponse = CmcdRequest & {
|
|
|
1115
1127
|
* This type is the intersection of {@link CmcdRequest}, {@link CmcdResponse},
|
|
1116
1128
|
* and {@link CmcdEvent}, combining all keys from all reporting modes.
|
|
1117
1129
|
*
|
|
1118
|
-
* @see {@link https://
|
|
1130
|
+
* @see {@link https://cta-wave.github.io/Resources/common-media-client-data--cta-5004-b.html | CTA-5004-B CMCD version 2}
|
|
1131
|
+
* @see {@link https://cdn.cta.tech/cta/media/media/resources/standards/pdfs/cta-5004-final.pdf|CMCD version 1}
|
|
1119
1132
|
*
|
|
1120
1133
|
* @public
|
|
1121
1134
|
*/
|
|
@@ -1198,7 +1211,7 @@ type CmcdFormatterOptions = {
|
|
|
1198
1211
|
/**
|
|
1199
1212
|
* Base URL (typically the manifest or current request URL) used to convert absolute `nor` values
|
|
1200
1213
|
* into paths relative to this base, per the CMCD specification. Values that are already relative
|
|
1201
|
-
* paths
|
|
1214
|
+
* paths remain unchanged. If omitted, `nor` values are emitted unchanged.
|
|
1202
1215
|
*/
|
|
1203
1216
|
baseUrl?: string;
|
|
1204
1217
|
};
|
|
@@ -1234,24 +1247,29 @@ type CmcdV1 = {
|
|
|
1234
1247
|
* Buffer length
|
|
1235
1248
|
*
|
|
1236
1249
|
* The buffer length associated with the media object being requested. This value MUST be rounded to the nearest 100 ms. This key SHOULD only be
|
|
1237
|
-
* sent with an object type of
|
|
1250
|
+
* sent with an object type of 'a', 'v' or 'av'.
|
|
1238
1251
|
*
|
|
1239
1252
|
* Integer milliseconds
|
|
1240
1253
|
*/
|
|
1241
1254
|
bl?: number;
|
|
1242
1255
|
/**
|
|
1243
|
-
*
|
|
1256
|
+
* Encoded bitrate
|
|
1244
1257
|
*
|
|
1245
|
-
*
|
|
1258
|
+
* The encoded bitrate of the audio or video object being requested. The player may not know this value precisely.
|
|
1259
|
+
* However, the player MAY estimate it based upon playlist/manifest declarations. If the playlist declares both peak
|
|
1260
|
+
* and average bitrate values, the peak value should be transmitted.
|
|
1261
|
+
*
|
|
1262
|
+
* Integer kbps
|
|
1246
1263
|
*/
|
|
1247
1264
|
br?: number;
|
|
1248
1265
|
/**
|
|
1249
|
-
* Measured
|
|
1266
|
+
* Measured throughput
|
|
1250
1267
|
*
|
|
1251
|
-
* The throughput between client and server, as measured by the client
|
|
1252
|
-
* SHOULD be the value that the client
|
|
1253
|
-
*
|
|
1254
|
-
*
|
|
1268
|
+
* The throughput between client and server, as measured by the client. Throughput MUST be rounded to the nearest
|
|
1269
|
+
* 100 kbps. This value, however derived, SHOULD be the value that the client uses for its next Adaptive Bitrate
|
|
1270
|
+
* switching decision. If the client is connected to multiple servers concurrently, it must report only the
|
|
1271
|
+
* throughput measured against the receiving server. If the client has multiple concurrent connections to the
|
|
1272
|
+
* server, this value is intended to communicate the client's aggregate throughput across all those connections.
|
|
1255
1273
|
*
|
|
1256
1274
|
* Integer kbps
|
|
1257
1275
|
*/
|
|
@@ -1259,22 +1277,22 @@ type CmcdV1 = {
|
|
|
1259
1277
|
/**
|
|
1260
1278
|
* Next object request
|
|
1261
1279
|
*
|
|
1262
|
-
* Relative path of the next object to be requested.
|
|
1263
|
-
* request.
|
|
1264
|
-
* pre-fetch
|
|
1280
|
+
* Relative path of the next object to be requested. The CDN can use this path to trigger pre-fetching. The path
|
|
1281
|
+
* MUST be relative to the current request. The string MUST be URL-encoded. The client SHOULD NOT depend upon any
|
|
1282
|
+
* pre-fetch action being taken. The key is only a request for such a pre-fetch.
|
|
1265
1283
|
*
|
|
1266
1284
|
* String
|
|
1267
1285
|
*
|
|
1268
1286
|
* @remarks
|
|
1269
|
-
* Values may be provided as absolute URLs for convenience
|
|
1270
|
-
*
|
|
1271
|
-
*
|
|
1287
|
+
* Values may be provided as absolute URLs for convenience. If `CmcdEncodeOptions.baseUrl` is set, same-origin URLs
|
|
1288
|
+
* are converted to paths relative to that base. Already-relative values are not converted. They are still
|
|
1289
|
+
* URL-encoded when emitted, as CMCD version 1 requires.
|
|
1272
1290
|
*/
|
|
1273
1291
|
nor?: string;
|
|
1274
1292
|
/**
|
|
1275
1293
|
* Next range request
|
|
1276
1294
|
*
|
|
1277
|
-
* @deprecated
|
|
1295
|
+
* @deprecated Removed in CMCD version 2. Version 2 sends the range as the 'r' parameter of 'nor'.
|
|
1278
1296
|
*
|
|
1279
1297
|
* String
|
|
1280
1298
|
*/
|
|
@@ -1285,14 +1303,14 @@ type CmcdV1 = {
|
|
|
1285
1303
|
* The highest bitrate rendition in the manifest or playlist that the client is allowed to play, given current codec, licensing and
|
|
1286
1304
|
* sizing constraints.
|
|
1287
1305
|
*
|
|
1288
|
-
* Integer
|
|
1306
|
+
* Integer kbps
|
|
1289
1307
|
*/
|
|
1290
1308
|
tb?: number;
|
|
1291
1309
|
};
|
|
1292
1310
|
//#endregion
|
|
1293
1311
|
//#region src/CmcdKey.d.ts
|
|
1294
1312
|
/**
|
|
1295
|
-
* A CMCD key
|
|
1313
|
+
* A CMCD key of any version.
|
|
1296
1314
|
*
|
|
1297
1315
|
* @public
|
|
1298
1316
|
*/
|
|
@@ -1384,7 +1402,7 @@ type CmcdHeaderMap = Record<CmcdHeaderField, CmcdKey[]>;
|
|
|
1384
1402
|
*/
|
|
1385
1403
|
type CmcdEncodeOptions = {
|
|
1386
1404
|
/**
|
|
1387
|
-
* The version of the CMCD specification to use. If
|
|
1405
|
+
* The version of the CMCD specification to use. If omitted, the version
|
|
1388
1406
|
* is inferred from the data's `v` key, defaulting to `CMCD_V2`.
|
|
1389
1407
|
*
|
|
1390
1408
|
* @defaultValue `CMCD_V2`
|
|
@@ -1414,9 +1432,9 @@ type CmcdEncodeOptions = {
|
|
|
1414
1432
|
filter?: (key: CmcdKey) => boolean;
|
|
1415
1433
|
/**
|
|
1416
1434
|
* Base URL (typically the manifest or current request URL) used to convert absolute `nor` values
|
|
1417
|
-
* into paths relative to this base, per the CMCD specification.
|
|
1418
|
-
*
|
|
1419
|
-
*
|
|
1435
|
+
* into paths relative to this base, per the CMCD specification. This option does not modify values
|
|
1436
|
+
* that are already relative paths, but CMCD version 1 still URL-encodes them on emission. If omitted,
|
|
1437
|
+
* `nor` values are emitted unchanged (subject to the version 1 URL-encoding rule).
|
|
1420
1438
|
*/
|
|
1421
1439
|
baseUrl?: string;
|
|
1422
1440
|
/**
|
|
@@ -1427,13 +1445,13 @@ type CmcdEncodeOptions = {
|
|
|
1427
1445
|
//#endregion
|
|
1428
1446
|
//#region src/appendCmcdHeaders.d.ts
|
|
1429
1447
|
/**
|
|
1430
|
-
* Append CMCD
|
|
1448
|
+
* Append CMCD header shards to a header object.
|
|
1431
1449
|
*
|
|
1432
1450
|
* @param headers - The headers to append to.
|
|
1433
1451
|
* @param cmcd - The CMCD object to append.
|
|
1434
|
-
* @param options -
|
|
1452
|
+
* @param options - Options for encoding.
|
|
1435
1453
|
*
|
|
1436
|
-
* @returns The headers with
|
|
1454
|
+
* @returns The headers with CMCD header shards appended.
|
|
1437
1455
|
*
|
|
1438
1456
|
* @public
|
|
1439
1457
|
*
|
|
@@ -1450,7 +1468,7 @@ declare function appendCmcdHeaders(headers: Record<string, string>, cmcd: Cmcd,
|
|
|
1450
1468
|
*
|
|
1451
1469
|
* @param url - The URL to append to.
|
|
1452
1470
|
* @param cmcd - The CMCD object to append.
|
|
1453
|
-
* @param options - Options for encoding
|
|
1471
|
+
* @param options - Options for encoding.
|
|
1454
1472
|
*
|
|
1455
1473
|
* @returns The URL with the CMCD query args appended.
|
|
1456
1474
|
*
|
|
@@ -1465,7 +1483,7 @@ declare function appendCmcdQuery(url: string, cmcd: Cmcd, options?: CmcdEncodeOp
|
|
|
1465
1483
|
//#endregion
|
|
1466
1484
|
//#region src/CMCD_DEFAULT_TIME_INTERVAL.d.ts
|
|
1467
1485
|
/**
|
|
1468
|
-
* The default time interval in seconds when using
|
|
1486
|
+
* The default time interval in seconds when using event mode
|
|
1469
1487
|
*
|
|
1470
1488
|
* @public
|
|
1471
1489
|
*/
|
|
@@ -1499,9 +1517,9 @@ type CmcdRequestKey = keyof CmcdRequest | "nrr";
|
|
|
1499
1517
|
/**
|
|
1500
1518
|
* The map of CMCD keys to their appropriate header shard.
|
|
1501
1519
|
*
|
|
1502
|
-
*
|
|
1503
|
-
*
|
|
1504
|
-
*
|
|
1520
|
+
* Event-only keys (e, ts, cen, h) and response-received keys (rc, ttfb,
|
|
1521
|
+
* ttlb, url, and others) are intentionally absent. They are transmitted
|
|
1522
|
+
* in the event-mode POST body, not HTTP headers.
|
|
1505
1523
|
*
|
|
1506
1524
|
* @public
|
|
1507
1525
|
*/
|
|
@@ -1541,25 +1559,26 @@ declare const CMCD_REQUEST_KEYS: readonly ["ab", "bg", "bl", "br", "bs", "bsa",
|
|
|
1541
1559
|
//#endregion
|
|
1542
1560
|
//#region src/CMCD_REQUEST_PROVENANCE.d.ts
|
|
1543
1561
|
/**
|
|
1544
|
-
* The `customData`
|
|
1545
|
-
*
|
|
1562
|
+
* The `customData` property where `CmcdReporter.createRequestReport()`
|
|
1563
|
+
* writes session provenance on every request it returns.
|
|
1546
1564
|
*
|
|
1547
|
-
* The value is a frozen `CmcdRequestProvenance` record
|
|
1548
|
-
* session that issued the request
|
|
1549
|
-
*
|
|
1550
|
-
*
|
|
1551
|
-
*
|
|
1552
|
-
*
|
|
1553
|
-
* Spread and `Object.assign`
|
|
1554
|
-
*
|
|
1555
|
-
*
|
|
1556
|
-
*
|
|
1557
|
-
*
|
|
1558
|
-
*
|
|
1559
|
-
*
|
|
1565
|
+
* The value is a frozen `CmcdRequestProvenance` record. `sid` names the
|
|
1566
|
+
* session that issued the request. `cid` is the content id at the time the
|
|
1567
|
+
* request was issued. `data` is the request's per-call data as an encoded
|
|
1568
|
+
* CMCD string. `CmcdReporter.recordResponseReceived()` reads the record to
|
|
1569
|
+
* attribute a late response to its session and to rebuild the request-time
|
|
1570
|
+
* report keys.
|
|
1571
|
+
* Spread and `Object.assign` copy the record into ordinary request clones.
|
|
1572
|
+
* `JSON.stringify` and structured clone drop symbol-keyed properties. Before
|
|
1573
|
+
* either operation, read the value and restore it afterward. JSON preserves
|
|
1574
|
+
* the record's fields. Attribution uses the `sid` value rather than object
|
|
1575
|
+
* identity, so a parsed plain-object copy attributes correctly. For a record
|
|
1576
|
+
* naming a `sid` the reporter does not retain, the reporter drops the
|
|
1577
|
+
* response rather than reattributing it.
|
|
1560
1578
|
*
|
|
1561
|
-
*
|
|
1562
|
-
* one bundle interoperate. The registry key is stable across
|
|
1579
|
+
* The symbol registry provides the symbol, so duplicated copies of this
|
|
1580
|
+
* library in one bundle interoperate. The registry key is stable across
|
|
1581
|
+
* versions.
|
|
1563
1582
|
*
|
|
1564
1583
|
* @public
|
|
1565
1584
|
*/
|
|
@@ -1567,7 +1586,7 @@ declare const CMCD_REQUEST_PROVENANCE: unique symbol;
|
|
|
1567
1586
|
//#endregion
|
|
1568
1587
|
//#region src/CMCD_RESPONSE_KEYS.d.ts
|
|
1569
1588
|
/**
|
|
1570
|
-
*
|
|
1589
|
+
* Response-only and timing keys for version 2.
|
|
1571
1590
|
*
|
|
1572
1591
|
* @public
|
|
1573
1592
|
*/
|
|
@@ -1585,8 +1604,8 @@ declare const CMCD_V1_KEYS: readonly ["bl", "br", "bs", "cid", "d", "dl", "mtp",
|
|
|
1585
1604
|
/**
|
|
1586
1605
|
* CMCD version 1 data.
|
|
1587
1606
|
*
|
|
1588
|
-
* Overrides keys whose types differ in version 1
|
|
1589
|
-
* are
|
|
1607
|
+
* Overrides keys whose types differ in version 1. For example, `bl` and
|
|
1608
|
+
* `br` are integers instead of inner lists.
|
|
1590
1609
|
*
|
|
1591
1610
|
* @public
|
|
1592
1611
|
*/
|
|
@@ -1607,7 +1626,7 @@ type CmcdV2Data = Omit<Cmcd, "v"> & {
|
|
|
1607
1626
|
/**
|
|
1608
1627
|
* A CMCD data object that is either version 1 or version 2.
|
|
1609
1628
|
*
|
|
1610
|
-
* The `v` property
|
|
1629
|
+
* The `v` property is the discriminator:
|
|
1611
1630
|
*
|
|
1612
1631
|
* - When `v` is `2`, the type narrows to {@link CmcdV2Data} with
|
|
1613
1632
|
* inner-list values and event/response keys.
|
|
@@ -1721,36 +1740,36 @@ type CmcdDataValidationResult = CmcdValidationResult & {
|
|
|
1721
1740
|
type CmcdDecodeOptions = {
|
|
1722
1741
|
/**
|
|
1723
1742
|
* When `true`, up-converts version 1 data to version 2 format by wrapping
|
|
1724
|
-
* scalar values in arrays for inner-list keys
|
|
1743
|
+
* scalar values in arrays for inner-list keys. Examples: `bl`, `br`, `mtp`.
|
|
1725
1744
|
*
|
|
1726
|
-
*
|
|
1727
|
-
*
|
|
1745
|
+
* The result has a consistent structure regardless of the source version.
|
|
1746
|
+
* This conversion corresponds to the down-conversion during encoding.
|
|
1728
1747
|
*
|
|
1729
1748
|
* @defaultValue false
|
|
1730
1749
|
*/
|
|
1731
1750
|
convertToLatest?: boolean;
|
|
1732
1751
|
/**
|
|
1733
|
-
* Controls how RFC 8941 token values
|
|
1734
|
-
*
|
|
1735
|
-
*
|
|
1736
|
-
*
|
|
1737
|
-
*
|
|
1738
|
-
*
|
|
1752
|
+
* Controls how the decoded data represents RFC 8941 token values. If
|
|
1753
|
+
* omitted, tokens decode to plain strings, which re-encoding cannot
|
|
1754
|
+
* distinguish from string values. `true` decodes tokens as registry
|
|
1755
|
+
* `Symbol`s and `false` as `SfToken` instances. Either preserved
|
|
1756
|
+
* representation re-encodes as a bare token, so a decode/encode round
|
|
1757
|
+
* trip reproduces the wire bytes.
|
|
1739
1758
|
*/
|
|
1740
1759
|
useSymbol?: boolean;
|
|
1741
1760
|
};
|
|
1742
1761
|
//#endregion
|
|
1743
1762
|
//#region src/CmcdTransformRequest.d.ts
|
|
1744
1763
|
/**
|
|
1745
|
-
* The media request
|
|
1764
|
+
* The media request passed to a report transform, as a read-only view.
|
|
1746
1765
|
*
|
|
1747
1766
|
* The request is context only. A transform reads it to decide what to do with
|
|
1748
|
-
* the report
|
|
1749
|
-
* be
|
|
1750
|
-
* every depth, so nested values cannot be written either.
|
|
1767
|
+
* the report. A transform must not mutate the request, which belongs to the
|
|
1768
|
+
* caller and may still be in use. Every member is `readonly`, and `customData`
|
|
1769
|
+
* is readonly at every depth, so nested values cannot be written either.
|
|
1751
1770
|
*
|
|
1752
1771
|
* By default `customData` values are `unknown` rather than `any`, because the
|
|
1753
|
-
* library cannot know the player's
|
|
1772
|
+
* library cannot know the player's fields. Narrow with a cast or bracket access
|
|
1754
1773
|
* to read player-specific fields:
|
|
1755
1774
|
*
|
|
1756
1775
|
* ```ts
|
|
@@ -1758,9 +1777,9 @@ type CmcdDecodeOptions = {
|
|
|
1758
1777
|
* request?.customData?.['requestType'] === 'segment' ? data : null
|
|
1759
1778
|
* ```
|
|
1760
1779
|
*
|
|
1761
|
-
* Supply `C` to describe the player's own `customData` instead and those
|
|
1762
|
-
* become typed dot access. Annotating one transform is enough: the
|
|
1763
|
-
* infers `C` for every other transform in the same configuration.
|
|
1780
|
+
* Supply `C` to describe the player's own `customData` instead, and those
|
|
1781
|
+
* reads become typed dot access. Annotating one transform is enough: the
|
|
1782
|
+
* reporter infers `C` for every other transform in the same configuration.
|
|
1764
1783
|
*
|
|
1765
1784
|
* ```ts
|
|
1766
1785
|
* type PlayerData = { requestType: string; };
|
|
@@ -1769,15 +1788,15 @@ type CmcdDecodeOptions = {
|
|
|
1769
1788
|
* request?.customData?.requestType === 'segment' ? data : null
|
|
1770
1789
|
* ```
|
|
1771
1790
|
*
|
|
1772
|
-
* `C`
|
|
1773
|
-
*
|
|
1791
|
+
* This type wraps `C` in {@link DeepReadonly}, so a nested `C` keeps both the
|
|
1792
|
+
* read-only guarantee and typed reads.
|
|
1774
1793
|
*
|
|
1775
|
-
* Two limits
|
|
1776
|
-
*
|
|
1777
|
-
*
|
|
1778
|
-
*
|
|
1794
|
+
* Two limits apply. A mutable body such as `FormData` or `URLSearchParams`
|
|
1795
|
+
* has mutating methods of its own that no type can block. JavaScript callers
|
|
1796
|
+
* get no enforcement at all. Both kinds of mutation are unsupported, and the
|
|
1797
|
+
* outgoing report may reflect them.
|
|
1779
1798
|
*
|
|
1780
|
-
* @typeParam C - The
|
|
1799
|
+
* @typeParam C - The type of the player's `customData`. Defaults to
|
|
1781
1800
|
* `Record<string, unknown>`.
|
|
1782
1801
|
*
|
|
1783
1802
|
* @public
|
|
@@ -1796,28 +1815,26 @@ type CmcdTransformRequest<C = Record<string, unknown>> = Readonly<Omit<HttpReque
|
|
|
1796
1815
|
//#endregion
|
|
1797
1816
|
//#region src/CmcdEventReportTransform.d.ts
|
|
1798
1817
|
/**
|
|
1799
|
-
* Transforms an event-mode CMCD report before
|
|
1800
|
-
* target.
|
|
1818
|
+
* Transforms an event-mode CMCD report before the reporter queues it for
|
|
1819
|
+
* its target.
|
|
1801
1820
|
*
|
|
1802
1821
|
* Return the data to continue, or `null` to cancel the report. The
|
|
1803
|
-
* `data` argument is a per-target copy, so mutating it
|
|
1804
|
-
*
|
|
1805
|
-
* other targets.
|
|
1822
|
+
* `data` argument is a per-target copy, so mutating it affects neither
|
|
1823
|
+
* the reporter's persistent data nor the reports for other targets.
|
|
1806
1824
|
*
|
|
1807
1825
|
* The `request` argument is the media request that triggered the event
|
|
1808
|
-
*
|
|
1826
|
+
* (for events recorded through
|
|
1809
1827
|
* {@link CmcdReporter.recordResponseReceived}), otherwise `undefined`.
|
|
1810
|
-
*
|
|
1811
|
-
*
|
|
1828
|
+
* The request is a read-only view for context only. A transform must
|
|
1829
|
+
* not mutate it. See {@link CmcdTransformRequest}.
|
|
1812
1830
|
*
|
|
1813
|
-
* The reporter
|
|
1814
|
-
*
|
|
1815
|
-
* overwritten.
|
|
1831
|
+
* The reporter rewrites `e` and `sid` and assigns `sn` and `msd` after this
|
|
1832
|
+
* function returns, so values written to those keys are overwritten.
|
|
1816
1833
|
*
|
|
1817
1834
|
* Must not throw. Exceptions propagate to the caller that recorded the
|
|
1818
|
-
* event
|
|
1835
|
+
* event. For time-interval events, that caller is the interval timer.
|
|
1819
1836
|
*
|
|
1820
|
-
* @typeParam C - The
|
|
1837
|
+
* @typeParam C - The type of the player's `customData` on the request.
|
|
1821
1838
|
* Defaults to `Record<string, unknown>`, whose values are
|
|
1822
1839
|
* `unknown` and read with bracket access.
|
|
1823
1840
|
*
|
|
@@ -1839,9 +1856,11 @@ type CmcdReportConfig = {
|
|
|
1839
1856
|
*/
|
|
1840
1857
|
version?: CmcdVersion;
|
|
1841
1858
|
/**
|
|
1842
|
-
* The list of CMCD keys to include in the report. If
|
|
1843
|
-
*
|
|
1844
|
-
*
|
|
1859
|
+
* The list of CMCD keys to include in the report. If omitted, no keys
|
|
1860
|
+
* are reported. In event mode, `e`, `ts`, and the key that CTA-5004-B
|
|
1861
|
+
* requires for the event type are reported even when this list omits
|
|
1862
|
+
* them. Examples of required keys: `sta` for a play state change, `ec`
|
|
1863
|
+
* for an error, `url` for a response received.
|
|
1845
1864
|
*
|
|
1846
1865
|
* @defaultValue `undefined`
|
|
1847
1866
|
*/
|
|
@@ -1852,33 +1871,33 @@ type CmcdReportConfig = {
|
|
|
1852
1871
|
/**
|
|
1853
1872
|
* Configuration for a CMCD event report.
|
|
1854
1873
|
*
|
|
1855
|
-
* @typeParam C - The
|
|
1874
|
+
* @typeParam C - The type of the player's `customData` on the request that
|
|
1856
1875
|
* triggered the event. Defaults to `Record<string, unknown>`.
|
|
1857
1876
|
*
|
|
1858
1877
|
* @public
|
|
1859
1878
|
*/
|
|
1860
1879
|
type CmcdEventReportConfig<C = Record<string, unknown>> = CmcdReportConfig & {
|
|
1861
1880
|
/**
|
|
1862
|
-
* The version of the CMCD protocol to use.
|
|
1863
|
-
* version 2
|
|
1881
|
+
* The version of the CMCD protocol to use. Event reporting
|
|
1882
|
+
* requires version 2.
|
|
1864
1883
|
*
|
|
1865
1884
|
* @defaultValue `CMCD_V2`
|
|
1866
1885
|
*/
|
|
1867
1886
|
version?: typeof CMCD_V2;
|
|
1868
1887
|
/**
|
|
1869
|
-
* The URL
|
|
1888
|
+
* The URL where the reporter sends CMCD event reports.
|
|
1870
1889
|
*/
|
|
1871
1890
|
url: string;
|
|
1872
1891
|
/**
|
|
1873
|
-
* The events to report. If no events
|
|
1874
|
-
* the event target
|
|
1892
|
+
* The events to report. If the caller provides no events,
|
|
1893
|
+
* the event target is effectively disabled.
|
|
1875
1894
|
*
|
|
1876
1895
|
* @defaultValue `undefined`
|
|
1877
1896
|
*/
|
|
1878
1897
|
events?: CmcdEventType[];
|
|
1879
1898
|
/**
|
|
1880
|
-
* When the time interval event is sent, the interval
|
|
1881
|
-
*
|
|
1899
|
+
* When the time interval event is sent, the interval in seconds at
|
|
1900
|
+
* which the reporter sends it.
|
|
1882
1901
|
*
|
|
1883
1902
|
* @defaultValue `CMCD_DEFAULT_TIME_INTERVAL`
|
|
1884
1903
|
*
|
|
@@ -1896,9 +1915,9 @@ type CmcdEventReportConfig<C = Record<string, unknown>> = CmcdReportConfig & {
|
|
|
1896
1915
|
* it is queued. Return the data to continue, or `null` to cancel
|
|
1897
1916
|
* the report for this target.
|
|
1898
1917
|
*
|
|
1899
|
-
*
|
|
1900
|
-
* each run their own transform
|
|
1901
|
-
* still
|
|
1918
|
+
* The transform is scoped to this target only. Targets that share a
|
|
1919
|
+
* collector URL each run their own transform. Other targets that
|
|
1920
|
+
* accept the event still receive a report cancelled by this transform.
|
|
1902
1921
|
*
|
|
1903
1922
|
* @defaultValue `undefined`
|
|
1904
1923
|
*
|
|
@@ -1942,29 +1961,29 @@ type CmcdHeaderValue = CmcdRequest | CmcdV1;
|
|
|
1942
1961
|
//#endregion
|
|
1943
1962
|
//#region src/CmcdRecordedReportMode.d.ts
|
|
1944
1963
|
/**
|
|
1945
|
-
* CMCD query reporting mode
|
|
1964
|
+
* CMCD query reporting mode: CMCD data transmitted as a `CMCD=` URL
|
|
1946
1965
|
* query parameter.
|
|
1947
1966
|
*
|
|
1948
1967
|
* @public
|
|
1949
1968
|
*/
|
|
1950
1969
|
declare const CMCD_RECORDED_REPORT_MODE_QUERY: "query";
|
|
1951
1970
|
/**
|
|
1952
|
-
* CMCD header reporting mode
|
|
1971
|
+
* CMCD header reporting mode: CMCD data transmitted as `CMCD-*` HTTP
|
|
1953
1972
|
* headers.
|
|
1954
1973
|
*
|
|
1955
1974
|
* @public
|
|
1956
1975
|
*/
|
|
1957
1976
|
declare const CMCD_RECORDED_REPORT_MODE_HEADER: "header";
|
|
1958
1977
|
/**
|
|
1959
|
-
* CMCD event reporting mode
|
|
1978
|
+
* CMCD event reporting mode: CMCD data transmitted as a POST body to an
|
|
1960
1979
|
* event-target URL.
|
|
1961
1980
|
*
|
|
1962
1981
|
* @public
|
|
1963
1982
|
*/
|
|
1964
1983
|
declare const CMCD_RECORDED_REPORT_MODE_EVENT: "event";
|
|
1965
1984
|
/**
|
|
1966
|
-
* Reporting mode
|
|
1967
|
-
*
|
|
1985
|
+
* Reporting mode in which `CmcdReportRecorder` observed a captured
|
|
1986
|
+
* report.
|
|
1968
1987
|
*
|
|
1969
1988
|
* @enum
|
|
1970
1989
|
*
|
|
@@ -2001,7 +2020,7 @@ declare const CMCD_RECORDED_REQUEST_TYPE_SEGMENT: "segment";
|
|
|
2001
2020
|
*/
|
|
2002
2021
|
declare const CMCD_RECORDED_REQUEST_TYPE_EVENT: "event";
|
|
2003
2022
|
/**
|
|
2004
|
-
*
|
|
2023
|
+
* Default classification for requests the recorder did not recognize
|
|
2005
2024
|
* as manifest, segment, or event.
|
|
2006
2025
|
*
|
|
2007
2026
|
* @public
|
|
@@ -2035,9 +2054,9 @@ type CmcdRecordedRequestType = ValueOf<typeof CmcdRecordedRequestType>;
|
|
|
2035
2054
|
*/
|
|
2036
2055
|
type CmcdRecordedReport = {
|
|
2037
2056
|
/**
|
|
2038
|
-
* The captured request that
|
|
2057
|
+
* The captured request that contained the CMCD report, normalized to
|
|
2039
2058
|
* {@link @svta/cml-utils!HttpRequest | HttpRequest}. Headers are
|
|
2040
|
-
* lowercase-keyed
|
|
2059
|
+
* lowercase-keyed. Bodies are eagerly read as strings.
|
|
2041
2060
|
*/
|
|
2042
2061
|
readonly request: HttpRequest;
|
|
2043
2062
|
/**
|
|
@@ -2045,8 +2064,8 @@ type CmcdRecordedReport = {
|
|
|
2045
2064
|
*/
|
|
2046
2065
|
readonly type: CmcdRecordedRequestType;
|
|
2047
2066
|
/**
|
|
2048
|
-
* Reporting mode under which the CMCD data was
|
|
2049
|
-
* `'query'` for `CMCD=` URL parameter, `'header'` for `
|
|
2067
|
+
* Reporting mode under which the CMCD data was transmitted:
|
|
2068
|
+
* `'query'` for `CMCD=` URL parameter, `'header'` for `CMCD-*`
|
|
2050
2069
|
* HTTP headers, `'event'` for an event-target POST body.
|
|
2051
2070
|
*/
|
|
2052
2071
|
readonly reportingMode: CmcdRecordedReportMode;
|
|
@@ -2059,12 +2078,12 @@ type CmcdRecordedReport = {
|
|
|
2059
2078
|
//#region src/CmcdTransportAdapter.d.ts
|
|
2060
2079
|
/**
|
|
2061
2080
|
* Callback the recorder supplies to a transport adapter. The adapter
|
|
2062
|
-
* calls
|
|
2081
|
+
* calls it once per intercepted request, with the request normalized
|
|
2063
2082
|
* to {@link @svta/cml-utils!HttpRequest | HttpRequest}.
|
|
2064
2083
|
*
|
|
2065
|
-
* If the callback returns a `Response`, the adapter must
|
|
2066
|
-
*
|
|
2067
|
-
*
|
|
2084
|
+
* If the callback returns a `Response`, the adapter must bypass the
|
|
2085
|
+
* transport. It must complete the request with that response (used for
|
|
2086
|
+
* event-target POST stubbing).
|
|
2068
2087
|
*
|
|
2069
2088
|
* If the callback returns `undefined`, the adapter forwards the request
|
|
2070
2089
|
* to the original transport unchanged.
|
|
@@ -2074,15 +2093,15 @@ type CmcdRecordedReport = {
|
|
|
2074
2093
|
type CmcdRequestDeliver = (request: HttpRequest) => Response | undefined;
|
|
2075
2094
|
/**
|
|
2076
2095
|
* Pluggable transport-interception contract for `CmcdReportRecorder`.
|
|
2077
|
-
* The default implementations
|
|
2096
|
+
* The default implementations, `createXhrTransport` and `createFetchTransport`,
|
|
2078
2097
|
* patch global `XMLHttpRequest` and `fetch`. Custom adapters can wrap
|
|
2079
|
-
* other transports
|
|
2098
|
+
* other transports, for example `undici` or a player-internal HTTP client.
|
|
2080
2099
|
*
|
|
2081
2100
|
* @public
|
|
2082
2101
|
*/
|
|
2083
2102
|
type CmcdTransportAdapter = {
|
|
2084
2103
|
/**
|
|
2085
|
-
* Install the transport
|
|
2104
|
+
* Install interception on the transport. Called once per
|
|
2086
2105
|
* recorder `attach()`. The adapter must normalize each outgoing
|
|
2087
2106
|
* request to `HttpRequest` (reading the body to a synchronous value
|
|
2088
2107
|
* if necessary) and invoke `deliver`. Returns a detach function that
|
|
@@ -2099,27 +2118,27 @@ type CmcdTransportAdapter = {
|
|
|
2099
2118
|
*/
|
|
2100
2119
|
type CmcdReportRecorderOptions = {
|
|
2101
2120
|
/**
|
|
2102
|
-
* URLs whose POST requests
|
|
2103
|
-
* synthetic 204 response
|
|
2104
|
-
*
|
|
2121
|
+
* URLs whose POST requests the recorder intercepts and answers with a
|
|
2122
|
+
* synthetic 204 response instead of sending them to the network. A
|
|
2123
|
+
* request matches if its URL starts with any entry.
|
|
2105
2124
|
*
|
|
2106
|
-
* Use this to verify CMCD event-mode reports without
|
|
2125
|
+
* Use this option to verify CMCD event-mode reports without real
|
|
2107
2126
|
* network calls to placeholder endpoints.
|
|
2108
2127
|
*/
|
|
2109
2128
|
eventTargetUrls?: readonly string[];
|
|
2110
2129
|
/**
|
|
2111
|
-
* Override the default
|
|
2130
|
+
* Override the default transport adapters. Defaults to
|
|
2112
2131
|
* `[createXhrTransport(), createFetchTransport()]`, which patches
|
|
2113
2132
|
* `XMLHttpRequest` and `fetch` on the current realm.
|
|
2114
2133
|
*
|
|
2115
|
-
*
|
|
2116
|
-
*
|
|
2134
|
+
* If the player under test uses a non-standard transport, for example
|
|
2135
|
+
* a custom HTTP client, supply this option.
|
|
2117
2136
|
*/
|
|
2118
2137
|
transports?: readonly CmcdTransportAdapter[];
|
|
2119
2138
|
/**
|
|
2120
2139
|
* Default timeout (in milliseconds) applied to every `waitFor*`
|
|
2121
|
-
* call on this recorder.
|
|
2122
|
-
*
|
|
2140
|
+
* call on this recorder. Each call can still pass an explicit
|
|
2141
|
+
* timeout to override this default.
|
|
2123
2142
|
*
|
|
2124
2143
|
* @defaultValue `15000`
|
|
2125
2144
|
*/
|
|
@@ -2128,13 +2147,13 @@ type CmcdReportRecorderOptions = {
|
|
|
2128
2147
|
* Called once for each captured CMCD report, immediately after it
|
|
2129
2148
|
* is appended to the buffer and before any pending `waitFor*`
|
|
2130
2149
|
* promises resolve. Use for live UI inspection in test harness
|
|
2131
|
-
* pages.
|
|
2132
|
-
* callback to a
|
|
2150
|
+
* pages. `detach()` clears the callback. To resume notification,
|
|
2151
|
+
* pass a new callback to a later `attach()`.
|
|
2133
2152
|
*
|
|
2134
2153
|
* The callback receives the same {@link CmcdRecordedReport}
|
|
2135
|
-
*
|
|
2136
|
-
* `report.reportingMode` inside the
|
|
2137
|
-
*
|
|
2154
|
+
* type that `getReports()` returns. If you only need a subset,
|
|
2155
|
+
* filter by `report.type` or `report.reportingMode` inside the
|
|
2156
|
+
* callback.
|
|
2138
2157
|
*
|
|
2139
2158
|
* @example
|
|
2140
2159
|
* {@includeCode ../test/CmcdReportRecorder.test.ts#example-on-report}
|
|
@@ -2157,8 +2176,8 @@ type CmcdReportRecorderWaitOptions = {
|
|
|
2157
2176
|
*/
|
|
2158
2177
|
count?: number;
|
|
2159
2178
|
/**
|
|
2160
|
-
* Maximum time to wait (in milliseconds) before rejecting.
|
|
2161
|
-
*
|
|
2179
|
+
* Maximum time to wait (in milliseconds) before rejecting. The
|
|
2180
|
+
* default is the recorder's `waitTimeout` attach option (15000 ms if
|
|
2162
2181
|
* unset).
|
|
2163
2182
|
*/
|
|
2164
2183
|
timeout?: number;
|
|
@@ -2166,10 +2185,10 @@ type CmcdReportRecorderWaitOptions = {
|
|
|
2166
2185
|
//#endregion
|
|
2167
2186
|
//#region src/CmcdReportRecorder.d.ts
|
|
2168
2187
|
/**
|
|
2169
|
-
* Test helper that records CMCD
|
|
2170
|
-
* transports for
|
|
2171
|
-
*
|
|
2172
|
-
* tests are identical regardless of which transport the player uses.
|
|
2188
|
+
* Test helper that records CMCD reports from the XHR and fetch
|
|
2189
|
+
* transports for assertions in e2e tests. The recorder normalizes each
|
|
2190
|
+
* captured request to {@link @svta/cml-utils!HttpRequest | HttpRequest},
|
|
2191
|
+
* so tests are identical regardless of which transport the player uses.
|
|
2173
2192
|
*
|
|
2174
2193
|
* @example
|
|
2175
2194
|
* {@includeCode ../test/CmcdReportRecorder.test.ts#example}
|
|
@@ -2179,11 +2198,11 @@ type CmcdReportRecorderWaitOptions = {
|
|
|
2179
2198
|
declare class CmcdReportRecorder {
|
|
2180
2199
|
#private;
|
|
2181
2200
|
/**
|
|
2182
|
-
* Install transport patches and
|
|
2183
|
-
*
|
|
2184
|
-
*
|
|
2185
|
-
*
|
|
2186
|
-
*
|
|
2201
|
+
* Install transport patches and start recording CMCD reports.
|
|
2202
|
+
* If the recorder is already attached, this call does nothing. The
|
|
2203
|
+
* recorder keeps the previous options and silently ignores the new
|
|
2204
|
+
* `options` argument. To re-attach with different options, call
|
|
2205
|
+
* `detach()` first.
|
|
2187
2206
|
*
|
|
2188
2207
|
* @public
|
|
2189
2208
|
*/
|
|
@@ -2202,15 +2221,15 @@ declare class CmcdReportRecorder {
|
|
|
2202
2221
|
*/
|
|
2203
2222
|
clear(): void;
|
|
2204
2223
|
/**
|
|
2205
|
-
* Return a
|
|
2224
|
+
* Return a copy of all recorded reports.
|
|
2206
2225
|
*
|
|
2207
2226
|
* @public
|
|
2208
2227
|
*/
|
|
2209
2228
|
getReports(): CmcdRecordedReport[];
|
|
2210
2229
|
/**
|
|
2211
2230
|
* Wait until at least `count` reports of any type are recorded.
|
|
2212
|
-
* Resolves with all matching reports
|
|
2213
|
-
* on timeout. `count` defaults to 1
|
|
2231
|
+
* Resolves with all matching reports. Rejects with a diagnostic error
|
|
2232
|
+
* on timeout. `count` defaults to 1. `timeout` defaults to the
|
|
2214
2233
|
* recorder's `waitTimeout` option (default 15000 ms).
|
|
2215
2234
|
*
|
|
2216
2235
|
* @public
|
|
@@ -2218,8 +2237,8 @@ declare class CmcdReportRecorder {
|
|
|
2218
2237
|
waitForReports(options?: CmcdReportRecorderWaitOptions): Promise<CmcdRecordedReport[]>;
|
|
2219
2238
|
/**
|
|
2220
2239
|
* Wait until at least `count` manifest reports are recorded.
|
|
2221
|
-
* Resolves with all matching reports
|
|
2222
|
-
* on timeout. `count` defaults to 1
|
|
2240
|
+
* Resolves with all matching reports. Rejects with a diagnostic error
|
|
2241
|
+
* on timeout. `count` defaults to 1. `timeout` defaults to the
|
|
2223
2242
|
* recorder's `waitTimeout` option (default 15000 ms).
|
|
2224
2243
|
*
|
|
2225
2244
|
* @public
|
|
@@ -2227,8 +2246,8 @@ declare class CmcdReportRecorder {
|
|
|
2227
2246
|
waitForManifest(options?: CmcdReportRecorderWaitOptions): Promise<CmcdRecordedReport[]>;
|
|
2228
2247
|
/**
|
|
2229
2248
|
* Wait until at least `count` segment reports are recorded.
|
|
2230
|
-
* Resolves with all matching reports
|
|
2231
|
-
* on timeout. `count` defaults to 1
|
|
2249
|
+
* Resolves with all matching reports. Rejects with a diagnostic error
|
|
2250
|
+
* on timeout. `count` defaults to 1. `timeout` defaults to the
|
|
2232
2251
|
* recorder's `waitTimeout` option (default 15000 ms).
|
|
2233
2252
|
*
|
|
2234
2253
|
* @public
|
|
@@ -2236,8 +2255,8 @@ declare class CmcdReportRecorder {
|
|
|
2236
2255
|
waitForSegments(options?: CmcdReportRecorderWaitOptions): Promise<CmcdRecordedReport[]>;
|
|
2237
2256
|
/**
|
|
2238
2257
|
* Wait until at least `count` event-mode reports are recorded.
|
|
2239
|
-
* Resolves with all matching reports
|
|
2240
|
-
* on timeout. `count` defaults to 1
|
|
2258
|
+
* Resolves with all matching reports. Rejects with a diagnostic error
|
|
2259
|
+
* on timeout. `count` defaults to 1. `timeout` defaults to the
|
|
2241
2260
|
* recorder's `waitTimeout` option (default 15000 ms).
|
|
2242
2261
|
*
|
|
2243
2262
|
* @public
|
|
@@ -2255,15 +2274,15 @@ declare class CmcdReportRecorder {
|
|
|
2255
2274
|
* mutating it in place never affects the reporter's persistent data.
|
|
2256
2275
|
* The `request` argument is the request passed to
|
|
2257
2276
|
* `createRequestReport()`, as a read-only view. It is context only and
|
|
2258
|
-
* must not be mutated
|
|
2277
|
+
* must not be mutated. See {@link CmcdTransformRequest}.
|
|
2259
2278
|
*
|
|
2260
|
-
* The reporter
|
|
2279
|
+
* The reporter rewrites `sid` and assigns `sn` and `msd` after this
|
|
2261
2280
|
* function returns, so values written to those keys are overwritten.
|
|
2262
2281
|
*
|
|
2263
2282
|
* Must not throw. Exceptions propagate to the `createRequestReport()`
|
|
2264
2283
|
* caller.
|
|
2265
2284
|
*
|
|
2266
|
-
* @typeParam C - The
|
|
2285
|
+
* @typeParam C - The type of the player's `customData` on the request.
|
|
2267
2286
|
* Defaults to `Record<string, unknown>`, whose values are
|
|
2268
2287
|
* `unknown` and read with bracket access.
|
|
2269
2288
|
*
|
|
@@ -2324,7 +2343,7 @@ type CmcdTransmissionMode = ValueOf<typeof CmcdTransmissionMode>;
|
|
|
2324
2343
|
/**
|
|
2325
2344
|
* Configuration for a CMCD request report.
|
|
2326
2345
|
*
|
|
2327
|
-
* @typeParam C - The
|
|
2346
|
+
* @typeParam C - The type of the player's `customData` on the requests
|
|
2328
2347
|
* passed to {@link CmcdReporter.createRequestReport}.
|
|
2329
2348
|
* Defaults to `Record<string, unknown>`.
|
|
2330
2349
|
*
|
|
@@ -2338,12 +2357,12 @@ type CmcdRequestReportConfig<C = Record<string, unknown>> = CmcdReportConfig & {
|
|
|
2338
2357
|
*/
|
|
2339
2358
|
transmissionMode?: CmcdTransmissionMode;
|
|
2340
2359
|
/**
|
|
2341
|
-
* A map of CMCD header fields to the custom keys
|
|
2342
|
-
*
|
|
2360
|
+
* A map of CMCD header fields to the custom keys to emit in them.
|
|
2361
|
+
* Applies when the transmission mode is
|
|
2343
2362
|
* `CmcdTransmissionMode.HEADERS`. Custom keys not listed in any
|
|
2344
2363
|
* shard are emitted in the `CMCD-Request` header. Standard keys
|
|
2345
2364
|
* have fixed shards per the CMCD specification and cannot be
|
|
2346
|
-
*
|
|
2365
|
+
* moved. Has no effect in query transmission mode or on event
|
|
2347
2366
|
* reports.
|
|
2348
2367
|
*
|
|
2349
2368
|
* @defaultValue `undefined`
|
|
@@ -2370,16 +2389,16 @@ type CmcdRequestReportConfig<C = Record<string, unknown>> = CmcdReportConfig & {
|
|
|
2370
2389
|
/**
|
|
2371
2390
|
* Configuration for a CMCD reporting component.
|
|
2372
2391
|
*
|
|
2373
|
-
* @typeParam C - The
|
|
2374
|
-
* reporter
|
|
2375
|
-
*
|
|
2392
|
+
* @typeParam C - The type of the player's `customData` on the requests this
|
|
2393
|
+
* reporter receives. If one `transform` is annotated, the rest
|
|
2394
|
+
* of the configuration infers the type. Defaults to
|
|
2376
2395
|
* `Record<string, unknown>`.
|
|
2377
2396
|
*
|
|
2378
2397
|
* @public
|
|
2379
2398
|
*/
|
|
2380
2399
|
type CmcdReporterConfig<C = Record<string, unknown>> = CmcdRequestReportConfig<C> & {
|
|
2381
2400
|
/**
|
|
2382
|
-
* The session ID. If
|
|
2401
|
+
* The session ID. If omitted, the reporter generates a new random session ID.
|
|
2383
2402
|
*
|
|
2384
2403
|
* @defaultValue `undefined`
|
|
2385
2404
|
*/
|
|
@@ -2391,7 +2410,7 @@ type CmcdReporterConfig<C = Record<string, unknown>> = CmcdRequestReportConfig<C
|
|
|
2391
2410
|
*/
|
|
2392
2411
|
cid?: string;
|
|
2393
2412
|
/**
|
|
2394
|
-
* The event configurations. If
|
|
2413
|
+
* The event configurations. If omitted, no events are reported.
|
|
2395
2414
|
*
|
|
2396
2415
|
* @defaultValue `undefined`
|
|
2397
2416
|
*/
|
|
@@ -2400,10 +2419,11 @@ type CmcdReporterConfig<C = Record<string, unknown>> = CmcdRequestReportConfig<C
|
|
|
2400
2419
|
* The number of ended sessions the reporter retains state for, in
|
|
2401
2420
|
* addition to the current one. Retained sessions let a response that
|
|
2402
2421
|
* completes after a `sid` change report under the session that issued
|
|
2403
|
-
* its request
|
|
2404
|
-
* `0` retains nothing, so stale responses are
|
|
2405
|
-
* evicts, which also retains every session's
|
|
2406
|
-
* Numbers are floored
|
|
2422
|
+
* its request. The report uses that session's data snapshot and
|
|
2423
|
+
* sequence numbers. `0` retains nothing, so stale responses are
|
|
2424
|
+
* dropped. `Infinity` never evicts, which also retains every session's
|
|
2425
|
+
* unsent report queues. Numbers are floored. Every other input uses
|
|
2426
|
+
* the default.
|
|
2407
2427
|
*
|
|
2408
2428
|
* @defaultValue 2
|
|
2409
2429
|
*/
|
|
@@ -2415,11 +2435,11 @@ type CmcdReporterConfig<C = Record<string, unknown>> = CmcdRequestReportConfig<C
|
|
|
2415
2435
|
* The `customData` a {@link CmcdReporter} method accepts, for a reporter typed
|
|
2416
2436
|
* `C`.
|
|
2417
2437
|
*
|
|
2418
|
-
* A reporter
|
|
2419
|
-
*
|
|
2420
|
-
*
|
|
2421
|
-
*
|
|
2422
|
-
*
|
|
2438
|
+
* A reporter with the default `C` constrains nothing, so requests with any
|
|
2439
|
+
* `customData` are accepted exactly as before `C` existed. A reporter with a
|
|
2440
|
+
* concrete `C` requires the request to satisfy it. The reporter's transforms
|
|
2441
|
+
* read `customData` as `C` and would otherwise receive a value their type
|
|
2442
|
+
* does not describe.
|
|
2423
2443
|
*
|
|
2424
2444
|
* @typeParam C - The reporter's `customData` type.
|
|
2425
2445
|
*
|
|
@@ -2429,33 +2449,34 @@ type CmcdReporterCustomData<C> = Record<string, unknown> extends C ? any : C;
|
|
|
2429
2449
|
//#endregion
|
|
2430
2450
|
//#region src/CmcdRequestProvenance.d.ts
|
|
2431
2451
|
/**
|
|
2432
|
-
* The session-provenance record `CmcdReporter.createRequestReport()`
|
|
2433
|
-
*
|
|
2452
|
+
* The session-provenance record `CmcdReporter.createRequestReport()` writes
|
|
2453
|
+
* to `customData` under `CMCD_REQUEST_PROVENANCE`.
|
|
2434
2454
|
*
|
|
2435
|
-
* `sid` names the session that issued the request
|
|
2436
|
-
*
|
|
2437
|
-
* reporter's retained sessions by value, never by object identity
|
|
2438
|
-
* copy
|
|
2439
|
-
*
|
|
2440
|
-
* CTA-5004-B expects to be unique per playback session
|
|
2441
|
-
* replaces the retained
|
|
2442
|
-
*
|
|
2455
|
+
* `sid` names the session that issued the request.
|
|
2456
|
+
* `CmcdReporter.recordResponseReceived()` matches `sid` against the
|
|
2457
|
+
* reporter's retained sessions by value, never by object identity. A record
|
|
2458
|
+
* copy restored from JSON attributes the response to the same
|
|
2459
|
+
* session. Session identity depends on the caller's own `sid` values, which
|
|
2460
|
+
* CTA-5004-B expects to be unique per playback session. Reusing a `sid`
|
|
2461
|
+
* replaces the retained session with that `sid`. The reporter then
|
|
2462
|
+
* attributes late responses of the replaced session to the replacement.
|
|
2443
2463
|
*
|
|
2444
|
-
* `cid` is the content id
|
|
2445
|
-
* `RESPONSE_RECEIVED` event reports
|
|
2446
|
-
* `cid
|
|
2447
|
-
*
|
|
2464
|
+
* `cid` is the content id at the time the reporter created the record. A
|
|
2465
|
+
* `RESPONSE_RECEIVED` event reports this `cid` instead of the session's
|
|
2466
|
+
* current `cid`. A response that completes after a content change
|
|
2467
|
+
* keeps the content id of its request.
|
|
2448
2468
|
*
|
|
2449
2469
|
* `data` is the per-call data the request was created with, encoded as a
|
|
2450
2470
|
* CMCD string. The reporter decodes it to rebuild the request-time report
|
|
2451
|
-
* keys for a `RESPONSE_RECEIVED` event
|
|
2452
|
-
*
|
|
2453
|
-
* request `transform` and key filter run
|
|
2454
|
-
* reporter does not decorate.
|
|
2471
|
+
* keys for a `RESPONSE_RECEIVED` event. Any copy of the record
|
|
2472
|
+
* contains the caller's inputs. The reporter captures `data` before the
|
|
2473
|
+
* request `transform` and key filter run. `data` is also present
|
|
2474
|
+
* on requests the reporter does not decorate.
|
|
2455
2475
|
*
|
|
2456
|
-
* The reporter freezes every record it
|
|
2457
|
-
* a hand-built request may
|
|
2458
|
-
*
|
|
2476
|
+
* The reporter freezes every record it creates. The record is constructible:
|
|
2477
|
+
* a hand-built request may include `{ sid }` to attribute the request to
|
|
2478
|
+
* that session. The reporter drops the response when the record names a
|
|
2479
|
+
* `sid` it does not retain.
|
|
2459
2480
|
*
|
|
2460
2481
|
* @public
|
|
2461
2482
|
*/
|
|
@@ -2469,9 +2490,9 @@ type CmcdRequestProvenance = {
|
|
|
2469
2490
|
/**
|
|
2470
2491
|
* A report of a CMCD request.
|
|
2471
2492
|
*
|
|
2472
|
-
* The provenance member is optional so
|
|
2473
|
-
*
|
|
2474
|
-
* `CmcdReporter.createRequestReport()`
|
|
2493
|
+
* The provenance member is optional so callers that build or mock request
|
|
2494
|
+
* reports can construct the type. Every request returned by
|
|
2495
|
+
* `CmcdReporter.createRequestReport()` includes the member.
|
|
2475
2496
|
*
|
|
2476
2497
|
* @public
|
|
2477
2498
|
*/
|
|
@@ -2487,12 +2508,12 @@ type CmcdRequestReport<D = unknown> = HttpRequest & {
|
|
|
2487
2508
|
/**
|
|
2488
2509
|
* The CMCD reporter.
|
|
2489
2510
|
*
|
|
2490
|
-
* `C` describes the player's own `customData`, which the reporter passes
|
|
2491
|
-
*
|
|
2492
|
-
*
|
|
2493
|
-
*
|
|
2511
|
+
* `C` describes the player's own `customData`, which the reporter passes to
|
|
2512
|
+
* each configured `transform`. TypeScript infers `C` from the configuration,
|
|
2513
|
+
* so an annotation on one `transform` types the request in every other
|
|
2514
|
+
* `transform`. The default leaves `customData` values `unknown`.
|
|
2494
2515
|
*
|
|
2495
|
-
* @typeParam C - The
|
|
2516
|
+
* @typeParam C - The type of the player's `customData`. Defaults to
|
|
2496
2517
|
* `Record<string, unknown>`.
|
|
2497
2518
|
*
|
|
2498
2519
|
* @see {@link https://cta-wave.github.io/Resources/common-media-client-data--cta-5004-b.html#reporting-modes-when-we-send-data | CTA-5004-B Reporting Modes}
|
|
@@ -2503,18 +2524,18 @@ declare class CmcdReporter<C = Record<string, unknown>> {
|
|
|
2503
2524
|
private timeOrigin;
|
|
2504
2525
|
private config;
|
|
2505
2526
|
/**
|
|
2506
|
-
* Retained sessions keyed by `sid`, insertion
|
|
2507
|
-
* current session last.
|
|
2508
|
-
*
|
|
2509
|
-
*
|
|
2510
|
-
*
|
|
2527
|
+
* Retained sessions keyed by `sid`, in insertion order: oldest first,
|
|
2528
|
+
* current session last. `config.sessionRetention` limits the ended-session
|
|
2529
|
+
* count. CTA-5004-B expects a `sid` to be unique per playback session. A
|
|
2530
|
+
* reused `sid` replaces the earlier session with that `sid` at the newest
|
|
2531
|
+
* position (see `startSession()`).
|
|
2511
2532
|
*/
|
|
2512
2533
|
private sessions;
|
|
2513
2534
|
private session;
|
|
2514
2535
|
/**
|
|
2515
|
-
*
|
|
2516
|
-
* changes (their callbacks report into whichever session is
|
|
2517
|
-
* fire
|
|
2536
|
+
* Active time-interval timers by target config. Timers continue across
|
|
2537
|
+
* session changes (their callbacks report into whichever session is
|
|
2538
|
+
* current when they fire), so the reporter owns them, not the session.
|
|
2518
2539
|
*/
|
|
2519
2540
|
private intervals;
|
|
2520
2541
|
private started;
|
|
@@ -2523,7 +2544,7 @@ declare class CmcdReporter<C = Record<string, unknown>> {
|
|
|
2523
2544
|
* Creates a new CMCD reporter.
|
|
2524
2545
|
*
|
|
2525
2546
|
* @param config - The configuration for the CMCD reporter.
|
|
2526
|
-
* @param requester - The function
|
|
2547
|
+
* @param requester - The function that sends the request.
|
|
2527
2548
|
* The default is a simple wrapper around the
|
|
2528
2549
|
* native `fetch` API.
|
|
2529
2550
|
*/
|
|
@@ -2531,170 +2552,169 @@ declare class CmcdReporter<C = Record<string, unknown>> {
|
|
|
2531
2552
|
status: number;
|
|
2532
2553
|
}>);
|
|
2533
2554
|
/**
|
|
2534
|
-
* Creates the state for a new session:
|
|
2535
|
-
*
|
|
2555
|
+
* Creates the state for a new session: initial counters, flags, queues, and
|
|
2556
|
+
* deduplication baseline for every configured target.
|
|
2536
2557
|
*/
|
|
2537
2558
|
private createSession;
|
|
2538
2559
|
/**
|
|
2539
|
-
* Starts the CMCD reporter.
|
|
2560
|
+
* Starts the CMCD reporter. The player calls this method when it enables the
|
|
2561
|
+
* reporter.
|
|
2540
2562
|
*
|
|
2541
|
-
*
|
|
2542
|
-
* before the first interval elapses.
|
|
2543
|
-
*
|
|
2563
|
+
* This method fires an initial time-interval event immediately (synchronously),
|
|
2564
|
+
* before the first interval elapses. Populate the CMCD data (sid, cid, and
|
|
2565
|
+
* others) before calling start().
|
|
2544
2566
|
*/
|
|
2545
2567
|
start(): void;
|
|
2546
2568
|
/**
|
|
2547
|
-
*
|
|
2548
|
-
*
|
|
2549
|
-
* whichever session is current when
|
|
2569
|
+
* Starts the time-interval timer for an event target when its config
|
|
2570
|
+
* requires one. Returns whether a timer started. The callback reports into
|
|
2571
|
+
* whichever session is current when the timer fires.
|
|
2550
2572
|
*/
|
|
2551
2573
|
private armInterval;
|
|
2552
2574
|
/**
|
|
2553
|
-
* Stops the CMCD reporter.
|
|
2575
|
+
* Stops the CMCD reporter. The player calls this method when it disables the
|
|
2576
|
+
* reporter.
|
|
2554
2577
|
*
|
|
2555
2578
|
* @param flush - Whether to flush the event targets.
|
|
2556
2579
|
*/
|
|
2557
2580
|
stop(flush?: boolean): void;
|
|
2558
2581
|
/**
|
|
2559
|
-
*
|
|
2560
|
-
*
|
|
2582
|
+
* Sends all outstanding event reports, regardless of the batch size or
|
|
2583
|
+
* interval. Use this method when the player is destroyed or a playback
|
|
2561
2584
|
* session ends.
|
|
2562
2585
|
*/
|
|
2563
2586
|
flush(): void;
|
|
2564
2587
|
/**
|
|
2565
2588
|
* Updates the CMCD data.
|
|
2566
2589
|
*
|
|
2567
|
-
*
|
|
2568
|
-
*
|
|
2569
|
-
*
|
|
2570
|
-
*
|
|
2571
|
-
*
|
|
2572
|
-
*
|
|
2573
|
-
*
|
|
2574
|
-
*
|
|
2575
|
-
*
|
|
2576
|
-
*
|
|
2577
|
-
*
|
|
2578
|
-
*
|
|
2579
|
-
*
|
|
2580
|
-
*
|
|
2581
|
-
*
|
|
2582
|
-
*
|
|
2583
|
-
*
|
|
2584
|
-
*
|
|
2585
|
-
*
|
|
2586
|
-
*
|
|
2587
|
-
*
|
|
2588
|
-
*
|
|
2589
|
-
*
|
|
2590
|
-
*
|
|
2591
|
-
*
|
|
2592
|
-
* `sid` and `msd` are session-owned: the reporter tracks them itself and
|
|
2593
|
-
* stamps them onto every outgoing report, so this method is the only way
|
|
2590
|
+
* The player calls this method when data changes. The tracked state fields
|
|
2591
|
+
* are `sta`, `pr`, `cid`, `bg`, and `br`. If a new value for one of them
|
|
2592
|
+
* differs from the last reported value for that field, the reporter fires
|
|
2593
|
+
* the matching state-change event. The comparison uses the last reported
|
|
2594
|
+
* value, not the previous persisted value. The first state-change event in
|
|
2595
|
+
* a new session therefore always fires, even when the persisted value did
|
|
2596
|
+
* not change across the `sid` boundary.
|
|
2597
|
+
*
|
|
2598
|
+
* Multi-field updates fire the events in this order: `sta`, `pr`, `cid`,
|
|
2599
|
+
* `bg`, `br`. The order of keys in the input object does not affect the
|
|
2600
|
+
* firing order.
|
|
2601
|
+
*
|
|
2602
|
+
* A state-change event can include context fields, for example `bl`, `mtp`,
|
|
2603
|
+
* `pt`, `ltc`. Those fields must be in the data store before the state field
|
|
2604
|
+
* changes. Either pass them with the state field in the same `update()`
|
|
2605
|
+
* call, or persist them with earlier `update()` calls. An auto-fired event
|
|
2606
|
+
* reports the current content of the data store. `TIME_INTERVAL` events also
|
|
2607
|
+
* read the data store, and the caller cannot add per-call data to them. The
|
|
2608
|
+
* player must therefore update the fields it wants in periodic reports with
|
|
2609
|
+
* this method.
|
|
2610
|
+
*
|
|
2611
|
+
* A `sid` change resets the deduplication baseline.
|
|
2612
|
+
*
|
|
2613
|
+
* `sid` and `msd` are session-owned. The reporter tracks them itself and
|
|
2614
|
+
* writes them into every outgoing report, so this method is the only way
|
|
2594
2615
|
* to change them. A per-call value on {@link CmcdReporter.recordEvent},
|
|
2595
2616
|
* {@link CmcdReporter.createRequestReport}, or
|
|
2596
|
-
* {@link CmcdReporter.recordResponseReceived} has no effect
|
|
2597
|
-
* attribution
|
|
2617
|
+
* {@link CmcdReporter.recordResponseReceived} has no effect. Response
|
|
2618
|
+
* attribution uses the provenance record alone.
|
|
2598
2619
|
* `msd` must be a finite number of milliseconds between `0` and
|
|
2599
|
-
* `999_999_999_999_999` (the RFC 8941 integer maximum)
|
|
2600
|
-
* the nearest integer
|
|
2620
|
+
* `999_999_999_999_999` (the RFC 8941 integer maximum). The reporter
|
|
2621
|
+
* rounds `msd` to the nearest integer and ignores invalid values.
|
|
2601
2622
|
*
|
|
2602
2623
|
* @param data - The data to update.
|
|
2603
2624
|
*/
|
|
2604
2625
|
update(data: Partial<Cmcd>): void;
|
|
2605
2626
|
/**
|
|
2606
|
-
* Starts a new session
|
|
2607
|
-
*
|
|
2608
|
-
* the oldest
|
|
2609
|
-
*
|
|
2610
|
-
*
|
|
2611
|
-
*
|
|
2612
|
-
*
|
|
2613
|
-
* session starts from a shallow copy of
|
|
2614
|
-
*
|
|
2615
|
-
*
|
|
2616
|
-
* unique per playback session
|
|
2617
|
-
*
|
|
2618
|
-
*
|
|
2627
|
+
* Starts a new session. The reporter retains the current session for late
|
|
2628
|
+
* responses and creates a new current session. It then sends the ended
|
|
2629
|
+
* sessions' queued reports and removes the oldest sessions beyond the
|
|
2630
|
+
* configured retention.
|
|
2631
|
+
*
|
|
2632
|
+
* The ended session's snapshot is frozen: the reporter detaches its value
|
|
2633
|
+
* graph, so nested values from earlier `update()` calls cannot mutate the
|
|
2634
|
+
* snapshot. The new session starts from a shallow copy of that graph, which
|
|
2635
|
+
* preserves the data store. All fields, including `cid`, `br`, and custom
|
|
2636
|
+
* keys, survive a `sid` change as before. CTA-5004-B expects a `sid` to be
|
|
2637
|
+
* unique per playback session, so a reused `sid` replaces the retained
|
|
2638
|
+
* session with that `sid`. The replaced session's remaining state is lost,
|
|
2639
|
+
* as if removed, and the reporter attributes its late responses to the
|
|
2640
|
+
* replacement.
|
|
2619
2641
|
*/
|
|
2620
2642
|
private startSession;
|
|
2621
2643
|
/**
|
|
2622
|
-
* Records an event.
|
|
2644
|
+
* Records an event. The player calls this method when an event occurs.
|
|
2623
2645
|
*
|
|
2624
2646
|
* For state-change events (`PLAY_STATE`, `PLAYBACK_RATE`, `CONTENT_ID`,
|
|
2625
2647
|
* `BACKGROUNDED_MODE`, `BITRATE_CHANGE`), this method:
|
|
2626
|
-
* 1.
|
|
2627
|
-
*
|
|
2628
|
-
* 2.
|
|
2629
|
-
*
|
|
2630
|
-
*
|
|
2631
|
-
* 3. Suppresses the event if the field's current value
|
|
2632
|
-
* last
|
|
2633
|
-
*
|
|
2634
|
-
*
|
|
2635
|
-
*
|
|
2636
|
-
* For state-change events, prefer {@link CmcdReporter.update}
|
|
2637
|
-
*
|
|
2638
|
-
* `update({ sta: 'p', bl: [3000], mtp: [8500] })`.
|
|
2639
|
-
*
|
|
2640
|
-
*
|
|
2641
|
-
*
|
|
2642
|
-
*
|
|
2643
|
-
*
|
|
2644
|
-
*
|
|
2645
|
-
*
|
|
2646
|
-
* `
|
|
2647
|
-
*
|
|
2648
|
-
* per-response fields automatically.
|
|
2648
|
+
* 1. Writes the state field from `data` (if present) into the reporter's
|
|
2649
|
+
* data store, as `update()` would.
|
|
2650
|
+
* 2. Discards the event if the state field has no value after that write
|
|
2651
|
+
* (never set, or cleared with `update({ field: undefined })`).
|
|
2652
|
+
* A state-change event without its required field would violate CTA-5004-B.
|
|
2653
|
+
* 3. Suppresses the event if the field's current value equals the
|
|
2654
|
+
* last reported value (no state transition).
|
|
2655
|
+
*
|
|
2656
|
+
* The reporter always records all other event types.
|
|
2657
|
+
*
|
|
2658
|
+
* For state-change events, prefer {@link CmcdReporter.update}, also for
|
|
2659
|
+
* context fields in a combined call like
|
|
2660
|
+
* `update({ sta: 'p', bl: [3000], mtp: [8500] })`. After `update()`
|
|
2661
|
+
* auto-fires a state-change event, deduplication suppresses a
|
|
2662
|
+
* `recordEvent()` call for the same event, and that call's `data` is
|
|
2663
|
+
* silently lost.
|
|
2664
|
+
*
|
|
2665
|
+
* Call `recordEvent()` directly for events whose data comes with the event
|
|
2666
|
+
* call. Examples: `CUSTOM_EVENT` with `cen`, `ERROR` with `ec`, ad lifecycle
|
|
2667
|
+
* events, `MUTE`/`UNMUTE`, `PLAYER_EXPAND`/`PLAYER_COLLAPSE`, `SKIP`. For
|
|
2668
|
+
* `RESPONSE_RECEIVED`, prefer {@link CmcdReporter.recordResponseReceived},
|
|
2669
|
+
* which derives the per-response fields automatically.
|
|
2649
2670
|
*
|
|
2650
2671
|
* @param type - The type of event to record.
|
|
2651
|
-
* @param data - Additional data to record with the event. This data
|
|
2652
|
-
* only
|
|
2653
|
-
*
|
|
2654
|
-
*
|
|
2655
|
-
* (`sid`, `msd`) supplied here
|
|
2656
|
-
* stamps its own values.
|
|
2672
|
+
* @param data - Additional data to record with the event. This data applies
|
|
2673
|
+
* only to this event report. The exception is the state field
|
|
2674
|
+
* of a state-change event, which the reporter also writes into
|
|
2675
|
+
* its data store. The reporter ignores session-owned keys
|
|
2676
|
+
* (`sid`, `msd`) supplied here and writes its own values.
|
|
2657
2677
|
*/
|
|
2658
2678
|
recordEvent(type: CmcdEventType, data?: Partial<Cmcd>): void;
|
|
2659
2679
|
/**
|
|
2660
|
-
* Records an event
|
|
2661
|
-
*
|
|
2680
|
+
* Records an event for every configured target of a session. State-change
|
|
2681
|
+
* deduplication runs once, before the per-target loop.
|
|
2662
2682
|
*
|
|
2663
2683
|
* @param session - The session the event belongs to. Everything the event
|
|
2664
|
-
* touches (data store,
|
|
2665
|
-
* is that session's
|
|
2666
|
-
* passes an
|
|
2684
|
+
* touches (data store, deduplication baseline, counters,
|
|
2685
|
+
* queues) is that session's. Only `recordResponseReceived()`
|
|
2686
|
+
* ever passes an ended session.
|
|
2667
2687
|
* @param type - The type of event to record.
|
|
2668
2688
|
* @param data - Additional data to record with the event.
|
|
2669
2689
|
* @param request - The media request that triggered the event, when
|
|
2670
|
-
* one exists. Only `recordResponseReceived()`
|
|
2671
|
-
*
|
|
2672
|
-
*
|
|
2690
|
+
* one exists. Only `recordResponseReceived()` sets this
|
|
2691
|
+
* parameter, which the reporter passes to each target's
|
|
2692
|
+
* `transform`.
|
|
2673
2693
|
*/
|
|
2674
2694
|
private emitEvent;
|
|
2675
2695
|
/**
|
|
2676
|
-
* Records an event for a target.
|
|
2696
|
+
* Records an event for a target. The reporter calls this method when an
|
|
2697
|
+
* event occurs.
|
|
2677
2698
|
*
|
|
2678
2699
|
* @param target - The target to record the event for.
|
|
2679
2700
|
* @param config - The configuration for the target.
|
|
2680
2701
|
* @param type - The type of event to record.
|
|
2681
2702
|
* @param data - Additional data to record with the event. This data
|
|
2682
|
-
* only applies to this event report.
|
|
2683
|
-
*
|
|
2703
|
+
* only applies to this event report. Use `update()` for
|
|
2704
|
+
* persistent data.
|
|
2684
2705
|
* @param request - The media request that triggered the event, when
|
|
2685
|
-
* one exists.
|
|
2706
|
+
* one exists. The target's `transform` receives it.
|
|
2686
2707
|
*/
|
|
2687
2708
|
private recordTargetEvent;
|
|
2688
2709
|
/**
|
|
2689
|
-
*
|
|
2690
|
-
* and pushes the
|
|
2710
|
+
* Writes the reporter-owned fields into a finished event report, encodes
|
|
2711
|
+
* the report, and pushes the encoded line to the target's queue.
|
|
2691
2712
|
*
|
|
2692
|
-
*
|
|
2693
|
-
* target's `events` filter
|
|
2694
|
-
* the session identity
|
|
2695
|
-
*
|
|
2696
|
-
*
|
|
2697
|
-
* forever.
|
|
2713
|
+
* This method runs after any transform. A transform cannot bypass the
|
|
2714
|
+
* target's `events` filter through `e`, break `sn` continuity, or replace
|
|
2715
|
+
* the session identity in `sid` and `msd`. Encoding here makes a report
|
|
2716
|
+
* that cannot serialize throw inside the recording call, instead of failing
|
|
2717
|
+
* the batch send and re-queueing forever.
|
|
2698
2718
|
*
|
|
2699
2719
|
* @param target - The target to queue the report for.
|
|
2700
2720
|
* @param config - The configuration for the target.
|
|
@@ -2703,10 +2723,10 @@ declare class CmcdReporter<C = Record<string, unknown>> {
|
|
|
2703
2723
|
*/
|
|
2704
2724
|
private queueTargetEvent;
|
|
2705
2725
|
/**
|
|
2706
|
-
* Records a response-received event.
|
|
2707
|
-
* request response has
|
|
2726
|
+
* Records a response-received event. The player calls this method when a
|
|
2727
|
+
* media request response has fully arrived.
|
|
2708
2728
|
*
|
|
2709
|
-
* This method
|
|
2729
|
+
* This method derives these `rr` event keys automatically:
|
|
2710
2730
|
*
|
|
2711
2731
|
* - `url` - the original requested URL (before any redirects)
|
|
2712
2732
|
* - `rc` - the HTTP response status code
|
|
@@ -2714,68 +2734,68 @@ declare class CmcdReporter<C = Record<string, unknown>> {
|
|
|
2714
2734
|
* - `ttfb` - time to first byte (from `resourceTiming.responseStart`)
|
|
2715
2735
|
* - `ttlb` - time to last byte (from `resourceTiming.duration`)
|
|
2716
2736
|
*
|
|
2717
|
-
*
|
|
2718
|
-
*
|
|
2737
|
+
* If the player has additional keys like `ttfbb`, `cmsdd`, `cmsds`, and
|
|
2738
|
+
* `smrt`, pass them in the `data` parameter.
|
|
2719
2739
|
*
|
|
2720
|
-
* The request's `customData` is generic, so a player can pass a request
|
|
2721
|
-
*
|
|
2722
|
-
*
|
|
2723
|
-
* {@link CmcdReporter.createRequestReport} writes there
|
|
2724
|
-
*
|
|
2725
|
-
*
|
|
2740
|
+
* The request's `customData` is generic, so a player can pass a request with
|
|
2741
|
+
* its own keys (for example `{ requestType: 'segment' }`) without a cast. The
|
|
2742
|
+
* reporter reads only the provenance record that
|
|
2743
|
+
* {@link CmcdReporter.createRequestReport} writes there. Every other key
|
|
2744
|
+
* stays unchanged and visible to an event target's `transform` through its
|
|
2745
|
+
* `request` argument.
|
|
2726
2746
|
*
|
|
2727
|
-
* A reporter
|
|
2728
|
-
*
|
|
2729
|
-
*
|
|
2747
|
+
* A reporter with a concrete `C` requires the request to satisfy that type.
|
|
2748
|
+
* TypeScript therefore rejects a call whose request the configured
|
|
2749
|
+
* transforms could not read. See {@link CmcdReporterCustomData}.
|
|
2730
2750
|
*
|
|
2731
|
-
* The event
|
|
2732
|
-
*
|
|
2751
|
+
* The reporter attributes the event only to the session that issued the
|
|
2752
|
+
* request. The provenance record that
|
|
2733
2753
|
* {@link CmcdReporter.createRequestReport} stored on the request's
|
|
2734
|
-
* `customData` (under {@link CMCD_REQUEST_PROVENANCE}) selects the
|
|
2735
|
-
*
|
|
2736
|
-
*
|
|
2737
|
-
*
|
|
2738
|
-
* {@link CMCD_REQUEST_PROVENANCE})
|
|
2739
|
-
*
|
|
2740
|
-
* `
|
|
2741
|
-
*
|
|
2742
|
-
*
|
|
2743
|
-
* A response that completes after a `sid`
|
|
2744
|
-
* retained session, with that session's data
|
|
2745
|
-
* numbers.
|
|
2746
|
-
*
|
|
2747
|
-
* Request-time report keys come from the record's encoded per-call
|
|
2748
|
-
*
|
|
2749
|
-
*
|
|
2750
|
-
* completes after a mid-session content change
|
|
2751
|
-
*
|
|
2752
|
-
*
|
|
2753
|
-
* @typeParam RD - The `customData` this request
|
|
2754
|
+
* `customData` (under {@link CMCD_REQUEST_PROVENANCE}) selects the session
|
|
2755
|
+
* by `sid`. Without a match, the reporter discards the response rather than
|
|
2756
|
+
* attributing it elsewhere. There is no other key. The reporter discards the
|
|
2757
|
+
* response when a serialization boundary lost the record and nothing
|
|
2758
|
+
* restored it (see {@link CMCD_REQUEST_PROVENANCE}). It also discards the
|
|
2759
|
+
* response when the session is no longer retained (see
|
|
2760
|
+
* `CmcdReporterConfig.sessionRetention`). A per-call `data.sid` cannot
|
|
2761
|
+
* substitute. The reporter accepts any record whose `sid` names a retained
|
|
2762
|
+
* session. The record may come from another reporter with the same session
|
|
2763
|
+
* attributes, or be hand-built. A response that completes after a `sid`
|
|
2764
|
+
* change reports under its own retained session, with that session's data
|
|
2765
|
+
* snapshot and sequence numbers.
|
|
2766
|
+
*
|
|
2767
|
+
* Request-time report keys come from the record's encoded per-call `data`
|
|
2768
|
+
* snapshot, which the reporter decodes for each response. The record's `cid`
|
|
2769
|
+
* replaces the session's current `cid` in the report. A response that
|
|
2770
|
+
* completes after a mid-session content change therefore reports its
|
|
2771
|
+
* request-time values.
|
|
2772
|
+
*
|
|
2773
|
+
* @typeParam RD - The `customData` of this request. Defaults to the
|
|
2754
2774
|
* reporter's own `C`.
|
|
2755
2775
|
*
|
|
2756
2776
|
* @param response - The HTTP response received.
|
|
2757
2777
|
* @param data - Additional CMCD data to include with the event.
|
|
2758
|
-
* Values provided here override
|
|
2759
|
-
*
|
|
2760
|
-
*
|
|
2778
|
+
* Values provided here override the derived values.
|
|
2779
|
+
* The reporter ignores session-owned keys (`sid`, `msd`)
|
|
2780
|
+
* supplied here. Attribution uses the provenance record alone.
|
|
2761
2781
|
*/
|
|
2762
2782
|
recordResponseReceived<RD extends CmcdReporterCustomData<C> = C>(response: HttpResponse<HttpRequest<RD & {
|
|
2763
2783
|
cmcd?: Cmcd;
|
|
2764
2784
|
[CMCD_REQUEST_PROVENANCE]?: CmcdRequestProvenance;
|
|
2765
2785
|
}>>, data?: Partial<Cmcd>): void;
|
|
2766
2786
|
/**
|
|
2767
|
-
* Resolves the session a response belongs to
|
|
2768
|
-
*
|
|
2769
|
-
*
|
|
2770
|
-
* names
|
|
2771
|
-
*
|
|
2772
|
-
*
|
|
2773
|
-
*
|
|
2787
|
+
* Resolves the session a response belongs to. The provenance record's `sid`
|
|
2788
|
+
* must name one of this reporter's retained sessions, or the reporter
|
|
2789
|
+
* discards the response. There is no other key. A lost record, or one that
|
|
2790
|
+
* names a removed or unknown `sid`, resolves nothing. Any other attribution
|
|
2791
|
+
* would be wrong. The reporter reads the `sid` as a plain property. A record
|
|
2792
|
+
* copied through JSON therefore resolves the same session, and a hand-built
|
|
2793
|
+
* record that names a retained session is accepted.
|
|
2774
2794
|
*/
|
|
2775
2795
|
private resolveSession;
|
|
2776
2796
|
/**
|
|
2777
|
-
* Applies the CMCD request report data to the request.
|
|
2778
|
-
* before sending the request.
|
|
2797
|
+
* Applies the CMCD request report data to the request. The player calls this
|
|
2798
|
+
* method before sending the request.
|
|
2779
2799
|
*
|
|
2780
2800
|
* @param req - The request to apply the CMCD request report to.
|
|
2781
2801
|
* @returns The request with the CMCD request report applied.
|
|
@@ -2784,50 +2804,51 @@ declare class CmcdReporter<C = Record<string, unknown>> {
|
|
|
2784
2804
|
*/
|
|
2785
2805
|
applyRequestReport(req: HttpRequest): HttpRequest;
|
|
2786
2806
|
/**
|
|
2787
|
-
* Checks
|
|
2807
|
+
* Checks whether request reporting is enabled.
|
|
2788
2808
|
*
|
|
2789
|
-
* @returns `true` if
|
|
2809
|
+
* @returns `true` if request reporting is enabled, `false` otherwise.
|
|
2790
2810
|
*/
|
|
2791
2811
|
isRequestReportingEnabled(): boolean;
|
|
2792
2812
|
/**
|
|
2793
|
-
* The provenance record to
|
|
2794
|
-
* frozen base record, extended with the caller's per-call data encoded
|
|
2795
|
-
*
|
|
2796
|
-
*
|
|
2797
|
-
*
|
|
2798
|
-
*
|
|
2799
|
-
*
|
|
2800
|
-
*
|
|
2801
|
-
* side.
|
|
2813
|
+
* The provenance record to write on a returned request. It is the session's
|
|
2814
|
+
* frozen base record, extended with the caller's per-call data encoded as a
|
|
2815
|
+
* CMCD string when there is any. Requests without per-call data share the
|
|
2816
|
+
* base record, so the reporter writes only one property. The snapshot never
|
|
2817
|
+
* contains reporter-written fields. A value that cannot encode contributes
|
|
2818
|
+
* no snapshot and does not fail the request. The response still attributes
|
|
2819
|
+
* and reports derived keys over session data, matching the tolerance of
|
|
2820
|
+
* `decodeSnapshot()` when reading.
|
|
2802
2821
|
*/
|
|
2803
2822
|
private createRequestProvenance;
|
|
2804
2823
|
/**
|
|
2805
|
-
* Creates a new request with the CMCD request report data applied.
|
|
2806
|
-
* before sending the request.
|
|
2824
|
+
* Creates a new request with the CMCD request report data applied. The
|
|
2825
|
+
* player calls this method before sending the request.
|
|
2807
2826
|
*
|
|
2808
|
-
* A reporter
|
|
2809
|
-
* satisfy
|
|
2810
|
-
*
|
|
2827
|
+
* A reporter with a concrete `C` requires the request's `customData` to
|
|
2828
|
+
* satisfy that type. TypeScript therefore rejects a call whose request the
|
|
2829
|
+
* configured transform could not read. See
|
|
2811
2830
|
* {@link CmcdReporterCustomData}.
|
|
2812
2831
|
*
|
|
2813
|
-
* @typeParam R - The
|
|
2832
|
+
* @typeParam R - The type of the request. Its `customData` must satisfy
|
|
2814
2833
|
* the reporter's `C`.
|
|
2815
2834
|
*
|
|
2816
2835
|
* @param request - The request to apply the CMCD request report to.
|
|
2817
2836
|
* @param data - The data to apply to the request. This data only
|
|
2818
|
-
* applies to this request report.
|
|
2819
|
-
*
|
|
2837
|
+
* applies to this request report. Use `update()` for
|
|
2838
|
+
* persistent data.
|
|
2820
2839
|
* @returns The request with the CMCD request report applied.
|
|
2821
2840
|
*/
|
|
2822
2841
|
createRequestReport<R extends HttpRequest<CmcdReporterCustomData<C>> = HttpRequest<C>>(request: R, data?: Partial<Cmcd>): R & CmcdRequestReport<R["customData"]>;
|
|
2823
2842
|
/**
|
|
2824
|
-
* Processes the event targets.
|
|
2843
|
+
* Processes the event targets. The reporter calls this method when an event
|
|
2844
|
+
* occurs.
|
|
2825
2845
|
*
|
|
2826
2846
|
* @param flush - Whether to flush the event targets.
|
|
2827
2847
|
*/
|
|
2828
2848
|
private processEventTargets;
|
|
2829
2849
|
/**
|
|
2830
|
-
* Sends an event report.
|
|
2850
|
+
* Sends an event report. The reporter calls this method when a batch is
|
|
2851
|
+
* ready.
|
|
2831
2852
|
*
|
|
2832
2853
|
* @param config - The target config to send the event report to.
|
|
2833
2854
|
* @param data - The encoded report lines to send in the event report.
|
|
@@ -2835,17 +2856,17 @@ declare class CmcdReporter<C = Record<string, unknown>> {
|
|
|
2835
2856
|
private sendEventReport;
|
|
2836
2857
|
/**
|
|
2837
2858
|
* Cancels the time-interval timer for an event target config and clears the
|
|
2838
|
-
* stored id. Safe to call when no timer is
|
|
2839
|
-
*
|
|
2859
|
+
* stored id. Safe to call when no timer is active (clearInterval(undefined)
|
|
2860
|
+
* does nothing).
|
|
2840
2861
|
*/
|
|
2841
2862
|
private disarmInterval;
|
|
2842
2863
|
/**
|
|
2843
|
-
* Silences an event target URL for the remainder of its session
|
|
2844
|
-
*
|
|
2845
|
-
*
|
|
2846
|
-
*
|
|
2847
|
-
*
|
|
2848
|
-
* the disposal
|
|
2864
|
+
* Silences an event target URL for the remainder of its session after the
|
|
2865
|
+
* collector signals that the target is gone (HTTP 410). The method clears
|
|
2866
|
+
* the queues and blocks further enqueues for every config in the session
|
|
2867
|
+
* that reports to the URL (the CTA-5004-B suppression scope). For the
|
|
2868
|
+
* current session, the method also cancels those configs' timers. A session
|
|
2869
|
+
* started after the disposal gets new target state and is unaffected.
|
|
2849
2870
|
*/
|
|
2850
2871
|
private disposeEventTarget;
|
|
2851
2872
|
}
|
|
@@ -2858,7 +2879,7 @@ declare class CmcdReporter<C = Record<string, unknown>> {
|
|
|
2858
2879
|
*/
|
|
2859
2880
|
type CmcdValidationOptions = {
|
|
2860
2881
|
/**
|
|
2861
|
-
* Explicit CMCD version override. If
|
|
2882
|
+
* Explicit CMCD version override. If omitted, the version is
|
|
2862
2883
|
* inferred from the payload's `v` key, defaulting to 1.
|
|
2863
2884
|
*/
|
|
2864
2885
|
version?: CmcdVersion;
|
|
@@ -2870,17 +2891,17 @@ type CmcdValidationOptions = {
|
|
|
2870
2891
|
//#endregion
|
|
2871
2892
|
//#region src/createFetchTransport.d.ts
|
|
2872
2893
|
/**
|
|
2873
|
-
* Create a transport adapter
|
|
2874
|
-
*
|
|
2875
|
-
*
|
|
2876
|
-
*
|
|
2877
|
-
*
|
|
2878
|
-
*
|
|
2879
|
-
* safe for the body types CMCD reports use
|
|
2880
|
-
* `Blob`, `ArrayBuffer`, `FormData`,
|
|
2881
|
-
*
|
|
2882
|
-
* a `ReadableStream` as `init.body
|
|
2883
|
-
*
|
|
2894
|
+
* Create a transport adapter for `CmcdReportRecorder` that patches
|
|
2895
|
+
* `globalThis.fetch` to capture requests with CMCD data. The patched
|
|
2896
|
+
* `fetch` normalizes each request to `HttpRequest` (lowercase headers,
|
|
2897
|
+
* body read as a UTF-8 string).
|
|
2898
|
+
*
|
|
2899
|
+
* The patched `fetch` reads each body once with `Request.text()` for
|
|
2900
|
+
* inspection. This read is safe for the body types that CMCD reports use
|
|
2901
|
+
* in practice: `string`, `Blob`, `ArrayBuffer`, `FormData`, and
|
|
2902
|
+
* `URLSearchParams`. The underlying `fetch` can read those bodies again.
|
|
2903
|
+
* Do not pass a `ReadableStream` as `init.body`. The patched `fetch`
|
|
2904
|
+
* consumes the stream, and the underlying `fetch` receives an
|
|
2884
2905
|
* already-disturbed stream.
|
|
2885
2906
|
*
|
|
2886
2907
|
* @public
|
|
@@ -2889,9 +2910,8 @@ declare function createFetchTransport(): CmcdTransportAdapter;
|
|
|
2889
2910
|
//#endregion
|
|
2890
2911
|
//#region src/createXhrTransport.d.ts
|
|
2891
2912
|
/**
|
|
2892
|
-
* Create a transport adapter
|
|
2893
|
-
*
|
|
2894
|
-
* `CmcdReportRecorder`.
|
|
2913
|
+
* Create a transport adapter for `CmcdReportRecorder` that patches
|
|
2914
|
+
* `XMLHttpRequest.prototype` to capture requests with CMCD data.
|
|
2895
2915
|
*
|
|
2896
2916
|
* @public
|
|
2897
2917
|
*/
|
|
@@ -2980,9 +3000,9 @@ declare function fromCmcdQuery(query: string | URLSearchParams, options?: CmcdDe
|
|
|
2980
3000
|
//#endregion
|
|
2981
3001
|
//#region src/fromCmcdUrl.d.ts
|
|
2982
3002
|
/**
|
|
2983
|
-
* Decode CMCD data from a
|
|
3003
|
+
* Decode CMCD data from a URL encoded string.
|
|
2984
3004
|
*
|
|
2985
|
-
* @param url - The
|
|
3005
|
+
* @param url - The URL encoded string to decode.
|
|
2986
3006
|
* @param options - Options for decoding.
|
|
2987
3007
|
*
|
|
2988
3008
|
* @returns The decoded CMCD data.
|
|
@@ -3001,9 +3021,9 @@ declare function fromCmcdUrl(url: string, options?: CmcdDecodeOptions): CmcdData
|
|
|
3001
3021
|
//#endregion
|
|
3002
3022
|
//#region src/groupCmcdHeaders.d.ts
|
|
3003
3023
|
/**
|
|
3004
|
-
* Group a CMCD
|
|
3024
|
+
* Group a CMCD object into header shards
|
|
3005
3025
|
*
|
|
3006
|
-
* @param cmcd - The CMCD
|
|
3026
|
+
* @param cmcd - The CMCD object to convert.
|
|
3007
3027
|
* @param customHeaderMap - A map of CMCD header fields to custom CMCD keys.
|
|
3008
3028
|
*
|
|
3009
3029
|
* @returns The CMCD header shards.
|
|
@@ -3017,9 +3037,9 @@ declare function groupCmcdHeaders(cmcd: Cmcd, customHeaderMap?: Partial<CmcdHead
|
|
|
3017
3037
|
//#region src/isCmcdCustomKey.d.ts
|
|
3018
3038
|
/**
|
|
3019
3039
|
* Check if a key is a valid custom key: a lowercase first letter, then
|
|
3020
|
-
* characters from `a-z 0-9 .
|
|
3021
|
-
*
|
|
3022
|
-
*
|
|
3040
|
+
* characters from `a-z 0-9 . -`. The key needs a hyphen, not at the start
|
|
3041
|
+
* or end. This check applies the CTA-5004-B custom-key rules, restricted
|
|
3042
|
+
* to names that RFC 8941 key serialization accepts.
|
|
3023
3043
|
*
|
|
3024
3044
|
* @param key - The key to check.
|
|
3025
3045
|
*
|
|
@@ -3068,7 +3088,7 @@ declare function isCmcdRequestKey(key: string): key is keyof Cmcd;
|
|
|
3068
3088
|
*
|
|
3069
3089
|
* @param key - The key to check.
|
|
3070
3090
|
*
|
|
3071
|
-
* @returns `true` if the key is a valid CMCD
|
|
3091
|
+
* @returns `true` if the key is a valid CMCD response key, `false` otherwise.
|
|
3072
3092
|
*
|
|
3073
3093
|
* @public
|
|
3074
3094
|
*
|
|
@@ -3094,7 +3114,7 @@ declare function isCmcdV1Data(data: CmcdData): data is CmcdV1Data;
|
|
|
3094
3114
|
//#endregion
|
|
3095
3115
|
//#region src/isCmcdV1Key.d.ts
|
|
3096
3116
|
/**
|
|
3097
|
-
* Filter
|
|
3117
|
+
* Filter for CMCD version 1 keys.
|
|
3098
3118
|
*
|
|
3099
3119
|
* @param key - The CMCD key to filter.
|
|
3100
3120
|
*
|
|
@@ -3138,10 +3158,10 @@ declare function prepareCmcdData(obj: Record<string, any>, options?: CmcdEncodeO
|
|
|
3138
3158
|
//#endregion
|
|
3139
3159
|
//#region src/toCmcdHeaders.d.ts
|
|
3140
3160
|
/**
|
|
3141
|
-
* Convert a CMCD
|
|
3161
|
+
* Convert a CMCD object to request headers
|
|
3142
3162
|
*
|
|
3143
|
-
* @param cmcd - The CMCD
|
|
3144
|
-
* @param options - Options for encoding
|
|
3163
|
+
* @param cmcd - The CMCD object to convert.
|
|
3164
|
+
* @param options - Options for encoding.
|
|
3145
3165
|
*
|
|
3146
3166
|
* @returns The CMCD header shards.
|
|
3147
3167
|
*
|
|
@@ -3156,10 +3176,10 @@ declare function toCmcdHeaders(cmcd: Cmcd, options?: CmcdEncodeOptions): Record<
|
|
|
3156
3176
|
//#endregion
|
|
3157
3177
|
//#region src/toCmcdQuery.d.ts
|
|
3158
3178
|
/**
|
|
3159
|
-
* Convert a CMCD
|
|
3179
|
+
* Convert a CMCD object to a query arg.
|
|
3160
3180
|
*
|
|
3161
3181
|
* @param cmcd - The CMCD object to convert.
|
|
3162
|
-
* @param options - Options for encoding
|
|
3182
|
+
* @param options - Options for encoding.
|
|
3163
3183
|
*
|
|
3164
3184
|
* @returns The CMCD query arg.
|
|
3165
3185
|
*
|
|
@@ -3174,10 +3194,10 @@ declare function toCmcdQuery(cmcd: Cmcd, options?: CmcdEncodeOptions): string;
|
|
|
3174
3194
|
//#endregion
|
|
3175
3195
|
//#region src/toCmcdUrl.d.ts
|
|
3176
3196
|
/**
|
|
3177
|
-
* Convert a CMCD
|
|
3197
|
+
* Convert a CMCD object to a URL encoded string.
|
|
3178
3198
|
*
|
|
3179
3199
|
* @param cmcd - The CMCD object to convert.
|
|
3180
|
-
* @param options - Options for encoding
|
|
3200
|
+
* @param options - Options for encoding.
|
|
3181
3201
|
*
|
|
3182
3202
|
* @returns The URL encoded CMCD data.
|
|
3183
3203
|
*
|
|
@@ -3192,7 +3212,7 @@ declare function toCmcdUrl(cmcd: Cmcd, options?: CmcdEncodeOptions): string;
|
|
|
3192
3212
|
* Convert a value to a CMCD value.
|
|
3193
3213
|
*
|
|
3194
3214
|
* @param value - The value to convert to a CMCD value.
|
|
3195
|
-
* @param params - The parameters
|
|
3215
|
+
* @param params - The parameters of the CMCD value.
|
|
3196
3216
|
* @returns The CMCD value.
|
|
3197
3217
|
*
|
|
3198
3218
|
* @public
|
|
@@ -3223,8 +3243,8 @@ declare function validateCmcd(data: Record<string, unknown>, options?: CmcdValid
|
|
|
3223
3243
|
* Accepts an {@link @svta/cml-utils!HttpRequest | HttpRequest} object.
|
|
3224
3244
|
*
|
|
3225
3245
|
* This function validates that the request uses the POST method and has
|
|
3226
|
-
* the correct `Content-Type` header (`application/cmcd`)
|
|
3227
|
-
*
|
|
3246
|
+
* the correct `Content-Type` header (`application/cmcd`). It also
|
|
3247
|
+
* validates the body content with {@link validateCmcdEvents}.
|
|
3228
3248
|
*
|
|
3229
3249
|
* @param request - An `HttpRequest` to validate.
|
|
3230
3250
|
* @param options - Validation options (excluding `reportingMode`).
|
|
@@ -3244,8 +3264,8 @@ declare function validateCmcdEventReport(request: HttpRequest, options?: Omit<Cm
|
|
|
3244
3264
|
*
|
|
3245
3265
|
* This function decodes the string internally and validates it with
|
|
3246
3266
|
* `reportingMode` set to `'event'`. The input may contain multiple
|
|
3247
|
-
* newline-separated events
|
|
3248
|
-
*
|
|
3267
|
+
* newline-separated events, for example an `application/cmcd` POST body.
|
|
3268
|
+
* The function validates each line independently and merges the results.
|
|
3249
3269
|
*
|
|
3250
3270
|
* @param cmcd - The raw CMCD-encoded string to validate. May contain
|
|
3251
3271
|
* multiple newline-separated event lines.
|
|
@@ -3265,15 +3285,15 @@ declare function validateCmcdEvents(cmcd: string, options?: Omit<CmcdValidationO
|
|
|
3265
3285
|
/**
|
|
3266
3286
|
* Validates CMCD HTTP headers by checking shard placement and payload validity.
|
|
3267
3287
|
*
|
|
3268
|
-
* This function accepts raw CMCD header strings
|
|
3269
|
-
* internally
|
|
3270
|
-
* then merges all shards and runs
|
|
3271
|
-
* structure) on the merged data.
|
|
3288
|
+
* This function accepts raw CMCD header strings and decodes each shard
|
|
3289
|
+
* internally. It verifies that each key is in its correct header shard.
|
|
3290
|
+
* The function then merges all shards and runs payload validation (keys,
|
|
3291
|
+
* values, and structure) on the merged data.
|
|
3272
3292
|
*
|
|
3273
3293
|
* @example
|
|
3274
3294
|
* {@includeCode ../test/validateCmcdHeaders.test.ts#example}
|
|
3275
3295
|
*
|
|
3276
|
-
* @param headers - A `Headers` instance or a record of CMCD header fields to
|
|
3296
|
+
* @param headers - A `Headers` instance or a record of CMCD header fields to raw encoded strings.
|
|
3277
3297
|
* @param options - Validation options (excluding `reportingMode`).
|
|
3278
3298
|
* @returns The validation result including decoded data.
|
|
3279
3299
|
*
|
|
@@ -3308,10 +3328,12 @@ declare function validateCmcdKeys(data: Record<string, unknown>, options?: CmcdV
|
|
|
3308
3328
|
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Request | Request}
|
|
3309
3329
|
* object or an {@link @svta/cml-utils!HttpRequest | HttpRequest} object.
|
|
3310
3330
|
*
|
|
3311
|
-
* The function checks for CMCD data
|
|
3312
|
-
*
|
|
3313
|
-
*
|
|
3314
|
-
*
|
|
3331
|
+
* The function checks the HTTP headers for CMCD data first. If the
|
|
3332
|
+
* request has CMCD headers, {@link validateCmcdHeaders} validates them,
|
|
3333
|
+
* including shard placement. Otherwise, the function validates the CMCD
|
|
3334
|
+
* query parameter of the URL. A request with CMCD data in both the
|
|
3335
|
+
* headers and the `CMCD` query parameter is an error. The function still
|
|
3336
|
+
* validates the headers and returns their data.
|
|
3315
3337
|
*
|
|
3316
3338
|
* @param request - A `Request` or `HttpRequest` to validate.
|
|
3317
3339
|
* @param options - Validation options (excluding `reportingMode`).
|