bitmovin-analytics 2.34.1 → 2.36.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.
@@ -99,9 +99,196 @@ export interface AdapterAPI {
99
99
  setCustomDataOnce: (values: CustomDataValues) => void;
100
100
  sourceChange: (config: AnalyticsConfig) => void;
101
101
  }
102
+ export interface SsaiAdMetadata {
103
+ adId?: string;
104
+ adSystem?: string;
105
+ customData?: CustomDataValues;
106
+ }
107
+ export interface SsaiAdBreakMetadata {
108
+ adPosition?: AdPosition;
109
+ }
110
+ export type AdPosition = "preroll" | "midroll" | "postroll";
111
+ export interface SsaiApi {
112
+ adBreakStart(adBreakMetadata?: SsaiAdBreakMetadata): any;
113
+ adStart(adMetadata?: SsaiAdMetadata): any;
114
+ adBreakEnd(): any;
115
+ }
102
116
  export interface AnalyticsStateMachineOptions {
103
117
  starttime: any;
104
118
  }
119
+ declare class ErrorCode {
120
+ readonly code: number;
121
+ readonly message: string;
122
+ static BITMOVIN_PLAYER_LICENSING_ERROR: ErrorCode;
123
+ static SETUP_MISSING_LICENSE_WHITELIST: ErrorCode;
124
+ static QUALITY_CHANGE_THRESHOLD_EXCEEDED: ErrorCode;
125
+ static BUFFERING_TIMEOUT_REACHED: ErrorCode;
126
+ static VIDEO_STARTUP_TIMEOUT_REACHED: ErrorCode;
127
+ private constructor();
128
+ }
129
+ declare class VideoStartFailedReason {
130
+ readonly reason: string;
131
+ readonly errorCode: ErrorCode | null;
132
+ static PAGE_CLOSED: VideoStartFailedReason;
133
+ static PLAYER_ERROR: VideoStartFailedReason;
134
+ static TIMEOUT: VideoStartFailedReason;
135
+ static UNKNOWN: VideoStartFailedReason;
136
+ private constructor();
137
+ }
138
+ export interface ErrorData {
139
+ exceptionMessage?: string | undefined;
140
+ exceptionStacktrace?: string[] | undefined;
141
+ additionalData?: string | undefined;
142
+ }
143
+ export interface AnalyticsEventBase {
144
+ currentTime?: number;
145
+ }
146
+ interface ErrorEvent$1 extends AnalyticsEventBase {
147
+ code: number | undefined;
148
+ message: string | undefined;
149
+ legacyData?: any;
150
+ data: ErrorData;
151
+ }
152
+ export interface VideoStartFailedEvent extends AnalyticsEventBase {
153
+ reason: VideoStartFailedReason;
154
+ }
155
+ export interface SsaiEventHandler {
156
+ onSsaiInteraction: (timestamp: number, eventData: AnalyticsEventBase) => void;
157
+ }
158
+ export interface DownloadSpeedInfo {
159
+ /**
160
+ * Number of completed segment downloads
161
+ */
162
+ segmentsDownloadCount: number;
163
+ /**
164
+ * Total download size in bytes
165
+ */
166
+ segmentsDownloadSize: number;
167
+ /**
168
+ * Total time spent downloading segments in milliseconds
169
+ */
170
+ segmentsDownloadTime: number;
171
+ /**
172
+ * Average download speed in kbps
173
+ */
174
+ avgDownloadSpeed: number;
175
+ /**
176
+ * Maximum download speed in kbps
177
+ */
178
+ maxDownloadSpeed: number;
179
+ /**
180
+ * Minimum download speed in kbps
181
+ */
182
+ minDownloadSpeed: number;
183
+ /**
184
+ * Average time to first byte in milliseconds
185
+ */
186
+ avgTimeToFirstByte: number;
187
+ }
188
+ export interface Sample extends CustomDataValues {
189
+ ad?: 0 | 1 | 2;
190
+ adId?: string;
191
+ adSystem?: string;
192
+ adPosition?: string;
193
+ adIndex?: number;
194
+ analyticsVersion?: any;
195
+ audioBitrate?: number;
196
+ audioCodec?: string;
197
+ audioLanguage?: string;
198
+ autoplay?: any;
199
+ buffered?: number;
200
+ castTech?: string;
201
+ cdnProvider?: any;
202
+ completed?: number;
203
+ completedTotal?: number;
204
+ customUserId?: string;
205
+ deviceInformation?: {
206
+ model?: string;
207
+ deviceClass?: string;
208
+ };
209
+ domain?: any;
210
+ downloadSpeedInfo?: DownloadSpeedInfo;
211
+ drmLoadTime?: number;
212
+ drmType?: string;
213
+ droppedFrames?: number;
214
+ duration?: number;
215
+ errorCode?: number;
216
+ errorData?: string;
217
+ errorMessage?: string;
218
+ errorSegments?: any[];
219
+ impressionId?: string;
220
+ isCasting?: boolean;
221
+ isLive?: boolean;
222
+ isMuted?: boolean;
223
+ key?: string;
224
+ language?: string;
225
+ m3u8Url?: string;
226
+ mpdUrl?: string;
227
+ pageLoadTime: number;
228
+ pageLoadType: number;
229
+ path?: string;
230
+ paused?: number;
231
+ platform: string;
232
+ played?: number;
233
+ player?: any;
234
+ playerKey?: any;
235
+ playerStartupTime: number;
236
+ playerTech?: string;
237
+ progUrl?: string;
238
+ screenHeight?: number;
239
+ screenWidth?: number;
240
+ seeked?: number;
241
+ sequenceNumber?: number;
242
+ size?: string;
243
+ startupTime?: number;
244
+ state?: string;
245
+ streamFormat?: string;
246
+ subtitleEnabled?: boolean;
247
+ subtitleLanguage?: string;
248
+ supportedVideoCodecs?: string[];
249
+ time?: number;
250
+ userAgent?: string;
251
+ userId?: string;
252
+ version?: string;
253
+ videoBitrate?: number;
254
+ videoCodec?: string;
255
+ videoDuration?: number;
256
+ videoId?: string;
257
+ videoPlaybackHeight?: number;
258
+ videoPlaybackWidth?: number;
259
+ videoStartFailed?: boolean;
260
+ videoStartFailedReason?: string;
261
+ videoStartupTime?: number;
262
+ videoTimeEnd?: number;
263
+ videoTimeStart?: number;
264
+ videoTitle?: string;
265
+ videoWindowHeight?: number;
266
+ videoWindowWidth?: number;
267
+ }
268
+ declare class SsaiService {
269
+ /**
270
+ * eventHandler is outside dependency.
271
+ * Due to the structure it is not possible to pass it to constructor of this class
272
+ */
273
+ eventHandler: undefined | SsaiEventHandler;
274
+ private state;
275
+ /**
276
+ * represents the current playing ad metdata
277
+ * is `undefined` when no ad is playing (after endAdBreak)
278
+ * or omitted by customer
279
+ */
280
+ private currentAdMetadata;
281
+ private adIndex;
282
+ private isFirstSampleOfAd;
283
+ private player;
284
+ constructor(player: any);
285
+ adBreakStart(adBreakMetadata?: SsaiAdBreakMetadata): void;
286
+ adStart(adMetadata?: SsaiAdMetadata): void;
287
+ adBreakEnd(): void;
288
+ private reset;
289
+ resetSourceRelatedState(): void;
290
+ manipulate(sample: Sample): void;
291
+ }
105
292
  declare class QualityChangeService {
106
293
  private qualityChangeThreshold;
107
294
  private qualityChangeCount;
@@ -174,36 +361,6 @@ declare abstract class Feature<TConfigContainer, TConfig extends FeatureConfig>
174
361
  configure(authenticated: boolean, configContainer?: TConfigContainer): TConfig | undefined;
175
362
  abstract extractConfig(configContainer: TConfigContainer): TConfig | undefined;
176
363
  }
177
- export interface DownloadSpeedInfo {
178
- /**
179
- * Number of completed segment downloads
180
- */
181
- segmentsDownloadCount: number;
182
- /**
183
- * Total download size in bytes
184
- */
185
- segmentsDownloadSize: number;
186
- /**
187
- * Total time spent downloading segments in milliseconds
188
- */
189
- segmentsDownloadTime: number;
190
- /**
191
- * Average download speed in kbps
192
- */
193
- avgDownloadSpeed: number;
194
- /**
195
- * Maximum download speed in kbps
196
- */
197
- maxDownloadSpeed: number;
198
- /**
199
- * Minimum download speed in kbps
200
- */
201
- minDownloadSpeed: number;
202
- /**
203
- * Average time to first byte in milliseconds
204
- */
205
- avgTimeToFirstByte: number;
206
- }
207
364
  export interface DrmPerformanceInfo {
208
365
  readonly drmType: string;
209
366
  readonly drmLoadTime: number;
@@ -251,118 +408,6 @@ export interface SegmentInfo {
251
408
  timestamp: number;
252
409
  url: string;
253
410
  }
254
- declare class ErrorCode {
255
- readonly code: number;
256
- readonly message: string;
257
- static BITMOVIN_PLAYER_LICENSING_ERROR: ErrorCode;
258
- static SETUP_MISSING_LICENSE_WHITELIST: ErrorCode;
259
- static QUALITY_CHANGE_THRESHOLD_EXCEEDED: ErrorCode;
260
- static BUFFERING_TIMEOUT_REACHED: ErrorCode;
261
- static VIDEO_STARTUP_TIMEOUT_REACHED: ErrorCode;
262
- private constructor();
263
- }
264
- declare class VideoStartFailedReason {
265
- readonly reason: string;
266
- readonly errorCode: ErrorCode | null;
267
- static PAGE_CLOSED: VideoStartFailedReason;
268
- static PLAYER_ERROR: VideoStartFailedReason;
269
- static TIMEOUT: VideoStartFailedReason;
270
- static UNKNOWN: VideoStartFailedReason;
271
- private constructor();
272
- }
273
- export interface ErrorData {
274
- exceptionMessage?: string | undefined;
275
- exceptionStacktrace?: string[] | undefined;
276
- additionalData?: string | undefined;
277
- }
278
- export interface AnalyticsEventBase {
279
- currentTime?: number;
280
- }
281
- interface ErrorEvent$1 extends AnalyticsEventBase {
282
- code: number | undefined;
283
- message: string | undefined;
284
- legacyData?: any;
285
- data: ErrorData;
286
- }
287
- export interface VideoStartFailedEvent extends AnalyticsEventBase {
288
- reason: VideoStartFailedReason;
289
- }
290
- export interface Sample extends CustomDataValues {
291
- ad?: number;
292
- analyticsVersion?: any;
293
- audioBitrate?: number;
294
- audioCodec?: string;
295
- audioLanguage?: string;
296
- autoplay?: any;
297
- buffered?: number;
298
- castTech?: string;
299
- cdnProvider?: any;
300
- completed?: number;
301
- completedTotal?: number;
302
- customUserId?: string;
303
- deviceInformation?: {
304
- model?: string;
305
- deviceClass?: string;
306
- };
307
- domain?: any;
308
- downloadSpeedInfo?: DownloadSpeedInfo;
309
- drmLoadTime?: number;
310
- drmType?: string;
311
- droppedFrames?: number;
312
- duration?: number;
313
- errorCode?: number;
314
- errorData?: string;
315
- errorMessage?: string;
316
- errorSegments?: any[];
317
- impressionId?: string;
318
- isCasting?: boolean;
319
- isLive?: boolean;
320
- isMuted?: boolean;
321
- key?: string;
322
- language?: string;
323
- m3u8Url?: string;
324
- mpdUrl?: string;
325
- pageLoadTime: number;
326
- pageLoadType: number;
327
- path?: string;
328
- paused?: number;
329
- platform: string;
330
- played?: number;
331
- player?: any;
332
- playerKey?: any;
333
- playerStartupTime: number;
334
- playerTech?: string;
335
- progUrl?: string;
336
- screenHeight?: number;
337
- screenWidth?: number;
338
- seeked?: number;
339
- sequenceNumber?: number;
340
- size?: string;
341
- startupTime?: number;
342
- state?: string;
343
- streamFormat?: string;
344
- subtitleEnabled?: boolean;
345
- subtitleLanguage?: string;
346
- supportedVideoCodecs?: string[];
347
- time?: number;
348
- userAgent?: string;
349
- userId?: string;
350
- version?: string;
351
- videoBitrate?: number;
352
- videoCodec?: string;
353
- videoDuration?: number;
354
- videoId?: string;
355
- videoPlaybackHeight?: number;
356
- videoPlaybackWidth?: number;
357
- videoStartFailed?: boolean;
358
- videoStartFailedReason?: string;
359
- videoStartupTime?: number;
360
- videoTimeEnd?: number;
361
- videoTimeStart?: number;
362
- videoTitle?: string;
363
- videoWindowHeight?: number;
364
- videoWindowWidth?: number;
365
- }
366
411
  export type HeartbeatPayload = Pick<Sample, "played"> | Pick<Sample, "buffered"> | Pick<Sample, "paused">;
367
412
  export interface StateMachineCallbacks {
368
413
  setup: (duration: number, state: string) => void;
@@ -410,6 +455,13 @@ export interface Subscribable<TArgs> {
410
455
  unsubscribe(callback: EventHandler<TArgs>): any;
411
456
  }
412
457
  export type EventHandler<TArgs> = (args: TArgs) => void;
458
+ declare class EventDispatcher<TArgs> implements Subscribable<TArgs> {
459
+ private callbacks;
460
+ subscribe(callback: EventHandler<TArgs>): () => void;
461
+ dispatch(args: TArgs): void;
462
+ unsubscribe(callback: EventHandler<TArgs>): void;
463
+ get subscriberCount(): number;
464
+ }
413
465
  export interface DeferredLicenseLoadingAdapterAPI {
414
466
  readonly supportsDeferredLicenseLoading?: boolean;
415
467
  readonly onLicenseKeyReceived: Subscribable<{
@@ -461,6 +513,13 @@ export interface InternalAdapterAPI extends DeferredLicenseLoadingAdapterAPI {
461
513
  onError?(): void;
462
514
  setCustomData(values: CustomDataValues): void;
463
515
  }
516
+ declare class FeatureManager<TConfigContainer> {
517
+ private features;
518
+ registerFeatures(features: Array<Feature<TConfigContainer, FeatureConfig>>): void;
519
+ unregisterFeatures(): void;
520
+ resetFeatures(): void;
521
+ configureFeatures(authenticated: boolean, featureConfigs?: TConfigContainer): void;
522
+ }
464
523
  export interface OnErrorDetailEventObject {
465
524
  code: number | undefined;
466
525
  message: string | undefined;
@@ -493,14 +552,19 @@ declare class BackendFactory {
493
552
  private isEnabled;
494
553
  private createInnerBackend;
495
554
  }
555
+ declare class SessionPersistenceHandler {
556
+ readonly userId: string;
557
+ constructor(config: AnalyticsConfig);
558
+ }
496
559
  declare class Analytics {
497
- get version(): string;
498
- static version: string;
499
- private readonly sessionHandler;
500
- private readonly adapter;
560
+ private adapter;
501
561
  private readonly backendFactory;
562
+ private readonly sessionHandler;
502
563
  private readonly featureManager;
503
564
  private readonly onErrorDetailEventDispatcher;
565
+ private readonly ssaiService?;
566
+ get version(): string;
567
+ static version: string;
504
568
  private readonly adAnalytics;
505
569
  pageLoadTime: number;
506
570
  playerStartupTime: number;
@@ -513,7 +577,7 @@ declare class Analytics {
513
577
  private droppedSampleFrames;
514
578
  private startupTime;
515
579
  private authenticationCallback;
516
- constructor(config: AnalyticsConfig, adapter: InternalAdapterAPI, backendFactory?: BackendFactory);
580
+ constructor(config: AnalyticsConfig, adapter: InternalAdapterAPI, backendFactory: BackendFactory, sessionHandler: SessionPersistenceHandler, featureManager: FeatureManager<FeatureConfigContainer>, onErrorDetailEventDispatcher: EventDispatcher<OnErrorDetailEventObject>, ssaiService?: SsaiService | undefined);
517
581
  get errorDetailSubscribable(): Subscribable<OnErrorDetailEventObject>;
518
582
  getPlayerInformationFromAdapter(): {
519
583
  player: string;
@@ -559,6 +623,7 @@ declare class Analytics {
559
623
  private setVideoTimeStart;
560
624
  private setVideoTimeEnd;
561
625
  private sendQualityChange;
626
+ static create(config: AnalyticsConfig, adapter: InternalAdapterAPI, ssaiService?: SsaiService): Analytics;
562
627
  }
563
628
  declare abstract class Adapter {
564
629
  protected analytics: Analytics;
@@ -578,6 +643,7 @@ export declare class AmazonIVSAdapter extends Adapter implements AdapterAPI {
578
643
  }
579
644
  export declare class Bitmovin8Adapter extends Adapter implements AdapterAPI {
580
645
  constructor(player: any, opts?: AnalyticsStateMachineOptions);
646
+ ssai: SsaiApi;
581
647
  /**
582
648
  * intercept `player.load` with automated sourceChange handling
583
649
  */