@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
@@ -0,0 +1,366 @@
1
+ import Tracker, { TrackerOptions } from "./tracker";
2
+ import TrackerState from "./videotrackerstate";
3
+ export interface VideoTrackerOptions extends TrackerOptions {
4
+ isAd?: boolean;
5
+ adsTracker?: VideoTracker;
6
+ src?: string;
7
+ tag?: any;
8
+ }
9
+ /**
10
+ * Base video tracker class provides extensible tracking over video elements. See {@link Tracker}.
11
+ * Extend this class to create your own video tracker class. Override getter methods and
12
+ * registerListeners/unregisterListeners to provide full integration with your video experience.
13
+ *
14
+ * @example
15
+ * Tracker instances should be added to Core library to start sending data:
16
+ * nrvideo.Core.addTracker(new Tracker())
17
+ *
18
+ * @extends Tracker
19
+ */
20
+ declare class VideoTracker extends Tracker {
21
+ static Events: Record<string, string>;
22
+ /**
23
+ * TrackerState instance. Stores the state of the view. Tracker will automatically update the
24
+ * state of its instance, so there's no need to modify/interact with it manually.
25
+ * @type TrackerState
26
+ */
27
+ state: TrackerState;
28
+ /**
29
+ * Another Tracker instance to track ads.
30
+ * @type Tracker
31
+ */
32
+ adsTracker: VideoTracker | null;
33
+ /** Redeclared narrower than base Tracker's `Tracker | null` — VideoTracker's own
34
+ * methods (getViewId, getAdPosition, sendStart, ...) always call it as a VideoTracker.
35
+ * Type-only (`declare`); the real assignment happens in the base Tracker constructor. */
36
+ parentTracker: VideoTracker | null;
37
+ /**
38
+ * Last bufferType value.
39
+ * @private
40
+ */
41
+ _lastBufferType: string | null;
42
+ _userId: any;
43
+ _src: string | null;
44
+ player?: any;
45
+ tag?: any;
46
+ _lastWebkitBitrate?: number;
47
+ _lastAdRendition?: number | null;
48
+ _lastRendition?: number | null;
49
+ /**
50
+ * Constructor, receives player and options.
51
+ * Lifecycle: constructor > {@link setOptions} > {@link setPlayer} > {@link registerListeners}.
52
+ *
53
+ * @param {Object} [player] Player to track. See {@link setPlayer}.
54
+ * @param {Object} [options] Options for the tracker. See {@link setOptions}.
55
+ */
56
+ constructor(player?: any, options?: VideoTrackerOptions);
57
+ setUserId(userId: any): void;
58
+ /**
59
+ * Set options for the Tracker.
60
+ *
61
+ * @param {Object} [options] Options for the tracker.
62
+ * @param {Boolean} [options.isAd] True if the tracker is tracking ads. See {@link setIsAd}.
63
+ * @param {number} [options.heartbeat] Set time between heartbeats. See {@link heartbeat}.
64
+ * @param {Object} [options.customData] Set custom data. See {@link customData}.
65
+ * @param {Tracker} [options.parentTracker] Set parent tracker. See {@link parentTracker}.
66
+ * @param {Tracker} [options.adsTracker] Set ads tracker. See {@link adsTracker}.
67
+ * @param {Object} [options.tag] DOM element to track. See {@link setPlayer}.
68
+ */
69
+ setOptions(options?: VideoTrackerOptions): void;
70
+ /**
71
+ * Set a player and/or a tag. If there was one already defined, it will call dispose() first.
72
+ * Will call this.registerListeners() afterwards.
73
+ *
74
+ * @param {Object|string} player New player to save as this.player. If a string is passed,
75
+ * document.getElementById will be called.
76
+ * @param {DOMObject|string} [tag] Optional DOMElement to save as this.tag. If a string is passed,
77
+ * document.getElementById will be called.
78
+ */
79
+ setPlayer(player: any, tag?: any): void;
80
+ /** Returns true if the tracker is currently on ads. */
81
+ isAd(): boolean;
82
+ /** Sets if the tracker is currenlty tracking ads */
83
+ setIsAd(isAd: boolean): void;
84
+ /**
85
+ * Use this function to set up a child ad tracker. You will be able to access it using
86
+ * this.adsTracker.
87
+ *
88
+ * @param {Tracker} tracker Ad tracker to add
89
+ */
90
+ setAdsTracker(tracker?: VideoTracker | null): void;
91
+ /**
92
+ * Dispose current adsTracker.
93
+ */
94
+ disposeAdsTracker(): void;
95
+ /**
96
+ * Prepares tracker to dispose. Calls unregisterListener and drops references to player and tag.
97
+ */
98
+ dispose(): void;
99
+ /**
100
+ * Override this method to register listeners to player/tag.
101
+ * @example
102
+ * class SpecificTracker extends Tracker {
103
+ * registerListeners() {
104
+ * this.player.on('play', () => this.playHandler)
105
+ * }
106
+ *
107
+ * playHandler() {
108
+ * this.send(VideoTracker.Events.REQUESTED)
109
+ * }
110
+ * }
111
+ */
112
+ registerListeners(): void;
113
+ /**
114
+ * Override this method to unregister listeners to player/tag created in registerListeners
115
+ * @example
116
+ * class SpecificTracker extends Tracker {
117
+ * registerListeners() {
118
+ * this.player.on('play', () => this.playHandler)
119
+ * }
120
+ *
121
+ * unregisterListeners() {
122
+ * this.player.off('play', () => this.playHandler)
123
+ * }
124
+ *
125
+ * playHandler() {
126
+ * this.send(VideoTracker.Events.REQUESTED)
127
+ * }
128
+ * }
129
+ */
130
+ unregisterListeners(): void;
131
+ /**
132
+ * Trackers will generate unique id's for every new video iteration. If you have your own unique
133
+ * view value, you can override this method to return it.
134
+ * If the tracker has a parentTracker defined, parent viewId will be used.
135
+ */
136
+ getViewId(): string;
137
+ /**
138
+ * Trackers will generate unique id's for every new video session. If you have your own unique
139
+ * view value, you can override this method to return it.
140
+ * If the tracker has a parentTracker defined, parent viewId will be used.
141
+ */
142
+ getViewSession(): string;
143
+ /** Override to return the Id of the video. */
144
+ getVideoId(): any;
145
+ /** Override to return Title of the video. */
146
+ getTitle(): any;
147
+ /** Override to return True if the video is live. */
148
+ isLive(): any;
149
+ /** Override to return Bitrate (in bits) of the video. */
150
+ getBitrate(): number | null;
151
+ /** Override to return the manifest-declared bitrate in bps (Indicated Bitrate). */
152
+ getManifestBitrate(): number | null;
153
+ /** Override to return the measured network bitrate in bps (Observed Bitrate). */
154
+ getSegmentDownloadBitrate(): number | null;
155
+ /** Override to return the download throughput in bps. */
156
+ getNetworkDownloadBitrate(): number | null;
157
+ /** Calculates consumed bitrate using webkitVideoDecodedByteCount. */
158
+ getWebkitBitrate(): number | null | undefined;
159
+ /** Override to return Name of the rendition (ie: 1080p). */
160
+ getRenditionName(): any;
161
+ /** Override to return Target Bitrate of the rendition. */
162
+ getRenditionBitrate(): any;
163
+ /**
164
+ * This method will return 'up', 'down' or null depending on if the bitrate of the rendition
165
+ * have changed from the last time it was called.
166
+ *
167
+ * @param {boolean} [saveNewRendition=false] If true, current rendition will be stored to be used
168
+ * the next time this method is called. This allows you to call this.getRenditionShift() without
169
+ * saving the current rendition and thus preventing interferences with RENDITION_CHANGE events.
170
+ */
171
+ getRenditionShift(saveNewRendition?: boolean): "up" | "down" | null;
172
+ /** Override to return renidtion actual Height (before re-scaling). */
173
+ getRenditionHeight(): any;
174
+ /** Override to return rendition actual Width (before re-scaling). */
175
+ getRenditionWidth(): any;
176
+ /** Override to return Duration of the video, in ms. */
177
+ getDuration(): any;
178
+ /** Override to return Playhead (currentTime) of the video, in ms. */
179
+ getPlayhead(): any;
180
+ /**
181
+ * Override to return Language of the video. We recommend using locale notation, ie: en_US.
182
+ * {@see https://gist.github.com/jacobbubu/1836273}
183
+ */
184
+ getLanguage(): any;
185
+ /** Override to return URL of the resource being played. */
186
+ getSrc(): any;
187
+ /** Override to return Playrate (speed) of the video. ie: 1.0, 0.5, 1.25... */
188
+ getPlayrate(): any;
189
+ /** Override to return True if the video is currently muted. */
190
+ isMuted(): any;
191
+ /** Override to return True if the video is currently fullscreen. */
192
+ isFullscreen(): any;
193
+ /** Override to return the CDN serving the content. */
194
+ getCdn(): any;
195
+ /** Override to return the Name of the player. */
196
+ getPlayerName(): string;
197
+ /** Override to return the Version of the player. */
198
+ getPlayerVersion(): string;
199
+ /** Override to return current FPS (Frames per second). */
200
+ getFps(): any;
201
+ /**
202
+ * Override to return if the player was autoplayed. By default: this.tag.autoplay
203
+ */
204
+ isAutoplayed(): any;
205
+ /**
206
+ * Override to return the player preload attribute. By default: this.tag.preload
207
+ */
208
+ getPreload(): any;
209
+ /**
210
+ * Override to return Quartile of the ad. 0 before first, 1 after first quartile, 2 after
211
+ * midpoint, 3 after third quartile, 4 when completed.
212
+ */
213
+ getAdQuartile(): any;
214
+ /**
215
+ * Override to return the position of the ad. Use {@link Constants.AdPositions} enum
216
+ * to fill this data.
217
+ */
218
+ getAdPosition(): any;
219
+ /**
220
+ * Override to return the ad partner. ie: ima, freewheel...
221
+ */
222
+ getAdPartner(): any;
223
+ /**
224
+ * Override to return the creative id of the ad.
225
+ */
226
+ getAdCreativeId(): any;
227
+ /**
228
+ * Override to return the instrumentation of the player.
229
+ */
230
+ getInstrumentationProvider(): any;
231
+ getInstrumentationName(): any;
232
+ getInstrumentationVersion(): any;
233
+ /**
234
+ * Do NOT override. This method fills all the appropiate attributes for tracked video.
235
+ *
236
+ * @param {object} [att] Collection of key value attributes
237
+ * @return {object} Filled attributes
238
+ * @final
239
+ */
240
+ getAttributes(att?: Record<string, any>, type?: string): Record<string, any>;
241
+ /**
242
+ * Sends custom event and registers a timeSince attribute.
243
+ * @param {Object} [actionName] Custom action name.
244
+ * @param {Object} [timeSinceAttName] Custom timeSince attribute name.
245
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
246
+ */
247
+ sendCustom(actionName: string, timeSinceAttName: string, att?: Record<string, any>): void;
248
+ /**
249
+ * Sends associated event and changes view state. An internal state machine will prevent
250
+ * duplicated events. Should be associated to an event using registerListeners.
251
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
252
+ */
253
+ sendPlayerReady(att?: Record<string, any>): void;
254
+ /**
255
+ * Sends associated event and changes view state. An internal state machine will prevent
256
+ * duplicated events. Should be associated to an event using registerListeners. Calls
257
+ * {@link startHeartbeat}.
258
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
259
+ */
260
+ sendRequest(att?: Record<string, any>): void;
261
+ /**
262
+ * Sends associated event and changes view state. An internal state machine will prevent
263
+ * duplicated events. Should be associated to an event using registerListeners.
264
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
265
+ */
266
+ sendStart(att?: Record<string, any>): void;
267
+ /**
268
+ * Sends associated event and changes view state. An internal state machine will prevent
269
+ * duplicated events. Should be associated to an event using registerListeners. Calls
270
+ * {@link stopHeartbeat}.
271
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
272
+ */
273
+ sendEnd(att?: Record<string, any>): void;
274
+ /**
275
+ * Sends associated event and changes view state. An internal state machine will prevent
276
+ * duplicated events. Should be associated to an event using registerListeners.
277
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
278
+ */
279
+ sendPause(att?: Record<string, any>): void;
280
+ /**
281
+ * Sends associated event and changes view state. An internal state machine will prevent
282
+ * duplicated events. Should be associated to an event using registerListeners.
283
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
284
+ */
285
+ sendResume(att?: Record<string, any>): void;
286
+ /**
287
+ * Sends associated event and changes view state. An internal state machine will prevent
288
+ * duplicated events. Should be associated to an event using registerListeners.
289
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
290
+ */
291
+ sendBufferStart(att?: Record<string, any>): void;
292
+ /**
293
+ * Sends associated event and changes view state. An internal state machine will prevent
294
+ * duplicated events. Should be associated to an event using registerListeners.
295
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
296
+ */
297
+ sendBufferEnd(att?: Record<string, any>): void;
298
+ buildBufferAttributes(att: Record<string, any>): Record<string, any>;
299
+ /**
300
+ * Sends associated event and changes view state. An internal state machine will prevent
301
+ * duplicated events. Should be associated to an event using registerListeners.
302
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
303
+ */
304
+ sendSeekStart(att?: Record<string, any>): void;
305
+ /**
306
+ * Sends associated event and changes view state. An internal state machine will prevent
307
+ * duplicated events. Should be associated to an event using registerListeners.
308
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
309
+ */
310
+ sendSeekEnd(att?: Record<string, any>): void;
311
+ /**
312
+ * Sends associated event and changes view state. An internal state machine will prevent
313
+ * duplicated events. Should be associated to an event using registerListeners.
314
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
315
+ * @param {String} att.state Download requires a string to distinguish different states.
316
+ */
317
+ sendDownload(att?: Record<string, any>): void;
318
+ /**
319
+ * Sends associated event and changes view state. An internal state machine will prevent
320
+ * duplicated events. Should be associated to an event using registerListeners.
321
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
322
+ */
323
+ sendError(att?: Record<string, any>): void;
324
+ /**
325
+ * Sends associated event and changes view state. An internal state machine will prevent
326
+ * duplicated events. Should be associated to an event using registerListeners.
327
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
328
+ */
329
+ sendRenditionChanged(att?: Record<string, any>): void;
330
+ /**
331
+ * Sends associated event and changes view state. Heartbeat will automatically be sent every
332
+ * 10 seconds. There's no need to call this manually.
333
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
334
+ * @param {number} att.url Url of the clicked ad.
335
+ *
336
+ */
337
+ sendHeartbeat(att?: Record<string, any>): void;
338
+ adjustElapsedTimeForPause(elapsedTime: number): number;
339
+ /**
340
+ * Sends associated event and changes view state. An internal state machine will prevent
341
+ * duplicated events. Should be associated to an event using registerListeners.
342
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
343
+ */
344
+ sendAdBreakStart(att?: Record<string, any>): void;
345
+ /**
346
+ * Sends associated event and changes view state. An internal state machine will prevent
347
+ * duplicated events. Should be associated to an event using registerListeners.
348
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
349
+ */
350
+ sendAdBreakEnd(att?: Record<string, any>): void;
351
+ /**
352
+ * Sends associated event and changes view state. An internal state machine will prevent
353
+ * duplicated events. Should be associated to an event using registerListeners.
354
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
355
+ * @param {number} att.quartile Number of the quartile.
356
+ */
357
+ sendAdQuartile(att?: Record<string, any>): void;
358
+ /**
359
+ * Sends associated event and changes view state. An internal state machine will prevent
360
+ * duplicated events. Should be associated to an event using registerListeners.
361
+ * @param {Object} [att] Collection of key:value attributes to send with the request.
362
+ * @param {number} att.url Url of the clicked ad.
363
+ */
364
+ sendAdClick(att?: Record<string, any>): void;
365
+ }
366
+ export default VideoTracker;
@@ -0,0 +1,228 @@
1
+ import Chrono from "./chrono";
2
+ /**
3
+ * State machine for a VideoTracker and its monitored video.
4
+ */
5
+ declare class VideoTrackerState {
6
+ _viewSession: string | null;
7
+ _viewCount: number;
8
+ _isAd: boolean;
9
+ numberOfErrors: number;
10
+ numberOfAds: number;
11
+ numberOfVideos: number;
12
+ totalPlaytime: number;
13
+ weightedAverageBitrate: number;
14
+ totalAdPlaytime: number;
15
+ isAdBreak: boolean;
16
+ initialBufferingHappened: boolean;
17
+ startupTime: number | null;
18
+ peakBitrate: number;
19
+ partialAverageBitrate: number;
20
+ _totalBitrateDuration: number;
21
+ weightedBitrate: number;
22
+ _lastBitrate: number | null;
23
+ _lastBitrateChangeTimestamp: number | null;
24
+ _downloadBitrates: number[];
25
+ _lastDownloadBitrate: number | null;
26
+ totalSwitchUps: number;
27
+ totalSwitchDowns: number;
28
+ totalPauseTime: number;
29
+ _playedRenditions: Set<string>;
30
+ hadStartupError: boolean;
31
+ hadPlaybackError: boolean;
32
+ totalRebufferingTime: number;
33
+ isPlayerReady: boolean;
34
+ isRequested: boolean;
35
+ isStarted: boolean;
36
+ isPaused: boolean;
37
+ isSeeking: boolean;
38
+ isBuffering: boolean;
39
+ isPlaying: boolean;
40
+ timeSinceRequested: Chrono;
41
+ timeSinceStarted: Chrono;
42
+ timeSincePaused: Chrono;
43
+ timeSinceSeekBegin: Chrono;
44
+ timeSinceBufferBegin: Chrono;
45
+ timeSinceAdBreakStart: Chrono;
46
+ timeSinceLastDownload: Chrono;
47
+ timeSinceLastHeartbeat: Chrono;
48
+ timeSinceLastRenditionChange: Chrono;
49
+ timeSinceLastAdQuartile: Chrono;
50
+ timeSinceLastAd: Chrono;
51
+ timeSinceLastError: Chrono;
52
+ timeSinceLastAdError: Chrono;
53
+ timeSinceResumed: Chrono;
54
+ timeSinceSeekEnd: Chrono;
55
+ playtimeSinceLastEvent: Chrono;
56
+ customTimeSinceAttributes: Record<string, Chrono>;
57
+ elapsedTime: Chrono;
58
+ bufferElapsedTime: Chrono;
59
+ _totalAdPlaytime: Chrono;
60
+ /** @private */
61
+ _createdAt: number;
62
+ _hb: boolean;
63
+ _acc: number;
64
+ _bufferAcc: number;
65
+ isError?: boolean;
66
+ /** Constructor */
67
+ constructor();
68
+ /** Resets all flags and chronos. */
69
+ reset(): void;
70
+ /** Resets flags. */
71
+ resetFlags(): void;
72
+ /** Resets chronos. */
73
+ resetChronos(): void;
74
+ /** Returns true if the tracker is currently on ads. */
75
+ isAd(): boolean;
76
+ /** Sets if the tracker is currenlty tracking ads */
77
+ setIsAd(isAd: boolean): void;
78
+ /**
79
+ * Set the Chrono for the custom attribute
80
+ *
81
+ * @param {object} name Time since attribute name.
82
+ */
83
+ setTimeSinceAttribute(name: string): void;
84
+ /**
85
+ * Delete a time since attribute
86
+ *
87
+ * @param {object} name Time since attribute name.
88
+ */
89
+ removeTimeSinceAttribute(name: string): void;
90
+ /**
91
+ * Returns a random-generated view Session ID, useful to sort by views.
92
+ */
93
+ getViewSession(): string;
94
+ /**
95
+ * Returns a random-generated view Session ID, plus a view count, allowing you to distinguish
96
+ * between two videos played in the same session.
97
+ */
98
+ getViewId(): string;
99
+ /**
100
+ * Fills given object with state-based attributes.
101
+ *
102
+ * @param {object} att Collection fo key value attributes
103
+ * @return {object} Filled attributes
104
+ */
105
+ getStateAttributes(att?: Record<string, any>): Record<string, any>;
106
+ getQoeAttributes(att?: Record<string, any>): Record<string, any>;
107
+ /**
108
+ * Calculate the bufferType attribute.
109
+ *
110
+ * @param {boolean} isInitialBuffering Is initial buffering event.
111
+ */
112
+ calculateBufferType(isInitialBuffering: boolean): string;
113
+ /**
114
+ * Augments view count. This will be called with each *_START and *_END.
115
+ */
116
+ goViewCountUp(): void;
117
+ /**
118
+ * Checks flags and changes state.
119
+ * @returns {boolean} True if the state changed.
120
+ */
121
+ goPlayerReady(): boolean;
122
+ /**
123
+ * Checks flags and changes state
124
+ * @returns {boolean} True if the state changed.
125
+ */
126
+ goRequest(): boolean;
127
+ /**
128
+ * Checks flags and changes state
129
+ * @returns {boolean} True if the state changed.
130
+ */
131
+ goStart(): boolean;
132
+ /**
133
+ * Checks flags and changes state
134
+ * @returns {boolean} True if the state changed.
135
+ */
136
+ goEnd(): boolean;
137
+ /**
138
+ * Checks flags and changes state
139
+ * @returns {boolean} True if the state changed.
140
+ */
141
+ goPause(): boolean;
142
+ /**
143
+ * Checks flags and changes state
144
+ * @returns {boolean} True if the state changed.
145
+ */
146
+ goResume(): boolean;
147
+ /**
148
+ * Checks flags and changes state
149
+ * @returns {boolean} True if the state changed.
150
+ */
151
+ goBufferStart(): boolean;
152
+ /**
153
+ * Checks flags and changes state
154
+ * @returns {boolean} True if the state changed.
155
+ */
156
+ goBufferEnd(): boolean;
157
+ /**
158
+ * Checks flags and changes state
159
+ * @returns {boolean} True if the state changed.
160
+ */
161
+ goSeekStart(): boolean;
162
+ /**
163
+ * Checks flags and changes state
164
+ * @returns {boolean} True if the state changed.
165
+ */
166
+ goSeekEnd(): boolean;
167
+ /**
168
+ * Checks flags and changes state
169
+ * @returns {boolean} True if the state changed.
170
+ */
171
+ goAdBreakStart(): boolean;
172
+ /**
173
+ * Checks flags and changes state
174
+ * @returns {boolean} True if the state changed.
175
+ */
176
+ goAdBreakEnd(): boolean;
177
+ /**
178
+ * Restarts download chrono.
179
+ */
180
+ goDownload(): void;
181
+ /**
182
+ * Restarts heartbeat chrono.
183
+ */
184
+ goHeartbeat(): void;
185
+ /**
186
+ * Restarts rendition change chrono.
187
+ */
188
+ goRenditionChange(): void;
189
+ /**
190
+ * Restarts ad quartile chrono.
191
+ */
192
+ goAdQuartile(): void;
193
+ /**
194
+ * Increments error counter and starts appropriate error timer.
195
+ */
196
+ goError(): void;
197
+ /**
198
+ * Restarts last ad chrono.
199
+ */
200
+ goLastAd(): void;
201
+ /**
202
+ * Updates peak bitrate and time-weighted average bitrate (content only).
203
+ * @param {number} bitrate Current content bitrate in bps.
204
+ */
205
+ trackContentBitrateState(bitrate: number): void;
206
+ /**
207
+ * Records network download bitrate observation. Only tracks values that differ from previous.
208
+ * @param {number} bps Network throughput in bits per second.
209
+ */
210
+ trackDownloadRate(bps: number): void;
211
+ /**
212
+ * Records a rendition play event (height x width combination).
213
+ * @param {number} height Rendition height in pixels.
214
+ * @param {number} width Rendition width in pixels.
215
+ */
216
+ addPlayedRendition(height: number, width: number): void;
217
+ /**
218
+ * Resets tracked variable for view id change
219
+ * */
220
+ resetViewIdTrackedState(): void;
221
+ /** Methods to manage total ads time chrono */
222
+ clearTotalAdsTime(): void;
223
+ totalAdTime(): number;
224
+ startAdsTime(): void;
225
+ stopAdsTime(): number | null;
226
+ setStartupTime(totalAdTime: number): void;
227
+ }
228
+ export default VideoTrackerState;