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
|
@@ -2046,6 +2046,106 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
2046
2046
|
}
|
|
2047
2047
|
};
|
|
2048
2048
|
}
|
|
2049
|
+
// src/utils/mqttConfig.ts
|
|
2050
|
+
var DEFAULT_MQTT_CONFIG = {
|
|
2051
|
+
enabled: true,
|
|
2052
|
+
brokerAddress: "vecbae77.ala.us-east-1.emqxsl.com",
|
|
2053
|
+
brokerPort: 8883,
|
|
2054
|
+
wsPort: 8084,
|
|
2055
|
+
username: "for-sonifi",
|
|
2056
|
+
password: "sonifi-mqtt",
|
|
2057
|
+
topicPrefix: "adstorm/players",
|
|
2058
|
+
qos: 1
|
|
2059
|
+
};
|
|
2060
|
+
var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
|
|
2061
|
+
function isMQTTEnabled() {
|
|
2062
|
+
return mqttConfig.enabled;
|
|
2063
|
+
}
|
|
2064
|
+
function buildMQTTBrokerUrl() {
|
|
2065
|
+
if (mqttConfig.brokerUrl) return mqttConfig.brokerUrl;
|
|
2066
|
+
return "wss://".concat(mqttConfig.brokerAddress, ":").concat(mqttConfig.wsPort, "/mqtt");
|
|
2067
|
+
}
|
|
2068
|
+
function buildPlayerTopic(licenseKey, channel) {
|
|
2069
|
+
return "".concat(mqttConfig.topicPrefix, "/").concat(licenseKey, "/").concat(channel);
|
|
2070
|
+
}
|
|
2071
|
+
// src/utils/mqttClient.ts
|
|
2072
|
+
var import_mqtt = __toESM(require("mqtt"), 1);
|
|
2073
|
+
var LOG2 = "[StormcloudVideoPlayer][MQTT]";
|
|
2074
|
+
var client = null;
|
|
2075
|
+
var status = "disconnected";
|
|
2076
|
+
function initMQTTClient() {
|
|
2077
|
+
if (client || !isMQTTEnabled()) return;
|
|
2078
|
+
var url = buildMQTTBrokerUrl();
|
|
2079
|
+
status = "connecting";
|
|
2080
|
+
var clientId = "stormcloud-vp-".concat(Math.random().toString(36).slice(2, 9));
|
|
2081
|
+
try {
|
|
2082
|
+
client = import_mqtt.default.connect(url, {
|
|
2083
|
+
clientId: clientId,
|
|
2084
|
+
username: mqttConfig.username,
|
|
2085
|
+
password: mqttConfig.password,
|
|
2086
|
+
keepalive: 60,
|
|
2087
|
+
clean: true,
|
|
2088
|
+
reconnectPeriod: 5e3,
|
|
2089
|
+
connectTimeout: 1e4,
|
|
2090
|
+
queueQoSZero: false
|
|
2091
|
+
});
|
|
2092
|
+
} catch (err) {
|
|
2093
|
+
status = "error";
|
|
2094
|
+
console.warn("".concat(LOG2, " connect() threw:"), err);
|
|
2095
|
+
return;
|
|
2096
|
+
}
|
|
2097
|
+
client.on("connect", function() {
|
|
2098
|
+
status = "connected";
|
|
2099
|
+
console.info("".concat(LOG2, " connected to ").concat(url));
|
|
2100
|
+
});
|
|
2101
|
+
client.on("reconnect", function() {
|
|
2102
|
+
status = "connecting";
|
|
2103
|
+
console.info("".concat(LOG2, " reconnecting…"));
|
|
2104
|
+
});
|
|
2105
|
+
client.on("offline", function() {
|
|
2106
|
+
status = "disconnected";
|
|
2107
|
+
console.warn("".concat(LOG2, " offline"));
|
|
2108
|
+
});
|
|
2109
|
+
client.on("error", function(err) {
|
|
2110
|
+
status = "error";
|
|
2111
|
+
console.warn("".concat(LOG2, " error:"), err.message);
|
|
2112
|
+
});
|
|
2113
|
+
client.on("close", function() {
|
|
2114
|
+
if (status === "connected") {
|
|
2115
|
+
status = "disconnected";
|
|
2116
|
+
}
|
|
2117
|
+
});
|
|
2118
|
+
}
|
|
2119
|
+
function ensureMQTTClient() {
|
|
2120
|
+
if (isMQTTEnabled() && !client) {
|
|
2121
|
+
initMQTTClient();
|
|
2122
|
+
}
|
|
2123
|
+
}
|
|
2124
|
+
function publishMQTT(topic, payload) {
|
|
2125
|
+
if (!isMQTTEnabled()) {
|
|
2126
|
+
return false;
|
|
2127
|
+
}
|
|
2128
|
+
ensureMQTTClient();
|
|
2129
|
+
if (!client) {
|
|
2130
|
+
return false;
|
|
2131
|
+
}
|
|
2132
|
+
try {
|
|
2133
|
+
client.publish(topic, JSON.stringify(payload), {
|
|
2134
|
+
qos: mqttConfig.qos
|
|
2135
|
+
});
|
|
2136
|
+
return true;
|
|
2137
|
+
} catch (err) {
|
|
2138
|
+
console.warn("".concat(LOG2, " publish failed on ").concat(topic, ":"), err);
|
|
2139
|
+
return false;
|
|
2140
|
+
}
|
|
2141
|
+
}
|
|
2142
|
+
function disconnectMQTT() {
|
|
2143
|
+
if (client) {
|
|
2144
|
+
client.end(true);
|
|
2145
|
+
client = null;
|
|
2146
|
+
status = "disconnected";
|
|
2147
|
+
}
|
|
2148
|
+
}
|
|
2049
2149
|
// src/utils/tracking.ts
|
|
2050
2150
|
var cachedBrowserId = null;
|
|
2051
2151
|
function getClientInfo() {
|
|
@@ -2077,8 +2177,8 @@ function getClientInfo() {
|
|
|
2077
2177
|
os = "webOS";
|
|
2078
2178
|
isSmartTV = true;
|
|
2079
2179
|
deviceType = "tv";
|
|
2080
|
-
var
|
|
2081
|
-
model =
|
|
2180
|
+
var m = ua.match(/Web0S\/([^\s]+)/);
|
|
2181
|
+
model = m ? "webOS ".concat(m[1]) : "webOS TV";
|
|
2082
2182
|
} else if (ua.includes("Tizen")) {
|
|
2083
2183
|
brand = "Samsung";
|
|
2084
2184
|
os = "Tizen";
|
|
@@ -2122,23 +2222,19 @@ function getClientInfo() {
|
|
|
2122
2222
|
isAndroid = true;
|
|
2123
2223
|
os = "Android";
|
|
2124
2224
|
deviceType = /Mobile/.test(ua) ? "mobile" : "tablet";
|
|
2125
|
-
if (
|
|
2225
|
+
if (maxTouchPoints === 0 || ua.includes("Google TV") || ua.includes("XiaoMi")) {
|
|
2126
2226
|
deviceType = "tv";
|
|
2127
2227
|
isSmartTV = true;
|
|
2128
2228
|
brand = brand === "Unknown" ? "Android TV" : brand;
|
|
2129
2229
|
}
|
|
2130
2230
|
var androidModelMatch = ua.match(/\(([^)]*Android[^)]*)\)/);
|
|
2131
|
-
if (androidModelMatch
|
|
2132
|
-
model = androidModelMatch[1];
|
|
2133
|
-
}
|
|
2231
|
+
if (androidModelMatch === null || androidModelMatch === void 0 ? void 0 : androidModelMatch[1]) model = androidModelMatch[1];
|
|
2134
2232
|
}
|
|
2135
2233
|
if (/iPad|iPhone|iPod/.test(ua)) {
|
|
2136
2234
|
os = "iOS";
|
|
2137
2235
|
deviceType = "mobile";
|
|
2138
2236
|
brand = "Apple";
|
|
2139
|
-
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua))
|
|
2140
|
-
deviceType = "tablet";
|
|
2141
|
-
}
|
|
2237
|
+
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua)) deviceType = "tablet";
|
|
2142
2238
|
}
|
|
2143
2239
|
if (!isAndroid && !isSmartTV && !/Mobile/.test(ua)) {
|
|
2144
2240
|
if (ua.includes("Windows")) {
|
|
@@ -2159,9 +2255,7 @@ function getClientInfo() {
|
|
|
2159
2255
|
if (vendor.includes("Samsung") || ua.includes("SM-")) brand = "Samsung";
|
|
2160
2256
|
}
|
|
2161
2257
|
isWebView = /wv|WebView|Linux; U;/.test(ua);
|
|
2162
|
-
if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0)
|
|
2163
|
-
isWebView = true;
|
|
2164
|
-
}
|
|
2258
|
+
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;
|
|
2165
2259
|
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;
|
|
2166
2260
|
return {
|
|
2167
2261
|
brand: brand,
|
|
@@ -2192,18 +2286,16 @@ function getClientInfo() {
|
|
|
2192
2286
|
}
|
|
2193
2287
|
function getBrowserID(clientInfo) {
|
|
2194
2288
|
return _async_to_generator(function() {
|
|
2195
|
-
var fingerprintString, encodedData, utf8, buffer, i, hashBuffer,
|
|
2289
|
+
var _crypto_subtle, fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashHex, unused, hash, i1, char, fallbackHash, timestamp, random;
|
|
2196
2290
|
return _ts_generator(this, function(_state) {
|
|
2197
2291
|
switch(_state.label){
|
|
2198
2292
|
case 0:
|
|
2199
|
-
if (cachedBrowserId)
|
|
2200
|
-
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
];
|
|
2204
|
-
}
|
|
2293
|
+
if (cachedBrowserId) return [
|
|
2294
|
+
2,
|
|
2295
|
+
cachedBrowserId
|
|
2296
|
+
];
|
|
2205
2297
|
fingerprintString = JSON.stringify(clientInfo);
|
|
2206
|
-
if (!(typeof crypto !== "undefined" && crypto.subtle
|
|
2298
|
+
if (!(typeof crypto !== "undefined" && ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest))) return [
|
|
2207
2299
|
3,
|
|
2208
2300
|
5
|
|
2209
2301
|
];
|
|
@@ -2230,9 +2322,7 @@ function getBrowserID(clientInfo) {
|
|
|
2230
2322
|
} else {
|
|
2231
2323
|
utf8 = unescape(encodeURIComponent(fingerprintString));
|
|
2232
2324
|
buffer = new Uint8Array(utf8.length);
|
|
2233
|
-
for(i = 0; i < utf8.length; i++)
|
|
2234
|
-
buffer[i] = utf8.charCodeAt(i);
|
|
2235
|
-
}
|
|
2325
|
+
for(i = 0; i < utf8.length; i++)buffer[i] = utf8.charCodeAt(i);
|
|
2236
2326
|
encodedData = buffer;
|
|
2237
2327
|
}
|
|
2238
2328
|
return [
|
|
@@ -2241,8 +2331,7 @@ function getBrowserID(clientInfo) {
|
|
|
2241
2331
|
];
|
|
2242
2332
|
case 3:
|
|
2243
2333
|
hashBuffer = _state.sent();
|
|
2244
|
-
|
|
2245
|
-
hashHex = hashArray.map(function(b) {
|
|
2334
|
+
hashHex = Array.from(new Uint8Array(hashBuffer)).map(function(b) {
|
|
2246
2335
|
return b.toString(16).padStart(2, "0");
|
|
2247
2336
|
}).join("");
|
|
2248
2337
|
cachedBrowserId = hashHex;
|
|
@@ -2251,8 +2340,8 @@ function getBrowserID(clientInfo) {
|
|
|
2251
2340
|
hashHex
|
|
2252
2341
|
];
|
|
2253
2342
|
case 4:
|
|
2254
|
-
|
|
2255
|
-
console.warn("[StormcloudVideoPlayer] crypto.subtle
|
|
2343
|
+
unused = _state.sent();
|
|
2344
|
+
console.warn("[StormcloudVideoPlayer] crypto.subtle not supported, using fallback hash");
|
|
2256
2345
|
return [
|
|
2257
2346
|
3,
|
|
2258
2347
|
5
|
|
@@ -2276,177 +2365,91 @@ function getBrowserID(clientInfo) {
|
|
|
2276
2365
|
});
|
|
2277
2366
|
})();
|
|
2278
2367
|
}
|
|
2279
|
-
|
|
2280
|
-
|
|
2281
|
-
var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
|
|
2282
|
-
var IMPRESSIONS_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/impressions/ingest");
|
|
2283
|
-
function buildHeaders(licenseKey) {
|
|
2284
|
-
var headers = {
|
|
2285
|
-
"Content-Type": "application/json"
|
|
2286
|
-
};
|
|
2287
|
-
if (licenseKey) {
|
|
2288
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2289
|
-
}
|
|
2290
|
-
return headers;
|
|
2291
|
-
}
|
|
2292
|
-
function sendTrackRequest(licenseKey, body) {
|
|
2293
|
-
return _async_to_generator(function() {
|
|
2294
|
-
var response;
|
|
2295
|
-
return _ts_generator(this, function(_state) {
|
|
2296
|
-
switch(_state.label){
|
|
2297
|
-
case 0:
|
|
2298
|
-
return [
|
|
2299
|
-
4,
|
|
2300
|
-
fetch(TRACK_URL, {
|
|
2301
|
-
method: "POST",
|
|
2302
|
-
headers: buildHeaders(licenseKey),
|
|
2303
|
-
body: JSON.stringify(body)
|
|
2304
|
-
})
|
|
2305
|
-
];
|
|
2306
|
-
case 1:
|
|
2307
|
-
response = _state.sent();
|
|
2308
|
-
if (!response.ok) {
|
|
2309
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2310
|
-
}
|
|
2311
|
-
return [
|
|
2312
|
-
4,
|
|
2313
|
-
response.json()
|
|
2314
|
-
];
|
|
2315
|
-
case 2:
|
|
2316
|
-
_state.sent();
|
|
2317
|
-
return [
|
|
2318
|
-
2
|
|
2319
|
-
];
|
|
2320
|
-
}
|
|
2321
|
-
});
|
|
2322
|
-
})();
|
|
2368
|
+
function canPublish(licenseKey) {
|
|
2369
|
+
return Boolean(isMQTTEnabled() && licenseKey);
|
|
2323
2370
|
}
|
|
2324
|
-
function
|
|
2371
|
+
function buildPlayerMetricEvent() {
|
|
2325
2372
|
return _async_to_generator(function() {
|
|
2326
|
-
var
|
|
2327
|
-
return _ts_generator(this, function(_state) {
|
|
2328
|
-
switch(_state.label){
|
|
2329
|
-
case 0:
|
|
2330
|
-
return [
|
|
2331
|
-
4,
|
|
2332
|
-
fetch(url, {
|
|
2333
|
-
method: "POST",
|
|
2334
|
-
headers: buildHeaders(licenseKey),
|
|
2335
|
-
body: JSON.stringify(body)
|
|
2336
|
-
})
|
|
2337
|
-
];
|
|
2338
|
-
case 1:
|
|
2339
|
-
response = _state.sent();
|
|
2340
|
-
if (!response.ok) {
|
|
2341
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2342
|
-
}
|
|
2343
|
-
return [
|
|
2344
|
-
4,
|
|
2345
|
-
response.json()
|
|
2346
|
-
];
|
|
2347
|
-
case 2:
|
|
2348
|
-
_state.sent();
|
|
2349
|
-
return [
|
|
2350
|
-
2
|
|
2351
|
-
];
|
|
2352
|
-
}
|
|
2353
|
-
});
|
|
2354
|
-
})();
|
|
2355
|
-
}
|
|
2356
|
-
function buildPlayerMetricEvent(_0) {
|
|
2357
|
-
return _async_to_generator(function(licenseKey) {
|
|
2358
|
-
var context, flags, _flags_captureAt, clientInfo, browserId, captureAt;
|
|
2373
|
+
var context, flags, _flags_captureAt, _flags_adLoaded, _flags_adDetect, clientInfo, playerId, captureAt;
|
|
2359
2374
|
var _arguments = arguments;
|
|
2360
2375
|
return _ts_generator(this, function(_state) {
|
|
2361
2376
|
switch(_state.label){
|
|
2362
2377
|
case 0:
|
|
2363
|
-
context = _arguments.length >
|
|
2378
|
+
context = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {}, flags = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2364
2379
|
clientInfo = getClientInfo();
|
|
2365
2380
|
return [
|
|
2366
2381
|
4,
|
|
2367
2382
|
getBrowserID(clientInfo)
|
|
2368
2383
|
];
|
|
2369
2384
|
case 1:
|
|
2370
|
-
|
|
2385
|
+
playerId = _state.sent();
|
|
2371
2386
|
captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
|
|
2372
2387
|
return [
|
|
2373
2388
|
2,
|
|
2374
|
-
{
|
|
2375
|
-
player_id:
|
|
2376
|
-
browserId: browserId,
|
|
2389
|
+
_object_spread({
|
|
2390
|
+
player_id: playerId,
|
|
2377
2391
|
device_type: clientInfo.deviceType,
|
|
2378
|
-
|
|
2379
|
-
|
|
2380
|
-
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
timestamp: captureAt
|
|
2386
|
-
}
|
|
2392
|
+
os: clientInfo.os.toLowerCase(),
|
|
2393
|
+
ad_loaded: (_flags_adLoaded = flags.adLoaded) !== null && _flags_adLoaded !== void 0 ? _flags_adLoaded : false,
|
|
2394
|
+
ad_detect: (_flags_adDetect = flags.adDetect) !== null && _flags_adDetect !== void 0 ? _flags_adDetect : false,
|
|
2395
|
+
capture_at: captureAt
|
|
2396
|
+
}, context.inputStreamType ? {
|
|
2397
|
+
input_stream_type: context.inputStreamType
|
|
2398
|
+
} : {})
|
|
2387
2399
|
];
|
|
2388
2400
|
}
|
|
2389
2401
|
});
|
|
2390
2402
|
}).apply(this, arguments);
|
|
2391
2403
|
}
|
|
2404
|
+
function publishTracking(licenseKey, channel, body) {
|
|
2405
|
+
ensureMQTTClient();
|
|
2406
|
+
publishMQTT(buildPlayerTopic(licenseKey, channel), body);
|
|
2407
|
+
}
|
|
2392
2408
|
function sendInitialTracking(_0) {
|
|
2393
2409
|
return _async_to_generator(function(licenseKey) {
|
|
2394
|
-
var context,
|
|
2410
|
+
var context, metricEvent, error;
|
|
2395
2411
|
var _arguments = arguments;
|
|
2396
2412
|
return _ts_generator(this, function(_state) {
|
|
2397
2413
|
switch(_state.label){
|
|
2398
2414
|
case 0:
|
|
2399
2415
|
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2416
|
+
if (!canPublish(licenseKey)) return [
|
|
2417
|
+
2
|
|
2418
|
+
];
|
|
2400
2419
|
_state.label = 1;
|
|
2401
2420
|
case 1:
|
|
2402
2421
|
_state.trys.push([
|
|
2403
2422
|
1,
|
|
2404
|
-
|
|
2423
|
+
3,
|
|
2405
2424
|
,
|
|
2406
|
-
|
|
2425
|
+
4
|
|
2407
2426
|
]);
|
|
2408
|
-
clientInfo = getClientInfo();
|
|
2409
2427
|
return [
|
|
2410
2428
|
4,
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
browserId = _state.sent();
|
|
2415
|
-
trackingData = _object_spread({
|
|
2416
|
-
browserId: browserId
|
|
2417
|
-
}, clientInfo);
|
|
2418
|
-
return [
|
|
2419
|
-
4,
|
|
2420
|
-
sendTrackRequest(licenseKey, {
|
|
2421
|
-
events: [
|
|
2422
|
-
{
|
|
2423
|
-
player_id: browserId,
|
|
2424
|
-
device_type: clientInfo.deviceType,
|
|
2425
|
-
input_stream_type: context.inputStreamType,
|
|
2426
|
-
os: clientInfo.os,
|
|
2427
|
-
ad_loaded: false,
|
|
2428
|
-
ad_detect: false,
|
|
2429
|
-
license_key: licenseKey,
|
|
2430
|
-
capture_at: /* @__PURE__ */ new Date().toISOString()
|
|
2431
|
-
}
|
|
2432
|
-
],
|
|
2433
|
-
trackingData: trackingData
|
|
2429
|
+
buildPlayerMetricEvent(context, {
|
|
2430
|
+
adLoaded: false,
|
|
2431
|
+
adDetect: false
|
|
2434
2432
|
})
|
|
2435
2433
|
];
|
|
2436
|
-
case
|
|
2437
|
-
_state.sent();
|
|
2434
|
+
case 2:
|
|
2435
|
+
metricEvent = _state.sent();
|
|
2436
|
+
publishTracking(licenseKey, "metrics", {
|
|
2437
|
+
events: [
|
|
2438
|
+
metricEvent
|
|
2439
|
+
]
|
|
2440
|
+
});
|
|
2438
2441
|
return [
|
|
2439
2442
|
3,
|
|
2440
|
-
|
|
2443
|
+
4
|
|
2441
2444
|
];
|
|
2442
|
-
case
|
|
2445
|
+
case 3:
|
|
2443
2446
|
error = _state.sent();
|
|
2444
2447
|
console.error("[StormcloudVideoPlayer] Error sending initial tracking data:", error);
|
|
2445
2448
|
return [
|
|
2446
2449
|
3,
|
|
2447
|
-
|
|
2450
|
+
4
|
|
2448
2451
|
];
|
|
2449
|
-
case
|
|
2452
|
+
case 4:
|
|
2450
2453
|
return [
|
|
2451
2454
|
2
|
|
2452
2455
|
];
|
|
@@ -2550,53 +2553,48 @@ function sendAdImpressionTracking(_0, _1) {
|
|
|
2550
2553
|
switch(_state.label){
|
|
2551
2554
|
case 0:
|
|
2552
2555
|
context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2556
|
+
if (!canPublish(licenseKey)) return [
|
|
2557
|
+
2
|
|
2558
|
+
];
|
|
2553
2559
|
_state.label = 1;
|
|
2554
2560
|
case 1:
|
|
2555
2561
|
_state.trys.push([
|
|
2556
2562
|
1,
|
|
2557
|
-
|
|
2563
|
+
3,
|
|
2558
2564
|
,
|
|
2559
|
-
|
|
2565
|
+
4
|
|
2560
2566
|
]);
|
|
2561
2567
|
return [
|
|
2562
2568
|
4,
|
|
2563
|
-
buildPlayerMetricEvent(
|
|
2569
|
+
buildPlayerMetricEvent(context, {
|
|
2564
2570
|
captureAt: adImpressionInfo.timestamp
|
|
2565
2571
|
})
|
|
2566
2572
|
];
|
|
2567
2573
|
case 2:
|
|
2568
2574
|
metricEvent = _state.sent();
|
|
2569
|
-
|
|
2570
|
-
|
|
2571
|
-
|
|
2572
|
-
|
|
2573
|
-
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
|
|
2580
|
-
capture_at: adImpressionInfo.timestamp
|
|
2581
|
-
}
|
|
2582
|
-
]
|
|
2583
|
-
})
|
|
2584
|
-
])
|
|
2585
|
-
];
|
|
2586
|
-
case 3:
|
|
2587
|
-
_state.sent();
|
|
2575
|
+
publishTracking(licenseKey, "heartbeat", metricEvent);
|
|
2576
|
+
publishTracking(licenseKey, "impressions", {
|
|
2577
|
+
events: [
|
|
2578
|
+
{
|
|
2579
|
+
player_id: metricEvent.player_id,
|
|
2580
|
+
ad_played_count: 1,
|
|
2581
|
+
ad_url: adImpressionInfo.adUrl,
|
|
2582
|
+
capture_at: adImpressionInfo.timestamp
|
|
2583
|
+
}
|
|
2584
|
+
]
|
|
2585
|
+
});
|
|
2588
2586
|
return [
|
|
2589
2587
|
3,
|
|
2590
|
-
|
|
2588
|
+
4
|
|
2591
2589
|
];
|
|
2592
|
-
case
|
|
2590
|
+
case 3:
|
|
2593
2591
|
error = _state.sent();
|
|
2594
2592
|
console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
|
|
2595
2593
|
return [
|
|
2596
2594
|
3,
|
|
2597
|
-
|
|
2595
|
+
4
|
|
2598
2596
|
];
|
|
2599
|
-
case
|
|
2597
|
+
case 4:
|
|
2600
2598
|
return [
|
|
2601
2599
|
2
|
|
2602
2600
|
];
|
|
@@ -2612,38 +2610,36 @@ function sendHeartbeat(_0) {
|
|
|
2612
2610
|
switch(_state.label){
|
|
2613
2611
|
case 0:
|
|
2614
2612
|
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2613
|
+
if (!canPublish(licenseKey)) return [
|
|
2614
|
+
2
|
|
2615
|
+
];
|
|
2615
2616
|
_state.label = 1;
|
|
2616
2617
|
case 1:
|
|
2617
2618
|
_state.trys.push([
|
|
2618
2619
|
1,
|
|
2619
|
-
|
|
2620
|
+
3,
|
|
2620
2621
|
,
|
|
2621
|
-
|
|
2622
|
+
4
|
|
2622
2623
|
]);
|
|
2623
2624
|
return [
|
|
2624
2625
|
4,
|
|
2625
|
-
buildPlayerMetricEvent(
|
|
2626
|
+
buildPlayerMetricEvent(context, flags)
|
|
2626
2627
|
];
|
|
2627
2628
|
case 2:
|
|
2628
2629
|
heartbeatData = _state.sent();
|
|
2629
|
-
|
|
2630
|
-
4,
|
|
2631
|
-
postJson(HEARTBEAT_URL, licenseKey, heartbeatData)
|
|
2632
|
-
];
|
|
2633
|
-
case 3:
|
|
2634
|
-
_state.sent();
|
|
2630
|
+
publishTracking(licenseKey, "heartbeat", heartbeatData);
|
|
2635
2631
|
return [
|
|
2636
2632
|
3,
|
|
2637
|
-
|
|
2633
|
+
4
|
|
2638
2634
|
];
|
|
2639
|
-
case
|
|
2635
|
+
case 3:
|
|
2640
2636
|
error = _state.sent();
|
|
2641
2637
|
console.error("[StormcloudVideoPlayer] Error sending heartbeat:", error);
|
|
2642
2638
|
return [
|
|
2643
2639
|
3,
|
|
2644
|
-
|
|
2640
|
+
4
|
|
2645
2641
|
];
|
|
2646
|
-
case
|
|
2642
|
+
case 4:
|
|
2647
2643
|
return [
|
|
2648
2644
|
2
|
|
2649
2645
|
];
|
|
@@ -4557,6 +4553,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4557
4553
|
key: "initializeTracking",
|
|
4558
4554
|
value: function initializeTracking() {
|
|
4559
4555
|
var _this = this;
|
|
4556
|
+
if (isMQTTEnabled()) {
|
|
4557
|
+
initMQTTClient();
|
|
4558
|
+
}
|
|
4560
4559
|
sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
|
|
4561
4560
|
_this.heartbeatInterval = window.setInterval(function() {
|
|
4562
4561
|
_this.sendHeartbeatIfNeeded();
|
|
@@ -6236,6 +6235,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6236
6235
|
clearInterval(this.heartbeatInterval);
|
|
6237
6236
|
this.heartbeatInterval = void 0;
|
|
6238
6237
|
}
|
|
6238
|
+
if (isMQTTEnabled()) {
|
|
6239
|
+
disconnectMQTT();
|
|
6240
|
+
}
|
|
6239
6241
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
6240
6242
|
(_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
|
|
6241
6243
|
this.consecutiveFailures = 0;
|