@newrelic/video-core 5.0.2 → 5.1.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.
Files changed (78) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +13 -0
  3. package/dist/cjs/browser/index.js +1 -1
  4. package/dist/cjs/browser/index.js.LICENSE.txt +1 -1
  5. package/dist/cjs/browser/index.js.map +1 -1
  6. package/dist/cjs/index.js +1 -1
  7. package/dist/cjs/index.js.LICENSE.txt +1 -1
  8. package/dist/cjs/index.js.map +1 -1
  9. package/dist/cjs/vega/index.js +1 -1
  10. package/dist/cjs/vega/index.js.LICENSE.txt +1 -1
  11. package/dist/cjs/vega/index.js.map +1 -1
  12. package/dist/esm/browser/index.js +1 -1
  13. package/dist/esm/browser/index.js.LICENSE.txt +1 -1
  14. package/dist/esm/browser/index.js.map +1 -1
  15. package/dist/esm/index.js +1 -1
  16. package/dist/esm/index.js.LICENSE.txt +1 -1
  17. package/dist/esm/index.js.map +1 -1
  18. package/dist/esm/vega/index.js +1 -1
  19. package/dist/esm/vega/index.js.LICENSE.txt +1 -1
  20. package/dist/esm/vega/index.js.map +1 -1
  21. package/dist/types/browser/agent.d.ts +46 -0
  22. package/dist/types/browser/harvestScheduler.d.ts +125 -0
  23. package/dist/types/browser/index.d.ts +34 -0
  24. package/dist/types/chrono.d.ts +52 -0
  25. package/dist/types/connectedDevice/connectedDeviceAgent.d.ts +63 -0
  26. package/dist/types/connectedDevice/connectedDeviceConstants.d.ts +51 -0
  27. package/dist/types/connectedDevice/connectedDeviceHarvester.d.ts +198 -0
  28. package/dist/types/connectedDevice/index.d.ts +30 -0
  29. package/dist/types/constants.d.ts +30 -0
  30. package/dist/types/core.d.ts +54 -0
  31. package/dist/types/emitter.d.ts +42 -0
  32. package/dist/types/eventAggregator.d.ts +97 -0
  33. package/dist/types/index.d.ts +33 -0
  34. package/dist/types/log.d.ts +61 -0
  35. package/dist/types/obfuscate.d.ts +13 -0
  36. package/dist/types/optimizedHttpClient.d.ts +83 -0
  37. package/dist/types/recordEvent.d.ts +30 -0
  38. package/dist/types/retryQueueHandler.d.ts +46 -0
  39. package/dist/types/tracker.d.ts +176 -0
  40. package/dist/types/utils/eventBuilder.d.ts +69 -0
  41. package/dist/types/utils/harvestTimer.d.ts +45 -0
  42. package/dist/types/utils/index.d.ts +38 -0
  43. package/dist/types/utils/qoeFilters.d.ts +88 -0
  44. package/dist/types/videoConfiguration.d.ts +90 -0
  45. package/dist/types/videotracker.d.ts +366 -0
  46. package/dist/types/videotrackerstate.d.ts +228 -0
  47. package/dist/umd/nrvideo.min.js +1 -1
  48. package/dist/umd/nrvideo.min.js.LICENSE.txt +1 -1
  49. package/dist/umd/nrvideo.min.js.map +1 -1
  50. package/package.json +14 -2
  51. package/src/browser/{agent.js → agent.ts} +21 -16
  52. package/src/browser/{harvestScheduler.js → harvestScheduler.ts} +51 -24
  53. package/src/{chrono.js → chrono.ts} +29 -24
  54. package/src/connectedDevice/{connectedDeviceAgent.js → connectedDeviceAgent.ts} +14 -10
  55. package/src/connectedDevice/{connectedDeviceConstants.js → connectedDeviceConstants.ts} +5 -3
  56. package/src/connectedDevice/{connectedDeviceHarvester.js → connectedDeviceHarvester.ts} +71 -34
  57. package/src/constants.ts +62 -0
  58. package/src/{core.js → core.ts} +31 -18
  59. package/src/{emitter.js → emitter.ts} +16 -5
  60. package/src/{eventAggregator.js → eventAggregator.ts} +33 -19
  61. package/src/global.d.ts +25 -0
  62. package/src/{log.js → log.ts} +23 -17
  63. package/src/{obfuscate.js → obfuscate.ts} +6 -1
  64. package/src/{optimizedHttpClient.js → optimizedHttpClient.ts} +37 -13
  65. package/src/{recordEvent.js → recordEvent.ts} +11 -9
  66. package/src/{retryQueueHandler.js → retryQueueHandler.ts} +17 -12
  67. package/src/{tracker.js → tracker.ts} +56 -23
  68. package/src/utils/{eventBuilder.js → eventBuilder.ts} +31 -14
  69. package/src/utils/{harvestTimer.js → harvestTimer.ts} +21 -4
  70. package/src/utils/{index.js → index.ts} +14 -14
  71. package/src/utils/{qoeFilters.js → qoeFilters.ts} +19 -8
  72. package/src/{videoConfiguration.js → videoConfiguration.ts} +44 -10
  73. package/src/{videotracker.js → videotracker.ts} +119 -78
  74. package/src/{videotrackerstate.js → videotrackerstate.ts} +113 -49
  75. package/src/constants.js +0 -63
  76. /package/src/browser/{index.js → index.ts} +0 -0
  77. /package/src/connectedDevice/{index.js → index.ts} +0 -0
  78. /package/src/{index.js → index.ts} +0 -0
@@ -1,8 +1,15 @@
1
1
  import Log from "./log";
2
- import Tracker from "./tracker";
2
+ import Tracker, { TrackerOptions } from "./tracker";
3
3
  import TrackerState from "./videotrackerstate";
4
4
  import pkg from "../package.json";
5
5
 
6
+ export interface VideoTrackerOptions extends TrackerOptions {
7
+ isAd?: boolean;
8
+ adsTracker?: VideoTracker;
9
+ src?: string;
10
+ tag?: any;
11
+ }
12
+
6
13
  /**
7
14
  * Base video tracker class provides extensible tracking over video elements. See {@link Tracker}.
8
15
  * Extend this class to create your own video tracker class. Override getter methods and
@@ -15,6 +22,40 @@ import pkg from "../package.json";
15
22
  * @extends Tracker
16
23
  */
17
24
  class VideoTracker extends Tracker {
25
+ static Events: Record<string, string>;
26
+
27
+ /**
28
+ * TrackerState instance. Stores the state of the view. Tracker will automatically update the
29
+ * state of its instance, so there's no need to modify/interact with it manually.
30
+ * @type TrackerState
31
+ */
32
+ state: TrackerState;
33
+
34
+ /**
35
+ * Another Tracker instance to track ads.
36
+ * @type Tracker
37
+ */
38
+ adsTracker: VideoTracker | null;
39
+
40
+ /** Redeclared narrower than base Tracker's `Tracker | null` — VideoTracker's own
41
+ * methods (getViewId, getAdPosition, sendStart, ...) always call it as a VideoTracker.
42
+ * Type-only (`declare`); the real assignment happens in the base Tracker constructor. */
43
+ declare parentTracker: VideoTracker | null;
44
+
45
+ /**
46
+ * Last bufferType value.
47
+ * @private
48
+ */
49
+ _lastBufferType: string | null;
50
+ _userId: any;
51
+ _src: string | null;
52
+
53
+ player?: any;
54
+ tag?: any;
55
+ _lastWebkitBitrate?: number;
56
+ _lastAdRendition?: number | null;
57
+ _lastRendition?: number | null;
58
+
18
59
  /**
19
60
  * Constructor, receives player and options.
20
61
  * Lifecycle: constructor > {@link setOptions} > {@link setPlayer} > {@link registerListeners}.
@@ -22,7 +63,7 @@ class VideoTracker extends Tracker {
22
63
  * @param {Object} [player] Player to track. See {@link setPlayer}.
23
64
  * @param {Object} [options] Options for the tracker. See {@link setOptions}.
24
65
  */
25
- constructor(player, options) {
66
+ constructor(player?: any, options?: VideoTrackerOptions) {
26
67
  super();
27
68
 
28
69
  /**
@@ -61,7 +102,7 @@ class VideoTracker extends Tracker {
61
102
 
62
103
  /* user can set the user Id */
63
104
 
64
- setUserId(userId) {
105
+ setUserId(userId: any): void {
65
106
  this._userId = userId;
66
107
  }
67
108
 
@@ -76,7 +117,7 @@ class VideoTracker extends Tracker {
76
117
  * @param {Tracker} [options.adsTracker] Set ads tracker. See {@link adsTracker}.
77
118
  * @param {Object} [options.tag] DOM element to track. See {@link setPlayer}.
78
119
  */
79
- setOptions(options) {
120
+ setOptions(options?: VideoTrackerOptions): void {
80
121
  if (options) {
81
122
  if (options.adsTracker) {
82
123
  this.setAdsTracker(options.adsTracker);
@@ -88,13 +129,13 @@ class VideoTracker extends Tracker {
88
129
  if (this._src !== null && this._src !== options.src) {
89
130
  Log.warn(`setOptions: src is locked to '${this._src}'. Ignoring override '${options.src}'.`);
90
131
  } else {
91
- this._src = options.src;
132
+ this._src = options.src as string;
92
133
  if (this.adsTracker && this.adsTracker._src == null) {
93
134
  this.adsTracker._src = this._src;
94
135
  }
95
136
  }
96
137
  }
97
- Tracker.prototype.setOptions.apply(this, arguments);
138
+ Tracker.prototype.setOptions.apply(this, arguments as any);
98
139
  }
99
140
  }
100
141
 
@@ -108,7 +149,7 @@ class VideoTracker extends Tracker {
108
149
  * document.getElementById will be called.
109
150
  */
110
151
 
111
- setPlayer(player, tag) {
152
+ setPlayer(player: any, tag?: any): void {
112
153
  if (this.player || this.tag) this.dispose();
113
154
 
114
155
  if (typeof document !== "undefined" && document.getElementById) {
@@ -124,12 +165,12 @@ class VideoTracker extends Tracker {
124
165
  }
125
166
 
126
167
  /** Returns true if the tracker is currently on ads. */
127
- isAd() {
168
+ isAd(): boolean {
128
169
  return this.state.isAd();
129
170
  }
130
171
 
131
172
  /** Sets if the tracker is currenlty tracking ads */
132
- setIsAd(isAd) {
173
+ setIsAd(isAd: boolean): void {
133
174
  this.state.setIsAd(isAd);
134
175
  }
135
176
 
@@ -139,7 +180,7 @@ class VideoTracker extends Tracker {
139
180
  *
140
181
  * @param {Tracker} tracker Ad tracker to add
141
182
  */
142
- setAdsTracker(tracker) {
183
+ setAdsTracker(tracker?: VideoTracker | null): void {
143
184
  this.disposeAdsTracker(); // dispose current one
144
185
  if (tracker) {
145
186
  this.adsTracker = tracker;
@@ -151,16 +192,16 @@ class VideoTracker extends Tracker {
151
192
  if (this._src != null && tracker._src == null) {
152
193
  tracker._src = this._src;
153
194
  }
154
- this.adsTracker.on("*", funnelAdEvents.bind(this));
195
+ this.adsTracker.on("*", funnelAdEvents.bind(this) as any);
155
196
  }
156
197
  }
157
198
 
158
199
  /**
159
200
  * Dispose current adsTracker.
160
201
  */
161
- disposeAdsTracker() {
202
+ disposeAdsTracker(): void {
162
203
  if (this.adsTracker) {
163
- this.adsTracker.off("*", funnelAdEvents);
204
+ this.adsTracker.off("*", funnelAdEvents as any);
164
205
  this.adsTracker.dispose();
165
206
  }
166
207
  }
@@ -168,7 +209,7 @@ class VideoTracker extends Tracker {
168
209
  /**
169
210
  * Prepares tracker to dispose. Calls unregisterListener and drops references to player and tag.
170
211
  */
171
- dispose() {
212
+ dispose(): void {
172
213
  this.stopHeartbeat();
173
214
  this.disposeAdsTracker();
174
215
  this.unregisterListeners();
@@ -189,7 +230,7 @@ class VideoTracker extends Tracker {
189
230
  * }
190
231
  * }
191
232
  */
192
- registerListeners() {}
233
+ registerListeners(): void {}
193
234
 
194
235
  /**
195
236
  * Override this method to unregister listeners to player/tag created in registerListeners
@@ -208,14 +249,14 @@ class VideoTracker extends Tracker {
208
249
  * }
209
250
  * }
210
251
  */
211
- unregisterListeners() {}
252
+ unregisterListeners(): void {}
212
253
 
213
254
  /**
214
255
  * Trackers will generate unique id's for every new video iteration. If you have your own unique
215
256
  * view value, you can override this method to return it.
216
257
  * If the tracker has a parentTracker defined, parent viewId will be used.
217
258
  */
218
- getViewId() {
259
+ getViewId(): string {
219
260
  if (this.parentTracker) {
220
261
  return this.parentTracker.getViewId();
221
262
  } else {
@@ -228,7 +269,7 @@ class VideoTracker extends Tracker {
228
269
  * view value, you can override this method to return it.
229
270
  * If the tracker has a parentTracker defined, parent viewId will be used.
230
271
  */
231
- getViewSession() {
272
+ getViewSession(): string {
232
273
  if (this.parentTracker) {
233
274
  return this.parentTracker.getViewSession();
234
275
  } else {
@@ -237,42 +278,42 @@ class VideoTracker extends Tracker {
237
278
  }
238
279
 
239
280
  /** Override to return the Id of the video. */
240
- getVideoId() {
281
+ getVideoId(): any {
241
282
  return null;
242
283
  }
243
284
 
244
285
  /** Override to return Title of the video. */
245
- getTitle() {
286
+ getTitle(): any {
246
287
  return null;
247
288
  }
248
289
 
249
290
  /** Override to return True if the video is live. */
250
- isLive() {
291
+ isLive(): any {
251
292
  return null;
252
293
  }
253
294
 
254
295
  /** Override to return Bitrate (in bits) of the video. */
255
- getBitrate() {
296
+ getBitrate(): number | null {
256
297
  return null;
257
298
  }
258
299
 
259
300
  /** Override to return the manifest-declared bitrate in bps (Indicated Bitrate). */
260
- getManifestBitrate() {
301
+ getManifestBitrate(): number | null {
261
302
  return null;
262
303
  }
263
304
 
264
305
  /** Override to return the measured network bitrate in bps (Observed Bitrate). */
265
- getSegmentDownloadBitrate() {
306
+ getSegmentDownloadBitrate(): number | null {
266
307
  return null;
267
308
  }
268
309
 
269
310
  /** Override to return the download throughput in bps. */
270
- getNetworkDownloadBitrate() {
311
+ getNetworkDownloadBitrate(): number | null {
271
312
  return null;
272
313
  }
273
314
 
274
315
  /** Calculates consumed bitrate using webkitVideoDecodedByteCount. */
275
- getWebkitBitrate() {
316
+ getWebkitBitrate(): number | null | undefined {
276
317
  if (this.tag && this.tag.webkitVideoDecodedByteCount) {
277
318
  let bitrate;
278
319
  if (this._lastWebkitBitrate) {
@@ -287,12 +328,12 @@ class VideoTracker extends Tracker {
287
328
  }
288
329
 
289
330
  /** Override to return Name of the rendition (ie: 1080p). */
290
- getRenditionName() {
331
+ getRenditionName(): any {
291
332
  return null;
292
333
  }
293
334
 
294
335
  /** Override to return Target Bitrate of the rendition. */
295
- getRenditionBitrate() {
336
+ getRenditionBitrate(): any {
296
337
  return null;
297
338
  }
298
339
 
@@ -304,7 +345,7 @@ class VideoTracker extends Tracker {
304
345
  * the next time this method is called. This allows you to call this.getRenditionShift() without
305
346
  * saving the current rendition and thus preventing interferences with RENDITION_CHANGE events.
306
347
  */
307
- getRenditionShift(saveNewRendition) {
348
+ getRenditionShift(saveNewRendition?: boolean): "up" | "down" | null {
308
349
  let current = this.getManifestBitrate();
309
350
  let last;
310
351
  if (this.isAd()) {
@@ -329,22 +370,22 @@ class VideoTracker extends Tracker {
329
370
  }
330
371
 
331
372
  /** Override to return renidtion actual Height (before re-scaling). */
332
- getRenditionHeight() {
373
+ getRenditionHeight(): any {
333
374
  return this.tag ? this.tag.videoHeight : null;
334
375
  }
335
376
 
336
377
  /** Override to return rendition actual Width (before re-scaling). */
337
- getRenditionWidth() {
378
+ getRenditionWidth(): any {
338
379
  return this.tag ? this.tag.videoWidth : null;
339
380
  }
340
381
 
341
382
  /** Override to return Duration of the video, in ms. */
342
- getDuration() {
383
+ getDuration(): any {
343
384
  return this.tag ? this.tag.duration : null;
344
385
  }
345
386
 
346
387
  /** Override to return Playhead (currentTime) of the video, in ms. */
347
- getPlayhead() {
388
+ getPlayhead(): any {
348
389
  return this.tag ? this.tag.currentTime : null;
349
390
  }
350
391
 
@@ -352,61 +393,61 @@ class VideoTracker extends Tracker {
352
393
  * Override to return Language of the video. We recommend using locale notation, ie: en_US.
353
394
  * {@see https://gist.github.com/jacobbubu/1836273}
354
395
  */
355
- getLanguage() {
396
+ getLanguage(): any {
356
397
  return null;
357
398
  }
358
399
 
359
400
  /** Override to return URL of the resource being played. */
360
- getSrc() {
401
+ getSrc(): any {
361
402
  return this.tag ? this.tag.currentSrc : null;
362
403
  }
363
404
 
364
405
  /** Override to return Playrate (speed) of the video. ie: 1.0, 0.5, 1.25... */
365
- getPlayrate() {
406
+ getPlayrate(): any {
366
407
  return this.tag ? this.tag.playbackRate : null;
367
408
  }
368
409
 
369
410
  /** Override to return True if the video is currently muted. */
370
- isMuted() {
411
+ isMuted(): any {
371
412
  return this.tag ? this.tag.muted : null;
372
413
  }
373
414
 
374
415
  /** Override to return True if the video is currently fullscreen. */
375
- isFullscreen() {
416
+ isFullscreen(): any {
376
417
  return null;
377
418
  }
378
419
 
379
420
  /** Override to return the CDN serving the content. */
380
- getCdn() {
421
+ getCdn(): any {
381
422
  return null;
382
423
  }
383
424
 
384
425
  /** Override to return the Name of the player. */
385
- getPlayerName() {
426
+ getPlayerName(): string {
386
427
  return this.getTrackerName();
387
428
  }
388
429
 
389
430
  /** Override to return the Version of the player. */
390
- getPlayerVersion() {
431
+ getPlayerVersion(): string {
391
432
  return pkg.version;
392
433
  }
393
434
 
394
435
  /** Override to return current FPS (Frames per second). */
395
- getFps() {
436
+ getFps(): any {
396
437
  return null;
397
438
  }
398
439
 
399
440
  /**
400
441
  * Override to return if the player was autoplayed. By default: this.tag.autoplay
401
442
  */
402
- isAutoplayed() {
443
+ isAutoplayed(): any {
403
444
  return this.tag ? this.tag.autoplay : null;
404
445
  }
405
446
 
406
447
  /**
407
448
  * Override to return the player preload attribute. By default: this.tag.preload
408
449
  */
409
- getPreload() {
450
+ getPreload(): any {
410
451
  return this.tag ? this.tag.preload : null;
411
452
  }
412
453
 
@@ -415,7 +456,7 @@ class VideoTracker extends Tracker {
415
456
  * Override to return Quartile of the ad. 0 before first, 1 after first quartile, 2 after
416
457
  * midpoint, 3 after third quartile, 4 when completed.
417
458
  */
418
- getAdQuartile() {
459
+ getAdQuartile(): any {
419
460
  return null;
420
461
  }
421
462
 
@@ -423,7 +464,7 @@ class VideoTracker extends Tracker {
423
464
  * Override to return the position of the ad. Use {@link Constants.AdPositions} enum
424
465
  * to fill this data.
425
466
  */
426
- getAdPosition() {
467
+ getAdPosition(): any {
427
468
  if (this.parentTracker) {
428
469
  return this.parentTracker.state.isStarted ? "mid" : "pre";
429
470
  } else {
@@ -434,14 +475,14 @@ class VideoTracker extends Tracker {
434
475
  /**
435
476
  * Override to return the ad partner. ie: ima, freewheel...
436
477
  */
437
- getAdPartner() {
478
+ getAdPartner(): any {
438
479
  return null;
439
480
  }
440
481
 
441
482
  /**
442
483
  * Override to return the creative id of the ad.
443
484
  */
444
- getAdCreativeId() {
485
+ getAdCreativeId(): any {
445
486
  return null;
446
487
  }
447
488
 
@@ -449,15 +490,15 @@ class VideoTracker extends Tracker {
449
490
  * Override to return the instrumentation of the player.
450
491
  */
451
492
 
452
- getInstrumentationProvider() {
493
+ getInstrumentationProvider(): any {
453
494
  return null;
454
495
  }
455
496
 
456
- getInstrumentationName() {
497
+ getInstrumentationName(): any {
457
498
  return null;
458
499
  }
459
500
 
460
- getInstrumentationVersion() {
501
+ getInstrumentationVersion(): any {
461
502
  return null;
462
503
  }
463
504
 
@@ -468,8 +509,8 @@ class VideoTracker extends Tracker {
468
509
  * @return {object} Filled attributes
469
510
  * @final
470
511
  */
471
- getAttributes(att, type) {
472
- att = Tracker.prototype.getAttributes.apply(this, arguments);
512
+ getAttributes(att?: Record<string, any>, type?: string): Record<string, any> {
513
+ att = Tracker.prototype.getAttributes.apply(this, arguments as any);
473
514
 
474
515
  if (typeof att.isAd === "undefined") att.isAd = this.isAd();
475
516
 
@@ -586,7 +627,7 @@ class VideoTracker extends Tracker {
586
627
  * @param {Object} [timeSinceAttName] Custom timeSince attribute name.
587
628
  * @param {Object} [att] Collection of key:value attributes to send with the request.
588
629
  */
589
- sendCustom(actionName, timeSinceAttName, att) {
630
+ sendCustom(actionName: string, timeSinceAttName: string, att?: Record<string, any>): void {
590
631
  att = att || {};
591
632
  this.sendVideoCustomAction(actionName, att);
592
633
  this.state.setTimeSinceAttribute(timeSinceAttName);
@@ -597,7 +638,7 @@ class VideoTracker extends Tracker {
597
638
  * duplicated events. Should be associated to an event using registerListeners.
598
639
  * @param {Object} [att] Collection of key:value attributes to send with the request.
599
640
  */
600
- sendPlayerReady(att) {
641
+ sendPlayerReady(att?: Record<string, any>): void {
601
642
  if (this.state.goPlayerReady()) {
602
643
  att = att || {};
603
644
  this.sendVideoAction(VideoTracker.Events.PLAYER_READY, att);
@@ -610,7 +651,7 @@ class VideoTracker extends Tracker {
610
651
  * {@link startHeartbeat}.
611
652
  * @param {Object} [att] Collection of key:value attributes to send with the request.
612
653
  */
613
- sendRequest(att) {
654
+ sendRequest(att?: Record<string, any>): void {
614
655
  if (this.state.goRequest()) {
615
656
  let ev;
616
657
  if (this.isAd()) {
@@ -631,7 +672,7 @@ class VideoTracker extends Tracker {
631
672
  * duplicated events. Should be associated to an event using registerListeners.
632
673
  * @param {Object} [att] Collection of key:value attributes to send with the request.
633
674
  */
634
- sendStart(att) {
675
+ sendStart(att?: Record<string, any>): void {
635
676
  if (this.state.goStart()) {
636
677
  let ev;
637
678
  if (this.isAd()) {
@@ -675,7 +716,7 @@ class VideoTracker extends Tracker {
675
716
  * {@link stopHeartbeat}.
676
717
  * @param {Object} [att] Collection of key:value attributes to send with the request.
677
718
  */
678
- sendEnd(att) {
719
+ sendEnd(att?: Record<string, any>): void {
679
720
  if (this.state.goEnd()) {
680
721
  att = att || {};
681
722
  let ev;
@@ -709,7 +750,7 @@ class VideoTracker extends Tracker {
709
750
  harvester?.forceNextQoeCycle?.();
710
751
  // Clear the before-drain callback so the next harvest doesn't overwrite
711
752
  // the final QoE (already in buffer) with zeroed-out state values
712
- harvester?.setBeforeDrainCallback?.(null);
753
+ harvester?.setBeforeDrainCallback(null);
713
754
  // reset the states after the view count is up
714
755
  if(this.adsTracker) this.adsTracker.state.clearTotalAdsTime();
715
756
  this.state.resetViewIdTrackedState();
@@ -722,7 +763,7 @@ class VideoTracker extends Tracker {
722
763
  * duplicated events. Should be associated to an event using registerListeners.
723
764
  * @param {Object} [att] Collection of key:value attributes to send with the request.
724
765
  */
725
- sendPause(att) {
766
+ sendPause(att?: Record<string, any>): void {
726
767
  if (this.state.goPause()) {
727
768
  let ev = this.isAd()
728
769
  ? VideoTracker.Events.AD_PAUSE
@@ -739,7 +780,7 @@ class VideoTracker extends Tracker {
739
780
  * duplicated events. Should be associated to an event using registerListeners.
740
781
  * @param {Object} [att] Collection of key:value attributes to send with the request.
741
782
  */
742
- sendResume(att) {
783
+ sendResume(att?: Record<string, any>): void {
743
784
  if (this.state.goResume()) {
744
785
  att = att || {};
745
786
  let ev;
@@ -762,7 +803,7 @@ class VideoTracker extends Tracker {
762
803
  * duplicated events. Should be associated to an event using registerListeners.
763
804
  * @param {Object} [att] Collection of key:value attributes to send with the request.
764
805
  */
765
- sendBufferStart(att) {
806
+ sendBufferStart(att?: Record<string, any>): void {
766
807
  if (this.state.goBufferStart()) {
767
808
  att = att || {};
768
809
  let ev;
@@ -787,7 +828,7 @@ class VideoTracker extends Tracker {
787
828
  * duplicated events. Should be associated to an event using registerListeners.
788
829
  * @param {Object} [att] Collection of key:value attributes to send with the request.
789
830
  */
790
- sendBufferEnd(att) {
831
+ sendBufferEnd(att?: Record<string, any>): void {
791
832
  if (this.state.goBufferEnd()) {
792
833
  att = att || {};
793
834
  let ev;
@@ -815,7 +856,7 @@ class VideoTracker extends Tracker {
815
856
  }
816
857
  }
817
858
 
818
- buildBufferAttributes(att) {
859
+ buildBufferAttributes(att: Record<string, any>): Record<string, any> {
819
860
  if (att.timeSinceStarted == undefined || att.timeSinceStarted < 100) {
820
861
  att.isInitialBuffering = !this.state.initialBufferingHappened;
821
862
  } else {
@@ -835,7 +876,7 @@ class VideoTracker extends Tracker {
835
876
  * duplicated events. Should be associated to an event using registerListeners.
836
877
  * @param {Object} [att] Collection of key:value attributes to send with the request.
837
878
  */
838
- sendSeekStart(att) {
879
+ sendSeekStart(att?: Record<string, any>): void {
839
880
  if (this.state.goSeekStart()) {
840
881
  let ev;
841
882
  if (this.isAd()) {
@@ -856,7 +897,7 @@ class VideoTracker extends Tracker {
856
897
  * duplicated events. Should be associated to an event using registerListeners.
857
898
  * @param {Object} [att] Collection of key:value attributes to send with the request.
858
899
  */
859
- sendSeekEnd(att) {
900
+ sendSeekEnd(att?: Record<string, any>): void {
860
901
  if (this.state.goSeekEnd()) {
861
902
  att = att || {};
862
903
  let ev;
@@ -881,7 +922,7 @@ class VideoTracker extends Tracker {
881
922
  * @param {Object} [att] Collection of key:value attributes to send with the request.
882
923
  * @param {String} att.state Download requires a string to distinguish different states.
883
924
  */
884
- sendDownload(att) {
925
+ sendDownload(att?: Record<string, any>): void {
885
926
  att = att || {};
886
927
  if (!att.state) Log.warn("Called sendDownload without { state: xxxxx }.");
887
928
  this.sendVideoAction(VideoTracker.Events.DOWNLOAD, att);
@@ -893,7 +934,7 @@ class VideoTracker extends Tracker {
893
934
  * duplicated events. Should be associated to an event using registerListeners.
894
935
  * @param {Object} [att] Collection of key:value attributes to send with the request.
895
936
  */
896
- sendError(att) {
937
+ sendError(att?: Record<string, any>): void {
897
938
  att = att || {};
898
939
 
899
940
  att.isAd = this.isAd();
@@ -911,7 +952,7 @@ class VideoTracker extends Tracker {
911
952
  * duplicated events. Should be associated to an event using registerListeners.
912
953
  * @param {Object} [att] Collection of key:value attributes to send with the request.
913
954
  */
914
- sendRenditionChanged(att) {
955
+ sendRenditionChanged(att?: Record<string, any>): void {
915
956
  att = att || {};
916
957
  att.timeSinceLastRenditionChange =
917
958
  this.state.timeSinceLastRenditionChange.getDeltaTime();
@@ -956,7 +997,7 @@ class VideoTracker extends Tracker {
956
997
  * @param {number} att.url Url of the clicked ad.
957
998
  *
958
999
  */
959
- sendHeartbeat(att) {
1000
+ sendHeartbeat(att?: Record<string, any>): void {
960
1001
  if (this.state.isRequested) {
961
1002
  let ev;
962
1003
 
@@ -979,14 +1020,14 @@ class VideoTracker extends Tracker {
979
1020
  }
980
1021
  }
981
1022
 
982
- adjustElapsedTimeForPause(elapsedTime) {
1023
+ adjustElapsedTimeForPause(elapsedTime: number): number {
983
1024
  if (this.state._acc) {
984
1025
  elapsedTime -= this.state._acc;
985
1026
  this.state._acc = 0;
986
1027
  }
987
1028
 
988
1029
  if (this.state.isPaused) {
989
- elapsedTime -= this.state.elapsedTime.getDeltaTime();
1030
+ elapsedTime -= this.state.elapsedTime.getDeltaTime() as number;
990
1031
  if (elapsedTime < 10) elapsedTime = 0;
991
1032
  this.state.elapsedTime.start();
992
1033
  }
@@ -995,7 +1036,7 @@ class VideoTracker extends Tracker {
995
1036
  elapsedTime -= this.state._bufferAcc;
996
1037
  this.state._bufferAcc = 0;
997
1038
  } else if (this.state.isBuffering) {
998
- elapsedTime -= this.state.bufferElapsedTime.getDeltaTime();
1039
+ elapsedTime -= this.state.bufferElapsedTime.getDeltaTime() as number;
999
1040
  if (elapsedTime < 5) {
1000
1041
  elapsedTime = 0;
1001
1042
  }
@@ -1011,7 +1052,7 @@ class VideoTracker extends Tracker {
1011
1052
  * duplicated events. Should be associated to an event using registerListeners.
1012
1053
  * @param {Object} [att] Collection of key:value attributes to send with the request.
1013
1054
  */
1014
- sendAdBreakStart(att) {
1055
+ sendAdBreakStart(att?: Record<string, any>): void {
1015
1056
  if (this.isAd() && this.state.goAdBreakStart()) {
1016
1057
  this.state.totalAdPlaytime = 0;
1017
1058
  if (this.parentTracker) this.parentTracker.state.isPlaying = false;
@@ -1025,7 +1066,7 @@ class VideoTracker extends Tracker {
1025
1066
  * duplicated events. Should be associated to an event using registerListeners.
1026
1067
  * @param {Object} [att] Collection of key:value attributes to send with the request.
1027
1068
  */
1028
- sendAdBreakEnd(att) {
1069
+ sendAdBreakEnd(att?: Record<string, any>): void {
1029
1070
  if (this.isAd() && this.state.goAdBreakEnd()) {
1030
1071
  att = att || {};
1031
1072
  att.timeSinceAdBreakBegin =
@@ -1046,7 +1087,7 @@ class VideoTracker extends Tracker {
1046
1087
  * @param {Object} [att] Collection of key:value attributes to send with the request.
1047
1088
  * @param {number} att.quartile Number of the quartile.
1048
1089
  */
1049
- sendAdQuartile(att) {
1090
+ sendAdQuartile(att?: Record<string, any>): void {
1050
1091
  if (this.isAd()) {
1051
1092
  att = att || {};
1052
1093
  if (!att.quartile)
@@ -1066,7 +1107,7 @@ class VideoTracker extends Tracker {
1066
1107
  * @param {Object} [att] Collection of key:value attributes to send with the request.
1067
1108
  * @param {number} att.url Url of the clicked ad.
1068
1109
  */
1069
- sendAdClick(att) {
1110
+ sendAdClick(att?: Record<string, any>): void {
1070
1111
  if (this.isAd()) {
1071
1112
  att = att || {};
1072
1113
  if (!att.url) Log.warn("Called sendAdClick without { url: xxxxx }.");
@@ -1154,7 +1195,7 @@ VideoTracker.Events = {
1154
1195
  };
1155
1196
 
1156
1197
  // Private members
1157
- function funnelAdEvents(e) {
1198
+ function funnelAdEvents(this: VideoTracker, e: any) {
1158
1199
  if (e.type === VideoTracker.Events.AD_ERROR) {
1159
1200
  this.sendVideoErrorAction(e.type, e.data);
1160
1201
  return;