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
package/lib/players/index.cjs
CHANGED
|
@@ -2096,6 +2096,106 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
2096
2096
|
}
|
|
2097
2097
|
};
|
|
2098
2098
|
}
|
|
2099
|
+
// src/utils/mqttConfig.ts
|
|
2100
|
+
var DEFAULT_MQTT_CONFIG = {
|
|
2101
|
+
enabled: true,
|
|
2102
|
+
brokerAddress: "vecbae77.ala.us-east-1.emqxsl.com",
|
|
2103
|
+
brokerPort: 8883,
|
|
2104
|
+
wsPort: 8084,
|
|
2105
|
+
username: "for-sonifi",
|
|
2106
|
+
password: "sonifi-mqtt",
|
|
2107
|
+
topicPrefix: "adstorm/players",
|
|
2108
|
+
qos: 1
|
|
2109
|
+
};
|
|
2110
|
+
var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
|
|
2111
|
+
function isMQTTEnabled() {
|
|
2112
|
+
return mqttConfig.enabled;
|
|
2113
|
+
}
|
|
2114
|
+
function buildMQTTBrokerUrl() {
|
|
2115
|
+
if (mqttConfig.brokerUrl) return mqttConfig.brokerUrl;
|
|
2116
|
+
return "wss://".concat(mqttConfig.brokerAddress, ":").concat(mqttConfig.wsPort, "/mqtt");
|
|
2117
|
+
}
|
|
2118
|
+
function buildPlayerTopic(licenseKey, channel) {
|
|
2119
|
+
return "".concat(mqttConfig.topicPrefix, "/").concat(licenseKey, "/").concat(channel);
|
|
2120
|
+
}
|
|
2121
|
+
// src/utils/mqttClient.ts
|
|
2122
|
+
var import_mqtt = __toESM(require("mqtt"), 1);
|
|
2123
|
+
var LOG2 = "[StormcloudVideoPlayer][MQTT]";
|
|
2124
|
+
var client = null;
|
|
2125
|
+
var status = "disconnected";
|
|
2126
|
+
function initMQTTClient() {
|
|
2127
|
+
if (client || !isMQTTEnabled()) return;
|
|
2128
|
+
var url = buildMQTTBrokerUrl();
|
|
2129
|
+
status = "connecting";
|
|
2130
|
+
var clientId = "stormcloud-vp-".concat(Math.random().toString(36).slice(2, 9));
|
|
2131
|
+
try {
|
|
2132
|
+
client = import_mqtt.default.connect(url, {
|
|
2133
|
+
clientId: clientId,
|
|
2134
|
+
username: mqttConfig.username,
|
|
2135
|
+
password: mqttConfig.password,
|
|
2136
|
+
keepalive: 60,
|
|
2137
|
+
clean: true,
|
|
2138
|
+
reconnectPeriod: 5e3,
|
|
2139
|
+
connectTimeout: 1e4,
|
|
2140
|
+
queueQoSZero: false
|
|
2141
|
+
});
|
|
2142
|
+
} catch (err) {
|
|
2143
|
+
status = "error";
|
|
2144
|
+
console.warn("".concat(LOG2, " connect() threw:"), err);
|
|
2145
|
+
return;
|
|
2146
|
+
}
|
|
2147
|
+
client.on("connect", function() {
|
|
2148
|
+
status = "connected";
|
|
2149
|
+
console.info("".concat(LOG2, " connected to ").concat(url));
|
|
2150
|
+
});
|
|
2151
|
+
client.on("reconnect", function() {
|
|
2152
|
+
status = "connecting";
|
|
2153
|
+
console.info("".concat(LOG2, " reconnecting…"));
|
|
2154
|
+
});
|
|
2155
|
+
client.on("offline", function() {
|
|
2156
|
+
status = "disconnected";
|
|
2157
|
+
console.warn("".concat(LOG2, " offline"));
|
|
2158
|
+
});
|
|
2159
|
+
client.on("error", function(err) {
|
|
2160
|
+
status = "error";
|
|
2161
|
+
console.warn("".concat(LOG2, " error:"), err.message);
|
|
2162
|
+
});
|
|
2163
|
+
client.on("close", function() {
|
|
2164
|
+
if (status === "connected") {
|
|
2165
|
+
status = "disconnected";
|
|
2166
|
+
}
|
|
2167
|
+
});
|
|
2168
|
+
}
|
|
2169
|
+
function ensureMQTTClient() {
|
|
2170
|
+
if (isMQTTEnabled() && !client) {
|
|
2171
|
+
initMQTTClient();
|
|
2172
|
+
}
|
|
2173
|
+
}
|
|
2174
|
+
function publishMQTT(topic, payload) {
|
|
2175
|
+
if (!isMQTTEnabled()) {
|
|
2176
|
+
return false;
|
|
2177
|
+
}
|
|
2178
|
+
ensureMQTTClient();
|
|
2179
|
+
if (!client) {
|
|
2180
|
+
return false;
|
|
2181
|
+
}
|
|
2182
|
+
try {
|
|
2183
|
+
client.publish(topic, JSON.stringify(payload), {
|
|
2184
|
+
qos: mqttConfig.qos
|
|
2185
|
+
});
|
|
2186
|
+
return true;
|
|
2187
|
+
} catch (err) {
|
|
2188
|
+
console.warn("".concat(LOG2, " publish failed on ").concat(topic, ":"), err);
|
|
2189
|
+
return false;
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
function disconnectMQTT() {
|
|
2193
|
+
if (client) {
|
|
2194
|
+
client.end(true);
|
|
2195
|
+
client = null;
|
|
2196
|
+
status = "disconnected";
|
|
2197
|
+
}
|
|
2198
|
+
}
|
|
2099
2199
|
// src/utils/tracking.ts
|
|
2100
2200
|
var cachedBrowserId = null;
|
|
2101
2201
|
function getClientInfo() {
|
|
@@ -2127,8 +2227,8 @@ function getClientInfo() {
|
|
|
2127
2227
|
os = "webOS";
|
|
2128
2228
|
isSmartTV = true;
|
|
2129
2229
|
deviceType = "tv";
|
|
2130
|
-
var
|
|
2131
|
-
model =
|
|
2230
|
+
var m = ua.match(/Web0S\/([^\s]+)/);
|
|
2231
|
+
model = m ? "webOS ".concat(m[1]) : "webOS TV";
|
|
2132
2232
|
} else if (ua.includes("Tizen")) {
|
|
2133
2233
|
brand = "Samsung";
|
|
2134
2234
|
os = "Tizen";
|
|
@@ -2172,23 +2272,19 @@ function getClientInfo() {
|
|
|
2172
2272
|
isAndroid = true;
|
|
2173
2273
|
os = "Android";
|
|
2174
2274
|
deviceType = /Mobile/.test(ua) ? "mobile" : "tablet";
|
|
2175
|
-
if (
|
|
2275
|
+
if (maxTouchPoints === 0 || ua.includes("Google TV") || ua.includes("XiaoMi")) {
|
|
2176
2276
|
deviceType = "tv";
|
|
2177
2277
|
isSmartTV = true;
|
|
2178
2278
|
brand = brand === "Unknown" ? "Android TV" : brand;
|
|
2179
2279
|
}
|
|
2180
2280
|
var androidModelMatch = ua.match(/\(([^)]*Android[^)]*)\)/);
|
|
2181
|
-
if (androidModelMatch
|
|
2182
|
-
model = androidModelMatch[1];
|
|
2183
|
-
}
|
|
2281
|
+
if (androidModelMatch === null || androidModelMatch === void 0 ? void 0 : androidModelMatch[1]) model = androidModelMatch[1];
|
|
2184
2282
|
}
|
|
2185
2283
|
if (/iPad|iPhone|iPod/.test(ua)) {
|
|
2186
2284
|
os = "iOS";
|
|
2187
2285
|
deviceType = "mobile";
|
|
2188
2286
|
brand = "Apple";
|
|
2189
|
-
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua))
|
|
2190
|
-
deviceType = "tablet";
|
|
2191
|
-
}
|
|
2287
|
+
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua)) deviceType = "tablet";
|
|
2192
2288
|
}
|
|
2193
2289
|
if (!isAndroid && !isSmartTV && !/Mobile/.test(ua)) {
|
|
2194
2290
|
if (ua.includes("Windows")) {
|
|
@@ -2209,9 +2305,7 @@ function getClientInfo() {
|
|
|
2209
2305
|
if (vendor.includes("Samsung") || ua.includes("SM-")) brand = "Samsung";
|
|
2210
2306
|
}
|
|
2211
2307
|
isWebView = /wv|WebView|Linux; U;/.test(ua);
|
|
2212
|
-
if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0)
|
|
2213
|
-
isWebView = true;
|
|
2214
|
-
}
|
|
2308
|
+
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;
|
|
2215
2309
|
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;
|
|
2216
2310
|
return {
|
|
2217
2311
|
brand: brand,
|
|
@@ -2242,18 +2336,16 @@ function getClientInfo() {
|
|
|
2242
2336
|
}
|
|
2243
2337
|
function getBrowserID(clientInfo) {
|
|
2244
2338
|
return _async_to_generator(function() {
|
|
2245
|
-
var fingerprintString, encodedData, utf8, buffer, i, hashBuffer,
|
|
2339
|
+
var _crypto_subtle, fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashHex, unused, hash, i1, char, fallbackHash, timestamp, random;
|
|
2246
2340
|
return _ts_generator(this, function(_state) {
|
|
2247
2341
|
switch(_state.label){
|
|
2248
2342
|
case 0:
|
|
2249
|
-
if (cachedBrowserId)
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
];
|
|
2254
|
-
}
|
|
2343
|
+
if (cachedBrowserId) return [
|
|
2344
|
+
2,
|
|
2345
|
+
cachedBrowserId
|
|
2346
|
+
];
|
|
2255
2347
|
fingerprintString = JSON.stringify(clientInfo);
|
|
2256
|
-
if (!(typeof crypto !== "undefined" && crypto.subtle
|
|
2348
|
+
if (!(typeof crypto !== "undefined" && ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest))) return [
|
|
2257
2349
|
3,
|
|
2258
2350
|
5
|
|
2259
2351
|
];
|
|
@@ -2280,9 +2372,7 @@ function getBrowserID(clientInfo) {
|
|
|
2280
2372
|
} else {
|
|
2281
2373
|
utf8 = unescape(encodeURIComponent(fingerprintString));
|
|
2282
2374
|
buffer = new Uint8Array(utf8.length);
|
|
2283
|
-
for(i = 0; i < utf8.length; i++)
|
|
2284
|
-
buffer[i] = utf8.charCodeAt(i);
|
|
2285
|
-
}
|
|
2375
|
+
for(i = 0; i < utf8.length; i++)buffer[i] = utf8.charCodeAt(i);
|
|
2286
2376
|
encodedData = buffer;
|
|
2287
2377
|
}
|
|
2288
2378
|
return [
|
|
@@ -2291,8 +2381,7 @@ function getBrowserID(clientInfo) {
|
|
|
2291
2381
|
];
|
|
2292
2382
|
case 3:
|
|
2293
2383
|
hashBuffer = _state.sent();
|
|
2294
|
-
|
|
2295
|
-
hashHex = hashArray.map(function(b) {
|
|
2384
|
+
hashHex = Array.from(new Uint8Array(hashBuffer)).map(function(b) {
|
|
2296
2385
|
return b.toString(16).padStart(2, "0");
|
|
2297
2386
|
}).join("");
|
|
2298
2387
|
cachedBrowserId = hashHex;
|
|
@@ -2301,8 +2390,8 @@ function getBrowserID(clientInfo) {
|
|
|
2301
2390
|
hashHex
|
|
2302
2391
|
];
|
|
2303
2392
|
case 4:
|
|
2304
|
-
|
|
2305
|
-
console.warn("[StormcloudVideoPlayer] crypto.subtle
|
|
2393
|
+
unused = _state.sent();
|
|
2394
|
+
console.warn("[StormcloudVideoPlayer] crypto.subtle not supported, using fallback hash");
|
|
2306
2395
|
return [
|
|
2307
2396
|
3,
|
|
2308
2397
|
5
|
|
@@ -2326,177 +2415,91 @@ function getBrowserID(clientInfo) {
|
|
|
2326
2415
|
});
|
|
2327
2416
|
})();
|
|
2328
2417
|
}
|
|
2329
|
-
|
|
2330
|
-
|
|
2331
|
-
var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
|
|
2332
|
-
var IMPRESSIONS_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/impressions/ingest");
|
|
2333
|
-
function buildHeaders(licenseKey) {
|
|
2334
|
-
var headers = {
|
|
2335
|
-
"Content-Type": "application/json"
|
|
2336
|
-
};
|
|
2337
|
-
if (licenseKey) {
|
|
2338
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2339
|
-
}
|
|
2340
|
-
return headers;
|
|
2341
|
-
}
|
|
2342
|
-
function sendTrackRequest(licenseKey, body) {
|
|
2343
|
-
return _async_to_generator(function() {
|
|
2344
|
-
var response;
|
|
2345
|
-
return _ts_generator(this, function(_state) {
|
|
2346
|
-
switch(_state.label){
|
|
2347
|
-
case 0:
|
|
2348
|
-
return [
|
|
2349
|
-
4,
|
|
2350
|
-
fetch(TRACK_URL, {
|
|
2351
|
-
method: "POST",
|
|
2352
|
-
headers: buildHeaders(licenseKey),
|
|
2353
|
-
body: JSON.stringify(body)
|
|
2354
|
-
})
|
|
2355
|
-
];
|
|
2356
|
-
case 1:
|
|
2357
|
-
response = _state.sent();
|
|
2358
|
-
if (!response.ok) {
|
|
2359
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2360
|
-
}
|
|
2361
|
-
return [
|
|
2362
|
-
4,
|
|
2363
|
-
response.json()
|
|
2364
|
-
];
|
|
2365
|
-
case 2:
|
|
2366
|
-
_state.sent();
|
|
2367
|
-
return [
|
|
2368
|
-
2
|
|
2369
|
-
];
|
|
2370
|
-
}
|
|
2371
|
-
});
|
|
2372
|
-
})();
|
|
2418
|
+
function canPublish(licenseKey) {
|
|
2419
|
+
return Boolean(isMQTTEnabled() && licenseKey);
|
|
2373
2420
|
}
|
|
2374
|
-
function
|
|
2421
|
+
function buildPlayerMetricEvent() {
|
|
2375
2422
|
return _async_to_generator(function() {
|
|
2376
|
-
var
|
|
2377
|
-
return _ts_generator(this, function(_state) {
|
|
2378
|
-
switch(_state.label){
|
|
2379
|
-
case 0:
|
|
2380
|
-
return [
|
|
2381
|
-
4,
|
|
2382
|
-
fetch(url, {
|
|
2383
|
-
method: "POST",
|
|
2384
|
-
headers: buildHeaders(licenseKey),
|
|
2385
|
-
body: JSON.stringify(body)
|
|
2386
|
-
})
|
|
2387
|
-
];
|
|
2388
|
-
case 1:
|
|
2389
|
-
response = _state.sent();
|
|
2390
|
-
if (!response.ok) {
|
|
2391
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2392
|
-
}
|
|
2393
|
-
return [
|
|
2394
|
-
4,
|
|
2395
|
-
response.json()
|
|
2396
|
-
];
|
|
2397
|
-
case 2:
|
|
2398
|
-
_state.sent();
|
|
2399
|
-
return [
|
|
2400
|
-
2
|
|
2401
|
-
];
|
|
2402
|
-
}
|
|
2403
|
-
});
|
|
2404
|
-
})();
|
|
2405
|
-
}
|
|
2406
|
-
function buildPlayerMetricEvent(_0) {
|
|
2407
|
-
return _async_to_generator(function(licenseKey) {
|
|
2408
|
-
var context, flags, _flags_captureAt, clientInfo, browserId, captureAt;
|
|
2423
|
+
var context, flags, _flags_captureAt, _flags_adLoaded, _flags_adDetect, clientInfo, playerId, captureAt;
|
|
2409
2424
|
var _arguments = arguments;
|
|
2410
2425
|
return _ts_generator(this, function(_state) {
|
|
2411
2426
|
switch(_state.label){
|
|
2412
2427
|
case 0:
|
|
2413
|
-
context = _arguments.length >
|
|
2428
|
+
context = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {}, flags = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2414
2429
|
clientInfo = getClientInfo();
|
|
2415
2430
|
return [
|
|
2416
2431
|
4,
|
|
2417
2432
|
getBrowserID(clientInfo)
|
|
2418
2433
|
];
|
|
2419
2434
|
case 1:
|
|
2420
|
-
|
|
2435
|
+
playerId = _state.sent();
|
|
2421
2436
|
captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
|
|
2422
2437
|
return [
|
|
2423
2438
|
2,
|
|
2424
|
-
{
|
|
2425
|
-
player_id:
|
|
2426
|
-
browserId: browserId,
|
|
2439
|
+
_object_spread({
|
|
2440
|
+
player_id: playerId,
|
|
2427
2441
|
device_type: clientInfo.deviceType,
|
|
2428
|
-
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
timestamp: captureAt
|
|
2436
|
-
}
|
|
2442
|
+
os: clientInfo.os.toLowerCase(),
|
|
2443
|
+
ad_loaded: (_flags_adLoaded = flags.adLoaded) !== null && _flags_adLoaded !== void 0 ? _flags_adLoaded : false,
|
|
2444
|
+
ad_detect: (_flags_adDetect = flags.adDetect) !== null && _flags_adDetect !== void 0 ? _flags_adDetect : false,
|
|
2445
|
+
capture_at: captureAt
|
|
2446
|
+
}, context.inputStreamType ? {
|
|
2447
|
+
input_stream_type: context.inputStreamType
|
|
2448
|
+
} : {})
|
|
2437
2449
|
];
|
|
2438
2450
|
}
|
|
2439
2451
|
});
|
|
2440
2452
|
}).apply(this, arguments);
|
|
2441
2453
|
}
|
|
2454
|
+
function publishTracking(licenseKey, channel, body) {
|
|
2455
|
+
ensureMQTTClient();
|
|
2456
|
+
publishMQTT(buildPlayerTopic(licenseKey, channel), body);
|
|
2457
|
+
}
|
|
2442
2458
|
function sendInitialTracking(_0) {
|
|
2443
2459
|
return _async_to_generator(function(licenseKey) {
|
|
2444
|
-
var context,
|
|
2460
|
+
var context, metricEvent, error;
|
|
2445
2461
|
var _arguments = arguments;
|
|
2446
2462
|
return _ts_generator(this, function(_state) {
|
|
2447
2463
|
switch(_state.label){
|
|
2448
2464
|
case 0:
|
|
2449
2465
|
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2466
|
+
if (!canPublish(licenseKey)) return [
|
|
2467
|
+
2
|
|
2468
|
+
];
|
|
2450
2469
|
_state.label = 1;
|
|
2451
2470
|
case 1:
|
|
2452
2471
|
_state.trys.push([
|
|
2453
2472
|
1,
|
|
2454
|
-
|
|
2473
|
+
3,
|
|
2455
2474
|
,
|
|
2456
|
-
|
|
2475
|
+
4
|
|
2457
2476
|
]);
|
|
2458
|
-
clientInfo = getClientInfo();
|
|
2459
|
-
return [
|
|
2460
|
-
4,
|
|
2461
|
-
getBrowserID(clientInfo)
|
|
2462
|
-
];
|
|
2463
|
-
case 2:
|
|
2464
|
-
browserId = _state.sent();
|
|
2465
|
-
trackingData = _object_spread({
|
|
2466
|
-
browserId: browserId
|
|
2467
|
-
}, clientInfo);
|
|
2468
2477
|
return [
|
|
2469
2478
|
4,
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
player_id: browserId,
|
|
2474
|
-
device_type: clientInfo.deviceType,
|
|
2475
|
-
input_stream_type: context.inputStreamType,
|
|
2476
|
-
os: clientInfo.os,
|
|
2477
|
-
ad_loaded: false,
|
|
2478
|
-
ad_detect: false,
|
|
2479
|
-
license_key: licenseKey,
|
|
2480
|
-
capture_at: /* @__PURE__ */ new Date().toISOString()
|
|
2481
|
-
}
|
|
2482
|
-
],
|
|
2483
|
-
trackingData: trackingData
|
|
2479
|
+
buildPlayerMetricEvent(context, {
|
|
2480
|
+
adLoaded: false,
|
|
2481
|
+
adDetect: false
|
|
2484
2482
|
})
|
|
2485
2483
|
];
|
|
2486
|
-
case
|
|
2487
|
-
_state.sent();
|
|
2484
|
+
case 2:
|
|
2485
|
+
metricEvent = _state.sent();
|
|
2486
|
+
publishTracking(licenseKey, "metrics", {
|
|
2487
|
+
events: [
|
|
2488
|
+
metricEvent
|
|
2489
|
+
]
|
|
2490
|
+
});
|
|
2488
2491
|
return [
|
|
2489
2492
|
3,
|
|
2490
|
-
|
|
2493
|
+
4
|
|
2491
2494
|
];
|
|
2492
|
-
case
|
|
2495
|
+
case 3:
|
|
2493
2496
|
error = _state.sent();
|
|
2494
2497
|
console.error("[StormcloudVideoPlayer] Error sending initial tracking data:", error);
|
|
2495
2498
|
return [
|
|
2496
2499
|
3,
|
|
2497
|
-
|
|
2500
|
+
4
|
|
2498
2501
|
];
|
|
2499
|
-
case
|
|
2502
|
+
case 4:
|
|
2500
2503
|
return [
|
|
2501
2504
|
2
|
|
2502
2505
|
];
|
|
@@ -2600,53 +2603,48 @@ function sendAdImpressionTracking(_0, _1) {
|
|
|
2600
2603
|
switch(_state.label){
|
|
2601
2604
|
case 0:
|
|
2602
2605
|
context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2606
|
+
if (!canPublish(licenseKey)) return [
|
|
2607
|
+
2
|
|
2608
|
+
];
|
|
2603
2609
|
_state.label = 1;
|
|
2604
2610
|
case 1:
|
|
2605
2611
|
_state.trys.push([
|
|
2606
2612
|
1,
|
|
2607
|
-
|
|
2613
|
+
3,
|
|
2608
2614
|
,
|
|
2609
|
-
|
|
2615
|
+
4
|
|
2610
2616
|
]);
|
|
2611
2617
|
return [
|
|
2612
2618
|
4,
|
|
2613
|
-
buildPlayerMetricEvent(
|
|
2619
|
+
buildPlayerMetricEvent(context, {
|
|
2614
2620
|
captureAt: adImpressionInfo.timestamp
|
|
2615
2621
|
})
|
|
2616
2622
|
];
|
|
2617
2623
|
case 2:
|
|
2618
2624
|
metricEvent = _state.sent();
|
|
2619
|
-
|
|
2620
|
-
|
|
2621
|
-
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
|
|
2625
|
-
|
|
2626
|
-
|
|
2627
|
-
|
|
2628
|
-
|
|
2629
|
-
|
|
2630
|
-
capture_at: adImpressionInfo.timestamp
|
|
2631
|
-
}
|
|
2632
|
-
]
|
|
2633
|
-
})
|
|
2634
|
-
])
|
|
2635
|
-
];
|
|
2636
|
-
case 3:
|
|
2637
|
-
_state.sent();
|
|
2625
|
+
publishTracking(licenseKey, "heartbeat", metricEvent);
|
|
2626
|
+
publishTracking(licenseKey, "impressions", {
|
|
2627
|
+
events: [
|
|
2628
|
+
{
|
|
2629
|
+
player_id: metricEvent.player_id,
|
|
2630
|
+
ad_played_count: 1,
|
|
2631
|
+
ad_url: adImpressionInfo.adUrl,
|
|
2632
|
+
capture_at: adImpressionInfo.timestamp
|
|
2633
|
+
}
|
|
2634
|
+
]
|
|
2635
|
+
});
|
|
2638
2636
|
return [
|
|
2639
2637
|
3,
|
|
2640
|
-
|
|
2638
|
+
4
|
|
2641
2639
|
];
|
|
2642
|
-
case
|
|
2640
|
+
case 3:
|
|
2643
2641
|
error = _state.sent();
|
|
2644
2642
|
console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
|
|
2645
2643
|
return [
|
|
2646
2644
|
3,
|
|
2647
|
-
|
|
2645
|
+
4
|
|
2648
2646
|
];
|
|
2649
|
-
case
|
|
2647
|
+
case 4:
|
|
2650
2648
|
return [
|
|
2651
2649
|
2
|
|
2652
2650
|
];
|
|
@@ -2662,38 +2660,36 @@ function sendHeartbeat(_0) {
|
|
|
2662
2660
|
switch(_state.label){
|
|
2663
2661
|
case 0:
|
|
2664
2662
|
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2663
|
+
if (!canPublish(licenseKey)) return [
|
|
2664
|
+
2
|
|
2665
|
+
];
|
|
2665
2666
|
_state.label = 1;
|
|
2666
2667
|
case 1:
|
|
2667
2668
|
_state.trys.push([
|
|
2668
2669
|
1,
|
|
2669
|
-
|
|
2670
|
+
3,
|
|
2670
2671
|
,
|
|
2671
|
-
|
|
2672
|
+
4
|
|
2672
2673
|
]);
|
|
2673
2674
|
return [
|
|
2674
2675
|
4,
|
|
2675
|
-
buildPlayerMetricEvent(
|
|
2676
|
+
buildPlayerMetricEvent(context, flags)
|
|
2676
2677
|
];
|
|
2677
2678
|
case 2:
|
|
2678
2679
|
heartbeatData = _state.sent();
|
|
2679
|
-
|
|
2680
|
-
4,
|
|
2681
|
-
postJson(HEARTBEAT_URL, licenseKey, heartbeatData)
|
|
2682
|
-
];
|
|
2683
|
-
case 3:
|
|
2684
|
-
_state.sent();
|
|
2680
|
+
publishTracking(licenseKey, "heartbeat", heartbeatData);
|
|
2685
2681
|
return [
|
|
2686
2682
|
3,
|
|
2687
|
-
|
|
2683
|
+
4
|
|
2688
2684
|
];
|
|
2689
|
-
case
|
|
2685
|
+
case 3:
|
|
2690
2686
|
error = _state.sent();
|
|
2691
2687
|
console.error("[StormcloudVideoPlayer] Error sending heartbeat:", error);
|
|
2692
2688
|
return [
|
|
2693
2689
|
3,
|
|
2694
|
-
|
|
2690
|
+
4
|
|
2695
2691
|
];
|
|
2696
|
-
case
|
|
2692
|
+
case 4:
|
|
2697
2693
|
return [
|
|
2698
2694
|
2
|
|
2699
2695
|
];
|
|
@@ -4607,6 +4603,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4607
4603
|
key: "initializeTracking",
|
|
4608
4604
|
value: function initializeTracking() {
|
|
4609
4605
|
var _this = this;
|
|
4606
|
+
if (isMQTTEnabled()) {
|
|
4607
|
+
initMQTTClient();
|
|
4608
|
+
}
|
|
4610
4609
|
sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
|
|
4611
4610
|
_this.heartbeatInterval = window.setInterval(function() {
|
|
4612
4611
|
_this.sendHeartbeatIfNeeded();
|
|
@@ -6286,6 +6285,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6286
6285
|
clearInterval(this.heartbeatInterval);
|
|
6287
6286
|
this.heartbeatInterval = void 0;
|
|
6288
6287
|
}
|
|
6288
|
+
if (isMQTTEnabled()) {
|
|
6289
|
+
disconnectMQTT();
|
|
6290
|
+
}
|
|
6289
6291
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
6290
6292
|
(_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
|
|
6291
6293
|
this.consecutiveFailures = 0;
|