stormcloud-video-player 0.6.11 → 0.6.13
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/README.md +33 -294
- package/dist/stormcloud-vp.min.js +3 -1
- package/lib/index.cjs +265 -191
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +29 -1
- package/lib/index.d.ts +29 -1
- package/lib/index.js +210 -192
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +193 -191
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.cjs +193 -191
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/index.cjs +193 -191
- package/lib/players/index.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.cjs +193 -191
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/utils/mqttClient.cjs +245 -0
- package/lib/utils/mqttClient.cjs.map +1 -0
- package/lib/utils/mqttClient.d.cts +13 -0
- package/lib/utils/mqttConfig.cjs +136 -0
- package/lib/utils/mqttConfig.cjs.map +1 -0
- package/lib/utils/mqttConfig.d.cts +19 -0
- package/lib/utils/tracking.cjs +193 -191
- package/lib/utils/tracking.cjs.map +1 -1
- package/package.json +3 -3
|
@@ -2060,6 +2060,106 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
2060
2060
|
}
|
|
2061
2061
|
};
|
|
2062
2062
|
}
|
|
2063
|
+
// src/utils/mqttConfig.ts
|
|
2064
|
+
var DEFAULT_MQTT_CONFIG = {
|
|
2065
|
+
enabled: true,
|
|
2066
|
+
brokerAddress: "vecbae77.ala.us-east-1.emqxsl.com",
|
|
2067
|
+
brokerPort: 8883,
|
|
2068
|
+
wsPort: 8084,
|
|
2069
|
+
username: "for-sonifi",
|
|
2070
|
+
password: "sonifi-mqtt",
|
|
2071
|
+
topicPrefix: "adstorm/players",
|
|
2072
|
+
qos: 1
|
|
2073
|
+
};
|
|
2074
|
+
var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
|
|
2075
|
+
function isMQTTEnabled() {
|
|
2076
|
+
return mqttConfig.enabled;
|
|
2077
|
+
}
|
|
2078
|
+
function buildMQTTBrokerUrl() {
|
|
2079
|
+
if (mqttConfig.brokerUrl) return mqttConfig.brokerUrl;
|
|
2080
|
+
return "wss://".concat(mqttConfig.brokerAddress, ":").concat(mqttConfig.wsPort, "/mqtt");
|
|
2081
|
+
}
|
|
2082
|
+
function buildPlayerTopic(licenseKey, channel) {
|
|
2083
|
+
return "".concat(mqttConfig.topicPrefix, "/").concat(licenseKey, "/").concat(channel);
|
|
2084
|
+
}
|
|
2085
|
+
// src/utils/mqttClient.ts
|
|
2086
|
+
var import_mqtt = __toESM(require("mqtt"), 1);
|
|
2087
|
+
var LOG2 = "[StormcloudVideoPlayer][MQTT]";
|
|
2088
|
+
var client = null;
|
|
2089
|
+
var status = "disconnected";
|
|
2090
|
+
function initMQTTClient() {
|
|
2091
|
+
if (client || !isMQTTEnabled()) return;
|
|
2092
|
+
var url = buildMQTTBrokerUrl();
|
|
2093
|
+
status = "connecting";
|
|
2094
|
+
var clientId = "stormcloud-vp-".concat(Math.random().toString(36).slice(2, 9));
|
|
2095
|
+
try {
|
|
2096
|
+
client = import_mqtt.default.connect(url, {
|
|
2097
|
+
clientId: clientId,
|
|
2098
|
+
username: mqttConfig.username,
|
|
2099
|
+
password: mqttConfig.password,
|
|
2100
|
+
keepalive: 60,
|
|
2101
|
+
clean: true,
|
|
2102
|
+
reconnectPeriod: 5e3,
|
|
2103
|
+
connectTimeout: 1e4,
|
|
2104
|
+
queueQoSZero: false
|
|
2105
|
+
});
|
|
2106
|
+
} catch (err) {
|
|
2107
|
+
status = "error";
|
|
2108
|
+
console.warn("".concat(LOG2, " connect() threw:"), err);
|
|
2109
|
+
return;
|
|
2110
|
+
}
|
|
2111
|
+
client.on("connect", function() {
|
|
2112
|
+
status = "connected";
|
|
2113
|
+
console.info("".concat(LOG2, " connected to ").concat(url));
|
|
2114
|
+
});
|
|
2115
|
+
client.on("reconnect", function() {
|
|
2116
|
+
status = "connecting";
|
|
2117
|
+
console.info("".concat(LOG2, " reconnecting…"));
|
|
2118
|
+
});
|
|
2119
|
+
client.on("offline", function() {
|
|
2120
|
+
status = "disconnected";
|
|
2121
|
+
console.warn("".concat(LOG2, " offline"));
|
|
2122
|
+
});
|
|
2123
|
+
client.on("error", function(err) {
|
|
2124
|
+
status = "error";
|
|
2125
|
+
console.warn("".concat(LOG2, " error:"), err.message);
|
|
2126
|
+
});
|
|
2127
|
+
client.on("close", function() {
|
|
2128
|
+
if (status === "connected") {
|
|
2129
|
+
status = "disconnected";
|
|
2130
|
+
}
|
|
2131
|
+
});
|
|
2132
|
+
}
|
|
2133
|
+
function ensureMQTTClient() {
|
|
2134
|
+
if (isMQTTEnabled() && !client) {
|
|
2135
|
+
initMQTTClient();
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
function publishMQTT(topic, payload) {
|
|
2139
|
+
if (!isMQTTEnabled()) {
|
|
2140
|
+
return false;
|
|
2141
|
+
}
|
|
2142
|
+
ensureMQTTClient();
|
|
2143
|
+
if (!client) {
|
|
2144
|
+
return false;
|
|
2145
|
+
}
|
|
2146
|
+
try {
|
|
2147
|
+
client.publish(topic, JSON.stringify(payload), {
|
|
2148
|
+
qos: mqttConfig.qos
|
|
2149
|
+
});
|
|
2150
|
+
return true;
|
|
2151
|
+
} catch (err) {
|
|
2152
|
+
console.warn("".concat(LOG2, " publish failed on ").concat(topic, ":"), err);
|
|
2153
|
+
return false;
|
|
2154
|
+
}
|
|
2155
|
+
}
|
|
2156
|
+
function disconnectMQTT() {
|
|
2157
|
+
if (client) {
|
|
2158
|
+
client.end(true);
|
|
2159
|
+
client = null;
|
|
2160
|
+
status = "disconnected";
|
|
2161
|
+
}
|
|
2162
|
+
}
|
|
2063
2163
|
// src/utils/tracking.ts
|
|
2064
2164
|
var cachedBrowserId = null;
|
|
2065
2165
|
function getClientInfo() {
|
|
@@ -2091,8 +2191,8 @@ function getClientInfo() {
|
|
|
2091
2191
|
os = "webOS";
|
|
2092
2192
|
isSmartTV = true;
|
|
2093
2193
|
deviceType = "tv";
|
|
2094
|
-
var
|
|
2095
|
-
model =
|
|
2194
|
+
var m = ua.match(/Web0S\/([^\s]+)/);
|
|
2195
|
+
model = m ? "webOS ".concat(m[1]) : "webOS TV";
|
|
2096
2196
|
} else if (ua.includes("Tizen")) {
|
|
2097
2197
|
brand = "Samsung";
|
|
2098
2198
|
os = "Tizen";
|
|
@@ -2136,23 +2236,19 @@ function getClientInfo() {
|
|
|
2136
2236
|
isAndroid = true;
|
|
2137
2237
|
os = "Android";
|
|
2138
2238
|
deviceType = /Mobile/.test(ua) ? "mobile" : "tablet";
|
|
2139
|
-
if (
|
|
2239
|
+
if (maxTouchPoints === 0 || ua.includes("Google TV") || ua.includes("XiaoMi")) {
|
|
2140
2240
|
deviceType = "tv";
|
|
2141
2241
|
isSmartTV = true;
|
|
2142
2242
|
brand = brand === "Unknown" ? "Android TV" : brand;
|
|
2143
2243
|
}
|
|
2144
2244
|
var androidModelMatch = ua.match(/\(([^)]*Android[^)]*)\)/);
|
|
2145
|
-
if (androidModelMatch
|
|
2146
|
-
model = androidModelMatch[1];
|
|
2147
|
-
}
|
|
2245
|
+
if (androidModelMatch === null || androidModelMatch === void 0 ? void 0 : androidModelMatch[1]) model = androidModelMatch[1];
|
|
2148
2246
|
}
|
|
2149
2247
|
if (/iPad|iPhone|iPod/.test(ua)) {
|
|
2150
2248
|
os = "iOS";
|
|
2151
2249
|
deviceType = "mobile";
|
|
2152
2250
|
brand = "Apple";
|
|
2153
|
-
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua))
|
|
2154
|
-
deviceType = "tablet";
|
|
2155
|
-
}
|
|
2251
|
+
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua)) deviceType = "tablet";
|
|
2156
2252
|
}
|
|
2157
2253
|
if (!isAndroid && !isSmartTV && !/Mobile/.test(ua)) {
|
|
2158
2254
|
if (ua.includes("Windows")) {
|
|
@@ -2173,9 +2269,7 @@ function getClientInfo() {
|
|
|
2173
2269
|
if (vendor.includes("Samsung") || ua.includes("SM-")) brand = "Samsung";
|
|
2174
2270
|
}
|
|
2175
2271
|
isWebView = /wv|WebView|Linux; U;/.test(ua);
|
|
2176
|
-
if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0)
|
|
2177
|
-
isWebView = true;
|
|
2178
|
-
}
|
|
2272
|
+
if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0) isWebView = true;
|
|
2179
2273
|
isWebApp = window.matchMedia("(display-mode: standalone)").matches || window.navigator.standalone === true || ((_window_screen = window.screen) === null || _window_screen === void 0 ? void 0 : (_window_screen_orientation = _window_screen.orientation) === null || _window_screen_orientation === void 0 ? void 0 : _window_screen_orientation.angle) !== void 0;
|
|
2180
2274
|
return {
|
|
2181
2275
|
brand: brand,
|
|
@@ -2206,18 +2300,16 @@ function getClientInfo() {
|
|
|
2206
2300
|
}
|
|
2207
2301
|
function getBrowserID(clientInfo) {
|
|
2208
2302
|
return _async_to_generator(function() {
|
|
2209
|
-
var fingerprintString, encodedData, utf8, buffer, i, hashBuffer,
|
|
2303
|
+
var _crypto_subtle, fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashHex, unused, hash, i1, char, fallbackHash, timestamp, random;
|
|
2210
2304
|
return _ts_generator(this, function(_state) {
|
|
2211
2305
|
switch(_state.label){
|
|
2212
2306
|
case 0:
|
|
2213
|
-
if (cachedBrowserId)
|
|
2214
|
-
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
];
|
|
2218
|
-
}
|
|
2307
|
+
if (cachedBrowserId) return [
|
|
2308
|
+
2,
|
|
2309
|
+
cachedBrowserId
|
|
2310
|
+
];
|
|
2219
2311
|
fingerprintString = JSON.stringify(clientInfo);
|
|
2220
|
-
if (!(typeof crypto !== "undefined" && crypto.subtle
|
|
2312
|
+
if (!(typeof crypto !== "undefined" && ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest))) return [
|
|
2221
2313
|
3,
|
|
2222
2314
|
5
|
|
2223
2315
|
];
|
|
@@ -2244,9 +2336,7 @@ function getBrowserID(clientInfo) {
|
|
|
2244
2336
|
} else {
|
|
2245
2337
|
utf8 = unescape(encodeURIComponent(fingerprintString));
|
|
2246
2338
|
buffer = new Uint8Array(utf8.length);
|
|
2247
|
-
for(i = 0; i < utf8.length; i++)
|
|
2248
|
-
buffer[i] = utf8.charCodeAt(i);
|
|
2249
|
-
}
|
|
2339
|
+
for(i = 0; i < utf8.length; i++)buffer[i] = utf8.charCodeAt(i);
|
|
2250
2340
|
encodedData = buffer;
|
|
2251
2341
|
}
|
|
2252
2342
|
return [
|
|
@@ -2255,8 +2345,7 @@ function getBrowserID(clientInfo) {
|
|
|
2255
2345
|
];
|
|
2256
2346
|
case 3:
|
|
2257
2347
|
hashBuffer = _state.sent();
|
|
2258
|
-
|
|
2259
|
-
hashHex = hashArray.map(function(b) {
|
|
2348
|
+
hashHex = Array.from(new Uint8Array(hashBuffer)).map(function(b) {
|
|
2260
2349
|
return b.toString(16).padStart(2, "0");
|
|
2261
2350
|
}).join("");
|
|
2262
2351
|
cachedBrowserId = hashHex;
|
|
@@ -2265,8 +2354,8 @@ function getBrowserID(clientInfo) {
|
|
|
2265
2354
|
hashHex
|
|
2266
2355
|
];
|
|
2267
2356
|
case 4:
|
|
2268
|
-
|
|
2269
|
-
console.warn("[StormcloudVideoPlayer] crypto.subtle
|
|
2357
|
+
unused = _state.sent();
|
|
2358
|
+
console.warn("[StormcloudVideoPlayer] crypto.subtle not supported, using fallback hash");
|
|
2270
2359
|
return [
|
|
2271
2360
|
3,
|
|
2272
2361
|
5
|
|
@@ -2290,177 +2379,91 @@ function getBrowserID(clientInfo) {
|
|
|
2290
2379
|
});
|
|
2291
2380
|
})();
|
|
2292
2381
|
}
|
|
2293
|
-
|
|
2294
|
-
|
|
2295
|
-
var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
|
|
2296
|
-
var IMPRESSIONS_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/impressions/ingest");
|
|
2297
|
-
function buildHeaders(licenseKey) {
|
|
2298
|
-
var headers = {
|
|
2299
|
-
"Content-Type": "application/json"
|
|
2300
|
-
};
|
|
2301
|
-
if (licenseKey) {
|
|
2302
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2303
|
-
}
|
|
2304
|
-
return headers;
|
|
2305
|
-
}
|
|
2306
|
-
function sendTrackRequest(licenseKey, body) {
|
|
2307
|
-
return _async_to_generator(function() {
|
|
2308
|
-
var response;
|
|
2309
|
-
return _ts_generator(this, function(_state) {
|
|
2310
|
-
switch(_state.label){
|
|
2311
|
-
case 0:
|
|
2312
|
-
return [
|
|
2313
|
-
4,
|
|
2314
|
-
fetch(TRACK_URL, {
|
|
2315
|
-
method: "POST",
|
|
2316
|
-
headers: buildHeaders(licenseKey),
|
|
2317
|
-
body: JSON.stringify(body)
|
|
2318
|
-
})
|
|
2319
|
-
];
|
|
2320
|
-
case 1:
|
|
2321
|
-
response = _state.sent();
|
|
2322
|
-
if (!response.ok) {
|
|
2323
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2324
|
-
}
|
|
2325
|
-
return [
|
|
2326
|
-
4,
|
|
2327
|
-
response.json()
|
|
2328
|
-
];
|
|
2329
|
-
case 2:
|
|
2330
|
-
_state.sent();
|
|
2331
|
-
return [
|
|
2332
|
-
2
|
|
2333
|
-
];
|
|
2334
|
-
}
|
|
2335
|
-
});
|
|
2336
|
-
})();
|
|
2382
|
+
function canPublish(licenseKey) {
|
|
2383
|
+
return Boolean(isMQTTEnabled() && licenseKey);
|
|
2337
2384
|
}
|
|
2338
|
-
function
|
|
2385
|
+
function buildPlayerMetricEvent() {
|
|
2339
2386
|
return _async_to_generator(function() {
|
|
2340
|
-
var
|
|
2341
|
-
return _ts_generator(this, function(_state) {
|
|
2342
|
-
switch(_state.label){
|
|
2343
|
-
case 0:
|
|
2344
|
-
return [
|
|
2345
|
-
4,
|
|
2346
|
-
fetch(url, {
|
|
2347
|
-
method: "POST",
|
|
2348
|
-
headers: buildHeaders(licenseKey),
|
|
2349
|
-
body: JSON.stringify(body)
|
|
2350
|
-
})
|
|
2351
|
-
];
|
|
2352
|
-
case 1:
|
|
2353
|
-
response = _state.sent();
|
|
2354
|
-
if (!response.ok) {
|
|
2355
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2356
|
-
}
|
|
2357
|
-
return [
|
|
2358
|
-
4,
|
|
2359
|
-
response.json()
|
|
2360
|
-
];
|
|
2361
|
-
case 2:
|
|
2362
|
-
_state.sent();
|
|
2363
|
-
return [
|
|
2364
|
-
2
|
|
2365
|
-
];
|
|
2366
|
-
}
|
|
2367
|
-
});
|
|
2368
|
-
})();
|
|
2369
|
-
}
|
|
2370
|
-
function buildPlayerMetricEvent(_0) {
|
|
2371
|
-
return _async_to_generator(function(licenseKey) {
|
|
2372
|
-
var context, flags, _flags_captureAt, clientInfo, browserId, captureAt;
|
|
2387
|
+
var context, flags, _flags_captureAt, _flags_adLoaded, _flags_adDetect, clientInfo, playerId, captureAt;
|
|
2373
2388
|
var _arguments = arguments;
|
|
2374
2389
|
return _ts_generator(this, function(_state) {
|
|
2375
2390
|
switch(_state.label){
|
|
2376
2391
|
case 0:
|
|
2377
|
-
context = _arguments.length >
|
|
2392
|
+
context = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {}, flags = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2378
2393
|
clientInfo = getClientInfo();
|
|
2379
2394
|
return [
|
|
2380
2395
|
4,
|
|
2381
2396
|
getBrowserID(clientInfo)
|
|
2382
2397
|
];
|
|
2383
2398
|
case 1:
|
|
2384
|
-
|
|
2399
|
+
playerId = _state.sent();
|
|
2385
2400
|
captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
|
|
2386
2401
|
return [
|
|
2387
2402
|
2,
|
|
2388
|
-
{
|
|
2389
|
-
player_id:
|
|
2390
|
-
browserId: browserId,
|
|
2403
|
+
_object_spread({
|
|
2404
|
+
player_id: playerId,
|
|
2391
2405
|
device_type: clientInfo.deviceType,
|
|
2392
|
-
|
|
2393
|
-
|
|
2394
|
-
|
|
2395
|
-
|
|
2396
|
-
|
|
2397
|
-
|
|
2398
|
-
|
|
2399
|
-
timestamp: captureAt
|
|
2400
|
-
}
|
|
2406
|
+
os: clientInfo.os.toLowerCase(),
|
|
2407
|
+
ad_loaded: (_flags_adLoaded = flags.adLoaded) !== null && _flags_adLoaded !== void 0 ? _flags_adLoaded : false,
|
|
2408
|
+
ad_detect: (_flags_adDetect = flags.adDetect) !== null && _flags_adDetect !== void 0 ? _flags_adDetect : false,
|
|
2409
|
+
capture_at: captureAt
|
|
2410
|
+
}, context.inputStreamType ? {
|
|
2411
|
+
input_stream_type: context.inputStreamType
|
|
2412
|
+
} : {})
|
|
2401
2413
|
];
|
|
2402
2414
|
}
|
|
2403
2415
|
});
|
|
2404
2416
|
}).apply(this, arguments);
|
|
2405
2417
|
}
|
|
2418
|
+
function publishTracking(licenseKey, channel, body) {
|
|
2419
|
+
ensureMQTTClient();
|
|
2420
|
+
publishMQTT(buildPlayerTopic(licenseKey, channel), body);
|
|
2421
|
+
}
|
|
2406
2422
|
function sendInitialTracking(_0) {
|
|
2407
2423
|
return _async_to_generator(function(licenseKey) {
|
|
2408
|
-
var context,
|
|
2424
|
+
var context, metricEvent, error;
|
|
2409
2425
|
var _arguments = arguments;
|
|
2410
2426
|
return _ts_generator(this, function(_state) {
|
|
2411
2427
|
switch(_state.label){
|
|
2412
2428
|
case 0:
|
|
2413
2429
|
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2430
|
+
if (!canPublish(licenseKey)) return [
|
|
2431
|
+
2
|
|
2432
|
+
];
|
|
2414
2433
|
_state.label = 1;
|
|
2415
2434
|
case 1:
|
|
2416
2435
|
_state.trys.push([
|
|
2417
2436
|
1,
|
|
2418
|
-
|
|
2437
|
+
3,
|
|
2419
2438
|
,
|
|
2420
|
-
|
|
2439
|
+
4
|
|
2421
2440
|
]);
|
|
2422
|
-
clientInfo = getClientInfo();
|
|
2423
|
-
return [
|
|
2424
|
-
4,
|
|
2425
|
-
getBrowserID(clientInfo)
|
|
2426
|
-
];
|
|
2427
|
-
case 2:
|
|
2428
|
-
browserId = _state.sent();
|
|
2429
|
-
trackingData = _object_spread({
|
|
2430
|
-
browserId: browserId
|
|
2431
|
-
}, clientInfo);
|
|
2432
2441
|
return [
|
|
2433
2442
|
4,
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
player_id: browserId,
|
|
2438
|
-
device_type: clientInfo.deviceType,
|
|
2439
|
-
input_stream_type: context.inputStreamType,
|
|
2440
|
-
os: clientInfo.os,
|
|
2441
|
-
ad_loaded: false,
|
|
2442
|
-
ad_detect: false,
|
|
2443
|
-
license_key: licenseKey,
|
|
2444
|
-
capture_at: /* @__PURE__ */ new Date().toISOString()
|
|
2445
|
-
}
|
|
2446
|
-
],
|
|
2447
|
-
trackingData: trackingData
|
|
2443
|
+
buildPlayerMetricEvent(context, {
|
|
2444
|
+
adLoaded: false,
|
|
2445
|
+
adDetect: false
|
|
2448
2446
|
})
|
|
2449
2447
|
];
|
|
2450
|
-
case
|
|
2451
|
-
_state.sent();
|
|
2448
|
+
case 2:
|
|
2449
|
+
metricEvent = _state.sent();
|
|
2450
|
+
publishTracking(licenseKey, "metrics", {
|
|
2451
|
+
events: [
|
|
2452
|
+
metricEvent
|
|
2453
|
+
]
|
|
2454
|
+
});
|
|
2452
2455
|
return [
|
|
2453
2456
|
3,
|
|
2454
|
-
|
|
2457
|
+
4
|
|
2455
2458
|
];
|
|
2456
|
-
case
|
|
2459
|
+
case 3:
|
|
2457
2460
|
error = _state.sent();
|
|
2458
2461
|
console.error("[StormcloudVideoPlayer] Error sending initial tracking data:", error);
|
|
2459
2462
|
return [
|
|
2460
2463
|
3,
|
|
2461
|
-
|
|
2464
|
+
4
|
|
2462
2465
|
];
|
|
2463
|
-
case
|
|
2466
|
+
case 4:
|
|
2464
2467
|
return [
|
|
2465
2468
|
2
|
|
2466
2469
|
];
|
|
@@ -2564,53 +2567,48 @@ function sendAdImpressionTracking(_0, _1) {
|
|
|
2564
2567
|
switch(_state.label){
|
|
2565
2568
|
case 0:
|
|
2566
2569
|
context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2570
|
+
if (!canPublish(licenseKey)) return [
|
|
2571
|
+
2
|
|
2572
|
+
];
|
|
2567
2573
|
_state.label = 1;
|
|
2568
2574
|
case 1:
|
|
2569
2575
|
_state.trys.push([
|
|
2570
2576
|
1,
|
|
2571
|
-
|
|
2577
|
+
3,
|
|
2572
2578
|
,
|
|
2573
|
-
|
|
2579
|
+
4
|
|
2574
2580
|
]);
|
|
2575
2581
|
return [
|
|
2576
2582
|
4,
|
|
2577
|
-
buildPlayerMetricEvent(
|
|
2583
|
+
buildPlayerMetricEvent(context, {
|
|
2578
2584
|
captureAt: adImpressionInfo.timestamp
|
|
2579
2585
|
})
|
|
2580
2586
|
];
|
|
2581
2587
|
case 2:
|
|
2582
2588
|
metricEvent = _state.sent();
|
|
2583
|
-
|
|
2584
|
-
|
|
2585
|
-
|
|
2586
|
-
|
|
2587
|
-
|
|
2588
|
-
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
capture_at: adImpressionInfo.timestamp
|
|
2595
|
-
}
|
|
2596
|
-
]
|
|
2597
|
-
})
|
|
2598
|
-
])
|
|
2599
|
-
];
|
|
2600
|
-
case 3:
|
|
2601
|
-
_state.sent();
|
|
2589
|
+
publishTracking(licenseKey, "heartbeat", metricEvent);
|
|
2590
|
+
publishTracking(licenseKey, "impressions", {
|
|
2591
|
+
events: [
|
|
2592
|
+
{
|
|
2593
|
+
player_id: metricEvent.player_id,
|
|
2594
|
+
ad_played_count: 1,
|
|
2595
|
+
ad_url: adImpressionInfo.adUrl,
|
|
2596
|
+
capture_at: adImpressionInfo.timestamp
|
|
2597
|
+
}
|
|
2598
|
+
]
|
|
2599
|
+
});
|
|
2602
2600
|
return [
|
|
2603
2601
|
3,
|
|
2604
|
-
|
|
2602
|
+
4
|
|
2605
2603
|
];
|
|
2606
|
-
case
|
|
2604
|
+
case 3:
|
|
2607
2605
|
error = _state.sent();
|
|
2608
2606
|
console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
|
|
2609
2607
|
return [
|
|
2610
2608
|
3,
|
|
2611
|
-
|
|
2609
|
+
4
|
|
2612
2610
|
];
|
|
2613
|
-
case
|
|
2611
|
+
case 4:
|
|
2614
2612
|
return [
|
|
2615
2613
|
2
|
|
2616
2614
|
];
|
|
@@ -2626,38 +2624,36 @@ function sendHeartbeat(_0) {
|
|
|
2626
2624
|
switch(_state.label){
|
|
2627
2625
|
case 0:
|
|
2628
2626
|
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2627
|
+
if (!canPublish(licenseKey)) return [
|
|
2628
|
+
2
|
|
2629
|
+
];
|
|
2629
2630
|
_state.label = 1;
|
|
2630
2631
|
case 1:
|
|
2631
2632
|
_state.trys.push([
|
|
2632
2633
|
1,
|
|
2633
|
-
|
|
2634
|
+
3,
|
|
2634
2635
|
,
|
|
2635
|
-
|
|
2636
|
+
4
|
|
2636
2637
|
]);
|
|
2637
2638
|
return [
|
|
2638
2639
|
4,
|
|
2639
|
-
buildPlayerMetricEvent(
|
|
2640
|
+
buildPlayerMetricEvent(context, flags)
|
|
2640
2641
|
];
|
|
2641
2642
|
case 2:
|
|
2642
2643
|
heartbeatData = _state.sent();
|
|
2643
|
-
|
|
2644
|
-
4,
|
|
2645
|
-
postJson(HEARTBEAT_URL, licenseKey, heartbeatData)
|
|
2646
|
-
];
|
|
2647
|
-
case 3:
|
|
2648
|
-
_state.sent();
|
|
2644
|
+
publishTracking(licenseKey, "heartbeat", heartbeatData);
|
|
2649
2645
|
return [
|
|
2650
2646
|
3,
|
|
2651
|
-
|
|
2647
|
+
4
|
|
2652
2648
|
];
|
|
2653
|
-
case
|
|
2649
|
+
case 3:
|
|
2654
2650
|
error = _state.sent();
|
|
2655
2651
|
console.error("[StormcloudVideoPlayer] Error sending heartbeat:", error);
|
|
2656
2652
|
return [
|
|
2657
2653
|
3,
|
|
2658
|
-
|
|
2654
|
+
4
|
|
2659
2655
|
];
|
|
2660
|
-
case
|
|
2656
|
+
case 4:
|
|
2661
2657
|
return [
|
|
2662
2658
|
2
|
|
2663
2659
|
];
|
|
@@ -4571,6 +4567,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4571
4567
|
key: "initializeTracking",
|
|
4572
4568
|
value: function initializeTracking() {
|
|
4573
4569
|
var _this = this;
|
|
4570
|
+
if (isMQTTEnabled()) {
|
|
4571
|
+
initMQTTClient();
|
|
4572
|
+
}
|
|
4574
4573
|
sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
|
|
4575
4574
|
_this.heartbeatInterval = window.setInterval(function() {
|
|
4576
4575
|
_this.sendHeartbeatIfNeeded();
|
|
@@ -6250,6 +6249,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6250
6249
|
clearInterval(this.heartbeatInterval);
|
|
6251
6250
|
this.heartbeatInterval = void 0;
|
|
6252
6251
|
}
|
|
6252
|
+
if (isMQTTEnabled()) {
|
|
6253
|
+
disconnectMQTT();
|
|
6254
|
+
}
|
|
6253
6255
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
6254
6256
|
(_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
|
|
6255
6257
|
this.consecutiveFailures = 0;
|