@eyevinn/player-analytics-client-sdk-web 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js ADDED
@@ -0,0 +1,776 @@
1
+ var $g5Y9E$eyevinnvideoeventfilter = require("@eyevinn/video-event-filter");
2
+
3
+ function $parcel$export(e, n, v, s) {
4
+ Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
5
+ }
6
+
7
+ $parcel$export(module.exports, "PlayerAnalytics", () => $7d88e8cdd46a09a5$exports.PlayerAnalytics);
8
+ $parcel$export(module.exports, "IPlayerAnalyticsInitOptions", () => $7d88e8cdd46a09a5$exports.IPlayerAnalyticsInitOptions);
9
+ $parcel$export(module.exports, "PlayerAnalyticsConnector", () => $c2e08ff125b5bcd1$exports.PlayerAnalyticsConnector);
10
+ $parcel$export(module.exports, "IPlayerAnalyticsConnectorInitOptions", () => $c2e08ff125b5bcd1$exports.IPlayerAnalyticsConnectorInitOptions);
11
+ var $7d88e8cdd46a09a5$exports = {};
12
+
13
+ $parcel$export($7d88e8cdd46a09a5$exports, "PlayerAnalytics", () => $7d88e8cdd46a09a5$export$f76c463fe9cb9f15, (v) => $7d88e8cdd46a09a5$export$f76c463fe9cb9f15 = v);
14
+ var $e8f16a459684b36f$export$342d7dbd8323f55e;
15
+ (function($e8f16a459684b36f$export$342d7dbd8323f55e) {
16
+ $e8f16a459684b36f$export$342d7dbd8323f55e["loading"] = "loading";
17
+ $e8f16a459684b36f$export$342d7dbd8323f55e["loaded"] = "loaded";
18
+ $e8f16a459684b36f$export$342d7dbd8323f55e["play"] = "playing";
19
+ $e8f16a459684b36f$export$342d7dbd8323f55e["resume"] = "playing";
20
+ $e8f16a459684b36f$export$342d7dbd8323f55e["pause"] = "paused";
21
+ $e8f16a459684b36f$export$342d7dbd8323f55e["seeking"] = "seeking";
22
+ $e8f16a459684b36f$export$342d7dbd8323f55e["seeked"] = "seeked";
23
+ $e8f16a459684b36f$export$342d7dbd8323f55e["buffering"] = "buffering";
24
+ $e8f16a459684b36f$export$342d7dbd8323f55e["buffered"] = "buffered";
25
+ $e8f16a459684b36f$export$342d7dbd8323f55e["ended"] = "stopped";
26
+ $e8f16a459684b36f$export$342d7dbd8323f55e["error"] = "error";
27
+ $e8f16a459684b36f$export$342d7dbd8323f55e["warning"] = "warning";
28
+ $e8f16a459684b36f$export$342d7dbd8323f55e["bitratechanged"] = "bitrate_changed";
29
+ $e8f16a459684b36f$export$342d7dbd8323f55e["heartbeat"] = "hearbeat";
30
+ })($e8f16a459684b36f$export$342d7dbd8323f55e || ($e8f16a459684b36f$export$342d7dbd8323f55e = {
31
+ }));
32
+ var $e8f16a459684b36f$export$31c453b5fe09788d = 5000;
33
+
34
+
35
+ var $4cb1735bdc43624b$exports = {};
36
+
37
+ $parcel$export($4cb1735bdc43624b$exports, "Reporter", () => $4cb1735bdc43624b$export$957313a2f485e5ed, (v) => $4cb1735bdc43624b$export$957313a2f485e5ed = v);
38
+
39
+ var $4cb1735bdc43624b$var$__assign = undefined && undefined.__assign || function() {
40
+ $4cb1735bdc43624b$var$__assign = Object.assign || function(t) {
41
+ for(var s, i = 1, n = arguments.length; i < n; i++){
42
+ s = arguments[i];
43
+ for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
44
+ }
45
+ return t;
46
+ };
47
+ return $4cb1735bdc43624b$var$__assign.apply(this, arguments);
48
+ };
49
+ var $4cb1735bdc43624b$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
50
+ function adopt(value) {
51
+ return value instanceof P ? value : new P(function(resolve) {
52
+ resolve(value);
53
+ });
54
+ }
55
+ return new (P || (P = Promise))(function(resolve, reject) {
56
+ function fulfilled(value) {
57
+ try {
58
+ step(generator.next(value));
59
+ } catch (e) {
60
+ reject(e);
61
+ }
62
+ }
63
+ function rejected(value) {
64
+ try {
65
+ step(generator["throw"](value));
66
+ } catch (e) {
67
+ reject(e);
68
+ }
69
+ }
70
+ function step(result) {
71
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
72
+ }
73
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
74
+ });
75
+ };
76
+ var $4cb1735bdc43624b$var$__generator = undefined && undefined.__generator || function(thisArg, body) {
77
+ var _ = {
78
+ label: 0,
79
+ sent: function() {
80
+ if (t[0] & 1) throw t[1];
81
+ return t[1];
82
+ },
83
+ trys: [],
84
+ ops: []
85
+ }, f, y, t, g;
86
+ function verb(n) {
87
+ return function(v) {
88
+ return step([
89
+ n,
90
+ v
91
+ ]);
92
+ };
93
+ }
94
+ function step(op) {
95
+ if (f) throw new TypeError("Generator is already executing.");
96
+ while(_)try {
97
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
98
+ if (y = 0, t) op = [
99
+ op[0] & 2,
100
+ t.value
101
+ ];
102
+ switch(op[0]){
103
+ case 0:
104
+ case 1:
105
+ t = op;
106
+ break;
107
+ case 4:
108
+ _.label++;
109
+ return {
110
+ value: op[1],
111
+ done: false
112
+ };
113
+ case 5:
114
+ _.label++;
115
+ y = op[1];
116
+ op = [
117
+ 0
118
+ ];
119
+ continue;
120
+ case 7:
121
+ op = _.ops.pop();
122
+ _.trys.pop();
123
+ continue;
124
+ default:
125
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
126
+ _ = 0;
127
+ continue;
128
+ }
129
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
130
+ _.label = op[1];
131
+ break;
132
+ }
133
+ if (op[0] === 6 && _.label < t[1]) {
134
+ _.label = t[1];
135
+ t = op;
136
+ break;
137
+ }
138
+ if (t && _.label < t[2]) {
139
+ _.label = t[2];
140
+ _.ops.push(op);
141
+ break;
142
+ }
143
+ if (t[2]) _.ops.pop();
144
+ _.trys.pop();
145
+ continue;
146
+ }
147
+ op = body.call(thisArg, _);
148
+ } catch (e) {
149
+ op = [
150
+ 6,
151
+ e
152
+ ];
153
+ y = 0;
154
+ } finally{
155
+ f = t = 0;
156
+ }
157
+ if (op[0] & 5) throw op[1];
158
+ return {
159
+ value: op[0] ? op[1] : void 0,
160
+ done: true
161
+ };
162
+ }
163
+ return g = {
164
+ next: verb(0),
165
+ "throw": verb(1),
166
+ "return": verb(2)
167
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
168
+ return this;
169
+ }), g;
170
+ };
171
+ var $4cb1735bdc43624b$export$957313a2f485e5ed = function() {
172
+ function $4cb1735bdc43624b$export$957313a2f485e5ed(options) {
173
+ this.debug = options.debug;
174
+ this.eventsinkUrl = options.eventsinkUrl;
175
+ this.sessionId = options.sessionId;
176
+ this.heartbeatInterval = options.heartbeatInterval || $e8f16a459684b36f$export$31c453b5fe09788d;
177
+ if (this.debug) console.log("[AnalyticsReporter] Initiated AnalyticsReporter", options);
178
+ }
179
+ $4cb1735bdc43624b$export$957313a2f485e5ed.prototype.init = function(sessionId, payload) {
180
+ return $4cb1735bdc43624b$var$__awaiter(this, void 0, Promise, function() {
181
+ var data, initResponse, initResponseJson;
182
+ return $4cb1735bdc43624b$var$__generator(this, function(_a) {
183
+ switch(_a.label){
184
+ case 0:
185
+ this.sessionId = sessionId || this.sessionId;
186
+ data = {
187
+ event: "init",
188
+ sessionId: this.sessionId,
189
+ timestamp: Date.now(),
190
+ playhead: -1,
191
+ duration: -1,
192
+ payload: payload
193
+ };
194
+ if (!this.debug) return [
195
+ 3 /*break*/ ,
196
+ 1
197
+ ];
198
+ console.log("[AnalyticsReporter] Init session:", data);
199
+ return [
200
+ 2 /*return*/ ,
201
+ {
202
+ sessionId: this.sessionId,
203
+ heartbeatInterval: this.heartbeatInterval
204
+ }
205
+ ];
206
+ case 1:
207
+ return [
208
+ 4 /*yield*/ ,
209
+ fetch("".concat(this.eventsinkUrl), {
210
+ method: "POST",
211
+ mode: "cors",
212
+ cache: "no-cache",
213
+ headers: {
214
+ "Content-Type": "application/json; charset=utf-8"
215
+ },
216
+ body: JSON.stringify(data)
217
+ })
218
+ ];
219
+ case 2:
220
+ initResponse = _a.sent();
221
+ if (!initResponse.ok) throw new Error("[AnalyticsReporter] init failed: ".concat(initResponse.statusText));
222
+ return [
223
+ 4 /*yield*/ ,
224
+ initResponse.json()
225
+ ];
226
+ case 3:
227
+ initResponseJson = _a.sent();
228
+ if (!this.sessionId && !initResponseJson.sessionId) throw new Error("[AnalyticsReporter] init failed: no sessionId");
229
+ if (!this.heartbeatInterval && !initResponseJson.heartbeatInterval) throw new Error("[AnalyticsReporter] init failed: heartbeatInterval not found in response");
230
+ if (initResponseJson.heartbeatInterval) this.heartbeatInterval = initResponseJson.heartbeatInterval;
231
+ if (initResponseJson.sessionId) this.sessionId = initResponseJson.sessionId;
232
+ return [
233
+ 2 /*return*/ ,
234
+ {
235
+ heartbeatInterval: this.heartbeatInterval,
236
+ sessionId: this.sessionId
237
+ }
238
+ ];
239
+ }
240
+ });
241
+ });
242
+ };
243
+ $4cb1735bdc43624b$export$957313a2f485e5ed.prototype.send = function(data) {
244
+ var payload = $4cb1735bdc43624b$var$__assign({
245
+ sessionId: this.sessionId
246
+ }, data);
247
+ if (this.debug) console.log("[AnalyticsReporter] Send payload:", payload);
248
+ else fetch("".concat(this.eventsinkUrl), {
249
+ method: "POST",
250
+ mode: "cors",
251
+ cache: "no-cache",
252
+ headers: {
253
+ "Content-Type": "application/json; charset=utf-8"
254
+ },
255
+ body: JSON.stringify(payload)
256
+ });
257
+ };
258
+ return $4cb1735bdc43624b$export$957313a2f485e5ed;
259
+ }();
260
+
261
+
262
+ var $7d88e8cdd46a09a5$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
263
+ function adopt(value) {
264
+ return value instanceof P ? value : new P(function(resolve) {
265
+ resolve(value);
266
+ });
267
+ }
268
+ return new (P || (P = Promise))(function(resolve, reject) {
269
+ function fulfilled(value) {
270
+ try {
271
+ step(generator.next(value));
272
+ } catch (e) {
273
+ reject(e);
274
+ }
275
+ }
276
+ function rejected(value) {
277
+ try {
278
+ step(generator["throw"](value));
279
+ } catch (e) {
280
+ reject(e);
281
+ }
282
+ }
283
+ function step(result) {
284
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
285
+ }
286
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
287
+ });
288
+ };
289
+ var $7d88e8cdd46a09a5$var$__generator = undefined && undefined.__generator || function(thisArg, body) {
290
+ var _ = {
291
+ label: 0,
292
+ sent: function() {
293
+ if (t[0] & 1) throw t[1];
294
+ return t[1];
295
+ },
296
+ trys: [],
297
+ ops: []
298
+ }, f, y, t, g;
299
+ function verb(n) {
300
+ return function(v) {
301
+ return step([
302
+ n,
303
+ v
304
+ ]);
305
+ };
306
+ }
307
+ function step(op) {
308
+ if (f) throw new TypeError("Generator is already executing.");
309
+ while(_)try {
310
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
311
+ if (y = 0, t) op = [
312
+ op[0] & 2,
313
+ t.value
314
+ ];
315
+ switch(op[0]){
316
+ case 0:
317
+ case 1:
318
+ t = op;
319
+ break;
320
+ case 4:
321
+ _.label++;
322
+ return {
323
+ value: op[1],
324
+ done: false
325
+ };
326
+ case 5:
327
+ _.label++;
328
+ y = op[1];
329
+ op = [
330
+ 0
331
+ ];
332
+ continue;
333
+ case 7:
334
+ op = _.ops.pop();
335
+ _.trys.pop();
336
+ continue;
337
+ default:
338
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
339
+ _ = 0;
340
+ continue;
341
+ }
342
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
343
+ _.label = op[1];
344
+ break;
345
+ }
346
+ if (op[0] === 6 && _.label < t[1]) {
347
+ _.label = t[1];
348
+ t = op;
349
+ break;
350
+ }
351
+ if (t && _.label < t[2]) {
352
+ _.label = t[2];
353
+ _.ops.push(op);
354
+ break;
355
+ }
356
+ if (t[2]) _.ops.pop();
357
+ _.trys.pop();
358
+ continue;
359
+ }
360
+ op = body.call(thisArg, _);
361
+ } catch (e) {
362
+ op = [
363
+ 6,
364
+ e
365
+ ];
366
+ y = 0;
367
+ } finally{
368
+ f = t = 0;
369
+ }
370
+ if (op[0] & 5) throw op[1];
371
+ return {
372
+ value: op[0] ? op[1] : void 0,
373
+ done: true
374
+ };
375
+ }
376
+ return g = {
377
+ next: verb(0),
378
+ "throw": verb(1),
379
+ "return": verb(2)
380
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
381
+ return this;
382
+ }), g;
383
+ };
384
+ var $7d88e8cdd46a09a5$var$__rest = undefined && undefined.__rest || function(s, e) {
385
+ var t = {
386
+ };
387
+ for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
388
+ if (s != null && typeof Object.getOwnPropertySymbols === "function") {
389
+ for(var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++)if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
390
+ }
391
+ return t;
392
+ };
393
+ var $7d88e8cdd46a09a5$export$f76c463fe9cb9f15 = function() {
394
+ function $7d88e8cdd46a09a5$export$f76c463fe9cb9f15(eventsinkUrl, debug) {
395
+ this.debug = false;
396
+ this.debug = debug;
397
+ this.eventsinkUrl = eventsinkUrl;
398
+ }
399
+ $7d88e8cdd46a09a5$export$f76c463fe9cb9f15.prototype.initiateAnalyticsReporter = function(_a) {
400
+ var sessionId = _a.sessionId, options = $7d88e8cdd46a09a5$var$__rest(_a, [
401
+ "sessionId"
402
+ ]);
403
+ return $7d88e8cdd46a09a5$var$__awaiter(this, void 0, void 0, function() {
404
+ var _b, generatedSessionId, heartbeatInterval;
405
+ return $7d88e8cdd46a09a5$var$__generator(this, function(_c) {
406
+ switch(_c.label){
407
+ case 0:
408
+ this.analyticsReporter = new $4cb1735bdc43624b$exports.Reporter({
409
+ sessionId: sessionId,
410
+ eventsinkUrl: this.eventsinkUrl,
411
+ debug: this.debug,
412
+ heartbeatInterval: $e8f16a459684b36f$export$31c453b5fe09788d
413
+ });
414
+ return [
415
+ 4 /*yield*/ ,
416
+ this.analyticsReporter.init(sessionId, options)
417
+ ];
418
+ case 1:
419
+ _b = _c.sent(), generatedSessionId = _b.sessionId, heartbeatInterval = _b.heartbeatInterval;
420
+ return [
421
+ 2 /*return*/ ,
422
+ {
423
+ sessionId: generatedSessionId,
424
+ heartbeatInterval: heartbeatInterval
425
+ }
426
+ ];
427
+ }
428
+ });
429
+ });
430
+ };
431
+ $7d88e8cdd46a09a5$export$f76c463fe9cb9f15.prototype.init = function(data) {
432
+ this.analyticsReporter.send(data);
433
+ };
434
+ $7d88e8cdd46a09a5$export$f76c463fe9cb9f15.prototype.heartbeat = function(data) {
435
+ this.analyticsReporter.send(data);
436
+ };
437
+ $7d88e8cdd46a09a5$export$f76c463fe9cb9f15.prototype.loading = function(data) {
438
+ this.analyticsReporter.send(data);
439
+ };
440
+ $7d88e8cdd46a09a5$export$f76c463fe9cb9f15.prototype.loaded = function(data) {
441
+ this.analyticsReporter.send(data);
442
+ };
443
+ $7d88e8cdd46a09a5$export$f76c463fe9cb9f15.prototype.playing = function(data) {
444
+ this.analyticsReporter.send(data);
445
+ };
446
+ $7d88e8cdd46a09a5$export$f76c463fe9cb9f15.prototype.paused = function(data) {
447
+ this.pause(data);
448
+ };
449
+ $7d88e8cdd46a09a5$export$f76c463fe9cb9f15.prototype.pause = function(data) {
450
+ this.analyticsReporter.send(data);
451
+ };
452
+ $7d88e8cdd46a09a5$export$f76c463fe9cb9f15.prototype.buffering = function(data) {
453
+ this.analyticsReporter.send(data);
454
+ };
455
+ $7d88e8cdd46a09a5$export$f76c463fe9cb9f15.prototype.buffered = function(data) {
456
+ this.analyticsReporter.send(data);
457
+ };
458
+ $7d88e8cdd46a09a5$export$f76c463fe9cb9f15.prototype.seeking = function(data) {
459
+ this.analyticsReporter.send(data);
460
+ };
461
+ $7d88e8cdd46a09a5$export$f76c463fe9cb9f15.prototype.seeked = function(data) {
462
+ this.analyticsReporter.send(data);
463
+ };
464
+ $7d88e8cdd46a09a5$export$f76c463fe9cb9f15.prototype.bitrateChanged = function(data) {
465
+ this.analyticsReporter.send(data);
466
+ };
467
+ $7d88e8cdd46a09a5$export$f76c463fe9cb9f15.prototype.error = function(data) {
468
+ this.analyticsReporter.send(data);
469
+ };
470
+ $7d88e8cdd46a09a5$export$f76c463fe9cb9f15.prototype.warning = function(data) {
471
+ this.analyticsReporter.send(data);
472
+ };
473
+ $7d88e8cdd46a09a5$export$f76c463fe9cb9f15.prototype.stopped = function(data) {
474
+ this.analyticsReporter.send(data);
475
+ };
476
+ $7d88e8cdd46a09a5$export$f76c463fe9cb9f15.prototype.destroy = function() {
477
+ this.analyticsReporter = null;
478
+ };
479
+ return $7d88e8cdd46a09a5$export$f76c463fe9cb9f15;
480
+ }();
481
+
482
+
483
+ var $c2e08ff125b5bcd1$exports = {};
484
+
485
+ $parcel$export($c2e08ff125b5bcd1$exports, "PlayerAnalyticsConnector", () => $c2e08ff125b5bcd1$export$2daf9923c014a26e, (v) => $c2e08ff125b5bcd1$export$2daf9923c014a26e = v);
486
+
487
+
488
+
489
+ var $c2e08ff125b5bcd1$var$__assign = undefined && undefined.__assign || function() {
490
+ $c2e08ff125b5bcd1$var$__assign = Object.assign || function(t) {
491
+ for(var s, i = 1, n = arguments.length; i < n; i++){
492
+ s = arguments[i];
493
+ for(var p in s)if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
494
+ }
495
+ return t;
496
+ };
497
+ return $c2e08ff125b5bcd1$var$__assign.apply(this, arguments);
498
+ };
499
+ var $c2e08ff125b5bcd1$var$__awaiter = undefined && undefined.__awaiter || function(thisArg, _arguments, P, generator) {
500
+ function adopt(value) {
501
+ return value instanceof P ? value : new P(function(resolve) {
502
+ resolve(value);
503
+ });
504
+ }
505
+ return new (P || (P = Promise))(function(resolve, reject) {
506
+ function fulfilled(value) {
507
+ try {
508
+ step(generator.next(value));
509
+ } catch (e) {
510
+ reject(e);
511
+ }
512
+ }
513
+ function rejected(value) {
514
+ try {
515
+ step(generator["throw"](value));
516
+ } catch (e) {
517
+ reject(e);
518
+ }
519
+ }
520
+ function step(result) {
521
+ result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
522
+ }
523
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
524
+ });
525
+ };
526
+ var $c2e08ff125b5bcd1$var$__generator = undefined && undefined.__generator || function(thisArg, body) {
527
+ var _ = {
528
+ label: 0,
529
+ sent: function() {
530
+ if (t[0] & 1) throw t[1];
531
+ return t[1];
532
+ },
533
+ trys: [],
534
+ ops: []
535
+ }, f, y, t, g;
536
+ function verb(n) {
537
+ return function(v) {
538
+ return step([
539
+ n,
540
+ v
541
+ ]);
542
+ };
543
+ }
544
+ function step(op) {
545
+ if (f) throw new TypeError("Generator is already executing.");
546
+ while(_)try {
547
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
548
+ if (y = 0, t) op = [
549
+ op[0] & 2,
550
+ t.value
551
+ ];
552
+ switch(op[0]){
553
+ case 0:
554
+ case 1:
555
+ t = op;
556
+ break;
557
+ case 4:
558
+ _.label++;
559
+ return {
560
+ value: op[1],
561
+ done: false
562
+ };
563
+ case 5:
564
+ _.label++;
565
+ y = op[1];
566
+ op = [
567
+ 0
568
+ ];
569
+ continue;
570
+ case 7:
571
+ op = _.ops.pop();
572
+ _.trys.pop();
573
+ continue;
574
+ default:
575
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
576
+ _ = 0;
577
+ continue;
578
+ }
579
+ if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
580
+ _.label = op[1];
581
+ break;
582
+ }
583
+ if (op[0] === 6 && _.label < t[1]) {
584
+ _.label = t[1];
585
+ t = op;
586
+ break;
587
+ }
588
+ if (t && _.label < t[2]) {
589
+ _.label = t[2];
590
+ _.ops.push(op);
591
+ break;
592
+ }
593
+ if (t[2]) _.ops.pop();
594
+ _.trys.pop();
595
+ continue;
596
+ }
597
+ op = body.call(thisArg, _);
598
+ } catch (e) {
599
+ op = [
600
+ 6,
601
+ e
602
+ ];
603
+ y = 0;
604
+ } finally{
605
+ f = t = 0;
606
+ }
607
+ if (op[0] & 5) throw op[1];
608
+ return {
609
+ value: op[0] ? op[1] : void 0,
610
+ done: true
611
+ };
612
+ }
613
+ return g = {
614
+ next: verb(0),
615
+ "throw": verb(1),
616
+ "return": verb(2)
617
+ }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
618
+ return this;
619
+ }), g;
620
+ };
621
+ var $c2e08ff125b5bcd1$export$2daf9923c014a26e = function() {
622
+ function $c2e08ff125b5bcd1$export$2daf9923c014a26e(eventsinkUrl, debug) {
623
+ this.eventsinkUrl = eventsinkUrl;
624
+ this.playerAnalytics = new $7d88e8cdd46a09a5$exports.PlayerAnalytics(this.eventsinkUrl, debug);
625
+ }
626
+ $c2e08ff125b5bcd1$export$2daf9923c014a26e.prototype.init = function(options) {
627
+ return $c2e08ff125b5bcd1$var$__awaiter(this, void 0, void 0, function() {
628
+ var heartbeatInterval;
629
+ return $c2e08ff125b5bcd1$var$__generator(this, function(_a) {
630
+ switch(_a.label){
631
+ case 0:
632
+ this.sessionId = options.sessionId;
633
+ return [
634
+ 4 /*yield*/ ,
635
+ this.playerAnalytics.initiateAnalyticsReporter($c2e08ff125b5bcd1$var$__assign({
636
+ sessionId: this.sessionId
637
+ }, options))
638
+ ];
639
+ case 1:
640
+ heartbeatInterval = _a.sent().heartbeatInterval;
641
+ this.heartbeatInterval = heartbeatInterval;
642
+ return [
643
+ 2 /*return*/
644
+ ];
645
+ }
646
+ });
647
+ });
648
+ };
649
+ $c2e08ff125b5bcd1$export$2daf9923c014a26e.prototype.load = function(player) {
650
+ this.player = player;
651
+ this.playerAnalytics.loading($c2e08ff125b5bcd1$var$__assign({
652
+ event: $e8f16a459684b36f$export$342d7dbd8323f55e.loading
653
+ }, this.playbackState()));
654
+ this.initiateVideoEventFilter();
655
+ };
656
+ $c2e08ff125b5bcd1$export$2daf9923c014a26e.prototype.initiateVideoEventFilter = function() {
657
+ var _this = this;
658
+ if (!this.player) return;
659
+ this.videoEventFilter = new $g5Y9E$eyevinnvideoeventfilter.VideoEventFilter(this.player);
660
+ this.videoEventFilter.addEventListener("*", this.videoEventListener = function(event) {
661
+ if (!Object.keys($e8f16a459684b36f$export$342d7dbd8323f55e).includes(event)) return;
662
+ var eventType;
663
+ var extraData = {
664
+ };
665
+ if (!event) return;
666
+ switch(event){
667
+ case $g5Y9E$eyevinnvideoeventfilter.PlayerEvents.Loaded:
668
+ eventType = $e8f16a459684b36f$export$342d7dbd8323f55e.loaded;
669
+ break;
670
+ case $g5Y9E$eyevinnvideoeventfilter.PlayerEvents.Loading:
671
+ eventType = $e8f16a459684b36f$export$342d7dbd8323f55e.loading;
672
+ break;
673
+ case $g5Y9E$eyevinnvideoeventfilter.PlayerEvents.Play:
674
+ case $g5Y9E$eyevinnvideoeventfilter.PlayerEvents.Resume:
675
+ eventType = $e8f16a459684b36f$export$342d7dbd8323f55e.play;
676
+ _this.startInterval();
677
+ break;
678
+ case $g5Y9E$eyevinnvideoeventfilter.PlayerEvents.Pause:
679
+ eventType = $e8f16a459684b36f$export$342d7dbd8323f55e.pause;
680
+ break;
681
+ case $g5Y9E$eyevinnvideoeventfilter.PlayerEvents.Seeking:
682
+ eventType = $e8f16a459684b36f$export$342d7dbd8323f55e.seeking;
683
+ break;
684
+ case $g5Y9E$eyevinnvideoeventfilter.PlayerEvents.Seeked:
685
+ eventType = $e8f16a459684b36f$export$342d7dbd8323f55e.seeked;
686
+ break;
687
+ case $g5Y9E$eyevinnvideoeventfilter.PlayerEvents.Buffering:
688
+ eventType = $e8f16a459684b36f$export$342d7dbd8323f55e.buffering;
689
+ break;
690
+ case $g5Y9E$eyevinnvideoeventfilter.PlayerEvents.Buffered:
691
+ eventType = $e8f16a459684b36f$export$342d7dbd8323f55e.buffered;
692
+ break;
693
+ case $g5Y9E$eyevinnvideoeventfilter.PlayerEvents.Ended:
694
+ eventType = $e8f16a459684b36f$export$342d7dbd8323f55e.ended;
695
+ extraData.reason = "ended";
696
+ _this.stopInterval();
697
+ break;
698
+ case $g5Y9E$eyevinnvideoeventfilter.PlayerEvents.Error:
699
+ eventType = $e8f16a459684b36f$export$342d7dbd8323f55e.error;
700
+ extraData.reason = "error";
701
+ _this.stopInterval();
702
+ break;
703
+ default:
704
+ break;
705
+ }
706
+ _this.playerAnalytics[eventType]($c2e08ff125b5bcd1$var$__assign($c2e08ff125b5bcd1$var$__assign({
707
+ event: eventType
708
+ }, _this.playbackState()), Object.keys(extraData).length > 0 && {
709
+ payload: extraData
710
+ }));
711
+ });
712
+ };
713
+ $c2e08ff125b5bcd1$export$2daf9923c014a26e.prototype.startInterval = function() {
714
+ var _this = this;
715
+ if (this.heartbeatIntervalTimer) return;
716
+ this.heartbeatIntervalTimer = setInterval(function() {
717
+ _this.playerAnalytics.heartbeat($c2e08ff125b5bcd1$var$__assign({
718
+ event: "heartbeat"
719
+ }, _this.playbackState()));
720
+ }, this.heartbeatInterval);
721
+ };
722
+ $c2e08ff125b5bcd1$export$2daf9923c014a26e.prototype.stopInterval = function() {
723
+ clearInterval(this.heartbeatIntervalTimer);
724
+ };
725
+ $c2e08ff125b5bcd1$export$2daf9923c014a26e.prototype.reportBitrateChange = function(payload) {
726
+ this.playerAnalytics.bitrateChanged($c2e08ff125b5bcd1$var$__assign($c2e08ff125b5bcd1$var$__assign({
727
+ event: $e8f16a459684b36f$export$342d7dbd8323f55e.bitratechanged
728
+ }, this.playbackState()), {
729
+ payload: payload
730
+ }));
731
+ };
732
+ $c2e08ff125b5bcd1$export$2daf9923c014a26e.prototype.reportError = function(error) {
733
+ this.playerAnalytics.error($c2e08ff125b5bcd1$var$__assign($c2e08ff125b5bcd1$var$__assign({
734
+ event: $e8f16a459684b36f$export$342d7dbd8323f55e.error
735
+ }, this.playbackState()), {
736
+ payload: error
737
+ }));
738
+ this.playerAnalytics.stopped($c2e08ff125b5bcd1$var$__assign($c2e08ff125b5bcd1$var$__assign({
739
+ event: $e8f16a459684b36f$export$342d7dbd8323f55e.ended
740
+ }, this.playbackState()), {
741
+ payload: {
742
+ reason: "error"
743
+ }
744
+ }));
745
+ this.stopInterval();
746
+ };
747
+ $c2e08ff125b5bcd1$export$2daf9923c014a26e.prototype.reportWarning = function(payload) {
748
+ this.playerAnalytics.warning($c2e08ff125b5bcd1$var$__assign($c2e08ff125b5bcd1$var$__assign({
749
+ event: $e8f16a459684b36f$export$342d7dbd8323f55e.warning
750
+ }, this.playbackState()), {
751
+ payload: payload
752
+ }));
753
+ };
754
+ $c2e08ff125b5bcd1$export$2daf9923c014a26e.prototype.playbackState = function() {
755
+ var playhead = !this.player.currentTime && this.player.currentTime !== 0 ? -1 : this.player.currentTime || 0;
756
+ var duration = !this.player.duration && this.player.duration !== 0 ? -1 : this.player.duration || 0;
757
+ return {
758
+ sessionId: this.sessionId,
759
+ timestamp: Date.now(),
760
+ playhead: playhead,
761
+ duration: duration
762
+ };
763
+ };
764
+ $c2e08ff125b5bcd1$export$2daf9923c014a26e.prototype.destroy = function() {
765
+ this.playerAnalytics.destroy();
766
+ this.heartbeatInterval = null;
767
+ this.videoEventFilter.removeEventListener("*", this.videoEventListener);
768
+ this.stopInterval();
769
+ };
770
+ return $c2e08ff125b5bcd1$export$2daf9923c014a26e;
771
+ }();
772
+
773
+
774
+
775
+
776
+ //# sourceMappingURL=index.js.map