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
|
@@ -2008,6 +2008,106 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
2008
2008
|
}
|
|
2009
2009
|
};
|
|
2010
2010
|
}
|
|
2011
|
+
// src/utils/mqttConfig.ts
|
|
2012
|
+
var DEFAULT_MQTT_CONFIG = {
|
|
2013
|
+
enabled: true,
|
|
2014
|
+
brokerAddress: "vecbae77.ala.us-east-1.emqxsl.com",
|
|
2015
|
+
brokerPort: 8883,
|
|
2016
|
+
wsPort: 8084,
|
|
2017
|
+
username: "for-sonifi",
|
|
2018
|
+
password: "sonifi-mqtt",
|
|
2019
|
+
topicPrefix: "adstorm/players",
|
|
2020
|
+
qos: 1
|
|
2021
|
+
};
|
|
2022
|
+
var mqttConfig = _object_spread({}, DEFAULT_MQTT_CONFIG);
|
|
2023
|
+
function isMQTTEnabled() {
|
|
2024
|
+
return mqttConfig.enabled;
|
|
2025
|
+
}
|
|
2026
|
+
function buildMQTTBrokerUrl() {
|
|
2027
|
+
if (mqttConfig.brokerUrl) return mqttConfig.brokerUrl;
|
|
2028
|
+
return "wss://".concat(mqttConfig.brokerAddress, ":").concat(mqttConfig.wsPort, "/mqtt");
|
|
2029
|
+
}
|
|
2030
|
+
function buildPlayerTopic(licenseKey, channel) {
|
|
2031
|
+
return "".concat(mqttConfig.topicPrefix, "/").concat(licenseKey, "/").concat(channel);
|
|
2032
|
+
}
|
|
2033
|
+
// src/utils/mqttClient.ts
|
|
2034
|
+
var import_mqtt = __toESM(require("mqtt"), 1);
|
|
2035
|
+
var LOG2 = "[StormcloudVideoPlayer][MQTT]";
|
|
2036
|
+
var client = null;
|
|
2037
|
+
var status = "disconnected";
|
|
2038
|
+
function initMQTTClient() {
|
|
2039
|
+
if (client || !isMQTTEnabled()) return;
|
|
2040
|
+
var url = buildMQTTBrokerUrl();
|
|
2041
|
+
status = "connecting";
|
|
2042
|
+
var clientId = "stormcloud-vp-".concat(Math.random().toString(36).slice(2, 9));
|
|
2043
|
+
try {
|
|
2044
|
+
client = import_mqtt.default.connect(url, {
|
|
2045
|
+
clientId: clientId,
|
|
2046
|
+
username: mqttConfig.username,
|
|
2047
|
+
password: mqttConfig.password,
|
|
2048
|
+
keepalive: 60,
|
|
2049
|
+
clean: true,
|
|
2050
|
+
reconnectPeriod: 5e3,
|
|
2051
|
+
connectTimeout: 1e4,
|
|
2052
|
+
queueQoSZero: false
|
|
2053
|
+
});
|
|
2054
|
+
} catch (err) {
|
|
2055
|
+
status = "error";
|
|
2056
|
+
console.warn("".concat(LOG2, " connect() threw:"), err);
|
|
2057
|
+
return;
|
|
2058
|
+
}
|
|
2059
|
+
client.on("connect", function() {
|
|
2060
|
+
status = "connected";
|
|
2061
|
+
console.info("".concat(LOG2, " connected to ").concat(url));
|
|
2062
|
+
});
|
|
2063
|
+
client.on("reconnect", function() {
|
|
2064
|
+
status = "connecting";
|
|
2065
|
+
console.info("".concat(LOG2, " reconnecting…"));
|
|
2066
|
+
});
|
|
2067
|
+
client.on("offline", function() {
|
|
2068
|
+
status = "disconnected";
|
|
2069
|
+
console.warn("".concat(LOG2, " offline"));
|
|
2070
|
+
});
|
|
2071
|
+
client.on("error", function(err) {
|
|
2072
|
+
status = "error";
|
|
2073
|
+
console.warn("".concat(LOG2, " error:"), err.message);
|
|
2074
|
+
});
|
|
2075
|
+
client.on("close", function() {
|
|
2076
|
+
if (status === "connected") {
|
|
2077
|
+
status = "disconnected";
|
|
2078
|
+
}
|
|
2079
|
+
});
|
|
2080
|
+
}
|
|
2081
|
+
function ensureMQTTClient() {
|
|
2082
|
+
if (isMQTTEnabled() && !client) {
|
|
2083
|
+
initMQTTClient();
|
|
2084
|
+
}
|
|
2085
|
+
}
|
|
2086
|
+
function publishMQTT(topic, payload) {
|
|
2087
|
+
if (!isMQTTEnabled()) {
|
|
2088
|
+
return false;
|
|
2089
|
+
}
|
|
2090
|
+
ensureMQTTClient();
|
|
2091
|
+
if (!client) {
|
|
2092
|
+
return false;
|
|
2093
|
+
}
|
|
2094
|
+
try {
|
|
2095
|
+
client.publish(topic, JSON.stringify(payload), {
|
|
2096
|
+
qos: mqttConfig.qos
|
|
2097
|
+
});
|
|
2098
|
+
return true;
|
|
2099
|
+
} catch (err) {
|
|
2100
|
+
console.warn("".concat(LOG2, " publish failed on ").concat(topic, ":"), err);
|
|
2101
|
+
return false;
|
|
2102
|
+
}
|
|
2103
|
+
}
|
|
2104
|
+
function disconnectMQTT() {
|
|
2105
|
+
if (client) {
|
|
2106
|
+
client.end(true);
|
|
2107
|
+
client = null;
|
|
2108
|
+
status = "disconnected";
|
|
2109
|
+
}
|
|
2110
|
+
}
|
|
2011
2111
|
// src/utils/tracking.ts
|
|
2012
2112
|
var cachedBrowserId = null;
|
|
2013
2113
|
function getClientInfo() {
|
|
@@ -2039,8 +2139,8 @@ function getClientInfo() {
|
|
|
2039
2139
|
os = "webOS";
|
|
2040
2140
|
isSmartTV = true;
|
|
2041
2141
|
deviceType = "tv";
|
|
2042
|
-
var
|
|
2043
|
-
model =
|
|
2142
|
+
var m = ua.match(/Web0S\/([^\s]+)/);
|
|
2143
|
+
model = m ? "webOS ".concat(m[1]) : "webOS TV";
|
|
2044
2144
|
} else if (ua.includes("Tizen")) {
|
|
2045
2145
|
brand = "Samsung";
|
|
2046
2146
|
os = "Tizen";
|
|
@@ -2084,23 +2184,19 @@ function getClientInfo() {
|
|
|
2084
2184
|
isAndroid = true;
|
|
2085
2185
|
os = "Android";
|
|
2086
2186
|
deviceType = /Mobile/.test(ua) ? "mobile" : "tablet";
|
|
2087
|
-
if (
|
|
2187
|
+
if (maxTouchPoints === 0 || ua.includes("Google TV") || ua.includes("XiaoMi")) {
|
|
2088
2188
|
deviceType = "tv";
|
|
2089
2189
|
isSmartTV = true;
|
|
2090
2190
|
brand = brand === "Unknown" ? "Android TV" : brand;
|
|
2091
2191
|
}
|
|
2092
2192
|
var androidModelMatch = ua.match(/\(([^)]*Android[^)]*)\)/);
|
|
2093
|
-
if (androidModelMatch
|
|
2094
|
-
model = androidModelMatch[1];
|
|
2095
|
-
}
|
|
2193
|
+
if (androidModelMatch === null || androidModelMatch === void 0 ? void 0 : androidModelMatch[1]) model = androidModelMatch[1];
|
|
2096
2194
|
}
|
|
2097
2195
|
if (/iPad|iPhone|iPod/.test(ua)) {
|
|
2098
2196
|
os = "iOS";
|
|
2099
2197
|
deviceType = "mobile";
|
|
2100
2198
|
brand = "Apple";
|
|
2101
|
-
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua))
|
|
2102
|
-
deviceType = "tablet";
|
|
2103
|
-
}
|
|
2199
|
+
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua)) deviceType = "tablet";
|
|
2104
2200
|
}
|
|
2105
2201
|
if (!isAndroid && !isSmartTV && !/Mobile/.test(ua)) {
|
|
2106
2202
|
if (ua.includes("Windows")) {
|
|
@@ -2121,9 +2217,7 @@ function getClientInfo() {
|
|
|
2121
2217
|
if (vendor.includes("Samsung") || ua.includes("SM-")) brand = "Samsung";
|
|
2122
2218
|
}
|
|
2123
2219
|
isWebView = /wv|WebView|Linux; U;/.test(ua);
|
|
2124
|
-
if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0)
|
|
2125
|
-
isWebView = true;
|
|
2126
|
-
}
|
|
2220
|
+
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;
|
|
2127
2221
|
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;
|
|
2128
2222
|
return {
|
|
2129
2223
|
brand: brand,
|
|
@@ -2154,18 +2248,16 @@ function getClientInfo() {
|
|
|
2154
2248
|
}
|
|
2155
2249
|
function getBrowserID(clientInfo) {
|
|
2156
2250
|
return _async_to_generator(function() {
|
|
2157
|
-
var fingerprintString, encodedData, utf8, buffer, i, hashBuffer,
|
|
2251
|
+
var _crypto_subtle, fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashHex, unused, hash, i1, char, fallbackHash, timestamp, random;
|
|
2158
2252
|
return _ts_generator(this, function(_state) {
|
|
2159
2253
|
switch(_state.label){
|
|
2160
2254
|
case 0:
|
|
2161
|
-
if (cachedBrowserId)
|
|
2162
|
-
|
|
2163
|
-
|
|
2164
|
-
|
|
2165
|
-
];
|
|
2166
|
-
}
|
|
2255
|
+
if (cachedBrowserId) return [
|
|
2256
|
+
2,
|
|
2257
|
+
cachedBrowserId
|
|
2258
|
+
];
|
|
2167
2259
|
fingerprintString = JSON.stringify(clientInfo);
|
|
2168
|
-
if (!(typeof crypto !== "undefined" && crypto.subtle
|
|
2260
|
+
if (!(typeof crypto !== "undefined" && ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest))) return [
|
|
2169
2261
|
3,
|
|
2170
2262
|
5
|
|
2171
2263
|
];
|
|
@@ -2192,9 +2284,7 @@ function getBrowserID(clientInfo) {
|
|
|
2192
2284
|
} else {
|
|
2193
2285
|
utf8 = unescape(encodeURIComponent(fingerprintString));
|
|
2194
2286
|
buffer = new Uint8Array(utf8.length);
|
|
2195
|
-
for(i = 0; i < utf8.length; i++)
|
|
2196
|
-
buffer[i] = utf8.charCodeAt(i);
|
|
2197
|
-
}
|
|
2287
|
+
for(i = 0; i < utf8.length; i++)buffer[i] = utf8.charCodeAt(i);
|
|
2198
2288
|
encodedData = buffer;
|
|
2199
2289
|
}
|
|
2200
2290
|
return [
|
|
@@ -2203,8 +2293,7 @@ function getBrowserID(clientInfo) {
|
|
|
2203
2293
|
];
|
|
2204
2294
|
case 3:
|
|
2205
2295
|
hashBuffer = _state.sent();
|
|
2206
|
-
|
|
2207
|
-
hashHex = hashArray.map(function(b) {
|
|
2296
|
+
hashHex = Array.from(new Uint8Array(hashBuffer)).map(function(b) {
|
|
2208
2297
|
return b.toString(16).padStart(2, "0");
|
|
2209
2298
|
}).join("");
|
|
2210
2299
|
cachedBrowserId = hashHex;
|
|
@@ -2213,8 +2302,8 @@ function getBrowserID(clientInfo) {
|
|
|
2213
2302
|
hashHex
|
|
2214
2303
|
];
|
|
2215
2304
|
case 4:
|
|
2216
|
-
|
|
2217
|
-
console.warn("[StormcloudVideoPlayer] crypto.subtle
|
|
2305
|
+
unused = _state.sent();
|
|
2306
|
+
console.warn("[StormcloudVideoPlayer] crypto.subtle not supported, using fallback hash");
|
|
2218
2307
|
return [
|
|
2219
2308
|
3,
|
|
2220
2309
|
5
|
|
@@ -2238,177 +2327,91 @@ function getBrowserID(clientInfo) {
|
|
|
2238
2327
|
});
|
|
2239
2328
|
})();
|
|
2240
2329
|
}
|
|
2241
|
-
|
|
2242
|
-
|
|
2243
|
-
var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
|
|
2244
|
-
var IMPRESSIONS_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/impressions/ingest");
|
|
2245
|
-
function buildHeaders(licenseKey) {
|
|
2246
|
-
var headers = {
|
|
2247
|
-
"Content-Type": "application/json"
|
|
2248
|
-
};
|
|
2249
|
-
if (licenseKey) {
|
|
2250
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2251
|
-
}
|
|
2252
|
-
return headers;
|
|
2253
|
-
}
|
|
2254
|
-
function sendTrackRequest(licenseKey, body) {
|
|
2255
|
-
return _async_to_generator(function() {
|
|
2256
|
-
var response;
|
|
2257
|
-
return _ts_generator(this, function(_state) {
|
|
2258
|
-
switch(_state.label){
|
|
2259
|
-
case 0:
|
|
2260
|
-
return [
|
|
2261
|
-
4,
|
|
2262
|
-
fetch(TRACK_URL, {
|
|
2263
|
-
method: "POST",
|
|
2264
|
-
headers: buildHeaders(licenseKey),
|
|
2265
|
-
body: JSON.stringify(body)
|
|
2266
|
-
})
|
|
2267
|
-
];
|
|
2268
|
-
case 1:
|
|
2269
|
-
response = _state.sent();
|
|
2270
|
-
if (!response.ok) {
|
|
2271
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2272
|
-
}
|
|
2273
|
-
return [
|
|
2274
|
-
4,
|
|
2275
|
-
response.json()
|
|
2276
|
-
];
|
|
2277
|
-
case 2:
|
|
2278
|
-
_state.sent();
|
|
2279
|
-
return [
|
|
2280
|
-
2
|
|
2281
|
-
];
|
|
2282
|
-
}
|
|
2283
|
-
});
|
|
2284
|
-
})();
|
|
2330
|
+
function canPublish(licenseKey) {
|
|
2331
|
+
return Boolean(isMQTTEnabled() && licenseKey);
|
|
2285
2332
|
}
|
|
2286
|
-
function
|
|
2333
|
+
function buildPlayerMetricEvent() {
|
|
2287
2334
|
return _async_to_generator(function() {
|
|
2288
|
-
var
|
|
2289
|
-
return _ts_generator(this, function(_state) {
|
|
2290
|
-
switch(_state.label){
|
|
2291
|
-
case 0:
|
|
2292
|
-
return [
|
|
2293
|
-
4,
|
|
2294
|
-
fetch(url, {
|
|
2295
|
-
method: "POST",
|
|
2296
|
-
headers: buildHeaders(licenseKey),
|
|
2297
|
-
body: JSON.stringify(body)
|
|
2298
|
-
})
|
|
2299
|
-
];
|
|
2300
|
-
case 1:
|
|
2301
|
-
response = _state.sent();
|
|
2302
|
-
if (!response.ok) {
|
|
2303
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2304
|
-
}
|
|
2305
|
-
return [
|
|
2306
|
-
4,
|
|
2307
|
-
response.json()
|
|
2308
|
-
];
|
|
2309
|
-
case 2:
|
|
2310
|
-
_state.sent();
|
|
2311
|
-
return [
|
|
2312
|
-
2
|
|
2313
|
-
];
|
|
2314
|
-
}
|
|
2315
|
-
});
|
|
2316
|
-
})();
|
|
2317
|
-
}
|
|
2318
|
-
function buildPlayerMetricEvent(_0) {
|
|
2319
|
-
return _async_to_generator(function(licenseKey) {
|
|
2320
|
-
var context, flags, _flags_captureAt, clientInfo, browserId, captureAt;
|
|
2335
|
+
var context, flags, _flags_captureAt, _flags_adLoaded, _flags_adDetect, clientInfo, playerId, captureAt;
|
|
2321
2336
|
var _arguments = arguments;
|
|
2322
2337
|
return _ts_generator(this, function(_state) {
|
|
2323
2338
|
switch(_state.label){
|
|
2324
2339
|
case 0:
|
|
2325
|
-
context = _arguments.length >
|
|
2340
|
+
context = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {}, flags = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2326
2341
|
clientInfo = getClientInfo();
|
|
2327
2342
|
return [
|
|
2328
2343
|
4,
|
|
2329
2344
|
getBrowserID(clientInfo)
|
|
2330
2345
|
];
|
|
2331
2346
|
case 1:
|
|
2332
|
-
|
|
2347
|
+
playerId = _state.sent();
|
|
2333
2348
|
captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
|
|
2334
2349
|
return [
|
|
2335
2350
|
2,
|
|
2336
|
-
{
|
|
2337
|
-
player_id:
|
|
2338
|
-
browserId: browserId,
|
|
2351
|
+
_object_spread({
|
|
2352
|
+
player_id: playerId,
|
|
2339
2353
|
device_type: clientInfo.deviceType,
|
|
2340
|
-
|
|
2341
|
-
|
|
2342
|
-
|
|
2343
|
-
|
|
2344
|
-
|
|
2345
|
-
|
|
2346
|
-
|
|
2347
|
-
timestamp: captureAt
|
|
2348
|
-
}
|
|
2354
|
+
os: clientInfo.os.toLowerCase(),
|
|
2355
|
+
ad_loaded: (_flags_adLoaded = flags.adLoaded) !== null && _flags_adLoaded !== void 0 ? _flags_adLoaded : false,
|
|
2356
|
+
ad_detect: (_flags_adDetect = flags.adDetect) !== null && _flags_adDetect !== void 0 ? _flags_adDetect : false,
|
|
2357
|
+
capture_at: captureAt
|
|
2358
|
+
}, context.inputStreamType ? {
|
|
2359
|
+
input_stream_type: context.inputStreamType
|
|
2360
|
+
} : {})
|
|
2349
2361
|
];
|
|
2350
2362
|
}
|
|
2351
2363
|
});
|
|
2352
2364
|
}).apply(this, arguments);
|
|
2353
2365
|
}
|
|
2366
|
+
function publishTracking(licenseKey, channel, body) {
|
|
2367
|
+
ensureMQTTClient();
|
|
2368
|
+
publishMQTT(buildPlayerTopic(licenseKey, channel), body);
|
|
2369
|
+
}
|
|
2354
2370
|
function sendInitialTracking(_0) {
|
|
2355
2371
|
return _async_to_generator(function(licenseKey) {
|
|
2356
|
-
var context,
|
|
2372
|
+
var context, metricEvent, error;
|
|
2357
2373
|
var _arguments = arguments;
|
|
2358
2374
|
return _ts_generator(this, function(_state) {
|
|
2359
2375
|
switch(_state.label){
|
|
2360
2376
|
case 0:
|
|
2361
2377
|
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
|
|
2378
|
+
if (!canPublish(licenseKey)) return [
|
|
2379
|
+
2
|
|
2380
|
+
];
|
|
2362
2381
|
_state.label = 1;
|
|
2363
2382
|
case 1:
|
|
2364
2383
|
_state.trys.push([
|
|
2365
2384
|
1,
|
|
2366
|
-
|
|
2385
|
+
3,
|
|
2367
2386
|
,
|
|
2368
|
-
|
|
2387
|
+
4
|
|
2369
2388
|
]);
|
|
2370
|
-
clientInfo = getClientInfo();
|
|
2371
|
-
return [
|
|
2372
|
-
4,
|
|
2373
|
-
getBrowserID(clientInfo)
|
|
2374
|
-
];
|
|
2375
|
-
case 2:
|
|
2376
|
-
browserId = _state.sent();
|
|
2377
|
-
trackingData = _object_spread({
|
|
2378
|
-
browserId: browserId
|
|
2379
|
-
}, clientInfo);
|
|
2380
2389
|
return [
|
|
2381
2390
|
4,
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
player_id: browserId,
|
|
2386
|
-
device_type: clientInfo.deviceType,
|
|
2387
|
-
input_stream_type: context.inputStreamType,
|
|
2388
|
-
os: clientInfo.os,
|
|
2389
|
-
ad_loaded: false,
|
|
2390
|
-
ad_detect: false,
|
|
2391
|
-
license_key: licenseKey,
|
|
2392
|
-
capture_at: /* @__PURE__ */ new Date().toISOString()
|
|
2393
|
-
}
|
|
2394
|
-
],
|
|
2395
|
-
trackingData: trackingData
|
|
2391
|
+
buildPlayerMetricEvent(context, {
|
|
2392
|
+
adLoaded: false,
|
|
2393
|
+
adDetect: false
|
|
2396
2394
|
})
|
|
2397
2395
|
];
|
|
2398
|
-
case
|
|
2399
|
-
_state.sent();
|
|
2396
|
+
case 2:
|
|
2397
|
+
metricEvent = _state.sent();
|
|
2398
|
+
publishTracking(licenseKey, "metrics", {
|
|
2399
|
+
events: [
|
|
2400
|
+
metricEvent
|
|
2401
|
+
]
|
|
2402
|
+
});
|
|
2400
2403
|
return [
|
|
2401
2404
|
3,
|
|
2402
|
-
|
|
2405
|
+
4
|
|
2403
2406
|
];
|
|
2404
|
-
case
|
|
2407
|
+
case 3:
|
|
2405
2408
|
error = _state.sent();
|
|
2406
2409
|
console.error("[StormcloudVideoPlayer] Error sending initial tracking data:", error);
|
|
2407
2410
|
return [
|
|
2408
2411
|
3,
|
|
2409
|
-
|
|
2412
|
+
4
|
|
2410
2413
|
];
|
|
2411
|
-
case
|
|
2414
|
+
case 4:
|
|
2412
2415
|
return [
|
|
2413
2416
|
2
|
|
2414
2417
|
];
|
|
@@ -2512,53 +2515,48 @@ function sendAdImpressionTracking(_0, _1) {
|
|
|
2512
2515
|
switch(_state.label){
|
|
2513
2516
|
case 0:
|
|
2514
2517
|
context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2518
|
+
if (!canPublish(licenseKey)) return [
|
|
2519
|
+
2
|
|
2520
|
+
];
|
|
2515
2521
|
_state.label = 1;
|
|
2516
2522
|
case 1:
|
|
2517
2523
|
_state.trys.push([
|
|
2518
2524
|
1,
|
|
2519
|
-
|
|
2525
|
+
3,
|
|
2520
2526
|
,
|
|
2521
|
-
|
|
2527
|
+
4
|
|
2522
2528
|
]);
|
|
2523
2529
|
return [
|
|
2524
2530
|
4,
|
|
2525
|
-
buildPlayerMetricEvent(
|
|
2531
|
+
buildPlayerMetricEvent(context, {
|
|
2526
2532
|
captureAt: adImpressionInfo.timestamp
|
|
2527
2533
|
})
|
|
2528
2534
|
];
|
|
2529
2535
|
case 2:
|
|
2530
2536
|
metricEvent = _state.sent();
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2534
|
-
|
|
2535
|
-
|
|
2536
|
-
|
|
2537
|
-
|
|
2538
|
-
|
|
2539
|
-
|
|
2540
|
-
|
|
2541
|
-
|
|
2542
|
-
capture_at: adImpressionInfo.timestamp
|
|
2543
|
-
}
|
|
2544
|
-
]
|
|
2545
|
-
})
|
|
2546
|
-
])
|
|
2547
|
-
];
|
|
2548
|
-
case 3:
|
|
2549
|
-
_state.sent();
|
|
2537
|
+
publishTracking(licenseKey, "heartbeat", metricEvent);
|
|
2538
|
+
publishTracking(licenseKey, "impressions", {
|
|
2539
|
+
events: [
|
|
2540
|
+
{
|
|
2541
|
+
player_id: metricEvent.player_id,
|
|
2542
|
+
ad_played_count: 1,
|
|
2543
|
+
ad_url: adImpressionInfo.adUrl,
|
|
2544
|
+
capture_at: adImpressionInfo.timestamp
|
|
2545
|
+
}
|
|
2546
|
+
]
|
|
2547
|
+
});
|
|
2550
2548
|
return [
|
|
2551
2549
|
3,
|
|
2552
|
-
|
|
2550
|
+
4
|
|
2553
2551
|
];
|
|
2554
|
-
case
|
|
2552
|
+
case 3:
|
|
2555
2553
|
error = _state.sent();
|
|
2556
2554
|
console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
|
|
2557
2555
|
return [
|
|
2558
2556
|
3,
|
|
2559
|
-
|
|
2557
|
+
4
|
|
2560
2558
|
];
|
|
2561
|
-
case
|
|
2559
|
+
case 4:
|
|
2562
2560
|
return [
|
|
2563
2561
|
2
|
|
2564
2562
|
];
|
|
@@ -2574,38 +2572,36 @@ function sendHeartbeat(_0) {
|
|
|
2574
2572
|
switch(_state.label){
|
|
2575
2573
|
case 0:
|
|
2576
2574
|
context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
|
|
2575
|
+
if (!canPublish(licenseKey)) return [
|
|
2576
|
+
2
|
|
2577
|
+
];
|
|
2577
2578
|
_state.label = 1;
|
|
2578
2579
|
case 1:
|
|
2579
2580
|
_state.trys.push([
|
|
2580
2581
|
1,
|
|
2581
|
-
|
|
2582
|
+
3,
|
|
2582
2583
|
,
|
|
2583
|
-
|
|
2584
|
+
4
|
|
2584
2585
|
]);
|
|
2585
2586
|
return [
|
|
2586
2587
|
4,
|
|
2587
|
-
buildPlayerMetricEvent(
|
|
2588
|
+
buildPlayerMetricEvent(context, flags)
|
|
2588
2589
|
];
|
|
2589
2590
|
case 2:
|
|
2590
2591
|
heartbeatData = _state.sent();
|
|
2591
|
-
|
|
2592
|
-
4,
|
|
2593
|
-
postJson(HEARTBEAT_URL, licenseKey, heartbeatData)
|
|
2594
|
-
];
|
|
2595
|
-
case 3:
|
|
2596
|
-
_state.sent();
|
|
2592
|
+
publishTracking(licenseKey, "heartbeat", heartbeatData);
|
|
2597
2593
|
return [
|
|
2598
2594
|
3,
|
|
2599
|
-
|
|
2595
|
+
4
|
|
2600
2596
|
];
|
|
2601
|
-
case
|
|
2597
|
+
case 3:
|
|
2602
2598
|
error = _state.sent();
|
|
2603
2599
|
console.error("[StormcloudVideoPlayer] Error sending heartbeat:", error);
|
|
2604
2600
|
return [
|
|
2605
2601
|
3,
|
|
2606
|
-
|
|
2602
|
+
4
|
|
2607
2603
|
];
|
|
2608
|
-
case
|
|
2604
|
+
case 4:
|
|
2609
2605
|
return [
|
|
2610
2606
|
2
|
|
2611
2607
|
];
|
|
@@ -4519,6 +4515,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4519
4515
|
key: "initializeTracking",
|
|
4520
4516
|
value: function initializeTracking() {
|
|
4521
4517
|
var _this = this;
|
|
4518
|
+
if (isMQTTEnabled()) {
|
|
4519
|
+
initMQTTClient();
|
|
4520
|
+
}
|
|
4522
4521
|
sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
|
|
4523
4522
|
_this.heartbeatInterval = window.setInterval(function() {
|
|
4524
4523
|
_this.sendHeartbeatIfNeeded();
|
|
@@ -6198,6 +6197,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6198
6197
|
clearInterval(this.heartbeatInterval);
|
|
6199
6198
|
this.heartbeatInterval = void 0;
|
|
6200
6199
|
}
|
|
6200
|
+
if (isMQTTEnabled()) {
|
|
6201
|
+
disconnectMQTT();
|
|
6202
|
+
}
|
|
6201
6203
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
6202
6204
|
(_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
|
|
6203
6205
|
this.consecutiveFailures = 0;
|