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.
@@ -1,4 +1,4 @@
1
- import { S as StormcloudVideoPlayerConfig } from '../types-DSKC4ySr.cjs';
1
+ import { S as StormcloudVideoPlayerConfig } from '../types-FjAlGhAL.cjs';
2
2
 
3
3
  declare class StormcloudVideoPlayer {
4
4
  private readonly video;
@@ -701,7 +701,8 @@ function fireTrackingPixels(urls, sessionId) {
701
701
  });
702
702
  }
703
703
  // src/sdk/vastManager.ts
704
- var VAST_TAG_URL = "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";
704
+ 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";
705
+ var ADSTORM_API_URL = "https://adstorm.co/api-adstorm-dev/adstorm/ads/web";
705
706
  var DEFAULT_TIMEOUT_MS = 5e3;
706
707
  var MAX_RETRIES = 3;
707
708
  var RETRY_BACKOFF_MS = 1500;
@@ -709,6 +710,7 @@ function createVastManager() {
709
710
  var options = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
710
711
  var _options_debug;
711
712
  var initialized = false;
713
+ var vastTagUrl = VAST_TAG_URL_FALLBACK;
712
714
  var debug = (_options_debug = options.debug) !== null && _options_debug !== void 0 ? _options_debug : false;
713
715
  function log() {
714
716
  for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
@@ -730,17 +732,97 @@ function createVastManager() {
730
732
  "[VastManager]"
731
733
  ].concat(_to_consumable_array(args)));
732
734
  }
735
+ function fetchVastUrlFromApi() {
736
+ return _async_to_generator(function() {
737
+ var apiUrl, _data_response_ima_publisherdeskima, _data_response_ima, _data_response, res, data, payload, err;
738
+ return _ts_generator(this, function(_state) {
739
+ switch(_state.label){
740
+ case 0:
741
+ apiUrl = options.adstormApiUrl || ADSTORM_API_URL;
742
+ _state.label = 1;
743
+ case 1:
744
+ _state.trys.push([
745
+ 1,
746
+ 4,
747
+ ,
748
+ 5
749
+ ]);
750
+ return [
751
+ 4,
752
+ fetch(apiUrl, {
753
+ method: "GET",
754
+ headers: {
755
+ Authorization: "Bearer ".concat(options.licenseKey),
756
+ Accept: "application/json"
757
+ }
758
+ })
759
+ ];
760
+ case 2:
761
+ res = _state.sent();
762
+ if (!res.ok) {
763
+ warn("Failed to fetch VAST URL from API (HTTP ".concat(res.status, "), using fallback"));
764
+ return [
765
+ 2
766
+ ];
767
+ }
768
+ return [
769
+ 4,
770
+ res.json()
771
+ ];
772
+ case 3:
773
+ data = _state.sent();
774
+ 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;
775
+ if (payload) {
776
+ vastTagUrl = payload;
777
+ log("VAST tag URL fetched from API:", vastTagUrl.split("?")[0]);
778
+ } else {
779
+ log("API response had no VAST payload, using fallback URL");
780
+ }
781
+ return [
782
+ 3,
783
+ 5
784
+ ];
785
+ case 4:
786
+ err = _state.sent();
787
+ warn("Error fetching VAST URL from API, using fallback:", err);
788
+ return [
789
+ 3,
790
+ 5
791
+ ];
792
+ case 5:
793
+ return [
794
+ 2
795
+ ];
796
+ }
797
+ });
798
+ })();
799
+ }
733
800
  function initialize() {
734
801
  return _async_to_generator(function() {
735
802
  return _ts_generator(this, function(_state) {
736
- if (initialized) return [
737
- 2
738
- ];
739
- initialized = true;
740
- log("Initialized, VAST tag URL:", VAST_TAG_URL.split("?")[0]);
741
- return [
742
- 2
743
- ];
803
+ switch(_state.label){
804
+ case 0:
805
+ if (initialized) return [
806
+ 2
807
+ ];
808
+ initialized = true;
809
+ if (!options.licenseKey) return [
810
+ 3,
811
+ 2
812
+ ];
813
+ return [
814
+ 4,
815
+ fetchVastUrlFromApi()
816
+ ];
817
+ case 1:
818
+ _state.sent();
819
+ _state.label = 2;
820
+ case 2:
821
+ log("Initialized, VAST tag URL:", vastTagUrl.split("?")[0]);
822
+ return [
823
+ 2
824
+ ];
825
+ }
744
826
  });
745
827
  })();
746
828
  }
@@ -754,7 +836,7 @@ function createVastManager() {
754
836
  throw new Error("VastManager not initialized. Call initialize() first.");
755
837
  }
756
838
  correlator = Math.floor(Math.random() * 1e12).toString();
757
- url = VAST_TAG_URL.replace("[placeholder]", correlator);
839
+ url = vastTagUrl.replace("[placeholder]", correlator);
758
840
  log("Fetching VAST tag, correlator:", correlator);
759
841
  controller = typeof AbortController !== "undefined" ? new AbortController() : null;
760
842
  timeoutId = setTimeout(function() {
@@ -948,6 +1030,7 @@ function createVastManager() {
948
1030
  }
949
1031
  function destroy() {
950
1032
  initialized = false;
1033
+ vastTagUrl = VAST_TAG_URL_FALLBACK;
951
1034
  log("Destroyed");
952
1035
  }
953
1036
  return {
@@ -1977,6 +2060,79 @@ function createVastAdLayer(contentVideo, options) {
1977
2060
  }
1978
2061
  };
1979
2062
  }
2063
+ // src/utils/mqttClient.ts
2064
+ var import_mqtt = __toESM(require("mqtt"), 1);
2065
+ var LOG2 = "[StormcloudVideoPlayer][MQTT]";
2066
+ var client = null;
2067
+ var status = "disconnected";
2068
+ var brokerUrl = "";
2069
+ function isMQTTConfigured() {
2070
+ return client !== null;
2071
+ }
2072
+ function initMQTTClient(url) {
2073
+ var _topicPrefix = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "adstorm";
2074
+ if (client) return;
2075
+ brokerUrl = url;
2076
+ status = "connecting";
2077
+ var clientId = "stormcloud-vp-".concat(Math.random().toString(36).slice(2, 9));
2078
+ try {
2079
+ client = import_mqtt.default.connect(url, {
2080
+ clientId: clientId,
2081
+ keepalive: 60,
2082
+ clean: true,
2083
+ reconnectPeriod: 5e3,
2084
+ connectTimeout: 1e4,
2085
+ queueQoSZero: false
2086
+ });
2087
+ } catch (err) {
2088
+ status = "error";
2089
+ console.warn("".concat(LOG2, " connect() threw:"), err);
2090
+ return;
2091
+ }
2092
+ client.on("connect", function() {
2093
+ status = "connected";
2094
+ console.info("".concat(LOG2, " connected to ").concat(url));
2095
+ });
2096
+ client.on("reconnect", function() {
2097
+ status = "connecting";
2098
+ console.info("".concat(LOG2, " reconnecting…"));
2099
+ });
2100
+ client.on("offline", function() {
2101
+ status = "disconnected";
2102
+ console.warn("".concat(LOG2, " offline"));
2103
+ });
2104
+ client.on("error", function(err) {
2105
+ status = "error";
2106
+ console.warn("".concat(LOG2, " error:"), err.message);
2107
+ });
2108
+ client.on("close", function() {
2109
+ if (status === "connected") {
2110
+ status = "disconnected";
2111
+ }
2112
+ });
2113
+ }
2114
+ function publishMQTT(topic, payload) {
2115
+ if (!client) {
2116
+ return false;
2117
+ }
2118
+ try {
2119
+ client.publish(topic, JSON.stringify(payload), {
2120
+ qos: 1
2121
+ });
2122
+ return true;
2123
+ } catch (err) {
2124
+ console.warn("".concat(LOG2, " publish failed on ").concat(topic, ":"), err);
2125
+ return false;
2126
+ }
2127
+ }
2128
+ function disconnectMQTT() {
2129
+ if (client) {
2130
+ client.end(true);
2131
+ client = null;
2132
+ status = "disconnected";
2133
+ brokerUrl = "";
2134
+ }
2135
+ }
1980
2136
  // src/utils/tracking.ts
1981
2137
  var cachedBrowserId = null;
1982
2138
  function getClientInfo() {
@@ -2008,8 +2164,8 @@ function getClientInfo() {
2008
2164
  os = "webOS";
2009
2165
  isSmartTV = true;
2010
2166
  deviceType = "tv";
2011
- var webosMatch = ua.match(/Web0S\/([^\s]+)/);
2012
- model = webosMatch ? "webOS ".concat(webosMatch[1]) : "webOS TV";
2167
+ var m = ua.match(/Web0S\/([^\s]+)/);
2168
+ model = m ? "webOS ".concat(m[1]) : "webOS TV";
2013
2169
  } else if (ua.includes("Tizen")) {
2014
2170
  brand = "Samsung";
2015
2171
  os = "Tizen";
@@ -2053,23 +2209,19 @@ function getClientInfo() {
2053
2209
  isAndroid = true;
2054
2210
  os = "Android";
2055
2211
  deviceType = /Mobile/.test(ua) ? "mobile" : "tablet";
2056
- if (ua.includes("Android") && (maxTouchPoints === 0 || ua.includes("Google TV") || ua.includes("XiaoMi"))) {
2212
+ if (maxTouchPoints === 0 || ua.includes("Google TV") || ua.includes("XiaoMi")) {
2057
2213
  deviceType = "tv";
2058
2214
  isSmartTV = true;
2059
2215
  brand = brand === "Unknown" ? "Android TV" : brand;
2060
2216
  }
2061
2217
  var androidModelMatch = ua.match(/\(([^)]*Android[^)]*)\)/);
2062
- if (androidModelMatch && androidModelMatch[1]) {
2063
- model = androidModelMatch[1];
2064
- }
2218
+ if (androidModelMatch === null || androidModelMatch === void 0 ? void 0 : androidModelMatch[1]) model = androidModelMatch[1];
2065
2219
  }
2066
2220
  if (/iPad|iPhone|iPod/.test(ua)) {
2067
2221
  os = "iOS";
2068
2222
  deviceType = "mobile";
2069
2223
  brand = "Apple";
2070
- if (navigator.maxTouchPoints > 1 && /iPad/.test(ua)) {
2071
- deviceType = "tablet";
2072
- }
2224
+ if (navigator.maxTouchPoints > 1 && /iPad/.test(ua)) deviceType = "tablet";
2073
2225
  }
2074
2226
  if (!isAndroid && !isSmartTV && !/Mobile/.test(ua)) {
2075
2227
  if (ua.includes("Windows")) {
@@ -2090,9 +2242,7 @@ function getClientInfo() {
2090
2242
  if (vendor.includes("Samsung") || ua.includes("SM-")) brand = "Samsung";
2091
2243
  }
2092
2244
  isWebView = /wv|WebView|Linux; U;/.test(ua);
2093
- if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0) {
2094
- isWebView = true;
2095
- }
2245
+ 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;
2096
2246
  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;
2097
2247
  return {
2098
2248
  brand: brand,
@@ -2123,18 +2273,16 @@ function getClientInfo() {
2123
2273
  }
2124
2274
  function getBrowserID(clientInfo) {
2125
2275
  return _async_to_generator(function() {
2126
- var fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashArray, hashHex, error, hash, i1, char, fallbackHash, timestamp, random;
2276
+ var _crypto_subtle, fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashHex, unused, hash, i1, char, fallbackHash, timestamp, random;
2127
2277
  return _ts_generator(this, function(_state) {
2128
2278
  switch(_state.label){
2129
2279
  case 0:
2130
- if (cachedBrowserId) {
2131
- return [
2132
- 2,
2133
- cachedBrowserId
2134
- ];
2135
- }
2280
+ if (cachedBrowserId) return [
2281
+ 2,
2282
+ cachedBrowserId
2283
+ ];
2136
2284
  fingerprintString = JSON.stringify(clientInfo);
2137
- if (!(typeof crypto !== "undefined" && crypto.subtle && crypto.subtle.digest)) return [
2285
+ if (!(typeof crypto !== "undefined" && ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest))) return [
2138
2286
  3,
2139
2287
  5
2140
2288
  ];
@@ -2161,9 +2309,7 @@ function getBrowserID(clientInfo) {
2161
2309
  } else {
2162
2310
  utf8 = unescape(encodeURIComponent(fingerprintString));
2163
2311
  buffer = new Uint8Array(utf8.length);
2164
- for(i = 0; i < utf8.length; i++){
2165
- buffer[i] = utf8.charCodeAt(i);
2166
- }
2312
+ for(i = 0; i < utf8.length; i++)buffer[i] = utf8.charCodeAt(i);
2167
2313
  encodedData = buffer;
2168
2314
  }
2169
2315
  return [
@@ -2172,8 +2318,7 @@ function getBrowserID(clientInfo) {
2172
2318
  ];
2173
2319
  case 3:
2174
2320
  hashBuffer = _state.sent();
2175
- hashArray = Array.from(new Uint8Array(hashBuffer));
2176
- hashHex = hashArray.map(function(b) {
2321
+ hashHex = Array.from(new Uint8Array(hashBuffer)).map(function(b) {
2177
2322
  return b.toString(16).padStart(2, "0");
2178
2323
  }).join("");
2179
2324
  cachedBrowserId = hashHex;
@@ -2182,8 +2327,8 @@ function getBrowserID(clientInfo) {
2182
2327
  hashHex
2183
2328
  ];
2184
2329
  case 4:
2185
- error = _state.sent();
2186
- console.warn("[StormcloudVideoPlayer] crypto.subtle.digest not supported, using fallback hash");
2330
+ unused = _state.sent();
2331
+ console.warn("[StormcloudVideoPlayer] crypto.subtle not supported, using fallback hash");
2187
2332
  return [
2188
2333
  3,
2189
2334
  5
@@ -2207,6 +2352,10 @@ function getBrowserID(clientInfo) {
2207
2352
  });
2208
2353
  })();
2209
2354
  }
2355
+ var mqttTopicPrefix = "adstorm";
2356
+ function setMQTTTopicPrefix(prefix) {
2357
+ mqttTopicPrefix = prefix || "adstorm";
2358
+ }
2210
2359
  var PLAYER_TRACKING_BASE_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking";
2211
2360
  var TRACK_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/metrics/ingest");
2212
2361
  var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
@@ -2215,43 +2364,9 @@ function buildHeaders(licenseKey) {
2215
2364
  var headers = {
2216
2365
  "Content-Type": "application/json"
2217
2366
  };
2218
- if (licenseKey) {
2219
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2220
- }
2367
+ if (licenseKey) headers["Authorization"] = "Bearer ".concat(licenseKey);
2221
2368
  return headers;
2222
2369
  }
2223
- function sendTrackRequest(licenseKey, body) {
2224
- return _async_to_generator(function() {
2225
- var response;
2226
- return _ts_generator(this, function(_state) {
2227
- switch(_state.label){
2228
- case 0:
2229
- return [
2230
- 4,
2231
- fetch(TRACK_URL, {
2232
- method: "POST",
2233
- headers: buildHeaders(licenseKey),
2234
- body: JSON.stringify(body)
2235
- })
2236
- ];
2237
- case 1:
2238
- response = _state.sent();
2239
- if (!response.ok) {
2240
- throw new Error("HTTP error! status: ".concat(response.status));
2241
- }
2242
- return [
2243
- 4,
2244
- response.json()
2245
- ];
2246
- case 2:
2247
- _state.sent();
2248
- return [
2249
- 2
2250
- ];
2251
- }
2252
- });
2253
- })();
2254
- }
2255
2370
  function postJson(url, licenseKey, body) {
2256
2371
  return _async_to_generator(function() {
2257
2372
  var response;
@@ -2268,9 +2383,7 @@ function postJson(url, licenseKey, body) {
2268
2383
  ];
2269
2384
  case 1:
2270
2385
  response = _state.sent();
2271
- if (!response.ok) {
2272
- throw new Error("HTTP error! status: ".concat(response.status));
2273
- }
2386
+ if (!response.ok) throw new Error("HTTP error! status: ".concat(response.status));
2274
2387
  return [
2275
2388
  4,
2276
2389
  response.json()
@@ -2320,9 +2433,33 @@ function buildPlayerMetricEvent(_0) {
2320
2433
  });
2321
2434
  }).apply(this, arguments);
2322
2435
  }
2436
+ function publishOrPost(mqttTopic, httpUrl, licenseKey, body) {
2437
+ return _async_to_generator(function() {
2438
+ return _ts_generator(this, function(_state) {
2439
+ switch(_state.label){
2440
+ case 0:
2441
+ if (isMQTTConfigured()) {
2442
+ publishMQTT(mqttTopic, body);
2443
+ return [
2444
+ 2
2445
+ ];
2446
+ }
2447
+ return [
2448
+ 4,
2449
+ postJson(httpUrl, licenseKey, body)
2450
+ ];
2451
+ case 1:
2452
+ _state.sent();
2453
+ return [
2454
+ 2
2455
+ ];
2456
+ }
2457
+ });
2458
+ })();
2459
+ }
2323
2460
  function sendInitialTracking(_0) {
2324
2461
  return _async_to_generator(function(licenseKey) {
2325
- var context, clientInfo, browserId, trackingData, error;
2462
+ var context, clientInfo, browserId, captureAt, trackingData, metricsBody, error;
2326
2463
  var _arguments = arguments;
2327
2464
  return _ts_generator(this, function(_state) {
2328
2465
  switch(_state.label){
@@ -2343,26 +2480,28 @@ function sendInitialTracking(_0) {
2343
2480
  ];
2344
2481
  case 2:
2345
2482
  browserId = _state.sent();
2483
+ captureAt = /* @__PURE__ */ new Date().toISOString();
2346
2484
  trackingData = _object_spread({
2347
2485
  browserId: browserId
2348
2486
  }, clientInfo);
2487
+ metricsBody = {
2488
+ events: [
2489
+ {
2490
+ player_id: browserId,
2491
+ device_type: clientInfo.deviceType,
2492
+ input_stream_type: context.inputStreamType,
2493
+ os: clientInfo.os,
2494
+ ad_loaded: false,
2495
+ ad_detect: false,
2496
+ license_key: licenseKey,
2497
+ capture_at: captureAt
2498
+ }
2499
+ ],
2500
+ trackingData: trackingData
2501
+ };
2349
2502
  return [
2350
2503
  4,
2351
- sendTrackRequest(licenseKey, {
2352
- events: [
2353
- {
2354
- player_id: browserId,
2355
- device_type: clientInfo.deviceType,
2356
- input_stream_type: context.inputStreamType,
2357
- os: clientInfo.os,
2358
- ad_loaded: false,
2359
- ad_detect: false,
2360
- license_key: licenseKey,
2361
- capture_at: /* @__PURE__ */ new Date().toISOString()
2362
- }
2363
- ],
2364
- trackingData: trackingData
2365
- })
2504
+ publishOrPost("".concat(mqttTopicPrefix, "/tracking/metrics"), TRACK_URL, licenseKey, metricsBody)
2366
2505
  ];
2367
2506
  case 3:
2368
2507
  _state.sent();
@@ -2475,7 +2614,7 @@ function sendAdLoadedTracking(_0, _1) {
2475
2614
  }
2476
2615
  function sendAdImpressionTracking(_0, _1) {
2477
2616
  return _async_to_generator(function(licenseKey, adImpressionInfo) {
2478
- var context, metricEvent, error;
2617
+ var context, metricEvent, heartbeatBody, impressionsBody, error;
2479
2618
  var _arguments = arguments;
2480
2619
  return _ts_generator(this, function(_state) {
2481
2620
  switch(_state.label){
@@ -2497,21 +2636,23 @@ function sendAdImpressionTracking(_0, _1) {
2497
2636
  ];
2498
2637
  case 2:
2499
2638
  metricEvent = _state.sent();
2639
+ heartbeatBody = metricEvent;
2640
+ impressionsBody = {
2641
+ events: [
2642
+ {
2643
+ player_id: metricEvent.player_id,
2644
+ ad_played_count: 1,
2645
+ ad_url: adImpressionInfo.adUrl,
2646
+ license_key: licenseKey,
2647
+ capture_at: adImpressionInfo.timestamp
2648
+ }
2649
+ ]
2650
+ };
2500
2651
  return [
2501
2652
  4,
2502
2653
  Promise.all([
2503
- postJson(HEARTBEAT_URL, licenseKey, metricEvent),
2504
- postJson(IMPRESSIONS_URL, licenseKey, {
2505
- events: [
2506
- {
2507
- player_id: metricEvent.player_id,
2508
- ad_played_count: 1,
2509
- ad_url: adImpressionInfo.adUrl,
2510
- license_key: licenseKey,
2511
- capture_at: adImpressionInfo.timestamp
2512
- }
2513
- ]
2514
- })
2654
+ publishOrPost("".concat(mqttTopicPrefix, "/tracking/heartbeat"), HEARTBEAT_URL, licenseKey, heartbeatBody),
2655
+ publishOrPost("".concat(mqttTopicPrefix, "/tracking/impressions"), IMPRESSIONS_URL, licenseKey, impressionsBody)
2515
2656
  ])
2516
2657
  ];
2517
2658
  case 3:
@@ -2559,7 +2700,7 @@ function sendHeartbeat(_0) {
2559
2700
  heartbeatData = _state.sent();
2560
2701
  return [
2561
2702
  4,
2562
- postJson(HEARTBEAT_URL, licenseKey, heartbeatData)
2703
+ publishOrPost("".concat(mqttTopicPrefix, "/tracking/heartbeat"), HEARTBEAT_URL, licenseKey, heartbeatData)
2563
2704
  ];
2564
2705
  case 3:
2565
2706
  _state.sent();
@@ -3135,9 +3276,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3135
3276
  this.video = config.videoElement;
3136
3277
  this.adTransitionGapMs = (_this_config_adTransitionGapMs = this.config.adTransitionGapMs) !== null && _this_config_adTransitionGapMs !== void 0 ? _this_config_adTransitionGapMs : 100;
3137
3278
  logBrowserInfo(config.debugAdTiming);
3138
- this.vastManager = createVastManager(config.debugAdTiming !== void 0 ? {
3139
- debug: !!config.debugAdTiming
3140
- } : {});
3279
+ this.vastManager = createVastManager(_object_spread({
3280
+ debug: config.debugAdTiming !== void 0 ? !!config.debugAdTiming : false
3281
+ }, config.licenseKey ? {
3282
+ licenseKey: config.licenseKey
3283
+ } : {}));
3141
3284
  var browserForAdLayer = detectBrowser();
3142
3285
  var isSinglePipeline = browserForAdLayer.isSmartTV || !!this.config.singlePipelineMode;
3143
3286
  this.adLayer = createVastAdLayer(this.video, {
@@ -3188,6 +3331,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3188
3331
  this.attach();
3189
3332
  }
3190
3333
  this.initializeTracking();
3334
+ if (!this.config.disableAds) {
3335
+ this.vastManager.initialize().catch(function() {});
3336
+ }
3191
3337
  if (!this.shouldUseNativeHls()) return [
3192
3338
  3,
3193
3339
  3
@@ -4483,6 +4629,11 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4483
4629
  key: "initializeTracking",
4484
4630
  value: function initializeTracking() {
4485
4631
  var _this = this;
4632
+ if (this.config.mqttBrokerUrl) {
4633
+ var topicPrefix = "adstorm";
4634
+ setMQTTTopicPrefix(topicPrefix);
4635
+ initMQTTClient(this.config.mqttBrokerUrl, topicPrefix);
4636
+ }
4486
4637
  sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
4487
4638
  _this.heartbeatInterval = window.setInterval(function() {
4488
4639
  _this.sendHeartbeatIfNeeded();
@@ -6162,6 +6313,9 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
6162
6313
  clearInterval(this.heartbeatInterval);
6163
6314
  this.heartbeatInterval = void 0;
6164
6315
  }
6316
+ if (this.config.mqttBrokerUrl) {
6317
+ disconnectMQTT();
6318
+ }
6165
6319
  (_this_hls = this.hls) === null || _this_hls === void 0 ? void 0 : _this_hls.destroy();
6166
6320
  (_this_adLayer = this.adLayer) === null || _this_adLayer === void 0 ? void 0 : _this_adLayer.destroy();
6167
6321
  this.consecutiveFailures = 0;