stormcloud-video-player 0.6.10 → 0.6.12
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 +296 -110
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +12 -1
- package/lib/index.d.ts +12 -1
- package/lib/index.js +273 -111
- package/lib/index.js.map +1 -1
- package/lib/player/StormcloudVideoPlayer.cjs +262 -108
- package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/players/HlsPlayer.cjs +262 -108
- package/lib/players/HlsPlayer.cjs.map +1 -1
- package/lib/players/HlsPlayer.d.cts +1 -1
- package/lib/players/index.cjs +262 -108
- package/lib/players/index.cjs.map +1 -1
- package/lib/sdk/vastAdLayer.d.cts +1 -1
- package/lib/sdk/vastManager.cjs +93 -10
- package/lib/sdk/vastManager.cjs.map +1 -1
- package/lib/sdk/vastManager.d.cts +3 -1
- package/lib/{types-DSKC4ySr.d.cts → types-FjAlGhAL.d.cts} +1 -0
- package/lib/ui/StormcloudVideoPlayer.cjs +266 -110
- package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
- package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
- package/lib/utils/mqttClient.cjs +174 -0
- package/lib/utils/mqttClient.cjs.map +1 -0
- package/lib/utils/mqttClient.d.cts +9 -0
- package/lib/utils/tracking.cjs +119 -96
- package/lib/utils/tracking.cjs.map +1 -1
- package/lib/utils/tracking.d.cts +3 -2
- package/package.json +2 -1
|
@@ -649,7 +649,8 @@ function fireTrackingPixels(urls, sessionId) {
|
|
|
649
649
|
});
|
|
650
650
|
}
|
|
651
651
|
// src/sdk/vastManager.ts
|
|
652
|
-
var
|
|
652
|
+
var VAST_TAG_URL_FALLBACK = "https://pubads.g.doubleclick.net/gampad/ads?iu=/21821455290/Airy-Android&description_url=http%3A%2F%2Fairy.tv&tfcd=0&npa=0&sz=1x1%7C300x250%7C400x300%7C640x480&gdfp_req=1&unviewed_position_start=1&correlator=[placeholder]&vpos=preroll&output=vast&env=vp&vpmute=0&vpa=click";
|
|
653
|
+
var ADSTORM_API_URL = "https://adstorm.co/api-adstorm-dev/adstorm/ads/web";
|
|
653
654
|
var DEFAULT_TIMEOUT_MS = 5e3;
|
|
654
655
|
var MAX_RETRIES = 3;
|
|
655
656
|
var RETRY_BACKOFF_MS = 1500;
|
|
@@ -657,6 +658,7 @@ function createVastManager() {
|
|
|
657
658
|
var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
658
659
|
var _options_debug;
|
|
659
660
|
var initialized = false;
|
|
661
|
+
var vastTagUrl = VAST_TAG_URL_FALLBACK;
|
|
660
662
|
var debug = (_options_debug = options.debug) !== null && _options_debug !== void 0 ? _options_debug : false;
|
|
661
663
|
function log() {
|
|
662
664
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
@@ -678,17 +680,97 @@ function createVastManager() {
|
|
|
678
680
|
"[VastManager]"
|
|
679
681
|
].concat(_to_consumable_array(args)));
|
|
680
682
|
}
|
|
683
|
+
function fetchVastUrlFromApi() {
|
|
684
|
+
return _async_to_generator(function() {
|
|
685
|
+
var apiUrl, _data_response_ima_publisherdeskima, _data_response_ima, _data_response, res, data, payload, err;
|
|
686
|
+
return _ts_generator(this, function(_state) {
|
|
687
|
+
switch(_state.label){
|
|
688
|
+
case 0:
|
|
689
|
+
apiUrl = options.adstormApiUrl || ADSTORM_API_URL;
|
|
690
|
+
_state.label = 1;
|
|
691
|
+
case 1:
|
|
692
|
+
_state.trys.push([
|
|
693
|
+
1,
|
|
694
|
+
4,
|
|
695
|
+
,
|
|
696
|
+
5
|
|
697
|
+
]);
|
|
698
|
+
return [
|
|
699
|
+
4,
|
|
700
|
+
fetch(apiUrl, {
|
|
701
|
+
method: "GET",
|
|
702
|
+
headers: {
|
|
703
|
+
Authorization: "Bearer ".concat(options.licenseKey),
|
|
704
|
+
Accept: "application/json"
|
|
705
|
+
}
|
|
706
|
+
})
|
|
707
|
+
];
|
|
708
|
+
case 2:
|
|
709
|
+
res = _state.sent();
|
|
710
|
+
if (!res.ok) {
|
|
711
|
+
warn("Failed to fetch VAST URL from API (HTTP ".concat(res.status, "), using fallback"));
|
|
712
|
+
return [
|
|
713
|
+
2
|
|
714
|
+
];
|
|
715
|
+
}
|
|
716
|
+
return [
|
|
717
|
+
4,
|
|
718
|
+
res.json()
|
|
719
|
+
];
|
|
720
|
+
case 3:
|
|
721
|
+
data = _state.sent();
|
|
722
|
+
payload = data === null || data === void 0 ? void 0 : (_data_response = data.response) === null || _data_response === void 0 ? void 0 : (_data_response_ima = _data_response.ima) === null || _data_response_ima === void 0 ? void 0 : (_data_response_ima_publisherdeskima = _data_response_ima["publisherdesk.ima"]) === null || _data_response_ima_publisherdeskima === void 0 ? void 0 : _data_response_ima_publisherdeskima.payload;
|
|
723
|
+
if (payload) {
|
|
724
|
+
vastTagUrl = payload;
|
|
725
|
+
log("VAST tag URL fetched from API:", vastTagUrl.split("?")[0]);
|
|
726
|
+
} else {
|
|
727
|
+
log("API response had no VAST payload, using fallback URL");
|
|
728
|
+
}
|
|
729
|
+
return [
|
|
730
|
+
3,
|
|
731
|
+
5
|
|
732
|
+
];
|
|
733
|
+
case 4:
|
|
734
|
+
err = _state.sent();
|
|
735
|
+
warn("Error fetching VAST URL from API, using fallback:", err);
|
|
736
|
+
return [
|
|
737
|
+
3,
|
|
738
|
+
5
|
|
739
|
+
];
|
|
740
|
+
case 5:
|
|
741
|
+
return [
|
|
742
|
+
2
|
|
743
|
+
];
|
|
744
|
+
}
|
|
745
|
+
});
|
|
746
|
+
})();
|
|
747
|
+
}
|
|
681
748
|
function initialize() {
|
|
682
749
|
return _async_to_generator(function() {
|
|
683
750
|
return _ts_generator(this, function(_state) {
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
751
|
+
switch(_state.label){
|
|
752
|
+
case 0:
|
|
753
|
+
if (initialized) return [
|
|
754
|
+
2
|
|
755
|
+
];
|
|
756
|
+
initialized = true;
|
|
757
|
+
if (!options.licenseKey) return [
|
|
758
|
+
3,
|
|
759
|
+
2
|
|
760
|
+
];
|
|
761
|
+
return [
|
|
762
|
+
4,
|
|
763
|
+
fetchVastUrlFromApi()
|
|
764
|
+
];
|
|
765
|
+
case 1:
|
|
766
|
+
_state.sent();
|
|
767
|
+
_state.label = 2;
|
|
768
|
+
case 2:
|
|
769
|
+
log("Initialized, VAST tag URL:", vastTagUrl.split("?")[0]);
|
|
770
|
+
return [
|
|
771
|
+
2
|
|
772
|
+
];
|
|
773
|
+
}
|
|
692
774
|
});
|
|
693
775
|
})();
|
|
694
776
|
}
|
|
@@ -702,7 +784,7 @@ function createVastManager() {
|
|
|
702
784
|
throw new Error("VastManager not initialized. Call initialize() first.");
|
|
703
785
|
}
|
|
704
786
|
correlator = Math.floor(Math.random() * 1e12).toString();
|
|
705
|
-
url =
|
|
787
|
+
url = vastTagUrl.replace("[placeholder]", correlator);
|
|
706
788
|
log("Fetching VAST tag, correlator:", correlator);
|
|
707
789
|
controller = typeof AbortController !== "undefined" ? new AbortController() : null;
|
|
708
790
|
timeoutId = setTimeout(function() {
|
|
@@ -896,6 +978,7 @@ function createVastManager() {
|
|
|
896
978
|
}
|
|
897
979
|
function destroy() {
|
|
898
980
|
initialized = false;
|
|
981
|
+
vastTagUrl = VAST_TAG_URL_FALLBACK;
|
|
899
982
|
log("Destroyed");
|
|
900
983
|
}
|
|
901
984
|
return {
|
|
@@ -1925,6 +2008,79 @@ function createVastAdLayer(contentVideo, options) {
|
|
|
1925
2008
|
}
|
|
1926
2009
|
};
|
|
1927
2010
|
}
|
|
2011
|
+
// src/utils/mqttClient.ts
|
|
2012
|
+
var import_mqtt = __toESM(require("mqtt"), 1);
|
|
2013
|
+
var LOG2 = "[StormcloudVideoPlayer][MQTT]";
|
|
2014
|
+
var client = null;
|
|
2015
|
+
var status = "disconnected";
|
|
2016
|
+
var brokerUrl = "";
|
|
2017
|
+
function isMQTTConfigured() {
|
|
2018
|
+
return client !== null;
|
|
2019
|
+
}
|
|
2020
|
+
function initMQTTClient(url) {
|
|
2021
|
+
var _topicPrefix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "adstorm";
|
|
2022
|
+
if (client) return;
|
|
2023
|
+
brokerUrl = url;
|
|
2024
|
+
status = "connecting";
|
|
2025
|
+
var clientId = "stormcloud-vp-".concat(Math.random().toString(36).slice(2, 9));
|
|
2026
|
+
try {
|
|
2027
|
+
client = import_mqtt.default.connect(url, {
|
|
2028
|
+
clientId: clientId,
|
|
2029
|
+
keepalive: 60,
|
|
2030
|
+
clean: true,
|
|
2031
|
+
reconnectPeriod: 5e3,
|
|
2032
|
+
connectTimeout: 1e4,
|
|
2033
|
+
queueQoSZero: false
|
|
2034
|
+
});
|
|
2035
|
+
} catch (err) {
|
|
2036
|
+
status = "error";
|
|
2037
|
+
console.warn("".concat(LOG2, " connect() threw:"), err);
|
|
2038
|
+
return;
|
|
2039
|
+
}
|
|
2040
|
+
client.on("connect", function() {
|
|
2041
|
+
status = "connected";
|
|
2042
|
+
console.info("".concat(LOG2, " connected to ").concat(url));
|
|
2043
|
+
});
|
|
2044
|
+
client.on("reconnect", function() {
|
|
2045
|
+
status = "connecting";
|
|
2046
|
+
console.info("".concat(LOG2, " reconnecting…"));
|
|
2047
|
+
});
|
|
2048
|
+
client.on("offline", function() {
|
|
2049
|
+
status = "disconnected";
|
|
2050
|
+
console.warn("".concat(LOG2, " offline"));
|
|
2051
|
+
});
|
|
2052
|
+
client.on("error", function(err) {
|
|
2053
|
+
status = "error";
|
|
2054
|
+
console.warn("".concat(LOG2, " error:"), err.message);
|
|
2055
|
+
});
|
|
2056
|
+
client.on("close", function() {
|
|
2057
|
+
if (status === "connected") {
|
|
2058
|
+
status = "disconnected";
|
|
2059
|
+
}
|
|
2060
|
+
});
|
|
2061
|
+
}
|
|
2062
|
+
function publishMQTT(topic, payload) {
|
|
2063
|
+
if (!client) {
|
|
2064
|
+
return false;
|
|
2065
|
+
}
|
|
2066
|
+
try {
|
|
2067
|
+
client.publish(topic, JSON.stringify(payload), {
|
|
2068
|
+
qos: 1
|
|
2069
|
+
});
|
|
2070
|
+
return true;
|
|
2071
|
+
} catch (err) {
|
|
2072
|
+
console.warn("".concat(LOG2, " publish failed on ").concat(topic, ":"), err);
|
|
2073
|
+
return false;
|
|
2074
|
+
}
|
|
2075
|
+
}
|
|
2076
|
+
function disconnectMQTT() {
|
|
2077
|
+
if (client) {
|
|
2078
|
+
client.end(true);
|
|
2079
|
+
client = null;
|
|
2080
|
+
status = "disconnected";
|
|
2081
|
+
brokerUrl = "";
|
|
2082
|
+
}
|
|
2083
|
+
}
|
|
1928
2084
|
// src/utils/tracking.ts
|
|
1929
2085
|
var cachedBrowserId = null;
|
|
1930
2086
|
function getClientInfo() {
|
|
@@ -1956,8 +2112,8 @@ function getClientInfo() {
|
|
|
1956
2112
|
os = "webOS";
|
|
1957
2113
|
isSmartTV = true;
|
|
1958
2114
|
deviceType = "tv";
|
|
1959
|
-
var
|
|
1960
|
-
model =
|
|
2115
|
+
var m = ua.match(/Web0S\/([^\s]+)/);
|
|
2116
|
+
model = m ? "webOS ".concat(m[1]) : "webOS TV";
|
|
1961
2117
|
} else if (ua.includes("Tizen")) {
|
|
1962
2118
|
brand = "Samsung";
|
|
1963
2119
|
os = "Tizen";
|
|
@@ -2001,23 +2157,19 @@ function getClientInfo() {
|
|
|
2001
2157
|
isAndroid = true;
|
|
2002
2158
|
os = "Android";
|
|
2003
2159
|
deviceType = /Mobile/.test(ua) ? "mobile" : "tablet";
|
|
2004
|
-
if (
|
|
2160
|
+
if (maxTouchPoints === 0 || ua.includes("Google TV") || ua.includes("XiaoMi")) {
|
|
2005
2161
|
deviceType = "tv";
|
|
2006
2162
|
isSmartTV = true;
|
|
2007
2163
|
brand = brand === "Unknown" ? "Android TV" : brand;
|
|
2008
2164
|
}
|
|
2009
2165
|
var androidModelMatch = ua.match(/\(([^)]*Android[^)]*)\)/);
|
|
2010
|
-
if (androidModelMatch
|
|
2011
|
-
model = androidModelMatch[1];
|
|
2012
|
-
}
|
|
2166
|
+
if (androidModelMatch === null || androidModelMatch === void 0 ? void 0 : androidModelMatch[1]) model = androidModelMatch[1];
|
|
2013
2167
|
}
|
|
2014
2168
|
if (/iPad|iPhone|iPod/.test(ua)) {
|
|
2015
2169
|
os = "iOS";
|
|
2016
2170
|
deviceType = "mobile";
|
|
2017
2171
|
brand = "Apple";
|
|
2018
|
-
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua))
|
|
2019
|
-
deviceType = "tablet";
|
|
2020
|
-
}
|
|
2172
|
+
if (navigator.maxTouchPoints > 1 && /iPad/.test(ua)) deviceType = "tablet";
|
|
2021
2173
|
}
|
|
2022
2174
|
if (!isAndroid && !isSmartTV && !/Mobile/.test(ua)) {
|
|
2023
2175
|
if (ua.includes("Windows")) {
|
|
@@ -2038,9 +2190,7 @@ function getClientInfo() {
|
|
|
2038
2190
|
if (vendor.includes("Samsung") || ua.includes("SM-")) brand = "Samsung";
|
|
2039
2191
|
}
|
|
2040
2192
|
isWebView = /wv|WebView|Linux; U;/.test(ua);
|
|
2041
|
-
if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0)
|
|
2042
|
-
isWebView = true;
|
|
2043
|
-
}
|
|
2193
|
+
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;
|
|
2044
2194
|
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;
|
|
2045
2195
|
return {
|
|
2046
2196
|
brand: brand,
|
|
@@ -2071,18 +2221,16 @@ function getClientInfo() {
|
|
|
2071
2221
|
}
|
|
2072
2222
|
function getBrowserID(clientInfo) {
|
|
2073
2223
|
return _async_to_generator(function() {
|
|
2074
|
-
var fingerprintString, encodedData, utf8, buffer, i, hashBuffer,
|
|
2224
|
+
var _crypto_subtle, fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashHex, unused, hash, i1, char, fallbackHash, timestamp, random;
|
|
2075
2225
|
return _ts_generator(this, function(_state) {
|
|
2076
2226
|
switch(_state.label){
|
|
2077
2227
|
case 0:
|
|
2078
|
-
if (cachedBrowserId)
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
|
|
2082
|
-
];
|
|
2083
|
-
}
|
|
2228
|
+
if (cachedBrowserId) return [
|
|
2229
|
+
2,
|
|
2230
|
+
cachedBrowserId
|
|
2231
|
+
];
|
|
2084
2232
|
fingerprintString = JSON.stringify(clientInfo);
|
|
2085
|
-
if (!(typeof crypto !== "undefined" && crypto.subtle
|
|
2233
|
+
if (!(typeof crypto !== "undefined" && ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest))) return [
|
|
2086
2234
|
3,
|
|
2087
2235
|
5
|
|
2088
2236
|
];
|
|
@@ -2109,9 +2257,7 @@ function getBrowserID(clientInfo) {
|
|
|
2109
2257
|
} else {
|
|
2110
2258
|
utf8 = unescape(encodeURIComponent(fingerprintString));
|
|
2111
2259
|
buffer = new Uint8Array(utf8.length);
|
|
2112
|
-
for(i = 0; i < utf8.length; i++)
|
|
2113
|
-
buffer[i] = utf8.charCodeAt(i);
|
|
2114
|
-
}
|
|
2260
|
+
for(i = 0; i < utf8.length; i++)buffer[i] = utf8.charCodeAt(i);
|
|
2115
2261
|
encodedData = buffer;
|
|
2116
2262
|
}
|
|
2117
2263
|
return [
|
|
@@ -2120,8 +2266,7 @@ function getBrowserID(clientInfo) {
|
|
|
2120
2266
|
];
|
|
2121
2267
|
case 3:
|
|
2122
2268
|
hashBuffer = _state.sent();
|
|
2123
|
-
|
|
2124
|
-
hashHex = hashArray.map(function(b) {
|
|
2269
|
+
hashHex = Array.from(new Uint8Array(hashBuffer)).map(function(b) {
|
|
2125
2270
|
return b.toString(16).padStart(2, "0");
|
|
2126
2271
|
}).join("");
|
|
2127
2272
|
cachedBrowserId = hashHex;
|
|
@@ -2130,8 +2275,8 @@ function getBrowserID(clientInfo) {
|
|
|
2130
2275
|
hashHex
|
|
2131
2276
|
];
|
|
2132
2277
|
case 4:
|
|
2133
|
-
|
|
2134
|
-
console.warn("[StormcloudVideoPlayer] crypto.subtle
|
|
2278
|
+
unused = _state.sent();
|
|
2279
|
+
console.warn("[StormcloudVideoPlayer] crypto.subtle not supported, using fallback hash");
|
|
2135
2280
|
return [
|
|
2136
2281
|
3,
|
|
2137
2282
|
5
|
|
@@ -2155,6 +2300,10 @@ function getBrowserID(clientInfo) {
|
|
|
2155
2300
|
});
|
|
2156
2301
|
})();
|
|
2157
2302
|
}
|
|
2303
|
+
var mqttTopicPrefix = "adstorm";
|
|
2304
|
+
function setMQTTTopicPrefix(prefix) {
|
|
2305
|
+
mqttTopicPrefix = prefix || "adstorm";
|
|
2306
|
+
}
|
|
2158
2307
|
var PLAYER_TRACKING_BASE_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking";
|
|
2159
2308
|
var TRACK_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/metrics/ingest");
|
|
2160
2309
|
var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
|
|
@@ -2163,43 +2312,9 @@ function buildHeaders(licenseKey) {
|
|
|
2163
2312
|
var headers = {
|
|
2164
2313
|
"Content-Type": "application/json"
|
|
2165
2314
|
};
|
|
2166
|
-
if (licenseKey)
|
|
2167
|
-
headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2168
|
-
}
|
|
2315
|
+
if (licenseKey) headers["Authorization"] = "Bearer ".concat(licenseKey);
|
|
2169
2316
|
return headers;
|
|
2170
2317
|
}
|
|
2171
|
-
function sendTrackRequest(licenseKey, body) {
|
|
2172
|
-
return _async_to_generator(function() {
|
|
2173
|
-
var response;
|
|
2174
|
-
return _ts_generator(this, function(_state) {
|
|
2175
|
-
switch(_state.label){
|
|
2176
|
-
case 0:
|
|
2177
|
-
return [
|
|
2178
|
-
4,
|
|
2179
|
-
fetch(TRACK_URL, {
|
|
2180
|
-
method: "POST",
|
|
2181
|
-
headers: buildHeaders(licenseKey),
|
|
2182
|
-
body: JSON.stringify(body)
|
|
2183
|
-
})
|
|
2184
|
-
];
|
|
2185
|
-
case 1:
|
|
2186
|
-
response = _state.sent();
|
|
2187
|
-
if (!response.ok) {
|
|
2188
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2189
|
-
}
|
|
2190
|
-
return [
|
|
2191
|
-
4,
|
|
2192
|
-
response.json()
|
|
2193
|
-
];
|
|
2194
|
-
case 2:
|
|
2195
|
-
_state.sent();
|
|
2196
|
-
return [
|
|
2197
|
-
2
|
|
2198
|
-
];
|
|
2199
|
-
}
|
|
2200
|
-
});
|
|
2201
|
-
})();
|
|
2202
|
-
}
|
|
2203
2318
|
function postJson(url, licenseKey, body) {
|
|
2204
2319
|
return _async_to_generator(function() {
|
|
2205
2320
|
var response;
|
|
@@ -2216,9 +2331,7 @@ function postJson(url, licenseKey, body) {
|
|
|
2216
2331
|
];
|
|
2217
2332
|
case 1:
|
|
2218
2333
|
response = _state.sent();
|
|
2219
|
-
if (!response.ok)
|
|
2220
|
-
throw new Error("HTTP error! status: ".concat(response.status));
|
|
2221
|
-
}
|
|
2334
|
+
if (!response.ok) throw new Error("HTTP error! status: ".concat(response.status));
|
|
2222
2335
|
return [
|
|
2223
2336
|
4,
|
|
2224
2337
|
response.json()
|
|
@@ -2268,9 +2381,33 @@ function buildPlayerMetricEvent(_0) {
|
|
|
2268
2381
|
});
|
|
2269
2382
|
}).apply(this, arguments);
|
|
2270
2383
|
}
|
|
2384
|
+
function publishOrPost(mqttTopic, httpUrl, licenseKey, body) {
|
|
2385
|
+
return _async_to_generator(function() {
|
|
2386
|
+
return _ts_generator(this, function(_state) {
|
|
2387
|
+
switch(_state.label){
|
|
2388
|
+
case 0:
|
|
2389
|
+
if (isMQTTConfigured()) {
|
|
2390
|
+
publishMQTT(mqttTopic, body);
|
|
2391
|
+
return [
|
|
2392
|
+
2
|
|
2393
|
+
];
|
|
2394
|
+
}
|
|
2395
|
+
return [
|
|
2396
|
+
4,
|
|
2397
|
+
postJson(httpUrl, licenseKey, body)
|
|
2398
|
+
];
|
|
2399
|
+
case 1:
|
|
2400
|
+
_state.sent();
|
|
2401
|
+
return [
|
|
2402
|
+
2
|
|
2403
|
+
];
|
|
2404
|
+
}
|
|
2405
|
+
});
|
|
2406
|
+
})();
|
|
2407
|
+
}
|
|
2271
2408
|
function sendInitialTracking(_0) {
|
|
2272
2409
|
return _async_to_generator(function(licenseKey) {
|
|
2273
|
-
var context, clientInfo, browserId, trackingData, error;
|
|
2410
|
+
var context, clientInfo, browserId, captureAt, trackingData, metricsBody, error;
|
|
2274
2411
|
var _arguments = arguments;
|
|
2275
2412
|
return _ts_generator(this, function(_state) {
|
|
2276
2413
|
switch(_state.label){
|
|
@@ -2291,26 +2428,28 @@ function sendInitialTracking(_0) {
|
|
|
2291
2428
|
];
|
|
2292
2429
|
case 2:
|
|
2293
2430
|
browserId = _state.sent();
|
|
2431
|
+
captureAt = /* @__PURE__ */ new Date().toISOString();
|
|
2294
2432
|
trackingData = _object_spread({
|
|
2295
2433
|
browserId: browserId
|
|
2296
2434
|
}, clientInfo);
|
|
2435
|
+
metricsBody = {
|
|
2436
|
+
events: [
|
|
2437
|
+
{
|
|
2438
|
+
player_id: browserId,
|
|
2439
|
+
device_type: clientInfo.deviceType,
|
|
2440
|
+
input_stream_type: context.inputStreamType,
|
|
2441
|
+
os: clientInfo.os,
|
|
2442
|
+
ad_loaded: false,
|
|
2443
|
+
ad_detect: false,
|
|
2444
|
+
license_key: licenseKey,
|
|
2445
|
+
capture_at: captureAt
|
|
2446
|
+
}
|
|
2447
|
+
],
|
|
2448
|
+
trackingData: trackingData
|
|
2449
|
+
};
|
|
2297
2450
|
return [
|
|
2298
2451
|
4,
|
|
2299
|
-
|
|
2300
|
-
events: [
|
|
2301
|
-
{
|
|
2302
|
-
player_id: browserId,
|
|
2303
|
-
device_type: clientInfo.deviceType,
|
|
2304
|
-
input_stream_type: context.inputStreamType,
|
|
2305
|
-
os: clientInfo.os,
|
|
2306
|
-
ad_loaded: false,
|
|
2307
|
-
ad_detect: false,
|
|
2308
|
-
license_key: licenseKey,
|
|
2309
|
-
capture_at: /* @__PURE__ */ new Date().toISOString()
|
|
2310
|
-
}
|
|
2311
|
-
],
|
|
2312
|
-
trackingData: trackingData
|
|
2313
|
-
})
|
|
2452
|
+
publishOrPost("".concat(mqttTopicPrefix, "/tracking/metrics"), TRACK_URL, licenseKey, metricsBody)
|
|
2314
2453
|
];
|
|
2315
2454
|
case 3:
|
|
2316
2455
|
_state.sent();
|
|
@@ -2423,7 +2562,7 @@ function sendAdLoadedTracking(_0, _1) {
|
|
|
2423
2562
|
}
|
|
2424
2563
|
function sendAdImpressionTracking(_0, _1) {
|
|
2425
2564
|
return _async_to_generator(function(licenseKey, adImpressionInfo) {
|
|
2426
|
-
var context, metricEvent, error;
|
|
2565
|
+
var context, metricEvent, heartbeatBody, impressionsBody, error;
|
|
2427
2566
|
var _arguments = arguments;
|
|
2428
2567
|
return _ts_generator(this, function(_state) {
|
|
2429
2568
|
switch(_state.label){
|
|
@@ -2445,21 +2584,23 @@ function sendAdImpressionTracking(_0, _1) {
|
|
|
2445
2584
|
];
|
|
2446
2585
|
case 2:
|
|
2447
2586
|
metricEvent = _state.sent();
|
|
2587
|
+
heartbeatBody = metricEvent;
|
|
2588
|
+
impressionsBody = {
|
|
2589
|
+
events: [
|
|
2590
|
+
{
|
|
2591
|
+
player_id: metricEvent.player_id,
|
|
2592
|
+
ad_played_count: 1,
|
|
2593
|
+
ad_url: adImpressionInfo.adUrl,
|
|
2594
|
+
license_key: licenseKey,
|
|
2595
|
+
capture_at: adImpressionInfo.timestamp
|
|
2596
|
+
}
|
|
2597
|
+
]
|
|
2598
|
+
};
|
|
2448
2599
|
return [
|
|
2449
2600
|
4,
|
|
2450
2601
|
Promise.all([
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
events: [
|
|
2454
|
-
{
|
|
2455
|
-
player_id: metricEvent.player_id,
|
|
2456
|
-
ad_played_count: 1,
|
|
2457
|
-
ad_url: adImpressionInfo.adUrl,
|
|
2458
|
-
license_key: licenseKey,
|
|
2459
|
-
capture_at: adImpressionInfo.timestamp
|
|
2460
|
-
}
|
|
2461
|
-
]
|
|
2462
|
-
})
|
|
2602
|
+
publishOrPost("".concat(mqttTopicPrefix, "/tracking/heartbeat"), HEARTBEAT_URL, licenseKey, heartbeatBody),
|
|
2603
|
+
publishOrPost("".concat(mqttTopicPrefix, "/tracking/impressions"), IMPRESSIONS_URL, licenseKey, impressionsBody)
|
|
2463
2604
|
])
|
|
2464
2605
|
];
|
|
2465
2606
|
case 3:
|
|
@@ -2507,7 +2648,7 @@ function sendHeartbeat(_0) {
|
|
|
2507
2648
|
heartbeatData = _state.sent();
|
|
2508
2649
|
return [
|
|
2509
2650
|
4,
|
|
2510
|
-
|
|
2651
|
+
publishOrPost("".concat(mqttTopicPrefix, "/tracking/heartbeat"), HEARTBEAT_URL, licenseKey, heartbeatData)
|
|
2511
2652
|
];
|
|
2512
2653
|
case 3:
|
|
2513
2654
|
_state.sent();
|
|
@@ -3083,9 +3224,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3083
3224
|
this.video = config.videoElement;
|
|
3084
3225
|
this.adTransitionGapMs = (_this_config_adTransitionGapMs = this.config.adTransitionGapMs) !== null && _this_config_adTransitionGapMs !== void 0 ? _this_config_adTransitionGapMs : 100;
|
|
3085
3226
|
logBrowserInfo(config.debugAdTiming);
|
|
3086
|
-
this.vastManager = createVastManager(
|
|
3087
|
-
debug: !!config.debugAdTiming
|
|
3088
|
-
}
|
|
3227
|
+
this.vastManager = createVastManager(_object_spread({
|
|
3228
|
+
debug: config.debugAdTiming !== void 0 ? !!config.debugAdTiming : false
|
|
3229
|
+
}, config.licenseKey ? {
|
|
3230
|
+
licenseKey: config.licenseKey
|
|
3231
|
+
} : {}));
|
|
3089
3232
|
var browserForAdLayer = detectBrowser();
|
|
3090
3233
|
var isSinglePipeline = browserForAdLayer.isSmartTV || !!this.config.singlePipelineMode;
|
|
3091
3234
|
this.adLayer = createVastAdLayer(this.video, {
|
|
@@ -3136,6 +3279,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
3136
3279
|
this.attach();
|
|
3137
3280
|
}
|
|
3138
3281
|
this.initializeTracking();
|
|
3282
|
+
if (!this.config.disableAds) {
|
|
3283
|
+
this.vastManager.initialize().catch(function() {});
|
|
3284
|
+
}
|
|
3139
3285
|
if (!this.shouldUseNativeHls()) return [
|
|
3140
3286
|
3,
|
|
3141
3287
|
3
|
|
@@ -4431,6 +4577,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
4431
4577
|
key: "initializeTracking",
|
|
4432
4578
|
value: function initializeTracking() {
|
|
4433
4579
|
var _this = this;
|
|
4580
|
+
if (this.config.mqttBrokerUrl) {
|
|
4581
|
+
var topicPrefix = "adstorm";
|
|
4582
|
+
setMQTTTopicPrefix(topicPrefix);
|
|
4583
|
+
initMQTTClient(this.config.mqttBrokerUrl, topicPrefix);
|
|
4584
|
+
}
|
|
4434
4585
|
sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
|
|
4435
4586
|
_this.heartbeatInterval = window.setInterval(function() {
|
|
4436
4587
|
_this.sendHeartbeatIfNeeded();
|
|
@@ -6110,6 +6261,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
|
|
|
6110
6261
|
clearInterval(this.heartbeatInterval);
|
|
6111
6262
|
this.heartbeatInterval = void 0;
|
|
6112
6263
|
}
|
|
6264
|
+
if (this.config.mqttBrokerUrl) {
|
|
6265
|
+
disconnectMQTT();
|
|
6266
|
+
}
|
|
6113
6267
|
(_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
|
|
6114
6268
|
(_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
|
|
6115
6269
|
this.consecutiveFailures = 0;
|