stormcloud-video-player 0.7.50 → 0.7.52
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/stormcloud-vp.min.js +3 -1
- package/lib/index.cjs +407 -158
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +73 -3
- package/lib/index.d.ts +73 -3
- package/lib/index.js +336 -159
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +246 -156
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +3 -1
- package/lib/players/HlsPlayer.cjs +246 -156
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +2 -1
- package/lib/players/index.cjs +246 -156
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/adstormPlayer.d.cts +2 -1
- package/lib/{types-CIHDHY7A.d.cts → types-Dobqa8vR.d.cts} +8 -1
- package/lib/ui/OverlayRenderer.cjs +2 -3
- package/lib/ui/OverlayRenderer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +286 -163
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +2 -1
- package/lib/utils/mqttClient.cjs +247 -0
- package/lib/utils/mqttClient.cjs.map +1 -0
- package/lib/utils/mqttClient.d.cts +13 -0
- package/lib/utils/mqttConfig.cjs +141 -0
- package/lib/utils/mqttConfig.cjs.map +1 -0
- package/lib/utils/mqttConfig.d.cts +20 -0
- package/lib/utils/tracking.cjs +237 -192
- package/lib/utils/tracking.cjs.map +1 -1
- package/lib/utils/tracking.d.cts +12 -6
- package/package.json +2 -1
package/lib/utils/tracking.cjs
CHANGED
|
@@ -56,30 +56,6 @@ function _object_spread(target) {
|
|
|
56
56
|
}
|
|
57
57
|
return target;
|
|
58
58
|
}
|
|
59
|
-
function ownKeys(object, enumerableOnly) {
|
|
60
|
-
var keys = Object.keys(object);
|
|
61
|
-
if (Object.getOwnPropertySymbols) {
|
|
62
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
63
|
-
if (enumerableOnly) {
|
|
64
|
-
symbols = symbols.filter(function(sym) {
|
|
65
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
keys.push.apply(keys, symbols);
|
|
69
|
-
}
|
|
70
|
-
return keys;
|
|
71
|
-
}
|
|
72
|
-
function _object_spread_props(target, source) {
|
|
73
|
-
source = source != null ? source : {};
|
|
74
|
-
if (Object.getOwnPropertyDescriptors) {
|
|
75
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
76
|
-
} else {
|
|
77
|
-
ownKeys(Object(source)).forEach(function(key) {
|
|
78
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
return target;
|
|
82
|
-
}
|
|
83
59
|
function _type_of(obj) {
|
|
84
60
|
"@swc/helpers - typeof";
|
|
85
61
|
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
|
|
@@ -183,9 +159,11 @@ function _ts_generator(thisArg, body) {
|
|
|
183
159
|
};
|
|
184
160
|
}
|
|
185
161
|
}
|
|
162
|
+
var __create = Object.create;
|
|
186
163
|
var __defProp = Object.defineProperty;
|
|
187
164
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
188
165
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
166
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
189
167
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
190
168
|
var __export = function __export(target, all) {
|
|
191
169
|
for(var name in all)__defProp(target, name, {
|
|
@@ -224,6 +202,16 @@ var __copyProps = function __copyProps(to, from, except, desc) {
|
|
|
224
202
|
}
|
|
225
203
|
return to;
|
|
226
204
|
};
|
|
205
|
+
var __toESM = function __toESM(mod, isNodeMode, target) {
|
|
206
|
+
return target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(// If the importer is in node compatibility mode or this is not an ESM
|
|
207
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
208
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
209
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
210
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
211
|
+
value: mod,
|
|
212
|
+
enumerable: true
|
|
213
|
+
}) : target, mod);
|
|
214
|
+
};
|
|
227
215
|
var __toCommonJS = function __toCommonJS(mod) {
|
|
228
216
|
return __copyProps(__defProp({}, "__esModule", {
|
|
229
217
|
value: true
|
|
@@ -255,6 +243,103 @@ __export(tracking_exports, {
|
|
|
255
243
|
}
|
|
256
244
|
});
|
|
257
245
|
module.exports = __toCommonJS(tracking_exports);
|
|
246
|
+
// src/utils/mqttClient.ts
|
|
247
|
+
var import_mqtt = __toESM(require("mqtt"), 1);
|
|
248
|
+
// src/utils/mqttConfig.ts
|
|
249
|
+
var DEFAULT_MQTT_CONFIG = {
|
|
250
|
+
enabled: true,
|
|
251
|
+
brokerAddress: "vecbae77.ala.us-east-1.emqxsl.com",
|
|
252
|
+
brokerPort: 8883,
|
|
253
|
+
wsPort: 8084,
|
|
254
|
+
username: "for-sonifi",
|
|
255
|
+
password: "sonifi-mqtt",
|
|
256
|
+
topicPrefix: "adstorm/players",
|
|
257
|
+
qos: 1
|
|
258
|
+
};
|
|
259
|
+
var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
|
|
260
|
+
function isMQTTEnabled() {
|
|
261
|
+
return mqttConfig.enabled;
|
|
262
|
+
}
|
|
263
|
+
function buildMQTTBrokerUrl() {
|
|
264
|
+
if (mqttConfig.brokerUrl) return mqttConfig.brokerUrl;
|
|
265
|
+
return "wss://".concat(mqttConfig.brokerAddress, ":").concat(mqttConfig.wsPort, "/mqtt");
|
|
266
|
+
}
|
|
267
|
+
function buildPlayerTopic(licenseKey, channel) {
|
|
268
|
+
return "".concat(mqttConfig.topicPrefix, "/").concat(licenseKey, "/").concat(channel);
|
|
269
|
+
}
|
|
270
|
+
// src/utils/mqttClient.ts
|
|
271
|
+
var LOG = "[StormcloudVideoPlayer][MQTT]";
|
|
272
|
+
var client = null;
|
|
273
|
+
var status = "disconnected";
|
|
274
|
+
function initMQTTClient() {
|
|
275
|
+
if (client || !isMQTTEnabled()) return;
|
|
276
|
+
var url = buildMQTTBrokerUrl();
|
|
277
|
+
status = "connecting";
|
|
278
|
+
var clientId = "stormcloud-vp-".concat(Math.random().toString(36).slice(2, 9));
|
|
279
|
+
try {
|
|
280
|
+
client = import_mqtt.default.connect(url, {
|
|
281
|
+
clientId: clientId,
|
|
282
|
+
username: mqttConfig.username,
|
|
283
|
+
password: mqttConfig.password,
|
|
284
|
+
keepalive: 60,
|
|
285
|
+
clean: true,
|
|
286
|
+
reconnectPeriod: 5e3,
|
|
287
|
+
connectTimeout: 1e4,
|
|
288
|
+
queueQoSZero: false
|
|
289
|
+
});
|
|
290
|
+
} catch (err) {
|
|
291
|
+
status = "error";
|
|
292
|
+
console.warn("".concat(LOG, " connect() threw:"), err);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
client.on("connect", function() {
|
|
296
|
+
status = "connected";
|
|
297
|
+
console.info("".concat(LOG, " connected to ").concat(url));
|
|
298
|
+
});
|
|
299
|
+
client.on("reconnect", function() {
|
|
300
|
+
status = "connecting";
|
|
301
|
+
console.info("".concat(LOG, " reconnecting..."));
|
|
302
|
+
});
|
|
303
|
+
client.on("offline", function() {
|
|
304
|
+
if (status !== "error") {
|
|
305
|
+
status = "disconnected";
|
|
306
|
+
}
|
|
307
|
+
console.warn("".concat(LOG, " offline"));
|
|
308
|
+
});
|
|
309
|
+
client.on("error", function(err) {
|
|
310
|
+
status = "error";
|
|
311
|
+
console.warn("".concat(LOG, " error:"), err.message);
|
|
312
|
+
});
|
|
313
|
+
client.on("close", function() {
|
|
314
|
+
if (status === "connected" || status === "connecting") {
|
|
315
|
+
status = "disconnected";
|
|
316
|
+
}
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
function ensureMQTTClient() {
|
|
320
|
+
if (isMQTTEnabled() && !client) {
|
|
321
|
+
initMQTTClient();
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
function publishMQTT(topic, payload) {
|
|
325
|
+
if (!isMQTTEnabled()) {
|
|
326
|
+
return false;
|
|
327
|
+
}
|
|
328
|
+
ensureMQTTClient();
|
|
329
|
+
if (!client) {
|
|
330
|
+
return false;
|
|
331
|
+
}
|
|
332
|
+
try {
|
|
333
|
+
client.publish(topic, JSON.stringify(payload), {
|
|
334
|
+
qos: mqttConfig.qos
|
|
335
|
+
});
|
|
336
|
+
return true;
|
|
337
|
+
} catch (err) {
|
|
338
|
+
console.warn("".concat(LOG, " publish failed on ").concat(topic, ":"), err);
|
|
339
|
+
return false;
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
// src/utils/tracking.ts
|
|
258
343
|
var cachedBrowserId = null;
|
|
259
344
|
function getClientInfo() {
|
|
260
345
|
var _screen, _screen1, _screen2, _screen3, _screen_orientation, _screen4, _screen5, _window, _window1, _window_screen_orientation, _window_screen, _navigator_languages;
|
|
@@ -484,139 +569,120 @@ function getBrowserID(clientInfo) {
|
|
|
484
569
|
});
|
|
485
570
|
})();
|
|
486
571
|
}
|
|
487
|
-
|
|
488
|
-
|
|
572
|
+
function canPublish(licenseKey) {
|
|
573
|
+
return Boolean(isMQTTEnabled() && licenseKey);
|
|
574
|
+
}
|
|
575
|
+
function buildPlayerMetricEvent() {
|
|
489
576
|
return _async_to_generator(function() {
|
|
490
|
-
var
|
|
577
|
+
var context, flags, _flags_captureAt, _flags_adLoaded, _flags_adDetect, clientInfo, playerId, captureAt;
|
|
578
|
+
var _arguments = arguments;
|
|
491
579
|
return _ts_generator(this, function(_state) {
|
|
492
580
|
switch(_state.label){
|
|
493
581
|
case 0:
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
};
|
|
497
|
-
if (licenseKey) {
|
|
498
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
499
|
-
}
|
|
582
|
+
context = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {}, flags = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
583
|
+
clientInfo = getClientInfo();
|
|
500
584
|
return [
|
|
501
585
|
4,
|
|
502
|
-
|
|
503
|
-
method: "POST",
|
|
504
|
-
headers: headers,
|
|
505
|
-
body: JSON.stringify(body)
|
|
506
|
-
})
|
|
586
|
+
getBrowserID(clientInfo)
|
|
507
587
|
];
|
|
508
588
|
case 1:
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
512
|
-
}
|
|
513
|
-
return [
|
|
514
|
-
4,
|
|
515
|
-
response.json()
|
|
516
|
-
];
|
|
517
|
-
case 2:
|
|
518
|
-
_state.sent();
|
|
589
|
+
playerId = _state.sent();
|
|
590
|
+
captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
|
|
519
591
|
return [
|
|
520
|
-
2
|
|
592
|
+
2,
|
|
593
|
+
_object_spread({
|
|
594
|
+
player_id: playerId,
|
|
595
|
+
device_type: clientInfo.deviceType,
|
|
596
|
+
os: clientInfo.os.toLowerCase(),
|
|
597
|
+
ad_loaded: (_flags_adLoaded = flags.adLoaded) !== null && _flags_adLoaded !== void 0 ? _flags_adLoaded : false,
|
|
598
|
+
ad_detect: (_flags_adDetect = flags.adDetect) !== null && _flags_adDetect !== void 0 ? _flags_adDetect : false,
|
|
599
|
+
capture_at: captureAt
|
|
600
|
+
}, context.inputStreamType ? {
|
|
601
|
+
input_stream_type: context.inputStreamType
|
|
602
|
+
} : {})
|
|
521
603
|
];
|
|
522
604
|
}
|
|
523
605
|
});
|
|
524
|
-
})();
|
|
606
|
+
}).apply(this, arguments);
|
|
525
607
|
}
|
|
526
|
-
function
|
|
527
|
-
|
|
528
|
-
|
|
608
|
+
function publishTracking(licenseKey, channel, body) {
|
|
609
|
+
ensureMQTTClient();
|
|
610
|
+
publishMQTT(buildPlayerTopic(licenseKey, channel), body);
|
|
611
|
+
}
|
|
612
|
+
function sendInitialTracking(_0) {
|
|
613
|
+
return _async_to_generator(function(licenseKey) {
|
|
614
|
+
var context, metricEvent, error;
|
|
615
|
+
var _arguments = arguments;
|
|
529
616
|
return _ts_generator(this, function(_state) {
|
|
530
617
|
switch(_state.label){
|
|
531
618
|
case 0:
|
|
619
|
+
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
620
|
+
if (!canPublish(licenseKey)) return [
|
|
621
|
+
2
|
|
622
|
+
];
|
|
623
|
+
_state.label = 1;
|
|
624
|
+
case 1:
|
|
532
625
|
_state.trys.push([
|
|
533
|
-
|
|
534
|
-
|
|
626
|
+
1,
|
|
627
|
+
3,
|
|
535
628
|
,
|
|
536
|
-
|
|
629
|
+
4
|
|
537
630
|
]);
|
|
538
|
-
clientInfo = getClientInfo();
|
|
539
|
-
return [
|
|
540
|
-
4,
|
|
541
|
-
getBrowserID(clientInfo)
|
|
542
|
-
];
|
|
543
|
-
case 1:
|
|
544
|
-
browserId = _state.sent();
|
|
545
|
-
trackingData = _object_spread({
|
|
546
|
-
browserId: browserId
|
|
547
|
-
}, clientInfo);
|
|
548
|
-
headers = {
|
|
549
|
-
"Content-Type": "application/json"
|
|
550
|
-
};
|
|
551
|
-
if (licenseKey) {
|
|
552
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
553
|
-
}
|
|
554
631
|
return [
|
|
555
632
|
4,
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
body: JSON.stringify(trackingData)
|
|
633
|
+
buildPlayerMetricEvent(context, {
|
|
634
|
+
adLoaded: false,
|
|
635
|
+
adDetect: false
|
|
560
636
|
})
|
|
561
637
|
];
|
|
562
638
|
case 2:
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
response.json()
|
|
570
|
-
];
|
|
571
|
-
case 3:
|
|
572
|
-
_state.sent();
|
|
639
|
+
metricEvent = _state.sent();
|
|
640
|
+
publishTracking(licenseKey, "metrics", {
|
|
641
|
+
events: [
|
|
642
|
+
metricEvent
|
|
643
|
+
]
|
|
644
|
+
});
|
|
573
645
|
return [
|
|
574
646
|
3,
|
|
575
|
-
|
|
647
|
+
4
|
|
576
648
|
];
|
|
577
|
-
case
|
|
649
|
+
case 3:
|
|
578
650
|
error = _state.sent();
|
|
579
651
|
console.error("[StormcloudVideoPlayer] Error sending initial tracking data:", error);
|
|
580
652
|
return [
|
|
581
653
|
3,
|
|
582
|
-
|
|
654
|
+
4
|
|
583
655
|
];
|
|
584
|
-
case
|
|
656
|
+
case 4:
|
|
585
657
|
return [
|
|
586
658
|
2
|
|
587
659
|
];
|
|
588
660
|
}
|
|
589
661
|
});
|
|
590
|
-
})();
|
|
662
|
+
}).apply(this, arguments);
|
|
591
663
|
}
|
|
592
|
-
function sendAdDetectTracking(
|
|
593
|
-
return _async_to_generator(function() {
|
|
594
|
-
var
|
|
664
|
+
function sendAdDetectTracking(_0, _1) {
|
|
665
|
+
return _async_to_generator(function(licenseKey, adDetectInfo) {
|
|
666
|
+
var context, error;
|
|
667
|
+
var _arguments = arguments;
|
|
595
668
|
return _ts_generator(this, function(_state) {
|
|
596
669
|
switch(_state.label){
|
|
597
670
|
case 0:
|
|
671
|
+
context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
672
|
+
_state.label = 1;
|
|
673
|
+
case 1:
|
|
598
674
|
_state.trys.push([
|
|
599
|
-
|
|
675
|
+
1,
|
|
600
676
|
3,
|
|
601
677
|
,
|
|
602
678
|
4
|
|
603
679
|
]);
|
|
604
|
-
clientInfo = getClientInfo();
|
|
605
680
|
return [
|
|
606
681
|
4,
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
trackingData = _object_spread({
|
|
612
|
-
browserId: browserId
|
|
613
|
-
}, clientInfo);
|
|
614
|
-
return [
|
|
615
|
-
4,
|
|
616
|
-
sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
|
|
617
|
-
licenseKey: licenseKey,
|
|
618
|
-
adDetectInfo: adDetectInfo
|
|
619
|
-
}))
|
|
682
|
+
sendHeartbeat(licenseKey, context, {
|
|
683
|
+
adDetect: true,
|
|
684
|
+
captureAt: adDetectInfo.timestamp
|
|
685
|
+
})
|
|
620
686
|
];
|
|
621
687
|
case 2:
|
|
622
688
|
_state.sent();
|
|
@@ -637,36 +703,30 @@ function sendAdDetectTracking(licenseKey, adDetectInfo) {
|
|
|
637
703
|
];
|
|
638
704
|
}
|
|
639
705
|
});
|
|
640
|
-
})();
|
|
706
|
+
}).apply(this, arguments);
|
|
641
707
|
}
|
|
642
|
-
function sendAdLoadedTracking(
|
|
643
|
-
return _async_to_generator(function() {
|
|
644
|
-
var
|
|
708
|
+
function sendAdLoadedTracking(_0, _1) {
|
|
709
|
+
return _async_to_generator(function(licenseKey, adLoadedInfo) {
|
|
710
|
+
var context, error;
|
|
711
|
+
var _arguments = arguments;
|
|
645
712
|
return _ts_generator(this, function(_state) {
|
|
646
713
|
switch(_state.label){
|
|
647
714
|
case 0:
|
|
715
|
+
context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
716
|
+
_state.label = 1;
|
|
717
|
+
case 1:
|
|
648
718
|
_state.trys.push([
|
|
649
|
-
|
|
719
|
+
1,
|
|
650
720
|
3,
|
|
651
721
|
,
|
|
652
722
|
4
|
|
653
723
|
]);
|
|
654
|
-
clientInfo = getClientInfo();
|
|
655
|
-
return [
|
|
656
|
-
4,
|
|
657
|
-
getBrowserID(clientInfo)
|
|
658
|
-
];
|
|
659
|
-
case 1:
|
|
660
|
-
browserId = _state.sent();
|
|
661
|
-
trackingData = _object_spread({
|
|
662
|
-
browserId: browserId
|
|
663
|
-
}, clientInfo);
|
|
664
724
|
return [
|
|
665
725
|
4,
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
})
|
|
726
|
+
sendHeartbeat(licenseKey, context, {
|
|
727
|
+
adLoaded: true,
|
|
728
|
+
captureAt: adLoadedInfo.timestamp
|
|
729
|
+
})
|
|
670
730
|
];
|
|
671
731
|
case 2:
|
|
672
732
|
_state.sent();
|
|
@@ -687,39 +747,46 @@ function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
|
|
|
687
747
|
];
|
|
688
748
|
}
|
|
689
749
|
});
|
|
690
|
-
})();
|
|
750
|
+
}).apply(this, arguments);
|
|
691
751
|
}
|
|
692
|
-
function sendAdImpressionTracking(
|
|
693
|
-
return _async_to_generator(function() {
|
|
694
|
-
var
|
|
752
|
+
function sendAdImpressionTracking(_0, _1) {
|
|
753
|
+
return _async_to_generator(function(licenseKey, adImpressionInfo) {
|
|
754
|
+
var context, metricEvent, error;
|
|
755
|
+
var _arguments = arguments;
|
|
695
756
|
return _ts_generator(this, function(_state) {
|
|
696
757
|
switch(_state.label){
|
|
697
758
|
case 0:
|
|
759
|
+
context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
760
|
+
if (!canPublish(licenseKey)) return [
|
|
761
|
+
2
|
|
762
|
+
];
|
|
763
|
+
_state.label = 1;
|
|
764
|
+
case 1:
|
|
698
765
|
_state.trys.push([
|
|
699
|
-
|
|
766
|
+
1,
|
|
700
767
|
3,
|
|
701
768
|
,
|
|
702
769
|
4
|
|
703
770
|
]);
|
|
704
|
-
clientInfo = getClientInfo();
|
|
705
771
|
return [
|
|
706
772
|
4,
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
browserId = _state.sent();
|
|
711
|
-
trackingData = _object_spread({
|
|
712
|
-
browserId: browserId
|
|
713
|
-
}, clientInfo);
|
|
714
|
-
return [
|
|
715
|
-
4,
|
|
716
|
-
sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
|
|
717
|
-
licenseKey: licenseKey,
|
|
718
|
-
adImpressionInfo: adImpressionInfo
|
|
719
|
-
}))
|
|
773
|
+
buildPlayerMetricEvent(context, {
|
|
774
|
+
captureAt: adImpressionInfo.timestamp
|
|
775
|
+
})
|
|
720
776
|
];
|
|
721
777
|
case 2:
|
|
722
|
-
_state.sent();
|
|
778
|
+
metricEvent = _state.sent();
|
|
779
|
+
publishTracking(licenseKey, "heartbeat", metricEvent);
|
|
780
|
+
publishTracking(licenseKey, "impressions", {
|
|
781
|
+
events: [
|
|
782
|
+
{
|
|
783
|
+
player_id: metricEvent.player_id,
|
|
784
|
+
ad_played_count: 1,
|
|
785
|
+
ad_url: adImpressionInfo.adUrl,
|
|
786
|
+
capture_at: adImpressionInfo.timestamp
|
|
787
|
+
}
|
|
788
|
+
]
|
|
789
|
+
});
|
|
723
790
|
return [
|
|
724
791
|
3,
|
|
725
792
|
4
|
|
@@ -737,74 +804,52 @@ function sendAdImpressionTracking(licenseKey, adImpressionInfo) {
|
|
|
737
804
|
];
|
|
738
805
|
}
|
|
739
806
|
});
|
|
740
|
-
})();
|
|
807
|
+
}).apply(this, arguments);
|
|
741
808
|
}
|
|
742
|
-
function sendHeartbeat(
|
|
743
|
-
return _async_to_generator(function() {
|
|
744
|
-
var
|
|
809
|
+
function sendHeartbeat(_0) {
|
|
810
|
+
return _async_to_generator(function(licenseKey) {
|
|
811
|
+
var context, flags, heartbeatData, error;
|
|
812
|
+
var _arguments = arguments;
|
|
745
813
|
return _ts_generator(this, function(_state) {
|
|
746
814
|
switch(_state.label){
|
|
747
815
|
case 0:
|
|
816
|
+
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
817
|
+
if (!canPublish(licenseKey)) return [
|
|
818
|
+
2
|
|
819
|
+
];
|
|
820
|
+
_state.label = 1;
|
|
821
|
+
case 1:
|
|
748
822
|
_state.trys.push([
|
|
749
|
-
|
|
750
|
-
|
|
823
|
+
1,
|
|
824
|
+
3,
|
|
751
825
|
,
|
|
752
|
-
|
|
826
|
+
4
|
|
753
827
|
]);
|
|
754
|
-
clientInfo = getClientInfo();
|
|
755
828
|
return [
|
|
756
829
|
4,
|
|
757
|
-
|
|
758
|
-
];
|
|
759
|
-
case 1:
|
|
760
|
-
browserId = _state.sent();
|
|
761
|
-
heartbeatData = {
|
|
762
|
-
browserId: browserId,
|
|
763
|
-
timestamp: /* @__PURE__ */ new Date().toISOString()
|
|
764
|
-
};
|
|
765
|
-
headers = {
|
|
766
|
-
"Content-Type": "application/json"
|
|
767
|
-
};
|
|
768
|
-
if (licenseKey) {
|
|
769
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
770
|
-
}
|
|
771
|
-
return [
|
|
772
|
-
4,
|
|
773
|
-
fetch("https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/heartbeat", {
|
|
774
|
-
method: "POST",
|
|
775
|
-
headers: headers,
|
|
776
|
-
body: JSON.stringify(heartbeatData)
|
|
777
|
-
})
|
|
830
|
+
buildPlayerMetricEvent(context, flags)
|
|
778
831
|
];
|
|
779
832
|
case 2:
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
783
|
-
}
|
|
784
|
-
return [
|
|
785
|
-
4,
|
|
786
|
-
response.json()
|
|
787
|
-
];
|
|
788
|
-
case 3:
|
|
789
|
-
_state.sent();
|
|
833
|
+
heartbeatData = _state.sent();
|
|
834
|
+
publishTracking(licenseKey, "heartbeat", heartbeatData);
|
|
790
835
|
return [
|
|
791
836
|
3,
|
|
792
|
-
|
|
837
|
+
4
|
|
793
838
|
];
|
|
794
|
-
case
|
|
839
|
+
case 3:
|
|
795
840
|
error = _state.sent();
|
|
796
841
|
console.error("[StormcloudVideoPlayer] Error sending heartbeat:", error);
|
|
797
842
|
return [
|
|
798
843
|
3,
|
|
799
|
-
|
|
844
|
+
4
|
|
800
845
|
];
|
|
801
|
-
case
|
|
846
|
+
case 4:
|
|
802
847
|
return [
|
|
803
848
|
2
|
|
804
849
|
];
|
|
805
850
|
}
|
|
806
851
|
});
|
|
807
|
-
})();
|
|
852
|
+
}).apply(this, arguments);
|
|
808
853
|
}
|
|
809
854
|
// Annotate the CommonJS export names for ESM import in node:
|
|
810
855
|
0 && (module.exports = {
|