@svta/cml-cmcd 2.6.1 → 2.8.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/README.md +3 -3
- package/dist/index.d.ts +617 -578
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1543 -939
- 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`
|
|
@@ -1397,7 +1415,16 @@ type CmcdEncodeOptions = {
|
|
|
1397
1415
|
*/
|
|
1398
1416
|
reportingMode?: CmcdReportingMode;
|
|
1399
1417
|
/**
|
|
1400
|
-
* A map of CMCD keys to custom formatters.
|
|
1418
|
+
* A map of CMCD keys to custom formatters. A formatter replaces the value rule of its key.
|
|
1419
|
+
* The encoder does not apply the type, length, and token rules of the key to the output.
|
|
1420
|
+
* The encoder still applies these rules to the output:
|
|
1421
|
+
*
|
|
1422
|
+
* - It drops an empty value. An empty value is `undefined`, `null`, an empty string, an empty array, or a number that is not finite.
|
|
1423
|
+
* - It drops a default value, with or without parameters. The default value is `false`, or `1` for `pr`. The exceptions are `pr` on a `pr` event and `bg` on a `b` event.
|
|
1424
|
+
* - It wraps a string for `e`, `ot`, `sf`, `st`, and `sta` in `SfToken`.
|
|
1425
|
+
* - It replaces a `ts` that is not a finite number with the current time.
|
|
1426
|
+
*
|
|
1427
|
+
* The encoder does not call a formatter for an empty value, for `false`, or for `v`. It also skips the formatter of a key that it does not send. The formatters of `ot` and `e` still run when a rule needs their value.
|
|
1401
1428
|
*/
|
|
1402
1429
|
formatters?: Partial<CmcdFormatterMap>;
|
|
1403
1430
|
/**
|
|
@@ -1414,9 +1441,10 @@ type CmcdEncodeOptions = {
|
|
|
1414
1441
|
filter?: (key: CmcdKey) => boolean;
|
|
1415
1442
|
/**
|
|
1416
1443
|
* 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
|
-
*
|
|
1444
|
+
* into paths relative to this base, per the CMCD specification. This option does not modify values
|
|
1445
|
+
* that are already relative paths, but CMCD version 1 still URL-encodes them on emission. If omitted,
|
|
1446
|
+
* `nor` values are emitted unchanged (subject to the version 1 URL-encoding rule).
|
|
1447
|
+
* If `baseUrl` is not a valid URL, the encoder ignores it.
|
|
1420
1448
|
*/
|
|
1421
1449
|
baseUrl?: string;
|
|
1422
1450
|
/**
|
|
@@ -1427,13 +1455,13 @@ type CmcdEncodeOptions = {
|
|
|
1427
1455
|
//#endregion
|
|
1428
1456
|
//#region src/appendCmcdHeaders.d.ts
|
|
1429
1457
|
/**
|
|
1430
|
-
* Append CMCD
|
|
1458
|
+
* Append CMCD header shards to a header object.
|
|
1431
1459
|
*
|
|
1432
1460
|
* @param headers - The headers to append to.
|
|
1433
1461
|
* @param cmcd - The CMCD object to append.
|
|
1434
|
-
* @param options -
|
|
1462
|
+
* @param options - Options for encoding.
|
|
1435
1463
|
*
|
|
1436
|
-
* @returns The headers with
|
|
1464
|
+
* @returns The headers with CMCD header shards appended.
|
|
1437
1465
|
*
|
|
1438
1466
|
* @public
|
|
1439
1467
|
*
|
|
@@ -1450,7 +1478,7 @@ declare function appendCmcdHeaders(headers: Record<string, string>, cmcd: Cmcd,
|
|
|
1450
1478
|
*
|
|
1451
1479
|
* @param url - The URL to append to.
|
|
1452
1480
|
* @param cmcd - The CMCD object to append.
|
|
1453
|
-
* @param options - Options for encoding
|
|
1481
|
+
* @param options - Options for encoding.
|
|
1454
1482
|
*
|
|
1455
1483
|
* @returns The URL with the CMCD query args appended.
|
|
1456
1484
|
*
|
|
@@ -1465,7 +1493,7 @@ declare function appendCmcdQuery(url: string, cmcd: Cmcd, options?: CmcdEncodeOp
|
|
|
1465
1493
|
//#endregion
|
|
1466
1494
|
//#region src/CMCD_DEFAULT_TIME_INTERVAL.d.ts
|
|
1467
1495
|
/**
|
|
1468
|
-
* The default time interval in seconds when using
|
|
1496
|
+
* The default time interval in seconds when using event mode
|
|
1469
1497
|
*
|
|
1470
1498
|
* @public
|
|
1471
1499
|
*/
|
|
@@ -1481,7 +1509,11 @@ declare const CMCD_EVENT_KEYS: readonly ["cen", "e", "h", "ts"];
|
|
|
1481
1509
|
//#endregion
|
|
1482
1510
|
//#region src/CMCD_FORMATTER_MAP.d.ts
|
|
1483
1511
|
/**
|
|
1484
|
-
*
|
|
1512
|
+
* Formatters for CMCD values.
|
|
1513
|
+
*
|
|
1514
|
+
* The encoder applies the same rounding through its key table, and `nor` is the `nor` rule of the encoder.
|
|
1515
|
+
* Use an entry to build a custom formatter for `CmcdEncodeOptions.formatters`.
|
|
1516
|
+
* The formatter of a numeric key drops a value or a list element that is not a finite number.
|
|
1485
1517
|
*
|
|
1486
1518
|
* @public
|
|
1487
1519
|
*/
|
|
@@ -1499,9 +1531,9 @@ type CmcdRequestKey = keyof CmcdRequest | "nrr";
|
|
|
1499
1531
|
/**
|
|
1500
1532
|
* The map of CMCD keys to their appropriate header shard.
|
|
1501
1533
|
*
|
|
1502
|
-
*
|
|
1503
|
-
*
|
|
1504
|
-
*
|
|
1534
|
+
* Event-only keys (e, ts, cen, h) and response-received keys (rc, ttfb,
|
|
1535
|
+
* ttlb, url, and others) are intentionally absent. They are transmitted
|
|
1536
|
+
* in the event-mode POST body, not HTTP headers.
|
|
1505
1537
|
*
|
|
1506
1538
|
* @public
|
|
1507
1539
|
*/
|
|
@@ -1541,25 +1573,26 @@ declare const CMCD_REQUEST_KEYS: readonly ["ab", "bg", "bl", "br", "bs", "bsa",
|
|
|
1541
1573
|
//#endregion
|
|
1542
1574
|
//#region src/CMCD_REQUEST_PROVENANCE.d.ts
|
|
1543
1575
|
/**
|
|
1544
|
-
* The `customData`
|
|
1545
|
-
*
|
|
1576
|
+
* The `customData` property where `CmcdReporter.createRequestReport()`
|
|
1577
|
+
* writes session provenance on every request it returns.
|
|
1546
1578
|
*
|
|
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
|
-
*
|
|
1579
|
+
* The value is a frozen `CmcdRequestProvenance` record. `sid` names the
|
|
1580
|
+
* session that issued the request. `cid` is the content id at the time the
|
|
1581
|
+
* request was issued. `data` is the request's per-call data as an encoded
|
|
1582
|
+
* CMCD string. `CmcdReporter.recordResponseReceived()` reads the record to
|
|
1583
|
+
* attribute a late response to its session and to rebuild the request-time
|
|
1584
|
+
* report keys.
|
|
1585
|
+
* Spread and `Object.assign` copy the record into ordinary request clones.
|
|
1586
|
+
* `JSON.stringify` and structured clone drop symbol-keyed properties. Before
|
|
1587
|
+
* either operation, read the value and restore it afterward. JSON preserves
|
|
1588
|
+
* the record's fields. Attribution uses the `sid` value rather than object
|
|
1589
|
+
* identity, so a parsed plain-object copy attributes correctly. For a record
|
|
1590
|
+
* naming a `sid` the reporter does not retain, the reporter drops the
|
|
1591
|
+
* response rather than reattributing it.
|
|
1560
1592
|
*
|
|
1561
|
-
*
|
|
1562
|
-
* one bundle interoperate. The registry key is stable across
|
|
1593
|
+
* The symbol registry provides the symbol, so duplicated copies of this
|
|
1594
|
+
* library in one bundle interoperate. The registry key is stable across
|
|
1595
|
+
* versions.
|
|
1563
1596
|
*
|
|
1564
1597
|
* @public
|
|
1565
1598
|
*/
|
|
@@ -1567,7 +1600,7 @@ declare const CMCD_REQUEST_PROVENANCE: unique symbol;
|
|
|
1567
1600
|
//#endregion
|
|
1568
1601
|
//#region src/CMCD_RESPONSE_KEYS.d.ts
|
|
1569
1602
|
/**
|
|
1570
|
-
*
|
|
1603
|
+
* Response-only and timing keys for version 2.
|
|
1571
1604
|
*
|
|
1572
1605
|
* @public
|
|
1573
1606
|
*/
|
|
@@ -1585,8 +1618,8 @@ declare const CMCD_V1_KEYS: readonly ["bl", "br", "bs", "cid", "d", "dl", "mtp",
|
|
|
1585
1618
|
/**
|
|
1586
1619
|
* CMCD version 1 data.
|
|
1587
1620
|
*
|
|
1588
|
-
* Overrides keys whose types differ in version 1
|
|
1589
|
-
* are
|
|
1621
|
+
* Overrides keys whose types differ in version 1. For example, `bl` and
|
|
1622
|
+
* `br` are integers instead of inner lists.
|
|
1590
1623
|
*
|
|
1591
1624
|
* @public
|
|
1592
1625
|
*/
|
|
@@ -1607,7 +1640,7 @@ type CmcdV2Data = Omit<Cmcd, "v"> & {
|
|
|
1607
1640
|
/**
|
|
1608
1641
|
* A CMCD data object that is either version 1 or version 2.
|
|
1609
1642
|
*
|
|
1610
|
-
* The `v` property
|
|
1643
|
+
* The `v` property is the discriminator:
|
|
1611
1644
|
*
|
|
1612
1645
|
* - When `v` is `2`, the type narrows to {@link CmcdV2Data} with
|
|
1613
1646
|
* inner-list values and event/response keys.
|
|
@@ -1721,36 +1754,36 @@ type CmcdDataValidationResult = CmcdValidationResult & {
|
|
|
1721
1754
|
type CmcdDecodeOptions = {
|
|
1722
1755
|
/**
|
|
1723
1756
|
* When `true`, up-converts version 1 data to version 2 format by wrapping
|
|
1724
|
-
* scalar values in arrays for inner-list keys
|
|
1757
|
+
* scalar values in arrays for inner-list keys. Examples: `bl`, `br`, `mtp`.
|
|
1725
1758
|
*
|
|
1726
|
-
*
|
|
1727
|
-
*
|
|
1759
|
+
* The result has a consistent structure regardless of the source version.
|
|
1760
|
+
* This conversion corresponds to the down-conversion during encoding.
|
|
1728
1761
|
*
|
|
1729
1762
|
* @defaultValue false
|
|
1730
1763
|
*/
|
|
1731
1764
|
convertToLatest?: boolean;
|
|
1732
1765
|
/**
|
|
1733
|
-
* Controls how RFC 8941 token values
|
|
1734
|
-
*
|
|
1735
|
-
*
|
|
1736
|
-
*
|
|
1737
|
-
*
|
|
1738
|
-
*
|
|
1766
|
+
* Controls how the decoded data represents RFC 8941 token values. If
|
|
1767
|
+
* omitted, tokens decode to plain strings, which re-encoding cannot
|
|
1768
|
+
* distinguish from string values. `true` decodes tokens as registry
|
|
1769
|
+
* `Symbol`s and `false` as `SfToken` instances. Either preserved
|
|
1770
|
+
* representation re-encodes as a bare token, so a decode/encode round
|
|
1771
|
+
* trip reproduces the wire bytes.
|
|
1739
1772
|
*/
|
|
1740
1773
|
useSymbol?: boolean;
|
|
1741
1774
|
};
|
|
1742
1775
|
//#endregion
|
|
1743
1776
|
//#region src/CmcdTransformRequest.d.ts
|
|
1744
1777
|
/**
|
|
1745
|
-
* The media request
|
|
1778
|
+
* The media request passed to a report transform, as a read-only view.
|
|
1746
1779
|
*
|
|
1747
1780
|
* 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.
|
|
1781
|
+
* the report. A transform must not mutate the request, which belongs to the
|
|
1782
|
+
* caller and may still be in use. Every member is `readonly`, and `customData`
|
|
1783
|
+
* is readonly at every depth, so nested values cannot be written either.
|
|
1751
1784
|
*
|
|
1752
1785
|
* By default `customData` values are `unknown` rather than `any`, because the
|
|
1753
|
-
* library cannot know the player's
|
|
1786
|
+
* library cannot know the player's fields. Narrow with a cast or bracket access
|
|
1754
1787
|
* to read player-specific fields:
|
|
1755
1788
|
*
|
|
1756
1789
|
* ```ts
|
|
@@ -1758,9 +1791,9 @@ type CmcdDecodeOptions = {
|
|
|
1758
1791
|
* request?.customData?.['requestType'] === 'segment' ? data : null
|
|
1759
1792
|
* ```
|
|
1760
1793
|
*
|
|
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.
|
|
1794
|
+
* Supply `C` to describe the player's own `customData` instead, and those
|
|
1795
|
+
* reads become typed dot access. Annotating one transform is enough: the
|
|
1796
|
+
* reporter infers `C` for every other transform in the same configuration.
|
|
1764
1797
|
*
|
|
1765
1798
|
* ```ts
|
|
1766
1799
|
* type PlayerData = { requestType: string; };
|
|
@@ -1769,15 +1802,15 @@ type CmcdDecodeOptions = {
|
|
|
1769
1802
|
* request?.customData?.requestType === 'segment' ? data : null
|
|
1770
1803
|
* ```
|
|
1771
1804
|
*
|
|
1772
|
-
* `C`
|
|
1773
|
-
*
|
|
1805
|
+
* This type wraps `C` in {@link DeepReadonly}, so a nested `C` keeps both the
|
|
1806
|
+
* read-only guarantee and typed reads.
|
|
1774
1807
|
*
|
|
1775
|
-
* Two limits
|
|
1776
|
-
*
|
|
1777
|
-
*
|
|
1778
|
-
*
|
|
1808
|
+
* Two limits apply. A mutable body such as `FormData` or `URLSearchParams`
|
|
1809
|
+
* has mutating methods of its own that no type can block. JavaScript callers
|
|
1810
|
+
* get no enforcement at all. Both kinds of mutation are unsupported, and the
|
|
1811
|
+
* outgoing report may reflect them.
|
|
1779
1812
|
*
|
|
1780
|
-
* @typeParam C - The
|
|
1813
|
+
* @typeParam C - The type of the player's `customData`. Defaults to
|
|
1781
1814
|
* `Record<string, unknown>`.
|
|
1782
1815
|
*
|
|
1783
1816
|
* @public
|
|
@@ -1796,28 +1829,26 @@ type CmcdTransformRequest<C = Record<string, unknown>> = Readonly<Omit<HttpReque
|
|
|
1796
1829
|
//#endregion
|
|
1797
1830
|
//#region src/CmcdEventReportTransform.d.ts
|
|
1798
1831
|
/**
|
|
1799
|
-
* Transforms an event-mode CMCD report before
|
|
1800
|
-
* target.
|
|
1832
|
+
* Transforms an event-mode CMCD report before the reporter queues it for
|
|
1833
|
+
* its target.
|
|
1801
1834
|
*
|
|
1802
1835
|
* 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.
|
|
1836
|
+
* `data` argument is a per-target copy, so mutating it affects neither
|
|
1837
|
+
* the reporter's persistent data nor the reports for other targets.
|
|
1806
1838
|
*
|
|
1807
1839
|
* The `request` argument is the media request that triggered the event
|
|
1808
|
-
*
|
|
1840
|
+
* (for events recorded through
|
|
1809
1841
|
* {@link CmcdReporter.recordResponseReceived}), otherwise `undefined`.
|
|
1810
|
-
*
|
|
1811
|
-
*
|
|
1842
|
+
* The request is a read-only view for context only. A transform must
|
|
1843
|
+
* not mutate it. See {@link CmcdTransformRequest}.
|
|
1812
1844
|
*
|
|
1813
|
-
* The reporter
|
|
1814
|
-
*
|
|
1815
|
-
* overwritten.
|
|
1845
|
+
* The reporter rewrites `e` and `sid` and assigns `sn` and `msd` after this
|
|
1846
|
+
* function returns, so values written to those keys are overwritten.
|
|
1816
1847
|
*
|
|
1817
1848
|
* Must not throw. Exceptions propagate to the caller that recorded the
|
|
1818
|
-
* event
|
|
1849
|
+
* event. For time-interval events, that caller is the interval timer.
|
|
1819
1850
|
*
|
|
1820
|
-
* @typeParam C - The
|
|
1851
|
+
* @typeParam C - The type of the player's `customData` on the request.
|
|
1821
1852
|
* Defaults to `Record<string, unknown>`, whose values are
|
|
1822
1853
|
* `unknown` and read with bracket access.
|
|
1823
1854
|
*
|
|
@@ -1839,9 +1870,10 @@ type CmcdReportConfig = {
|
|
|
1839
1870
|
*/
|
|
1840
1871
|
version?: CmcdVersion;
|
|
1841
1872
|
/**
|
|
1842
|
-
* The list of CMCD keys to include in the report. If
|
|
1843
|
-
*
|
|
1844
|
-
*
|
|
1873
|
+
* The list of CMCD keys to include in the report. If omitted, no keys
|
|
1874
|
+
* are reported. In event mode, this list cannot remove `e`, `ts`, or the
|
|
1875
|
+
* required key of the event type. Examples of required keys: `sta` for a
|
|
1876
|
+
* play state change, `ec` for an error, `url` for a response received.
|
|
1845
1877
|
*
|
|
1846
1878
|
* @defaultValue `undefined`
|
|
1847
1879
|
*/
|
|
@@ -1852,33 +1884,33 @@ type CmcdReportConfig = {
|
|
|
1852
1884
|
/**
|
|
1853
1885
|
* Configuration for a CMCD event report.
|
|
1854
1886
|
*
|
|
1855
|
-
* @typeParam C - The
|
|
1887
|
+
* @typeParam C - The type of the player's `customData` on the request that
|
|
1856
1888
|
* triggered the event. Defaults to `Record<string, unknown>`.
|
|
1857
1889
|
*
|
|
1858
1890
|
* @public
|
|
1859
1891
|
*/
|
|
1860
1892
|
type CmcdEventReportConfig<C = Record<string, unknown>> = CmcdReportConfig & {
|
|
1861
1893
|
/**
|
|
1862
|
-
* The version of the CMCD protocol to use.
|
|
1863
|
-
* version 2
|
|
1894
|
+
* The version of the CMCD protocol to use. Event reporting
|
|
1895
|
+
* requires version 2.
|
|
1864
1896
|
*
|
|
1865
1897
|
* @defaultValue `CMCD_V2`
|
|
1866
1898
|
*/
|
|
1867
1899
|
version?: typeof CMCD_V2;
|
|
1868
1900
|
/**
|
|
1869
|
-
* The URL
|
|
1901
|
+
* The URL where the reporter sends CMCD event reports.
|
|
1870
1902
|
*/
|
|
1871
1903
|
url: string;
|
|
1872
1904
|
/**
|
|
1873
|
-
* The events to report. If no events
|
|
1874
|
-
* the event target
|
|
1905
|
+
* The events to report. If the caller provides no events,
|
|
1906
|
+
* the event target is effectively disabled.
|
|
1875
1907
|
*
|
|
1876
1908
|
* @defaultValue `undefined`
|
|
1877
1909
|
*/
|
|
1878
1910
|
events?: CmcdEventType[];
|
|
1879
1911
|
/**
|
|
1880
|
-
* When the time interval event is sent, the interval
|
|
1881
|
-
*
|
|
1912
|
+
* When the time interval event is sent, the interval in seconds at
|
|
1913
|
+
* which the reporter sends it.
|
|
1882
1914
|
*
|
|
1883
1915
|
* @defaultValue `CMCD_DEFAULT_TIME_INTERVAL`
|
|
1884
1916
|
*
|
|
@@ -1896,9 +1928,9 @@ type CmcdEventReportConfig<C = Record<string, unknown>> = CmcdReportConfig & {
|
|
|
1896
1928
|
* it is queued. Return the data to continue, or `null` to cancel
|
|
1897
1929
|
* the report for this target.
|
|
1898
1930
|
*
|
|
1899
|
-
*
|
|
1900
|
-
* each run their own transform
|
|
1901
|
-
* still
|
|
1931
|
+
* The transform is scoped to this target only. Targets that share a
|
|
1932
|
+
* collector URL each run their own transform. Other targets that
|
|
1933
|
+
* accept the event still receive a report cancelled by this transform.
|
|
1902
1934
|
*
|
|
1903
1935
|
* @defaultValue `undefined`
|
|
1904
1936
|
*
|
|
@@ -1942,29 +1974,29 @@ type CmcdHeaderValue = CmcdRequest | CmcdV1;
|
|
|
1942
1974
|
//#endregion
|
|
1943
1975
|
//#region src/CmcdRecordedReportMode.d.ts
|
|
1944
1976
|
/**
|
|
1945
|
-
* CMCD query reporting mode
|
|
1977
|
+
* CMCD query reporting mode: CMCD data transmitted as a `CMCD=` URL
|
|
1946
1978
|
* query parameter.
|
|
1947
1979
|
*
|
|
1948
1980
|
* @public
|
|
1949
1981
|
*/
|
|
1950
1982
|
declare const CMCD_RECORDED_REPORT_MODE_QUERY: "query";
|
|
1951
1983
|
/**
|
|
1952
|
-
* CMCD header reporting mode
|
|
1984
|
+
* CMCD header reporting mode: CMCD data transmitted as `CMCD-*` HTTP
|
|
1953
1985
|
* headers.
|
|
1954
1986
|
*
|
|
1955
1987
|
* @public
|
|
1956
1988
|
*/
|
|
1957
1989
|
declare const CMCD_RECORDED_REPORT_MODE_HEADER: "header";
|
|
1958
1990
|
/**
|
|
1959
|
-
* CMCD event reporting mode
|
|
1991
|
+
* CMCD event reporting mode: CMCD data transmitted as a POST body to an
|
|
1960
1992
|
* event-target URL.
|
|
1961
1993
|
*
|
|
1962
1994
|
* @public
|
|
1963
1995
|
*/
|
|
1964
1996
|
declare const CMCD_RECORDED_REPORT_MODE_EVENT: "event";
|
|
1965
1997
|
/**
|
|
1966
|
-
* Reporting mode
|
|
1967
|
-
*
|
|
1998
|
+
* Reporting mode in which `CmcdReportRecorder` observed a captured
|
|
1999
|
+
* report.
|
|
1968
2000
|
*
|
|
1969
2001
|
* @enum
|
|
1970
2002
|
*
|
|
@@ -2001,7 +2033,7 @@ declare const CMCD_RECORDED_REQUEST_TYPE_SEGMENT: "segment";
|
|
|
2001
2033
|
*/
|
|
2002
2034
|
declare const CMCD_RECORDED_REQUEST_TYPE_EVENT: "event";
|
|
2003
2035
|
/**
|
|
2004
|
-
*
|
|
2036
|
+
* Default classification for requests the recorder did not recognize
|
|
2005
2037
|
* as manifest, segment, or event.
|
|
2006
2038
|
*
|
|
2007
2039
|
* @public
|
|
@@ -2035,9 +2067,9 @@ type CmcdRecordedRequestType = ValueOf<typeof CmcdRecordedRequestType>;
|
|
|
2035
2067
|
*/
|
|
2036
2068
|
type CmcdRecordedReport = {
|
|
2037
2069
|
/**
|
|
2038
|
-
* The captured request that
|
|
2070
|
+
* The captured request that contained the CMCD report, normalized to
|
|
2039
2071
|
* {@link @svta/cml-utils!HttpRequest | HttpRequest}. Headers are
|
|
2040
|
-
* lowercase-keyed
|
|
2072
|
+
* lowercase-keyed. Bodies are eagerly read as strings.
|
|
2041
2073
|
*/
|
|
2042
2074
|
readonly request: HttpRequest;
|
|
2043
2075
|
/**
|
|
@@ -2045,8 +2077,8 @@ type CmcdRecordedReport = {
|
|
|
2045
2077
|
*/
|
|
2046
2078
|
readonly type: CmcdRecordedRequestType;
|
|
2047
2079
|
/**
|
|
2048
|
-
* Reporting mode under which the CMCD data was
|
|
2049
|
-
* `'query'` for `CMCD=` URL parameter, `'header'` for `
|
|
2080
|
+
* Reporting mode under which the CMCD data was transmitted:
|
|
2081
|
+
* `'query'` for `CMCD=` URL parameter, `'header'` for `CMCD-*`
|
|
2050
2082
|
* HTTP headers, `'event'` for an event-target POST body.
|
|
2051
2083
|
*/
|
|
2052
2084
|
readonly reportingMode: CmcdRecordedReportMode;
|
|
@@ -2059,12 +2091,12 @@ type CmcdRecordedReport = {
|
|
|
2059
2091
|
//#region src/CmcdTransportAdapter.d.ts
|
|
2060
2092
|
/**
|
|
2061
2093
|
* Callback the recorder supplies to a transport adapter. The adapter
|
|
2062
|
-
* calls
|
|
2094
|
+
* calls it once per intercepted request, with the request normalized
|
|
2063
2095
|
* to {@link @svta/cml-utils!HttpRequest | HttpRequest}.
|
|
2064
2096
|
*
|
|
2065
|
-
* If the callback returns a `Response`, the adapter must
|
|
2066
|
-
*
|
|
2067
|
-
*
|
|
2097
|
+
* If the callback returns a `Response`, the adapter must bypass the
|
|
2098
|
+
* transport. It must complete the request with that response (used for
|
|
2099
|
+
* event-target POST stubbing).
|
|
2068
2100
|
*
|
|
2069
2101
|
* If the callback returns `undefined`, the adapter forwards the request
|
|
2070
2102
|
* to the original transport unchanged.
|
|
@@ -2074,15 +2106,15 @@ type CmcdRecordedReport = {
|
|
|
2074
2106
|
type CmcdRequestDeliver = (request: HttpRequest) => Response | undefined;
|
|
2075
2107
|
/**
|
|
2076
2108
|
* Pluggable transport-interception contract for `CmcdReportRecorder`.
|
|
2077
|
-
* The default implementations
|
|
2109
|
+
* The default implementations, `createXhrTransport` and `createFetchTransport`,
|
|
2078
2110
|
* patch global `XMLHttpRequest` and `fetch`. Custom adapters can wrap
|
|
2079
|
-
* other transports
|
|
2111
|
+
* other transports, for example `undici` or a player-internal HTTP client.
|
|
2080
2112
|
*
|
|
2081
2113
|
* @public
|
|
2082
2114
|
*/
|
|
2083
2115
|
type CmcdTransportAdapter = {
|
|
2084
2116
|
/**
|
|
2085
|
-
* Install the transport
|
|
2117
|
+
* Install interception on the transport. Called once per
|
|
2086
2118
|
* recorder `attach()`. The adapter must normalize each outgoing
|
|
2087
2119
|
* request to `HttpRequest` (reading the body to a synchronous value
|
|
2088
2120
|
* if necessary) and invoke `deliver`. Returns a detach function that
|
|
@@ -2099,27 +2131,27 @@ type CmcdTransportAdapter = {
|
|
|
2099
2131
|
*/
|
|
2100
2132
|
type CmcdReportRecorderOptions = {
|
|
2101
2133
|
/**
|
|
2102
|
-
* URLs whose POST requests
|
|
2103
|
-
* synthetic 204 response
|
|
2104
|
-
*
|
|
2134
|
+
* URLs whose POST requests the recorder intercepts and answers with a
|
|
2135
|
+
* synthetic 204 response instead of sending them to the network. A
|
|
2136
|
+
* request matches if its URL starts with any entry.
|
|
2105
2137
|
*
|
|
2106
|
-
* Use this to verify CMCD event-mode reports without
|
|
2138
|
+
* Use this option to verify CMCD event-mode reports without real
|
|
2107
2139
|
* network calls to placeholder endpoints.
|
|
2108
2140
|
*/
|
|
2109
2141
|
eventTargetUrls?: readonly string[];
|
|
2110
2142
|
/**
|
|
2111
|
-
* Override the default
|
|
2143
|
+
* Override the default transport adapters. Defaults to
|
|
2112
2144
|
* `[createXhrTransport(), createFetchTransport()]`, which patches
|
|
2113
2145
|
* `XMLHttpRequest` and `fetch` on the current realm.
|
|
2114
2146
|
*
|
|
2115
|
-
*
|
|
2116
|
-
*
|
|
2147
|
+
* If the player under test uses a non-standard transport, for example
|
|
2148
|
+
* a custom HTTP client, supply this option.
|
|
2117
2149
|
*/
|
|
2118
2150
|
transports?: readonly CmcdTransportAdapter[];
|
|
2119
2151
|
/**
|
|
2120
2152
|
* Default timeout (in milliseconds) applied to every `waitFor*`
|
|
2121
|
-
* call on this recorder.
|
|
2122
|
-
*
|
|
2153
|
+
* call on this recorder. Each call can still pass an explicit
|
|
2154
|
+
* timeout to override this default.
|
|
2123
2155
|
*
|
|
2124
2156
|
* @defaultValue `15000`
|
|
2125
2157
|
*/
|
|
@@ -2128,13 +2160,13 @@ type CmcdReportRecorderOptions = {
|
|
|
2128
2160
|
* Called once for each captured CMCD report, immediately after it
|
|
2129
2161
|
* is appended to the buffer and before any pending `waitFor*`
|
|
2130
2162
|
* promises resolve. Use for live UI inspection in test harness
|
|
2131
|
-
* pages.
|
|
2132
|
-
* callback to a
|
|
2163
|
+
* pages. `detach()` clears the callback. To resume notification,
|
|
2164
|
+
* pass a new callback to a later `attach()`.
|
|
2133
2165
|
*
|
|
2134
2166
|
* The callback receives the same {@link CmcdRecordedReport}
|
|
2135
|
-
*
|
|
2136
|
-
* `report.reportingMode` inside the
|
|
2137
|
-
*
|
|
2167
|
+
* type that `getReports()` returns. If you only need a subset,
|
|
2168
|
+
* filter by `report.type` or `report.reportingMode` inside the
|
|
2169
|
+
* callback.
|
|
2138
2170
|
*
|
|
2139
2171
|
* @example
|
|
2140
2172
|
* {@includeCode ../test/CmcdReportRecorder.test.ts#example-on-report}
|
|
@@ -2157,8 +2189,8 @@ type CmcdReportRecorderWaitOptions = {
|
|
|
2157
2189
|
*/
|
|
2158
2190
|
count?: number;
|
|
2159
2191
|
/**
|
|
2160
|
-
* Maximum time to wait (in milliseconds) before rejecting.
|
|
2161
|
-
*
|
|
2192
|
+
* Maximum time to wait (in milliseconds) before rejecting. The
|
|
2193
|
+
* default is the recorder's `waitTimeout` attach option (15000 ms if
|
|
2162
2194
|
* unset).
|
|
2163
2195
|
*/
|
|
2164
2196
|
timeout?: number;
|
|
@@ -2166,10 +2198,10 @@ type CmcdReportRecorderWaitOptions = {
|
|
|
2166
2198
|
//#endregion
|
|
2167
2199
|
//#region src/CmcdReportRecorder.d.ts
|
|
2168
2200
|
/**
|
|
2169
|
-
* Test helper that records CMCD
|
|
2170
|
-
* transports for
|
|
2171
|
-
*
|
|
2172
|
-
* tests are identical regardless of which transport the player uses.
|
|
2201
|
+
* Test helper that records CMCD reports from the XHR and fetch
|
|
2202
|
+
* transports for assertions in e2e tests. The recorder normalizes each
|
|
2203
|
+
* captured request to {@link @svta/cml-utils!HttpRequest | HttpRequest},
|
|
2204
|
+
* so tests are identical regardless of which transport the player uses.
|
|
2173
2205
|
*
|
|
2174
2206
|
* @example
|
|
2175
2207
|
* {@includeCode ../test/CmcdReportRecorder.test.ts#example}
|
|
@@ -2179,11 +2211,11 @@ type CmcdReportRecorderWaitOptions = {
|
|
|
2179
2211
|
declare class CmcdReportRecorder {
|
|
2180
2212
|
#private;
|
|
2181
2213
|
/**
|
|
2182
|
-
* Install transport patches and
|
|
2183
|
-
*
|
|
2184
|
-
*
|
|
2185
|
-
*
|
|
2186
|
-
*
|
|
2214
|
+
* Install transport patches and start recording CMCD reports.
|
|
2215
|
+
* If the recorder is already attached, this call does nothing. The
|
|
2216
|
+
* recorder keeps the previous options and silently ignores the new
|
|
2217
|
+
* `options` argument. To re-attach with different options, call
|
|
2218
|
+
* `detach()` first.
|
|
2187
2219
|
*
|
|
2188
2220
|
* @public
|
|
2189
2221
|
*/
|
|
@@ -2202,15 +2234,15 @@ declare class CmcdReportRecorder {
|
|
|
2202
2234
|
*/
|
|
2203
2235
|
clear(): void;
|
|
2204
2236
|
/**
|
|
2205
|
-
* Return a
|
|
2237
|
+
* Return a copy of all recorded reports.
|
|
2206
2238
|
*
|
|
2207
2239
|
* @public
|
|
2208
2240
|
*/
|
|
2209
2241
|
getReports(): CmcdRecordedReport[];
|
|
2210
2242
|
/**
|
|
2211
2243
|
* Wait until at least `count` reports of any type are recorded.
|
|
2212
|
-
* Resolves with all matching reports
|
|
2213
|
-
* on timeout. `count` defaults to 1
|
|
2244
|
+
* Resolves with all matching reports. Rejects with a diagnostic error
|
|
2245
|
+
* on timeout. `count` defaults to 1. `timeout` defaults to the
|
|
2214
2246
|
* recorder's `waitTimeout` option (default 15000 ms).
|
|
2215
2247
|
*
|
|
2216
2248
|
* @public
|
|
@@ -2218,8 +2250,8 @@ declare class CmcdReportRecorder {
|
|
|
2218
2250
|
waitForReports(options?: CmcdReportRecorderWaitOptions): Promise<CmcdRecordedReport[]>;
|
|
2219
2251
|
/**
|
|
2220
2252
|
* Wait until at least `count` manifest reports are recorded.
|
|
2221
|
-
* Resolves with all matching reports
|
|
2222
|
-
* on timeout. `count` defaults to 1
|
|
2253
|
+
* Resolves with all matching reports. Rejects with a diagnostic error
|
|
2254
|
+
* on timeout. `count` defaults to 1. `timeout` defaults to the
|
|
2223
2255
|
* recorder's `waitTimeout` option (default 15000 ms).
|
|
2224
2256
|
*
|
|
2225
2257
|
* @public
|
|
@@ -2227,8 +2259,8 @@ declare class CmcdReportRecorder {
|
|
|
2227
2259
|
waitForManifest(options?: CmcdReportRecorderWaitOptions): Promise<CmcdRecordedReport[]>;
|
|
2228
2260
|
/**
|
|
2229
2261
|
* Wait until at least `count` segment reports are recorded.
|
|
2230
|
-
* Resolves with all matching reports
|
|
2231
|
-
* on timeout. `count` defaults to 1
|
|
2262
|
+
* Resolves with all matching reports. Rejects with a diagnostic error
|
|
2263
|
+
* on timeout. `count` defaults to 1. `timeout` defaults to the
|
|
2232
2264
|
* recorder's `waitTimeout` option (default 15000 ms).
|
|
2233
2265
|
*
|
|
2234
2266
|
* @public
|
|
@@ -2236,8 +2268,8 @@ declare class CmcdReportRecorder {
|
|
|
2236
2268
|
waitForSegments(options?: CmcdReportRecorderWaitOptions): Promise<CmcdRecordedReport[]>;
|
|
2237
2269
|
/**
|
|
2238
2270
|
* Wait until at least `count` event-mode reports are recorded.
|
|
2239
|
-
* Resolves with all matching reports
|
|
2240
|
-
* on timeout. `count` defaults to 1
|
|
2271
|
+
* Resolves with all matching reports. Rejects with a diagnostic error
|
|
2272
|
+
* on timeout. `count` defaults to 1. `timeout` defaults to the
|
|
2241
2273
|
* recorder's `waitTimeout` option (default 15000 ms).
|
|
2242
2274
|
*
|
|
2243
2275
|
* @public
|
|
@@ -2255,15 +2287,15 @@ declare class CmcdReportRecorder {
|
|
|
2255
2287
|
* mutating it in place never affects the reporter's persistent data.
|
|
2256
2288
|
* The `request` argument is the request passed to
|
|
2257
2289
|
* `createRequestReport()`, as a read-only view. It is context only and
|
|
2258
|
-
* must not be mutated
|
|
2290
|
+
* must not be mutated. See {@link CmcdTransformRequest}.
|
|
2259
2291
|
*
|
|
2260
|
-
* The reporter
|
|
2292
|
+
* The reporter rewrites `sid` and assigns `sn` and `msd` after this
|
|
2261
2293
|
* function returns, so values written to those keys are overwritten.
|
|
2262
2294
|
*
|
|
2263
2295
|
* Must not throw. Exceptions propagate to the `createRequestReport()`
|
|
2264
2296
|
* caller.
|
|
2265
2297
|
*
|
|
2266
|
-
* @typeParam C - The
|
|
2298
|
+
* @typeParam C - The type of the player's `customData` on the request.
|
|
2267
2299
|
* Defaults to `Record<string, unknown>`, whose values are
|
|
2268
2300
|
* `unknown` and read with bracket access.
|
|
2269
2301
|
*
|
|
@@ -2324,7 +2356,7 @@ type CmcdTransmissionMode = ValueOf<typeof CmcdTransmissionMode>;
|
|
|
2324
2356
|
/**
|
|
2325
2357
|
* Configuration for a CMCD request report.
|
|
2326
2358
|
*
|
|
2327
|
-
* @typeParam C - The
|
|
2359
|
+
* @typeParam C - The type of the player's `customData` on the requests
|
|
2328
2360
|
* passed to {@link CmcdReporter.createRequestReport}.
|
|
2329
2361
|
* Defaults to `Record<string, unknown>`.
|
|
2330
2362
|
*
|
|
@@ -2338,12 +2370,12 @@ type CmcdRequestReportConfig<C = Record<string, unknown>> = CmcdReportConfig & {
|
|
|
2338
2370
|
*/
|
|
2339
2371
|
transmissionMode?: CmcdTransmissionMode;
|
|
2340
2372
|
/**
|
|
2341
|
-
* A map of CMCD header fields to the custom keys
|
|
2342
|
-
*
|
|
2373
|
+
* A map of CMCD header fields to the custom keys to emit in them.
|
|
2374
|
+
* Applies when the transmission mode is
|
|
2343
2375
|
* `CmcdTransmissionMode.HEADERS`. Custom keys not listed in any
|
|
2344
2376
|
* shard are emitted in the `CMCD-Request` header. Standard keys
|
|
2345
2377
|
* have fixed shards per the CMCD specification and cannot be
|
|
2346
|
-
*
|
|
2378
|
+
* moved. Has no effect in query transmission mode or on event
|
|
2347
2379
|
* reports.
|
|
2348
2380
|
*
|
|
2349
2381
|
* @defaultValue `undefined`
|
|
@@ -2370,16 +2402,16 @@ type CmcdRequestReportConfig<C = Record<string, unknown>> = CmcdReportConfig & {
|
|
|
2370
2402
|
/**
|
|
2371
2403
|
* Configuration for a CMCD reporting component.
|
|
2372
2404
|
*
|
|
2373
|
-
* @typeParam C - The
|
|
2374
|
-
* reporter
|
|
2375
|
-
*
|
|
2405
|
+
* @typeParam C - The type of the player's `customData` on the requests this
|
|
2406
|
+
* reporter receives. If one `transform` is annotated, the rest
|
|
2407
|
+
* of the configuration infers the type. Defaults to
|
|
2376
2408
|
* `Record<string, unknown>`.
|
|
2377
2409
|
*
|
|
2378
2410
|
* @public
|
|
2379
2411
|
*/
|
|
2380
2412
|
type CmcdReporterConfig<C = Record<string, unknown>> = CmcdRequestReportConfig<C> & {
|
|
2381
2413
|
/**
|
|
2382
|
-
* The session ID. If
|
|
2414
|
+
* The session ID. If omitted, the reporter generates a new random session ID.
|
|
2383
2415
|
*
|
|
2384
2416
|
* @defaultValue `undefined`
|
|
2385
2417
|
*/
|
|
@@ -2391,7 +2423,7 @@ type CmcdReporterConfig<C = Record<string, unknown>> = CmcdRequestReportConfig<C
|
|
|
2391
2423
|
*/
|
|
2392
2424
|
cid?: string;
|
|
2393
2425
|
/**
|
|
2394
|
-
* The event configurations. If
|
|
2426
|
+
* The event configurations. If omitted, no events are reported.
|
|
2395
2427
|
*
|
|
2396
2428
|
* @defaultValue `undefined`
|
|
2397
2429
|
*/
|
|
@@ -2400,10 +2432,11 @@ type CmcdReporterConfig<C = Record<string, unknown>> = CmcdRequestReportConfig<C
|
|
|
2400
2432
|
* The number of ended sessions the reporter retains state for, in
|
|
2401
2433
|
* addition to the current one. Retained sessions let a response that
|
|
2402
2434
|
* 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
|
|
2435
|
+
* its request. The report uses that session's data snapshot and
|
|
2436
|
+
* sequence numbers. `0` retains nothing, so stale responses are
|
|
2437
|
+
* dropped. `Infinity` never evicts, which also retains every session's
|
|
2438
|
+
* unsent report queues. Numbers are floored. Every other input uses
|
|
2439
|
+
* the default.
|
|
2407
2440
|
*
|
|
2408
2441
|
* @defaultValue 2
|
|
2409
2442
|
*/
|
|
@@ -2415,11 +2448,11 @@ type CmcdReporterConfig<C = Record<string, unknown>> = CmcdRequestReportConfig<C
|
|
|
2415
2448
|
* The `customData` a {@link CmcdReporter} method accepts, for a reporter typed
|
|
2416
2449
|
* `C`.
|
|
2417
2450
|
*
|
|
2418
|
-
* A reporter
|
|
2419
|
-
*
|
|
2420
|
-
*
|
|
2421
|
-
*
|
|
2422
|
-
*
|
|
2451
|
+
* A reporter with the default `C` constrains nothing, so requests with any
|
|
2452
|
+
* `customData` are accepted exactly as before `C` existed. A reporter with a
|
|
2453
|
+
* concrete `C` requires the request to satisfy it. The reporter's transforms
|
|
2454
|
+
* read `customData` as `C` and would otherwise receive a value their type
|
|
2455
|
+
* does not describe.
|
|
2423
2456
|
*
|
|
2424
2457
|
* @typeParam C - The reporter's `customData` type.
|
|
2425
2458
|
*
|
|
@@ -2429,33 +2462,34 @@ type CmcdReporterCustomData<C> = Record<string, unknown> extends C ? any : C;
|
|
|
2429
2462
|
//#endregion
|
|
2430
2463
|
//#region src/CmcdRequestProvenance.d.ts
|
|
2431
2464
|
/**
|
|
2432
|
-
* The session-provenance record `CmcdReporter.createRequestReport()`
|
|
2433
|
-
*
|
|
2465
|
+
* The session-provenance record `CmcdReporter.createRequestReport()` writes
|
|
2466
|
+
* to `customData` under `CMCD_REQUEST_PROVENANCE`.
|
|
2434
2467
|
*
|
|
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
|
-
*
|
|
2468
|
+
* `sid` names the session that issued the request.
|
|
2469
|
+
* `CmcdReporter.recordResponseReceived()` matches `sid` against the
|
|
2470
|
+
* reporter's retained sessions by value, never by object identity. A record
|
|
2471
|
+
* copy restored from JSON attributes the response to the same
|
|
2472
|
+
* session. Session identity depends on the caller's own `sid` values, which
|
|
2473
|
+
* CTA-5004-B expects to be unique per playback session. Reusing a `sid`
|
|
2474
|
+
* replaces the retained session with that `sid`. The reporter then
|
|
2475
|
+
* attributes late responses of the replaced session to the replacement.
|
|
2443
2476
|
*
|
|
2444
|
-
* `cid` is the content id
|
|
2445
|
-
* `RESPONSE_RECEIVED` event reports
|
|
2446
|
-
* `cid
|
|
2447
|
-
*
|
|
2477
|
+
* `cid` is the content id at the time the reporter created the record. A
|
|
2478
|
+
* `RESPONSE_RECEIVED` event reports this `cid` instead of the session's
|
|
2479
|
+
* current `cid`. A response that completes after a content change
|
|
2480
|
+
* keeps the content id of its request.
|
|
2448
2481
|
*
|
|
2449
2482
|
* `data` is the per-call data the request was created with, encoded as a
|
|
2450
2483
|
* 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.
|
|
2484
|
+
* keys for a `RESPONSE_RECEIVED` event. Any copy of the record
|
|
2485
|
+
* contains the caller's inputs. The reporter captures `data` before the
|
|
2486
|
+
* request `transform` and key filter run. `data` is also present
|
|
2487
|
+
* on requests the reporter does not decorate.
|
|
2455
2488
|
*
|
|
2456
|
-
* The reporter freezes every record it
|
|
2457
|
-
* a hand-built request may
|
|
2458
|
-
*
|
|
2489
|
+
* The reporter freezes every record it creates. The record is constructible:
|
|
2490
|
+
* a hand-built request may include `{ sid }` to attribute the request to
|
|
2491
|
+
* that session. The reporter drops the response when the record names a
|
|
2492
|
+
* `sid` it does not retain.
|
|
2459
2493
|
*
|
|
2460
2494
|
* @public
|
|
2461
2495
|
*/
|
|
@@ -2469,9 +2503,9 @@ type CmcdRequestProvenance = {
|
|
|
2469
2503
|
/**
|
|
2470
2504
|
* A report of a CMCD request.
|
|
2471
2505
|
*
|
|
2472
|
-
* The provenance member is optional so
|
|
2473
|
-
*
|
|
2474
|
-
* `CmcdReporter.createRequestReport()`
|
|
2506
|
+
* The provenance member is optional so callers that build or mock request
|
|
2507
|
+
* reports can construct the type. Every request returned by
|
|
2508
|
+
* `CmcdReporter.createRequestReport()` includes the member.
|
|
2475
2509
|
*
|
|
2476
2510
|
* @public
|
|
2477
2511
|
*/
|
|
@@ -2487,12 +2521,12 @@ type CmcdRequestReport<D = unknown> = HttpRequest & {
|
|
|
2487
2521
|
/**
|
|
2488
2522
|
* The CMCD reporter.
|
|
2489
2523
|
*
|
|
2490
|
-
* `C` describes the player's own `customData`, which the reporter passes
|
|
2491
|
-
*
|
|
2492
|
-
*
|
|
2493
|
-
*
|
|
2524
|
+
* `C` describes the player's own `customData`, which the reporter passes to
|
|
2525
|
+
* each configured `transform`. TypeScript infers `C` from the configuration,
|
|
2526
|
+
* so an annotation on one `transform` types the request in every other
|
|
2527
|
+
* `transform`. The default leaves `customData` values `unknown`.
|
|
2494
2528
|
*
|
|
2495
|
-
* @typeParam C - The
|
|
2529
|
+
* @typeParam C - The type of the player's `customData`. Defaults to
|
|
2496
2530
|
* `Record<string, unknown>`.
|
|
2497
2531
|
*
|
|
2498
2532
|
* @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 +2537,18 @@ declare class CmcdReporter<C = Record<string, unknown>> {
|
|
|
2503
2537
|
private timeOrigin;
|
|
2504
2538
|
private config;
|
|
2505
2539
|
/**
|
|
2506
|
-
* Retained sessions keyed by `sid`, insertion
|
|
2507
|
-
* current session last.
|
|
2508
|
-
*
|
|
2509
|
-
*
|
|
2510
|
-
*
|
|
2540
|
+
* Retained sessions keyed by `sid`, in insertion order: oldest first,
|
|
2541
|
+
* current session last. `config.sessionRetention` limits the ended-session
|
|
2542
|
+
* count. CTA-5004-B expects a `sid` to be unique per playback session. A
|
|
2543
|
+
* reused `sid` replaces the earlier session with that `sid` at the newest
|
|
2544
|
+
* position (see `startSession()`).
|
|
2511
2545
|
*/
|
|
2512
2546
|
private sessions;
|
|
2513
2547
|
private session;
|
|
2514
2548
|
/**
|
|
2515
|
-
*
|
|
2516
|
-
* changes (their callbacks report into whichever session is
|
|
2517
|
-
* fire
|
|
2549
|
+
* Active time-interval timers by target config. Timers continue across
|
|
2550
|
+
* session changes (their callbacks report into whichever session is
|
|
2551
|
+
* current when they fire), so the reporter owns them, not the session.
|
|
2518
2552
|
*/
|
|
2519
2553
|
private intervals;
|
|
2520
2554
|
private started;
|
|
@@ -2523,7 +2557,7 @@ declare class CmcdReporter<C = Record<string, unknown>> {
|
|
|
2523
2557
|
* Creates a new CMCD reporter.
|
|
2524
2558
|
*
|
|
2525
2559
|
* @param config - The configuration for the CMCD reporter.
|
|
2526
|
-
* @param requester - The function
|
|
2560
|
+
* @param requester - The function that sends the request.
|
|
2527
2561
|
* The default is a simple wrapper around the
|
|
2528
2562
|
* native `fetch` API.
|
|
2529
2563
|
*/
|
|
@@ -2531,170 +2565,176 @@ declare class CmcdReporter<C = Record<string, unknown>> {
|
|
|
2531
2565
|
status: number;
|
|
2532
2566
|
}>);
|
|
2533
2567
|
/**
|
|
2534
|
-
* Creates the state for a new session:
|
|
2535
|
-
*
|
|
2568
|
+
* Creates the state for a new session: initial counters, flags, queues, and
|
|
2569
|
+
* deduplication baseline for every configured target.
|
|
2536
2570
|
*/
|
|
2537
2571
|
private createSession;
|
|
2538
2572
|
/**
|
|
2539
|
-
* Starts the CMCD reporter.
|
|
2573
|
+
* Starts the CMCD reporter. The player calls this method when it enables the
|
|
2574
|
+
* reporter.
|
|
2540
2575
|
*
|
|
2541
|
-
*
|
|
2542
|
-
* before the first interval elapses.
|
|
2543
|
-
*
|
|
2576
|
+
* This method fires an initial time-interval event immediately (synchronously),
|
|
2577
|
+
* before the first interval elapses. Populate the CMCD data (sid, cid, and
|
|
2578
|
+
* others) before calling start().
|
|
2544
2579
|
*/
|
|
2545
2580
|
start(): void;
|
|
2546
2581
|
/**
|
|
2547
|
-
*
|
|
2548
|
-
*
|
|
2549
|
-
* whichever session is current when
|
|
2582
|
+
* Starts the time-interval timer for an event target when its config
|
|
2583
|
+
* requires one. Returns whether a timer started. The callback reports into
|
|
2584
|
+
* whichever session is current when the timer fires.
|
|
2550
2585
|
*/
|
|
2551
2586
|
private armInterval;
|
|
2552
2587
|
/**
|
|
2553
|
-
* Stops the CMCD reporter.
|
|
2588
|
+
* Stops the CMCD reporter. The player calls this method when it disables the
|
|
2589
|
+
* reporter.
|
|
2554
2590
|
*
|
|
2555
2591
|
* @param flush - Whether to flush the event targets.
|
|
2556
2592
|
*/
|
|
2557
2593
|
stop(flush?: boolean): void;
|
|
2558
2594
|
/**
|
|
2559
|
-
*
|
|
2560
|
-
*
|
|
2595
|
+
* Sends all outstanding event reports, regardless of the batch size or
|
|
2596
|
+
* interval. Use this method when the player is destroyed or a playback
|
|
2561
2597
|
* session ends.
|
|
2562
2598
|
*/
|
|
2563
2599
|
flush(): void;
|
|
2564
2600
|
/**
|
|
2565
2601
|
* Updates the CMCD data.
|
|
2566
2602
|
*
|
|
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
|
-
*
|
|
2593
|
-
*
|
|
2603
|
+
* The player calls this method when data changes. The tracked state fields
|
|
2604
|
+
* are `sta`, `pr`, `cid`, `bg`, and `br`. If a new value for one of them
|
|
2605
|
+
* differs from the last reported value for that field, the reporter fires
|
|
2606
|
+
* the matching state-change event. The comparison uses the last reported
|
|
2607
|
+
* value, not the previous persisted value. The first state-change event in
|
|
2608
|
+
* a new session therefore always fires, even when the persisted value did
|
|
2609
|
+
* not change across the `sid` boundary.
|
|
2610
|
+
*
|
|
2611
|
+
* The `bg` field is an exception. A session that does not start with
|
|
2612
|
+
* `bg: true` begins with `false` as its last reported `bg` value.
|
|
2613
|
+
* `bg: false` therefore fires `BACKGROUNDED_MODE` only if the session
|
|
2614
|
+
* started with `bg: true` or reported `bg: true`. CTA-5004-B defines a
|
|
2615
|
+
* `b` event without `bg` as the exit from backgrounded mode, so the exit
|
|
2616
|
+
* report does not carry `bg`. A target transform can add `bg: false` to
|
|
2617
|
+
* the exit report. The encoder writes that value as `?0`.
|
|
2618
|
+
*
|
|
2619
|
+
* Multi-field updates fire the events in this order: `sta`, `pr`, `cid`,
|
|
2620
|
+
* `bg`, `br`. The order of keys in the input object does not affect the
|
|
2621
|
+
* firing order.
|
|
2622
|
+
*
|
|
2623
|
+
* A state-change event can include context fields, for example `bl`, `mtp`,
|
|
2624
|
+
* `pt`, `ltc`. Those fields must be in the data store before the state field
|
|
2625
|
+
* changes. Either pass them with the state field in the same `update()`
|
|
2626
|
+
* call, or persist them with earlier `update()` calls. An auto-fired event
|
|
2627
|
+
* reports the current content of the data store. `TIME_INTERVAL` events also
|
|
2628
|
+
* read the data store, and the caller cannot add per-call data to them. The
|
|
2629
|
+
* player must therefore update the fields it wants in periodic reports with
|
|
2630
|
+
* this method.
|
|
2631
|
+
*
|
|
2632
|
+
* A `sid` change resets the deduplication baseline.
|
|
2633
|
+
*
|
|
2634
|
+
* `sid` and `msd` are session-owned. The reporter tracks them itself and
|
|
2635
|
+
* writes them into every outgoing report, so this method is the only way
|
|
2594
2636
|
* to change them. A per-call value on {@link CmcdReporter.recordEvent},
|
|
2595
2637
|
* {@link CmcdReporter.createRequestReport}, or
|
|
2596
|
-
* {@link CmcdReporter.recordResponseReceived} has no effect
|
|
2597
|
-
* attribution is by the provenance record alone.
|
|
2638
|
+
* {@link CmcdReporter.recordResponseReceived} has no effect.
|
|
2598
2639
|
* `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
|
|
2640
|
+
* `999_999_999_999_999` (the RFC 8941 integer maximum). The reporter
|
|
2641
|
+
* rounds `msd` to the nearest integer and ignores invalid values.
|
|
2601
2642
|
*
|
|
2602
2643
|
* @param data - The data to update.
|
|
2603
2644
|
*/
|
|
2604
2645
|
update(data: Partial<Cmcd>): void;
|
|
2605
2646
|
/**
|
|
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
|
-
*
|
|
2647
|
+
* Starts a new session. The reporter retains the current session for late
|
|
2648
|
+
* responses and creates a new current session. It then sends the ended
|
|
2649
|
+
* sessions' queued reports and removes the oldest sessions beyond the
|
|
2650
|
+
* configured retention.
|
|
2651
|
+
*
|
|
2652
|
+
* The ended session's snapshot is frozen: the reporter detaches its value
|
|
2653
|
+
* graph, so nested values from earlier `update()` calls cannot mutate the
|
|
2654
|
+
* snapshot. The new session starts from a shallow copy of that graph, which
|
|
2655
|
+
* preserves the data store. All fields, including `cid`, `br`, and custom
|
|
2656
|
+
* keys, survive a `sid` change as before. CTA-5004-B expects a `sid` to be
|
|
2657
|
+
* unique per playback session, so a reused `sid` replaces the retained
|
|
2658
|
+
* session with that `sid`. The replaced session's remaining state is lost,
|
|
2659
|
+
* as if removed, and the reporter attributes its late responses to the
|
|
2660
|
+
* replacement.
|
|
2619
2661
|
*/
|
|
2620
2662
|
private startSession;
|
|
2621
2663
|
/**
|
|
2622
|
-
* Records an event.
|
|
2664
|
+
* Records an event. The player calls this method when an event occurs.
|
|
2623
2665
|
*
|
|
2624
2666
|
* For state-change events (`PLAY_STATE`, `PLAYBACK_RATE`, `CONTENT_ID`,
|
|
2625
2667
|
* `BACKGROUNDED_MODE`, `BITRATE_CHANGE`), this method:
|
|
2626
|
-
* 1.
|
|
2627
|
-
*
|
|
2628
|
-
* 2.
|
|
2629
|
-
*
|
|
2630
|
-
*
|
|
2631
|
-
*
|
|
2632
|
-
*
|
|
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.
|
|
2668
|
+
* 1. Writes the state field from `data` (if present) into the reporter's
|
|
2669
|
+
* data store, as `update()` would.
|
|
2670
|
+
* 2. Discards the event if the state field has no value after that write
|
|
2671
|
+
* (never set, or cleared with `update({ field: undefined })`).
|
|
2672
|
+
* 3. Suppresses the event if the field's current value equals the
|
|
2673
|
+
* last reported value (no state transition). {@link CmcdReporter.update}
|
|
2674
|
+
* describes the `bg` value that a new session starts with.
|
|
2675
|
+
*
|
|
2676
|
+
* The reporter always records all other event types.
|
|
2677
|
+
*
|
|
2678
|
+
* For state-change events, prefer {@link CmcdReporter.update}, also for
|
|
2679
|
+
* context fields in a combined call like
|
|
2680
|
+
* `update({ sta: 'p', bl: [3000], mtp: [8500] })`. After `update()`
|
|
2681
|
+
* auto-fires a state-change event, deduplication suppresses a
|
|
2682
|
+
* `recordEvent()` call for the same event, and that call's `data` is
|
|
2683
|
+
* silently lost.
|
|
2684
|
+
*
|
|
2685
|
+
* Call `recordEvent()` directly for events whose data comes with the event
|
|
2686
|
+
* call. Examples: `CUSTOM_EVENT` with `cen`, `ERROR` with `ec`, ad lifecycle
|
|
2687
|
+
* events, `MUTE`/`UNMUTE`, `PLAYER_EXPAND`/`PLAYER_COLLAPSE`, `SKIP`. For
|
|
2688
|
+
* `RESPONSE_RECEIVED`, prefer {@link CmcdReporter.recordResponseReceived},
|
|
2689
|
+
* which derives the per-response fields automatically.
|
|
2649
2690
|
*
|
|
2650
2691
|
* @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.
|
|
2692
|
+
* @param data - Additional data to record with the event. This data applies
|
|
2693
|
+
* only to this event report. The exception is the state field
|
|
2694
|
+
* of a state-change event, which the reporter also writes into
|
|
2695
|
+
* its data store. The reporter ignores session-owned keys
|
|
2696
|
+
* (`sid`, `msd`) supplied here and writes its own values.
|
|
2657
2697
|
*/
|
|
2658
2698
|
recordEvent(type: CmcdEventType, data?: Partial<Cmcd>): void;
|
|
2659
2699
|
/**
|
|
2660
|
-
* Records an event
|
|
2661
|
-
*
|
|
2700
|
+
* Records an event for every configured target of a session. State-change
|
|
2701
|
+
* deduplication runs once, before the per-target loop.
|
|
2662
2702
|
*
|
|
2663
2703
|
* @param session - The session the event belongs to. Everything the event
|
|
2664
|
-
* touches (data store,
|
|
2665
|
-
* is that session's
|
|
2666
|
-
* passes an
|
|
2704
|
+
* touches (data store, deduplication baseline, counters,
|
|
2705
|
+
* queues) is that session's. Only `recordResponseReceived()`
|
|
2706
|
+
* ever passes an ended session.
|
|
2667
2707
|
* @param type - The type of event to record.
|
|
2668
2708
|
* @param data - Additional data to record with the event.
|
|
2669
2709
|
* @param request - The media request that triggered the event, when
|
|
2670
|
-
* one exists. Only `recordResponseReceived()`
|
|
2671
|
-
*
|
|
2672
|
-
*
|
|
2710
|
+
* one exists. Only `recordResponseReceived()` sets this
|
|
2711
|
+
* parameter, which the reporter passes to each target's
|
|
2712
|
+
* `transform`.
|
|
2673
2713
|
*/
|
|
2674
2714
|
private emitEvent;
|
|
2675
2715
|
/**
|
|
2676
|
-
* Records an event for a target.
|
|
2716
|
+
* Records an event for a target. The reporter calls this method when an
|
|
2717
|
+
* event occurs.
|
|
2677
2718
|
*
|
|
2678
2719
|
* @param target - The target to record the event for.
|
|
2679
2720
|
* @param config - The configuration for the target.
|
|
2680
2721
|
* @param type - The type of event to record.
|
|
2681
2722
|
* @param data - Additional data to record with the event. This data
|
|
2682
|
-
* only applies to this event report.
|
|
2683
|
-
*
|
|
2723
|
+
* only applies to this event report. Use `update()` for
|
|
2724
|
+
* persistent data.
|
|
2684
2725
|
* @param request - The media request that triggered the event, when
|
|
2685
|
-
* one exists.
|
|
2726
|
+
* one exists. The target's `transform` receives it.
|
|
2686
2727
|
*/
|
|
2687
2728
|
private recordTargetEvent;
|
|
2688
2729
|
/**
|
|
2689
|
-
*
|
|
2690
|
-
* and pushes the
|
|
2730
|
+
* Writes the reporter-owned fields into a finished event report, encodes
|
|
2731
|
+
* the report, and pushes the encoded line to the target's queue.
|
|
2691
2732
|
*
|
|
2692
|
-
*
|
|
2693
|
-
* target's `events` filter
|
|
2694
|
-
* the session identity
|
|
2695
|
-
*
|
|
2696
|
-
*
|
|
2697
|
-
* forever.
|
|
2733
|
+
* This method runs after any transform. A transform cannot bypass the
|
|
2734
|
+
* target's `events` filter through `e`, break `sn` continuity, or replace
|
|
2735
|
+
* the session identity in `sid` and `msd`. Encoding here makes a report
|
|
2736
|
+
* that cannot serialize throw inside the recording call, instead of failing
|
|
2737
|
+
* the batch send and re-queueing forever.
|
|
2698
2738
|
*
|
|
2699
2739
|
* @param target - The target to queue the report for.
|
|
2700
2740
|
* @param config - The configuration for the target.
|
|
@@ -2703,10 +2743,10 @@ declare class CmcdReporter<C = Record<string, unknown>> {
|
|
|
2703
2743
|
*/
|
|
2704
2744
|
private queueTargetEvent;
|
|
2705
2745
|
/**
|
|
2706
|
-
* Records a response-received event.
|
|
2707
|
-
* request response has
|
|
2746
|
+
* Records a response-received event. The player calls this method when a
|
|
2747
|
+
* media request response has fully arrived.
|
|
2708
2748
|
*
|
|
2709
|
-
* This method
|
|
2749
|
+
* This method derives these `rr` event keys automatically:
|
|
2710
2750
|
*
|
|
2711
2751
|
* - `url` - the original requested URL (before any redirects)
|
|
2712
2752
|
* - `rc` - the HTTP response status code
|
|
@@ -2714,68 +2754,65 @@ declare class CmcdReporter<C = Record<string, unknown>> {
|
|
|
2714
2754
|
* - `ttfb` - time to first byte (from `resourceTiming.responseStart`)
|
|
2715
2755
|
* - `ttlb` - time to last byte (from `resourceTiming.duration`)
|
|
2716
2756
|
*
|
|
2717
|
-
*
|
|
2718
|
-
*
|
|
2719
|
-
*
|
|
2720
|
-
* The request's `customData` is generic, so a player can pass a request
|
|
2721
|
-
*
|
|
2722
|
-
*
|
|
2723
|
-
* {@link CmcdReporter.createRequestReport} writes there
|
|
2724
|
-
*
|
|
2725
|
-
*
|
|
2726
|
-
*
|
|
2727
|
-
* A reporter
|
|
2728
|
-
*
|
|
2729
|
-
*
|
|
2730
|
-
*
|
|
2731
|
-
* The
|
|
2732
|
-
*
|
|
2733
|
-
* {@link
|
|
2734
|
-
*
|
|
2735
|
-
*
|
|
2736
|
-
*
|
|
2737
|
-
*
|
|
2738
|
-
*
|
|
2739
|
-
*
|
|
2740
|
-
*
|
|
2741
|
-
* `sid`
|
|
2742
|
-
*
|
|
2743
|
-
*
|
|
2744
|
-
*
|
|
2745
|
-
*
|
|
2746
|
-
*
|
|
2747
|
-
*
|
|
2748
|
-
*
|
|
2749
|
-
*
|
|
2750
|
-
*
|
|
2751
|
-
* had when its request was issued.
|
|
2752
|
-
*
|
|
2753
|
-
* @typeParam RD - The `customData` this request carries. Defaults to the
|
|
2757
|
+
* If the player has additional keys like `ttfbb`, `cmsdd`, `cmsds`, and
|
|
2758
|
+
* `smrt`, pass them in the `data` parameter.
|
|
2759
|
+
*
|
|
2760
|
+
* The request's `customData` is generic, so a player can pass a request with
|
|
2761
|
+
* its own keys (for example `{ requestType: 'segment' }`) without a cast. The
|
|
2762
|
+
* reporter reads only the provenance record that
|
|
2763
|
+
* {@link CmcdReporter.createRequestReport} writes there. Every other key
|
|
2764
|
+
* stays unchanged and visible to an event target's `transform` through its
|
|
2765
|
+
* `request` argument.
|
|
2766
|
+
*
|
|
2767
|
+
* A reporter with a concrete `C` requires the request to satisfy that type.
|
|
2768
|
+
* TypeScript therefore rejects a call whose request the configured
|
|
2769
|
+
* transforms could not read. See {@link CmcdReporterCustomData}.
|
|
2770
|
+
*
|
|
2771
|
+
* The provenance record that {@link CmcdReporter.createRequestReport}
|
|
2772
|
+
* stored on the request's `customData` (under
|
|
2773
|
+
* {@link CMCD_REQUEST_PROVENANCE}) selects the session by `sid`. A record
|
|
2774
|
+
* that names no retained session drops the response (see
|
|
2775
|
+
* `CmcdReporterConfig.sessionRetention`). A request without a record reports
|
|
2776
|
+
* under the current session, as in version 2.4.0. The request-time data then
|
|
2777
|
+
* comes from `customData.cmcd`. A per-call `data.sid` cannot substitute. The
|
|
2778
|
+
* reporter accepts any record whose `sid` names a retained session. The
|
|
2779
|
+
* record may come from another reporter with the same session attributes,
|
|
2780
|
+
* or be hand-built. If the request has a record, a response that completes
|
|
2781
|
+
* after a `sid` change reports under its own retained session, with that
|
|
2782
|
+
* session's data snapshot and sequence numbers.
|
|
2783
|
+
*
|
|
2784
|
+
* With a record, request-time report keys come from the record's encoded
|
|
2785
|
+
* per-call `data` snapshot, which the reporter decodes for each response.
|
|
2786
|
+
* The record's `cid` replaces the session's current `cid` in the report. A
|
|
2787
|
+
* response that completes after a mid-session content change therefore
|
|
2788
|
+
* reports its request-time values.
|
|
2789
|
+
*
|
|
2790
|
+
* @typeParam RD - The `customData` of this request. Defaults to the
|
|
2754
2791
|
* reporter's own `C`.
|
|
2755
2792
|
*
|
|
2756
2793
|
* @param response - The HTTP response received.
|
|
2757
2794
|
* @param data - Additional CMCD data to include with the event.
|
|
2758
|
-
* Values provided here override
|
|
2759
|
-
*
|
|
2760
|
-
*
|
|
2795
|
+
* Values provided here override the derived values.
|
|
2796
|
+
* The reporter ignores session-owned keys (`sid`, `msd`)
|
|
2797
|
+
* supplied here.
|
|
2761
2798
|
*/
|
|
2762
2799
|
recordResponseReceived<RD extends CmcdReporterCustomData<C> = C>(response: HttpResponse<HttpRequest<RD & {
|
|
2763
2800
|
cmcd?: Cmcd;
|
|
2764
2801
|
[CMCD_REQUEST_PROVENANCE]?: CmcdRequestProvenance;
|
|
2765
2802
|
}>>, data?: Partial<Cmcd>): void;
|
|
2766
2803
|
/**
|
|
2767
|
-
* Resolves the session a
|
|
2768
|
-
*
|
|
2769
|
-
*
|
|
2770
|
-
*
|
|
2771
|
-
*
|
|
2772
|
-
*
|
|
2773
|
-
*
|
|
2804
|
+
* Resolves the session that a provenance record names. The record's `sid`
|
|
2805
|
+
* must name one of this reporter's retained sessions, or the reporter
|
|
2806
|
+
* discards the response. A record that names a removed or unknown `sid`
|
|
2807
|
+
* resolves nothing. Any other attribution would be wrong. The reporter reads
|
|
2808
|
+
* the `sid` as a plain property. A record
|
|
2809
|
+
* copied through JSON therefore resolves the same session, and a hand-built
|
|
2810
|
+
* record that names a retained session is accepted.
|
|
2774
2811
|
*/
|
|
2775
2812
|
private resolveSession;
|
|
2776
2813
|
/**
|
|
2777
|
-
* Applies the CMCD request report data to the request.
|
|
2778
|
-
* before sending the request.
|
|
2814
|
+
* Applies the CMCD request report data to the request. The player calls this
|
|
2815
|
+
* method before sending the request.
|
|
2779
2816
|
*
|
|
2780
2817
|
* @param req - The request to apply the CMCD request report to.
|
|
2781
2818
|
* @returns The request with the CMCD request report applied.
|
|
@@ -2784,50 +2821,51 @@ declare class CmcdReporter<C = Record<string, unknown>> {
|
|
|
2784
2821
|
*/
|
|
2785
2822
|
applyRequestReport(req: HttpRequest): HttpRequest;
|
|
2786
2823
|
/**
|
|
2787
|
-
* Checks
|
|
2824
|
+
* Checks whether request reporting is enabled.
|
|
2788
2825
|
*
|
|
2789
|
-
* @returns `true` if
|
|
2826
|
+
* @returns `true` if request reporting is enabled, `false` otherwise.
|
|
2790
2827
|
*/
|
|
2791
2828
|
isRequestReportingEnabled(): boolean;
|
|
2792
2829
|
/**
|
|
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.
|
|
2830
|
+
* The provenance record to write on a returned request. It is the session's
|
|
2831
|
+
* frozen base record, extended with the caller's per-call data encoded as a
|
|
2832
|
+
* CMCD string when there is any. Requests without per-call data share the
|
|
2833
|
+
* base record, so the reporter writes only one property. The snapshot never
|
|
2834
|
+
* contains reporter-written fields. A value that cannot encode contributes
|
|
2835
|
+
* no snapshot and does not fail the request. The response still attributes
|
|
2836
|
+
* and reports derived keys over session data, matching the tolerance of
|
|
2837
|
+
* `decodeSnapshot()` when reading.
|
|
2802
2838
|
*/
|
|
2803
2839
|
private createRequestProvenance;
|
|
2804
2840
|
/**
|
|
2805
|
-
* Creates a new request with the CMCD request report data applied.
|
|
2806
|
-
* before sending the request.
|
|
2841
|
+
* Creates a new request with the CMCD request report data applied. The
|
|
2842
|
+
* player calls this method before sending the request.
|
|
2807
2843
|
*
|
|
2808
|
-
* A reporter
|
|
2809
|
-
* satisfy
|
|
2810
|
-
*
|
|
2844
|
+
* A reporter with a concrete `C` requires the request's `customData` to
|
|
2845
|
+
* satisfy that type. TypeScript therefore rejects a call whose request the
|
|
2846
|
+
* configured transform could not read. See
|
|
2811
2847
|
* {@link CmcdReporterCustomData}.
|
|
2812
2848
|
*
|
|
2813
|
-
* @typeParam R - The
|
|
2849
|
+
* @typeParam R - The type of the request. Its `customData` must satisfy
|
|
2814
2850
|
* the reporter's `C`.
|
|
2815
2851
|
*
|
|
2816
2852
|
* @param request - The request to apply the CMCD request report to.
|
|
2817
2853
|
* @param data - The data to apply to the request. This data only
|
|
2818
|
-
* applies to this request report.
|
|
2819
|
-
*
|
|
2854
|
+
* applies to this request report. Use `update()` for
|
|
2855
|
+
* persistent data.
|
|
2820
2856
|
* @returns The request with the CMCD request report applied.
|
|
2821
2857
|
*/
|
|
2822
2858
|
createRequestReport<R extends HttpRequest<CmcdReporterCustomData<C>> = HttpRequest<C>>(request: R, data?: Partial<Cmcd>): R & CmcdRequestReport<R["customData"]>;
|
|
2823
2859
|
/**
|
|
2824
|
-
* Processes the event targets.
|
|
2860
|
+
* Processes the event targets. The reporter calls this method when an event
|
|
2861
|
+
* occurs.
|
|
2825
2862
|
*
|
|
2826
2863
|
* @param flush - Whether to flush the event targets.
|
|
2827
2864
|
*/
|
|
2828
2865
|
private processEventTargets;
|
|
2829
2866
|
/**
|
|
2830
|
-
* Sends an event report.
|
|
2867
|
+
* Sends an event report. The reporter calls this method when a batch is
|
|
2868
|
+
* ready.
|
|
2831
2869
|
*
|
|
2832
2870
|
* @param config - The target config to send the event report to.
|
|
2833
2871
|
* @param data - The encoded report lines to send in the event report.
|
|
@@ -2835,17 +2873,17 @@ declare class CmcdReporter<C = Record<string, unknown>> {
|
|
|
2835
2873
|
private sendEventReport;
|
|
2836
2874
|
/**
|
|
2837
2875
|
* Cancels the time-interval timer for an event target config and clears the
|
|
2838
|
-
* stored id. Safe to call when no timer is
|
|
2839
|
-
*
|
|
2876
|
+
* stored id. Safe to call when no timer is active (clearInterval(undefined)
|
|
2877
|
+
* does nothing).
|
|
2840
2878
|
*/
|
|
2841
2879
|
private disarmInterval;
|
|
2842
2880
|
/**
|
|
2843
|
-
* Silences an event target URL for the remainder of its session
|
|
2844
|
-
*
|
|
2845
|
-
*
|
|
2846
|
-
*
|
|
2847
|
-
*
|
|
2848
|
-
* the disposal
|
|
2881
|
+
* Silences an event target URL for the remainder of its session after the
|
|
2882
|
+
* collector signals that the target is gone (HTTP 410). The method clears
|
|
2883
|
+
* the queues and blocks further enqueues for every config in the session
|
|
2884
|
+
* that reports to the URL (the CTA-5004-B suppression scope). For the
|
|
2885
|
+
* current session, the method also cancels those configs' timers. A session
|
|
2886
|
+
* started after the disposal gets new target state and is unaffected.
|
|
2849
2887
|
*/
|
|
2850
2888
|
private disposeEventTarget;
|
|
2851
2889
|
}
|
|
@@ -2858,7 +2896,7 @@ declare class CmcdReporter<C = Record<string, unknown>> {
|
|
|
2858
2896
|
*/
|
|
2859
2897
|
type CmcdValidationOptions = {
|
|
2860
2898
|
/**
|
|
2861
|
-
* Explicit CMCD version override. If
|
|
2899
|
+
* Explicit CMCD version override. If omitted, the version is
|
|
2862
2900
|
* inferred from the payload's `v` key, defaulting to 1.
|
|
2863
2901
|
*/
|
|
2864
2902
|
version?: CmcdVersion;
|
|
@@ -2870,17 +2908,17 @@ type CmcdValidationOptions = {
|
|
|
2870
2908
|
//#endregion
|
|
2871
2909
|
//#region src/createFetchTransport.d.ts
|
|
2872
2910
|
/**
|
|
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
|
-
*
|
|
2911
|
+
* Create a transport adapter for `CmcdReportRecorder` that patches
|
|
2912
|
+
* `globalThis.fetch` to capture requests with CMCD data. The patched
|
|
2913
|
+
* `fetch` normalizes each request to `HttpRequest` (lowercase headers,
|
|
2914
|
+
* body read as a UTF-8 string).
|
|
2915
|
+
*
|
|
2916
|
+
* The patched `fetch` reads each body once with `Request.text()` for
|
|
2917
|
+
* inspection. This read is safe for the body types that CMCD reports use
|
|
2918
|
+
* in practice: `string`, `Blob`, `ArrayBuffer`, `FormData`, and
|
|
2919
|
+
* `URLSearchParams`. The underlying `fetch` can read those bodies again.
|
|
2920
|
+
* Do not pass a `ReadableStream` as `init.body`. The patched `fetch`
|
|
2921
|
+
* consumes the stream, and the underlying `fetch` receives an
|
|
2884
2922
|
* already-disturbed stream.
|
|
2885
2923
|
*
|
|
2886
2924
|
* @public
|
|
@@ -2889,9 +2927,8 @@ declare function createFetchTransport(): CmcdTransportAdapter;
|
|
|
2889
2927
|
//#endregion
|
|
2890
2928
|
//#region src/createXhrTransport.d.ts
|
|
2891
2929
|
/**
|
|
2892
|
-
* Create a transport adapter
|
|
2893
|
-
*
|
|
2894
|
-
* `CmcdReportRecorder`.
|
|
2930
|
+
* Create a transport adapter for `CmcdReportRecorder` that patches
|
|
2931
|
+
* `XMLHttpRequest.prototype` to capture requests with CMCD data.
|
|
2895
2932
|
*
|
|
2896
2933
|
* @public
|
|
2897
2934
|
*/
|
|
@@ -2980,9 +3017,9 @@ declare function fromCmcdQuery(query: string | URLSearchParams, options?: CmcdDe
|
|
|
2980
3017
|
//#endregion
|
|
2981
3018
|
//#region src/fromCmcdUrl.d.ts
|
|
2982
3019
|
/**
|
|
2983
|
-
* Decode CMCD data from a
|
|
3020
|
+
* Decode CMCD data from a URL encoded string.
|
|
2984
3021
|
*
|
|
2985
|
-
* @param url - The
|
|
3022
|
+
* @param url - The URL encoded string to decode.
|
|
2986
3023
|
* @param options - Options for decoding.
|
|
2987
3024
|
*
|
|
2988
3025
|
* @returns The decoded CMCD data.
|
|
@@ -3001,9 +3038,9 @@ declare function fromCmcdUrl(url: string, options?: CmcdDecodeOptions): CmcdData
|
|
|
3001
3038
|
//#endregion
|
|
3002
3039
|
//#region src/groupCmcdHeaders.d.ts
|
|
3003
3040
|
/**
|
|
3004
|
-
* Group a CMCD
|
|
3041
|
+
* Group a CMCD object into header shards
|
|
3005
3042
|
*
|
|
3006
|
-
* @param cmcd - The CMCD
|
|
3043
|
+
* @param cmcd - The CMCD object to convert.
|
|
3007
3044
|
* @param customHeaderMap - A map of CMCD header fields to custom CMCD keys.
|
|
3008
3045
|
*
|
|
3009
3046
|
* @returns The CMCD header shards.
|
|
@@ -3017,9 +3054,9 @@ declare function groupCmcdHeaders(cmcd: Cmcd, customHeaderMap?: Partial<CmcdHead
|
|
|
3017
3054
|
//#region src/isCmcdCustomKey.d.ts
|
|
3018
3055
|
/**
|
|
3019
3056
|
* Check if a key is a valid custom key: a lowercase first letter, then
|
|
3020
|
-
* characters from `a-z 0-9 .
|
|
3021
|
-
*
|
|
3022
|
-
*
|
|
3057
|
+
* characters from `a-z 0-9 . -`. The key needs a hyphen, not at the start
|
|
3058
|
+
* or end. This check applies the CTA-5004-B custom-key rules, restricted
|
|
3059
|
+
* to names that RFC 8941 key serialization accepts.
|
|
3023
3060
|
*
|
|
3024
3061
|
* @param key - The key to check.
|
|
3025
3062
|
*
|
|
@@ -3068,7 +3105,7 @@ declare function isCmcdRequestKey(key: string): key is keyof Cmcd;
|
|
|
3068
3105
|
*
|
|
3069
3106
|
* @param key - The key to check.
|
|
3070
3107
|
*
|
|
3071
|
-
* @returns `true` if the key is a valid CMCD
|
|
3108
|
+
* @returns `true` if the key is a valid CMCD response key, `false` otherwise.
|
|
3072
3109
|
*
|
|
3073
3110
|
* @public
|
|
3074
3111
|
*
|
|
@@ -3094,7 +3131,7 @@ declare function isCmcdV1Data(data: CmcdData): data is CmcdV1Data;
|
|
|
3094
3131
|
//#endregion
|
|
3095
3132
|
//#region src/isCmcdV1Key.d.ts
|
|
3096
3133
|
/**
|
|
3097
|
-
* Filter
|
|
3134
|
+
* Filter for CMCD version 1 keys.
|
|
3098
3135
|
*
|
|
3099
3136
|
* @param key - The CMCD key to filter.
|
|
3100
3137
|
*
|
|
@@ -3138,10 +3175,10 @@ declare function prepareCmcdData(obj: Record<string, any>, options?: CmcdEncodeO
|
|
|
3138
3175
|
//#endregion
|
|
3139
3176
|
//#region src/toCmcdHeaders.d.ts
|
|
3140
3177
|
/**
|
|
3141
|
-
* Convert a CMCD
|
|
3178
|
+
* Convert a CMCD object to request headers
|
|
3142
3179
|
*
|
|
3143
|
-
* @param cmcd - The CMCD
|
|
3144
|
-
* @param options - Options for encoding
|
|
3180
|
+
* @param cmcd - The CMCD object to convert.
|
|
3181
|
+
* @param options - Options for encoding.
|
|
3145
3182
|
*
|
|
3146
3183
|
* @returns The CMCD header shards.
|
|
3147
3184
|
*
|
|
@@ -3156,10 +3193,10 @@ declare function toCmcdHeaders(cmcd: Cmcd, options?: CmcdEncodeOptions): Record<
|
|
|
3156
3193
|
//#endregion
|
|
3157
3194
|
//#region src/toCmcdQuery.d.ts
|
|
3158
3195
|
/**
|
|
3159
|
-
* Convert a CMCD
|
|
3196
|
+
* Convert a CMCD object to a query arg.
|
|
3160
3197
|
*
|
|
3161
3198
|
* @param cmcd - The CMCD object to convert.
|
|
3162
|
-
* @param options - Options for encoding
|
|
3199
|
+
* @param options - Options for encoding.
|
|
3163
3200
|
*
|
|
3164
3201
|
* @returns The CMCD query arg.
|
|
3165
3202
|
*
|
|
@@ -3174,10 +3211,10 @@ declare function toCmcdQuery(cmcd: Cmcd, options?: CmcdEncodeOptions): string;
|
|
|
3174
3211
|
//#endregion
|
|
3175
3212
|
//#region src/toCmcdUrl.d.ts
|
|
3176
3213
|
/**
|
|
3177
|
-
* Convert a CMCD
|
|
3214
|
+
* Convert a CMCD object to a URL encoded string.
|
|
3178
3215
|
*
|
|
3179
3216
|
* @param cmcd - The CMCD object to convert.
|
|
3180
|
-
* @param options - Options for encoding
|
|
3217
|
+
* @param options - Options for encoding.
|
|
3181
3218
|
*
|
|
3182
3219
|
* @returns The URL encoded CMCD data.
|
|
3183
3220
|
*
|
|
@@ -3192,7 +3229,7 @@ declare function toCmcdUrl(cmcd: Cmcd, options?: CmcdEncodeOptions): string;
|
|
|
3192
3229
|
* Convert a value to a CMCD value.
|
|
3193
3230
|
*
|
|
3194
3231
|
* @param value - The value to convert to a CMCD value.
|
|
3195
|
-
* @param params - The parameters
|
|
3232
|
+
* @param params - The parameters of the CMCD value.
|
|
3196
3233
|
* @returns The CMCD value.
|
|
3197
3234
|
*
|
|
3198
3235
|
* @public
|
|
@@ -3223,8 +3260,8 @@ declare function validateCmcd(data: Record<string, unknown>, options?: CmcdValid
|
|
|
3223
3260
|
* Accepts an {@link @svta/cml-utils!HttpRequest | HttpRequest} object.
|
|
3224
3261
|
*
|
|
3225
3262
|
* This function validates that the request uses the POST method and has
|
|
3226
|
-
* the correct `Content-Type` header (`application/cmcd`)
|
|
3227
|
-
*
|
|
3263
|
+
* the correct `Content-Type` header (`application/cmcd`). It also
|
|
3264
|
+
* validates the body content with {@link validateCmcdEvents}.
|
|
3228
3265
|
*
|
|
3229
3266
|
* @param request - An `HttpRequest` to validate.
|
|
3230
3267
|
* @param options - Validation options (excluding `reportingMode`).
|
|
@@ -3244,8 +3281,8 @@ declare function validateCmcdEventReport(request: HttpRequest, options?: Omit<Cm
|
|
|
3244
3281
|
*
|
|
3245
3282
|
* This function decodes the string internally and validates it with
|
|
3246
3283
|
* `reportingMode` set to `'event'`. The input may contain multiple
|
|
3247
|
-
* newline-separated events
|
|
3248
|
-
*
|
|
3284
|
+
* newline-separated events, for example an `application/cmcd` POST body.
|
|
3285
|
+
* The function validates each line independently and merges the results.
|
|
3249
3286
|
*
|
|
3250
3287
|
* @param cmcd - The raw CMCD-encoded string to validate. May contain
|
|
3251
3288
|
* multiple newline-separated event lines.
|
|
@@ -3265,15 +3302,15 @@ declare function validateCmcdEvents(cmcd: string, options?: Omit<CmcdValidationO
|
|
|
3265
3302
|
/**
|
|
3266
3303
|
* Validates CMCD HTTP headers by checking shard placement and payload validity.
|
|
3267
3304
|
*
|
|
3268
|
-
* This function accepts raw CMCD header strings
|
|
3269
|
-
* internally
|
|
3270
|
-
* then merges all shards and runs
|
|
3271
|
-
* structure) on the merged data.
|
|
3305
|
+
* This function accepts raw CMCD header strings and decodes each shard
|
|
3306
|
+
* internally. It verifies that each key is in its correct header shard.
|
|
3307
|
+
* The function then merges all shards and runs payload validation (keys,
|
|
3308
|
+
* values, and structure) on the merged data.
|
|
3272
3309
|
*
|
|
3273
3310
|
* @example
|
|
3274
3311
|
* {@includeCode ../test/validateCmcdHeaders.test.ts#example}
|
|
3275
3312
|
*
|
|
3276
|
-
* @param headers - A `Headers` instance or a record of CMCD header fields to
|
|
3313
|
+
* @param headers - A `Headers` instance or a record of CMCD header fields to raw encoded strings.
|
|
3277
3314
|
* @param options - Validation options (excluding `reportingMode`).
|
|
3278
3315
|
* @returns The validation result including decoded data.
|
|
3279
3316
|
*
|
|
@@ -3308,10 +3345,12 @@ declare function validateCmcdKeys(data: Record<string, unknown>, options?: CmcdV
|
|
|
3308
3345
|
* {@link https://developer.mozilla.org/en-US/docs/Web/API/Request | Request}
|
|
3309
3346
|
* object or an {@link @svta/cml-utils!HttpRequest | HttpRequest} object.
|
|
3310
3347
|
*
|
|
3311
|
-
* The function checks for CMCD data
|
|
3312
|
-
*
|
|
3313
|
-
*
|
|
3314
|
-
*
|
|
3348
|
+
* The function checks the HTTP headers for CMCD data first. If the
|
|
3349
|
+
* request has CMCD headers, {@link validateCmcdHeaders} validates them,
|
|
3350
|
+
* including shard placement. Otherwise, the function validates the CMCD
|
|
3351
|
+
* query parameter of the URL. A request with CMCD data in both the
|
|
3352
|
+
* headers and the `CMCD` query parameter is an error. The function still
|
|
3353
|
+
* validates the headers and returns their data.
|
|
3315
3354
|
*
|
|
3316
3355
|
* @param request - A `Request` or `HttpRequest` to validate.
|
|
3317
3356
|
* @param options - Validation options (excluding `reportingMode`).
|