stormcloud-video-player 0.8.23 → 0.8.25

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.
Files changed (42) hide show
  1. package/dist/stormcloud-vp.min.js +1 -1
  2. package/lib/index.cjs +1187 -1109
  3. package/lib/index.cjs.map +1 -1
  4. package/lib/index.d.cts +3 -1
  5. package/lib/index.d.ts +3 -1
  6. package/lib/index.js +1028 -954
  7. package/lib/index.js.map +1 -1
  8. package/lib/player/AdBreakOrchestrator.cjs +419 -26
  9. package/lib/player/AdBreakOrchestrator.cjs.map +1 -1
  10. package/lib/player/AdBreakOrchestrator.d.cts +2 -1
  11. package/lib/player/AdConfigManager.cjs +90 -22
  12. package/lib/player/AdConfigManager.cjs.map +1 -1
  13. package/lib/player/AdConfigManager.d.cts +1 -1
  14. package/lib/player/AdPreloadPool.d.cts +1 -1
  15. package/lib/player/AdTimingService.d.cts +1 -1
  16. package/lib/player/HlsEngine.d.cts +1 -1
  17. package/lib/player/PlayerControls.d.cts +1 -1
  18. package/lib/player/Scte35CueManager.d.cts +1 -1
  19. package/lib/player/Scte35Parser.d.cts +1 -1
  20. package/lib/player/StormcloudVideoPlayer.cjs +1184 -1110
  21. package/lib/player/StormcloudVideoPlayer.cjs.map +1 -1
  22. package/lib/player/StormcloudVideoPlayer.d.cts +1 -1
  23. package/lib/player/playerTypes.d.cts +1 -1
  24. package/lib/players/HlsPlayer.cjs +1184 -1110
  25. package/lib/players/HlsPlayer.cjs.map +1 -1
  26. package/lib/players/HlsPlayer.d.cts +1 -1
  27. package/lib/players/index.cjs +1184 -1110
  28. package/lib/players/index.cjs.map +1 -1
  29. package/lib/sdk/hlsAdPlayer.d.cts +1 -1
  30. package/lib/{types-DNiBmPKK.d.cts → types-Bz4aRmzc.d.cts} +1 -0
  31. package/lib/ui/StormcloudVideoPlayer.cjs +1184 -1110
  32. package/lib/ui/StormcloudVideoPlayer.cjs.map +1 -1
  33. package/lib/ui/StormcloudVideoPlayer.d.cts +1 -1
  34. package/lib/utils/ctvVastSignals.cjs.map +1 -1
  35. package/lib/utils/tracking.cjs +411 -20
  36. package/lib/utils/tracking.cjs.map +1 -1
  37. package/lib/utils/tracking.d.cts +3 -2
  38. package/lib/utils/vastEnvironmentSignals.cjs +37 -0
  39. package/lib/utils/vastEnvironmentSignals.cjs.map +1 -1
  40. package/lib/utils/vastEnvironmentSignals.d.cts +4 -1
  41. package/lib/utils/vastMacros.cjs.map +1 -1
  42. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -1555,163 +1555,599 @@ function disconnectMQTT() {
1555
1555
  status = "disconnected";
1556
1556
  }
1557
1557
  }
1558
- // src/utils/tracking.ts
1559
- var cachedBrowserId = null;
1560
- function getClientInfo() {
1561
- var _screen, _screen1, _screen2, _screen3, _screen_orientation, _screen4, _screen5, _window, _window1, _window_screen_orientation, _window_screen, _navigator_languages;
1558
+ // src/utils/vastEnvironmentSignals.ts
1559
+ var AIRY_ANDROID_APP_ID = "com.freeairytv.android";
1560
+ var AIRY_WEBOS_APP_ID = "com.freeairytv.webos";
1561
+ var AIRY_TIZEN_APP_ID = "com.freeairytv.samsung";
1562
+ var AIRY_ROKU_APP_ID = "com.freeairytv.roku";
1563
+ var AIRY_APP_NAME = "AiryTV Movies & TV";
1564
+ var AIRY_DEFAULT_CONTENT_URL = "https://live.airy.tv";
1565
+ var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
1566
+ var PLAYER_ID_STORAGE_KEY = "stormcloud.player.id";
1567
+ var LG_TEST_APP_ID = "com.hulu.plus";
1568
+ var LG_TEST_APP_NAME = "Hulu";
1569
+ var LG_TEST_CONTENT_URL = "https://www.hulu.com/live-tv";
1570
+ var _lgTestDeviceId;
1571
+ function getLgTestDeviceId() {
1572
+ if (!_lgTestDeviceId) _lgTestDeviceId = createUuid();
1573
+ return _lgTestDeviceId;
1574
+ }
1575
+ function isLgWebOS() {
1576
+ if (typeof navigator === "undefined") return false;
1577
+ return /Web0S|webOS|LG Browser|LGSTB|LGE/i.test(navigator.userAgent);
1578
+ }
1579
+ function getDefaultAppId() {
1580
+ if (typeof navigator === "undefined") return AIRY_ANDROID_APP_ID;
1562
1581
  var ua = navigator.userAgent;
1563
- var platform = navigator.platform;
1564
- var vendor = navigator.vendor || "";
1565
- var maxTouchPoints = navigator.maxTouchPoints || 0;
1566
- var memory = navigator.deviceMemory || null;
1567
- var hardwareConcurrency = navigator.hardwareConcurrency || 1;
1568
- var screenInfo = {
1569
- width: (_screen = screen) === null || _screen === void 0 ? void 0 : _screen.width,
1570
- height: (_screen1 = screen) === null || _screen1 === void 0 ? void 0 : _screen1.height,
1571
- availWidth: (_screen2 = screen) === null || _screen2 === void 0 ? void 0 : _screen2.availWidth,
1572
- availHeight: (_screen3 = screen) === null || _screen3 === void 0 ? void 0 : _screen3.availHeight,
1573
- orientation: ((_screen4 = screen) === null || _screen4 === void 0 ? void 0 : (_screen_orientation = _screen4.orientation) === null || _screen_orientation === void 0 ? void 0 : _screen_orientation.type) || "",
1574
- pixelDepth: (_screen5 = screen) === null || _screen5 === void 0 ? void 0 : _screen5.pixelDepth
1575
- };
1576
- var deviceType = "desktop";
1577
- var brand = "Unknown";
1578
- var os = "Unknown";
1579
- var model = "";
1580
- var isSmartTV = false;
1581
- var isAndroid = false;
1582
- var isWebView = false;
1583
- var isWebApp = false;
1584
- if (ua.includes("Web0S")) {
1585
- brand = "LG";
1586
- os = "webOS";
1587
- isSmartTV = true;
1588
- deviceType = "tv";
1589
- var webosMatch = ua.match(/Web0S\/([^\s]+)/);
1590
- model = webosMatch ? "webOS ".concat(webosMatch[1]) : "webOS TV";
1591
- } else if (ua.includes("Tizen")) {
1592
- brand = "Samsung";
1593
- os = "Tizen";
1594
- isSmartTV = true;
1595
- deviceType = "tv";
1596
- var tizenMatch = ua.match(/Tizen\/([^\s]+)/);
1597
- var tvMatch = ua.match(/(?:Smart-TV|SMART-TV|TV)/i) ? "Smart TV" : "";
1598
- model = tizenMatch ? "Tizen ".concat(tizenMatch[1], " ").concat(tvMatch).trim() : "Tizen TV";
1599
- } else if (ua.includes("Philips")) {
1600
- brand = "Philips";
1601
- os = "Saphi";
1602
- isSmartTV = true;
1603
- deviceType = "tv";
1604
- } else if (ua.includes("Sharp") || ua.includes("AQUOS")) {
1605
- brand = "Sharp";
1606
- os = "Android TV";
1607
- isSmartTV = true;
1608
- deviceType = "tv";
1609
- } else if (ua.includes("Android") && (ua.includes("Sony") || vendor.includes("Sony"))) {
1610
- brand = "Sony";
1611
- os = "Android TV";
1612
- isSmartTV = true;
1613
- deviceType = "tv";
1614
- } else if (ua.includes("Android") && (ua.includes("NetCast") || ua.includes("LG"))) {
1615
- brand = "LG";
1616
- os = "Android TV";
1617
- isSmartTV = true;
1618
- deviceType = "tv";
1619
- } else if (ua.includes(" Roku") || ua.includes("Roku/")) {
1620
- brand = "Roku";
1621
- os = "Roku OS";
1622
- isSmartTV = true;
1623
- deviceType = "tv";
1624
- } else if (ua.includes("AppleTV")) {
1625
- brand = "Apple";
1626
- os = "tvOS";
1627
- isSmartTV = true;
1628
- deviceType = "tv";
1582
+ if (/Web0S|webOS|LG Browser|LGSTB|LGE/i.test(ua)) return AIRY_WEBOS_APP_ID;
1583
+ if (/Tizen|Samsung/i.test(ua)) return AIRY_TIZEN_APP_ID;
1584
+ if (/Roku/i.test(ua)) return AIRY_ROKU_APP_ID;
1585
+ return AIRY_ANDROID_APP_ID;
1586
+ }
1587
+ var DEVICE_ID_STORAGE_KEYS = [
1588
+ "rdid",
1589
+ "ifa",
1590
+ "advertisingId",
1591
+ "advertising_id",
1592
+ "deviceAdvertisingId",
1593
+ "aaid",
1594
+ "adid",
1595
+ "rida",
1596
+ "tifa",
1597
+ "lgudid"
1598
+ ];
1599
+ var ANDROID_ID_TYPES = /* @__PURE__ */ new Set([
1600
+ "aaid",
1601
+ "adid"
1602
+ ]);
1603
+ function resolveVastEnvironmentSignals(isCtv) {
1604
+ var _ref;
1605
+ var bridgeSignals = readNativeBridgeSignals();
1606
+ var platformDevice = readPlatformNativeDeviceId();
1607
+ var lg = isCtv && isLgWebOS();
1608
+ var deviceId = bridgeSignals.deviceId || readStoredDeviceId() || platformDevice.deviceId || (lg && platformDevice.limitAdTracking !== true ? getLgTestDeviceId() : void 0);
1609
+ var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || readStoredString("idtype") || platformDevice.deviceIdType || inferDeviceIdType() || (lg ? "lgudid" : void 0);
1610
+ var platformLat = bridgeSignals.deviceId ? bridgeSignals.limitAdTracking : platformDevice.limitAdTracking;
1611
+ var limitAdTracking = deviceId != null ? (_ref = platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking()) !== null && _ref !== void 0 ? _ref : false : void 0;
1612
+ if (isCtv) {
1613
+ return _object_spread_props(_object_spread({
1614
+ isCtv: true,
1615
+ contentUrl: bridgeSignals.contentUrl || readStoredString("contentUrl") || (lg ? LG_TEST_CONTENT_URL : AIRY_DEFAULT_CONTENT_URL),
1616
+ appId: bridgeSignals.appId || readStoredString("appId") || readStoredString("msid") || (lg ? LG_TEST_APP_ID : getDefaultAppId()),
1617
+ appName: bridgeSignals.appName || readStoredString("appName") || readStoredString("an") || (lg ? LG_TEST_APP_NAME : AIRY_APP_NAME),
1618
+ sessionId: getOrCreateCtvSessionId()
1619
+ }, deviceId ? {
1620
+ deviceId: deviceId
1621
+ } : {}, deviceIdType ? {
1622
+ deviceIdType: deviceIdType
1623
+ } : {}, limitAdTracking != null ? {
1624
+ limitAdTracking: limitAdTracking
1625
+ } : {}), {
1626
+ deviceTypeHint: 5
1627
+ });
1629
1628
  }
1630
- if (ua.includes("Android")) {
1631
- isAndroid = true;
1632
- os = "Android";
1633
- deviceType = /Mobile/.test(ua) ? "mobile" : "tablet";
1634
- if (ua.includes("Android") && (maxTouchPoints === 0 || ua.includes("Google TV") || ua.includes("XiaoMi"))) {
1635
- deviceType = "tv";
1636
- isSmartTV = true;
1637
- brand = brand === "Unknown" ? "Android TV" : brand;
1638
- }
1639
- var androidModelMatch = ua.match(/\(([^)]*Android[^)]*)\)/);
1640
- if (androidModelMatch && androidModelMatch[1]) {
1641
- model = androidModelMatch[1];
1642
- }
1629
+ return _object_spread({
1630
+ isCtv: false
1631
+ }, deviceId ? {
1632
+ deviceId: deviceId
1633
+ } : {}, deviceIdType ? {
1634
+ deviceIdType: deviceIdType
1635
+ } : {}, limitAdTracking != null ? {
1636
+ limitAdTracking: limitAdTracking
1637
+ } : {});
1638
+ }
1639
+ function inferDeviceIdType() {
1640
+ if (typeof navigator === "undefined") {
1641
+ return void 0;
1643
1642
  }
1644
- if (/iPad|iPhone|iPod/.test(ua)) {
1645
- os = "iOS";
1646
- deviceType = "mobile";
1647
- brand = "Apple";
1648
- if (navigator.maxTouchPoints > 1 && /iPad/.test(ua)) {
1649
- deviceType = "tablet";
1650
- }
1643
+ var ua = navigator.userAgent;
1644
+ if (/Roku/i.test(ua)) return "rida";
1645
+ if (/Tizen|Samsung/i.test(ua)) return "tifa";
1646
+ if (/AppleTV|Apple TV/i.test(ua)) return "tvOS";
1647
+ if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
1648
+ if (/Web0S|webOS|LG Browser|LGSTB|LGE/i.test(ua)) return "lgudid";
1649
+ if (/Android|Google TV/i.test(ua)) return "aaid";
1650
+ if (/iPhone|iPad|iPod/i.test(ua)) return "idfa";
1651
+ return void 0;
1652
+ }
1653
+ function isEquivalentDeviceIdType(tagType, runtimeType) {
1654
+ if (!tagType || !runtimeType) return false;
1655
+ var tag = tagType.toLowerCase();
1656
+ var runtime = runtimeType.toLowerCase();
1657
+ if (tag === runtime) return true;
1658
+ return ANDROID_ID_TYPES.has(tag) && ANDROID_ID_TYPES.has(runtime);
1659
+ }
1660
+ function resolveNativeDeviceId() {
1661
+ var bridgeSignals = readNativeBridgeSignals();
1662
+ var platformDevice = readPlatformNativeDeviceId();
1663
+ var deviceId = bridgeSignals.deviceId || readStoredDeviceId() || platformDevice.deviceId;
1664
+ if (!deviceId || isMacroPlaceholder(deviceId) || isZeroedAdId(deviceId)) {
1665
+ return void 0;
1651
1666
  }
1652
- if (!isAndroid && !isSmartTV && !/Mobile/.test(ua)) {
1653
- if (ua.includes("Windows")) {
1654
- os = "Windows";
1655
- deviceType = "desktop";
1656
- } else if (ua.includes("Mac") && !/iPhone/.test(ua)) {
1657
- os = "macOS";
1658
- deviceType = "desktop";
1659
- if (maxTouchPoints > 1) deviceType = "tablet";
1660
- } else if (ua.includes("Linux")) {
1661
- os = "Linux";
1662
- deviceType = "desktop";
1663
- }
1667
+ return deviceId;
1668
+ }
1669
+ function getOrCreateStoredUuid(storageKey) {
1670
+ if (typeof window === "undefined") {
1671
+ return void 0;
1664
1672
  }
1665
- if (brand === "Unknown") {
1666
- if (vendor.includes("Google") || ua.includes("Chrome")) brand = "Google";
1667
- if (vendor.includes("Apple")) brand = "Apple";
1668
- if (vendor.includes("Samsung") || ua.includes("SM-")) brand = "Samsung";
1673
+ var existing = readStoredString(storageKey);
1674
+ if (existing) {
1675
+ return existing;
1669
1676
  }
1670
- isWebView = /wv|WebView|Linux; U;/.test(ua);
1671
- if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0) {
1672
- isWebView = true;
1677
+ var id = createUuid();
1678
+ try {
1679
+ var _window_localStorage;
1680
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(storageKey, id);
1681
+ } catch (unused) {}
1682
+ return id;
1683
+ }
1684
+ function getOrCreateCtvSessionId() {
1685
+ var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
1686
+ if (existing) {
1687
+ return existing;
1673
1688
  }
1674
- 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;
1675
- return {
1676
- brand: brand,
1677
- os: os,
1678
- model: model || ua.substring(0, 50) + "...",
1679
- deviceType: deviceType,
1680
- isSmartTV: isSmartTV,
1681
- isAndroid: isAndroid,
1682
- isWebView: isWebView,
1683
- isWebApp: isWebApp,
1684
- domain: window.location.hostname,
1685
- origin: window.location.origin,
1686
- path: window.location.pathname,
1687
- userAgent: ua,
1688
- vendor: vendor,
1689
- platform: platform,
1690
- screen: screenInfo,
1691
- hardwareConcurrency: hardwareConcurrency,
1692
- deviceMemory: memory,
1693
- maxTouchPoints: maxTouchPoints,
1694
- language: navigator.language,
1695
- languages: ((_navigator_languages = navigator.languages) === null || _navigator_languages === void 0 ? void 0 : _navigator_languages.join(",")) || "",
1696
- cookieEnabled: navigator.cookieEnabled,
1697
- doNotTrack: navigator.doNotTrack || "",
1698
- referrer: document.referrer,
1699
- visibilityState: document.visibilityState
1700
- };
1689
+ var sessionId = createUuid();
1690
+ try {
1691
+ var _window_localStorage;
1692
+ (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
1693
+ } catch (unused) {}
1694
+ return sessionId;
1701
1695
  }
1702
- function getBrowserID(clientInfo) {
1696
+ function createUuid() {
1697
+ if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
1698
+ return crypto.randomUUID();
1699
+ }
1700
+ return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
1701
+ var value = Math.floor(Math.random() * 16);
1702
+ var nibble = char === "x" ? value : value & 3 | 8;
1703
+ return nibble.toString(16);
1704
+ });
1705
+ }
1706
+ function readPlatformNativeDeviceId() {
1707
+ if (typeof window === "undefined") return {};
1708
+ try {
1709
+ var _window_webapis;
1710
+ var adinfo = (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.adinfo;
1711
+ if (adinfo) {
1712
+ var tifa = typeof adinfo.getTIFA === "function" ? adinfo.getTIFA() : adinfo.tifa;
1713
+ if (typeof tifa === "string" && tifa && !isMacroPlaceholder(tifa)) {
1714
+ var lat = typeof adinfo.isLATEnabled === "function" ? adinfo.isLATEnabled() : void 0;
1715
+ return _object_spread({
1716
+ deviceId: tifa,
1717
+ deviceIdType: "tifa"
1718
+ }, typeof lat === "boolean" ? {
1719
+ limitAdTracking: lat
1720
+ } : {});
1721
+ }
1722
+ }
1723
+ } catch (unused) {}
1724
+ try {
1725
+ var webOSDev = window.webOSDev;
1726
+ if (webOSDev) {
1727
+ var _webOSDev_lgudid;
1728
+ var lgudid = typeof webOSDev.LGUDID === "function" ? webOSDev.LGUDID() : (_webOSDev_lgudid = webOSDev.lgudid) !== null && _webOSDev_lgudid !== void 0 ? _webOSDev_lgudid : webOSDev.LGUDID;
1729
+ if (typeof lgudid === "string" && lgudid) {
1730
+ if (isZeroedAdId(lgudid)) {
1731
+ return {
1732
+ deviceIdType: "lgudid",
1733
+ limitAdTracking: true
1734
+ };
1735
+ }
1736
+ if (!isMacroPlaceholder(lgudid)) {
1737
+ return {
1738
+ deviceId: lgudid,
1739
+ deviceIdType: "lgudid",
1740
+ limitAdTracking: false
1741
+ };
1742
+ }
1743
+ }
1744
+ }
1745
+ } catch (unused) {}
1746
+ try {
1747
+ var roku = window.Roku;
1748
+ if (roku) {
1749
+ var rida = typeof roku.getPublisherUniqueId === "function" ? roku.getPublisherUniqueId() : roku.rida;
1750
+ if (typeof rida === "string" && rida && !isMacroPlaceholder(rida)) {
1751
+ return {
1752
+ deviceId: rida,
1753
+ deviceIdType: "rida",
1754
+ limitAdTracking: false
1755
+ };
1756
+ }
1757
+ }
1758
+ } catch (unused) {}
1759
+ return {};
1760
+ }
1761
+ var ZEROED_AD_ID_PATTERNS = /* @__PURE__ */ new Set([
1762
+ "38400000-8cf0-11bd-b23e-10b96e40000d",
1763
+ "00000000-0000-0000-0000-000000000000"
1764
+ ]);
1765
+ function isMacroPlaceholder(value) {
1766
+ var t = value.trim();
1767
+ return !t || /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/.test(t) || /^(unknown|null|undefined|none|n\/a|\$\{[^}]+\})$/i.test(t) || ZEROED_AD_ID_PATTERNS.has(t.toLowerCase());
1768
+ }
1769
+ function isZeroedAdId(value) {
1770
+ return ZEROED_AD_ID_PATTERNS.has(value.trim().toLowerCase());
1771
+ }
1772
+ function readNativeBridgeSignals() {
1773
+ if (typeof window === "undefined") {
1774
+ return {};
1775
+ }
1776
+ var candidates = [
1777
+ window.__STORMCLOUD_CTV_AD_INFO__,
1778
+ window.__STORMCLOUD_CTV__,
1779
+ window.stormcloudCtv,
1780
+ window.AiryTV,
1781
+ window.Android,
1782
+ window.webOS,
1783
+ window.tizen,
1784
+ window.amazon
1785
+ ].filter(Boolean);
1786
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1787
+ try {
1788
+ for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1789
+ var source = _step.value;
1790
+ var contentUrl = readBridgeValue(source, [
1791
+ "contentUrl",
1792
+ "url",
1793
+ "videoUrl",
1794
+ "canonicalUrl"
1795
+ ]) || void 0;
1796
+ var appId = readBridgeValue(source, [
1797
+ "appId",
1798
+ "msid",
1799
+ "applicationId",
1800
+ "packageName"
1801
+ ]) || void 0;
1802
+ var appName = readBridgeValue(source, [
1803
+ "appName",
1804
+ "an",
1805
+ "applicationName"
1806
+ ]) || void 0;
1807
+ var deviceId = readBridgeValue(source, [
1808
+ "rdid",
1809
+ "ifa",
1810
+ "advertisingId",
1811
+ "adId",
1812
+ "deviceId",
1813
+ "lgudid",
1814
+ "LGUDID",
1815
+ "tifa",
1816
+ "rida",
1817
+ "afai",
1818
+ "aaid"
1819
+ ]) || void 0;
1820
+ if (!contentUrl && !deviceId && !appId && !appName) continue;
1821
+ var deviceIdType = readBridgeValue(source, [
1822
+ "idtype",
1823
+ "deviceIdType",
1824
+ "advertisingIdType",
1825
+ "idType"
1826
+ ]) || inferDeviceIdType();
1827
+ var limitAdTracking = readBridgeBoolean(source, [
1828
+ "is_lat",
1829
+ "limitAdTracking",
1830
+ "limitedAdTracking",
1831
+ "lat"
1832
+ ]);
1833
+ return _object_spread({}, contentUrl ? {
1834
+ contentUrl: contentUrl
1835
+ } : {}, appId ? {
1836
+ appId: appId
1837
+ } : {}, appName ? {
1838
+ appName: appName
1839
+ } : {}, deviceId ? {
1840
+ deviceId: deviceId
1841
+ } : {}, deviceId && deviceIdType ? {
1842
+ deviceIdType: deviceIdType
1843
+ } : {}, deviceId && limitAdTracking != null ? {
1844
+ limitAdTracking: limitAdTracking
1845
+ } : {});
1846
+ }
1847
+ } catch (err) {
1848
+ _didIteratorError = true;
1849
+ _iteratorError = err;
1850
+ } finally{
1851
+ try {
1852
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1853
+ _iterator.return();
1854
+ }
1855
+ } finally{
1856
+ if (_didIteratorError) {
1857
+ throw _iteratorError;
1858
+ }
1859
+ }
1860
+ }
1861
+ return {};
1862
+ }
1863
+ function readBridgeValue(source, keys) {
1864
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1865
+ try {
1866
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1867
+ var key = _step.value;
1868
+ var value = source === null || source === void 0 ? void 0 : source[key];
1869
+ if (typeof value === "string" && value) {
1870
+ return value;
1871
+ }
1872
+ if (typeof value === "function") {
1873
+ try {
1874
+ var result = value.call(source);
1875
+ if (typeof result === "string" && result) {
1876
+ return result;
1877
+ }
1878
+ } catch (unused) {}
1879
+ }
1880
+ }
1881
+ } catch (err) {
1882
+ _didIteratorError = true;
1883
+ _iteratorError = err;
1884
+ } finally{
1885
+ try {
1886
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1887
+ _iterator.return();
1888
+ }
1889
+ } finally{
1890
+ if (_didIteratorError) {
1891
+ throw _iteratorError;
1892
+ }
1893
+ }
1894
+ }
1895
+ return void 0;
1896
+ }
1897
+ function readBridgeBoolean(source, keys) {
1898
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1899
+ try {
1900
+ for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1901
+ var key = _step.value;
1902
+ var value = source === null || source === void 0 ? void 0 : source[key];
1903
+ var normalized = normalizeBoolean(value);
1904
+ if (normalized != null) {
1905
+ return normalized;
1906
+ }
1907
+ if (typeof value === "function") {
1908
+ try {
1909
+ var result = normalizeBoolean(value.call(source));
1910
+ if (result != null) {
1911
+ return result;
1912
+ }
1913
+ } catch (unused) {}
1914
+ }
1915
+ }
1916
+ } catch (err) {
1917
+ _didIteratorError = true;
1918
+ _iteratorError = err;
1919
+ } finally{
1920
+ try {
1921
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1922
+ _iterator.return();
1923
+ }
1924
+ } finally{
1925
+ if (_didIteratorError) {
1926
+ throw _iteratorError;
1927
+ }
1928
+ }
1929
+ }
1930
+ return void 0;
1931
+ }
1932
+ function readStoredDeviceId() {
1933
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
1934
+ try {
1935
+ for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
1936
+ var key = _step.value;
1937
+ var value = readStoredString(key);
1938
+ if (value) {
1939
+ return value;
1940
+ }
1941
+ }
1942
+ } catch (err) {
1943
+ _didIteratorError = true;
1944
+ _iteratorError = err;
1945
+ } finally{
1946
+ try {
1947
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
1948
+ _iterator.return();
1949
+ }
1950
+ } finally{
1951
+ if (_didIteratorError) {
1952
+ throw _iteratorError;
1953
+ }
1954
+ }
1955
+ }
1956
+ return void 0;
1957
+ }
1958
+ function readStoredString(key) {
1959
+ if (typeof window === "undefined") {
1960
+ return void 0;
1961
+ }
1962
+ try {
1963
+ var _window_localStorage;
1964
+ var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
1965
+ return value || void 0;
1966
+ } catch (unused) {
1967
+ return void 0;
1968
+ }
1969
+ }
1970
+ function readStoredLimitAdTracking() {
1971
+ return normalizeBoolean(readStoredString("limitAdTracking") || readStoredString("limitedAdTracking") || readStoredString("is_lat"));
1972
+ }
1973
+ function normalizeBoolean(value) {
1974
+ if (typeof value === "boolean") {
1975
+ return value;
1976
+ }
1977
+ if (typeof value === "number") {
1978
+ return value === 1;
1979
+ }
1980
+ if (typeof value === "string") {
1981
+ var normalized = value.toLowerCase();
1982
+ if (normalized === "1" || normalized === "true" || normalized === "yes") {
1983
+ return true;
1984
+ }
1985
+ if (normalized === "0" || normalized === "false" || normalized === "no") {
1986
+ return false;
1987
+ }
1988
+ }
1989
+ return void 0;
1990
+ }
1991
+ // src/utils/tracking.ts
1992
+ var cachedBrowserId = null;
1993
+ function buildAnalyticsContext(config) {
1994
+ var context = {};
1995
+ if (config.debugAdTiming) {
1996
+ context.debugAdTiming = true;
1997
+ }
1998
+ if (config.isLiveStream !== void 0) {
1999
+ context.inputStreamType = config.isLiveStream ? "live" : "vod";
2000
+ }
2001
+ return context;
2002
+ }
2003
+ function getClientInfo() {
2004
+ var _screen, _screen1, _screen2, _screen3, _screen_orientation, _screen4, _screen5, _window, _window1, _window_screen_orientation, _window_screen, _navigator_languages;
2005
+ var ua = navigator.userAgent;
2006
+ var platform = navigator.platform;
2007
+ var vendor = navigator.vendor || "";
2008
+ var maxTouchPoints = navigator.maxTouchPoints || 0;
2009
+ var memory = navigator.deviceMemory || null;
2010
+ var hardwareConcurrency = navigator.hardwareConcurrency || 1;
2011
+ var screenInfo = {
2012
+ width: (_screen = screen) === null || _screen === void 0 ? void 0 : _screen.width,
2013
+ height: (_screen1 = screen) === null || _screen1 === void 0 ? void 0 : _screen1.height,
2014
+ availWidth: (_screen2 = screen) === null || _screen2 === void 0 ? void 0 : _screen2.availWidth,
2015
+ availHeight: (_screen3 = screen) === null || _screen3 === void 0 ? void 0 : _screen3.availHeight,
2016
+ orientation: ((_screen4 = screen) === null || _screen4 === void 0 ? void 0 : (_screen_orientation = _screen4.orientation) === null || _screen_orientation === void 0 ? void 0 : _screen_orientation.type) || "",
2017
+ pixelDepth: (_screen5 = screen) === null || _screen5 === void 0 ? void 0 : _screen5.pixelDepth
2018
+ };
2019
+ var deviceType = "desktop";
2020
+ var brand = "Unknown";
2021
+ var os = "Unknown";
2022
+ var model = "";
2023
+ var isSmartTV = false;
2024
+ var isAndroid = false;
2025
+ var isWebView = false;
2026
+ var isWebApp = false;
2027
+ if (ua.includes("Web0S")) {
2028
+ brand = "LG";
2029
+ os = "webOS";
2030
+ isSmartTV = true;
2031
+ deviceType = "tv";
2032
+ var webosMatch = ua.match(/Web0S\/([^\s]+)/);
2033
+ model = webosMatch ? "webOS ".concat(webosMatch[1]) : "webOS TV";
2034
+ } else if (ua.includes("Tizen")) {
2035
+ brand = "Samsung";
2036
+ os = "Tizen";
2037
+ isSmartTV = true;
2038
+ deviceType = "tv";
2039
+ var tizenMatch = ua.match(/Tizen\/([^\s]+)/);
2040
+ var tvMatch = ua.match(/(?:Smart-TV|SMART-TV|TV)/i) ? "Smart TV" : "";
2041
+ model = tizenMatch ? "Tizen ".concat(tizenMatch[1], " ").concat(tvMatch).trim() : "Tizen TV";
2042
+ } else if (ua.includes("Philips")) {
2043
+ brand = "Philips";
2044
+ os = "Saphi";
2045
+ isSmartTV = true;
2046
+ deviceType = "tv";
2047
+ } else if (ua.includes("Sharp") || ua.includes("AQUOS")) {
2048
+ brand = "Sharp";
2049
+ os = "Android TV";
2050
+ isSmartTV = true;
2051
+ deviceType = "tv";
2052
+ } else if (ua.includes("Android") && (ua.includes("Sony") || vendor.includes("Sony"))) {
2053
+ brand = "Sony";
2054
+ os = "Android TV";
2055
+ isSmartTV = true;
2056
+ deviceType = "tv";
2057
+ } else if (ua.includes("Android") && (ua.includes("NetCast") || ua.includes("LG"))) {
2058
+ brand = "LG";
2059
+ os = "Android TV";
2060
+ isSmartTV = true;
2061
+ deviceType = "tv";
2062
+ } else if (ua.includes(" Roku") || ua.includes("Roku/")) {
2063
+ brand = "Roku";
2064
+ os = "Roku OS";
2065
+ isSmartTV = true;
2066
+ deviceType = "tv";
2067
+ } else if (ua.includes("AppleTV")) {
2068
+ brand = "Apple";
2069
+ os = "tvOS";
2070
+ isSmartTV = true;
2071
+ deviceType = "tv";
2072
+ }
2073
+ if (ua.includes("Android")) {
2074
+ isAndroid = true;
2075
+ os = "Android";
2076
+ deviceType = /Mobile/.test(ua) ? "mobile" : "tablet";
2077
+ if (ua.includes("Android") && (maxTouchPoints === 0 || ua.includes("Google TV") || ua.includes("XiaoMi"))) {
2078
+ deviceType = "tv";
2079
+ isSmartTV = true;
2080
+ brand = brand === "Unknown" ? "Android TV" : brand;
2081
+ }
2082
+ var androidModelMatch = ua.match(/\(([^)]*Android[^)]*)\)/);
2083
+ if (androidModelMatch && androidModelMatch[1]) {
2084
+ model = androidModelMatch[1];
2085
+ }
2086
+ }
2087
+ if (/iPad|iPhone|iPod/.test(ua)) {
2088
+ os = "iOS";
2089
+ deviceType = "mobile";
2090
+ brand = "Apple";
2091
+ if (navigator.maxTouchPoints > 1 && /iPad/.test(ua)) {
2092
+ deviceType = "tablet";
2093
+ }
2094
+ }
2095
+ if (!isAndroid && !isSmartTV && !/Mobile/.test(ua)) {
2096
+ if (ua.includes("Windows")) {
2097
+ os = "Windows";
2098
+ deviceType = "desktop";
2099
+ } else if (ua.includes("Mac") && !/iPhone/.test(ua)) {
2100
+ os = "macOS";
2101
+ deviceType = "desktop";
2102
+ if (maxTouchPoints > 1) deviceType = "tablet";
2103
+ } else if (ua.includes("Linux")) {
2104
+ os = "Linux";
2105
+ deviceType = "desktop";
2106
+ }
2107
+ }
2108
+ if (brand === "Unknown") {
2109
+ if (vendor.includes("Google") || ua.includes("Chrome")) brand = "Google";
2110
+ if (vendor.includes("Apple")) brand = "Apple";
2111
+ if (vendor.includes("Samsung") || ua.includes("SM-")) brand = "Samsung";
2112
+ }
2113
+ isWebView = /wv|WebView|Linux; U;/.test(ua);
2114
+ if (((_window = window) === null || _window === void 0 ? void 0 : _window.outerHeight) === 0 && ((_window1 = window) === null || _window1 === void 0 ? void 0 : _window1.outerWidth) === 0) {
2115
+ isWebView = true;
2116
+ }
2117
+ 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;
2118
+ return {
2119
+ brand: brand,
2120
+ os: os,
2121
+ model: model || ua.substring(0, 50) + "...",
2122
+ deviceType: deviceType,
2123
+ isSmartTV: isSmartTV,
2124
+ isAndroid: isAndroid,
2125
+ isWebView: isWebView,
2126
+ isWebApp: isWebApp,
2127
+ domain: window.location.hostname,
2128
+ origin: window.location.origin,
2129
+ path: window.location.pathname,
2130
+ userAgent: ua,
2131
+ vendor: vendor,
2132
+ platform: platform,
2133
+ screen: screenInfo,
2134
+ hardwareConcurrency: hardwareConcurrency,
2135
+ deviceMemory: memory,
2136
+ maxTouchPoints: maxTouchPoints,
2137
+ language: navigator.language,
2138
+ languages: ((_navigator_languages = navigator.languages) === null || _navigator_languages === void 0 ? void 0 : _navigator_languages.join(",")) || "",
2139
+ cookieEnabled: navigator.cookieEnabled,
2140
+ doNotTrack: navigator.doNotTrack || "",
2141
+ referrer: document.referrer,
2142
+ visibilityState: document.visibilityState
2143
+ };
2144
+ }
2145
+ function sha256Hex(input) {
1703
2146
  return _async_to_generator(function() {
1704
- var _crypto_subtle, fingerprintString, encodedData, utf8, buffer, i, hashBuffer, hashHex, unused, hash, i1, char, fallbackHash, timestamp, random;
2147
+ var _crypto_subtle, encodedData, utf8, buffer, i, hashBuffer, unused, hash, i1, char, fallbackHash, timestamp, random;
1705
2148
  return _ts_generator(this, function(_state) {
1706
2149
  switch(_state.label){
1707
2150
  case 0:
1708
- if (cachedBrowserId) {
1709
- return [
1710
- 2,
1711
- cachedBrowserId
1712
- ];
1713
- }
1714
- fingerprintString = JSON.stringify(clientInfo);
1715
2151
  if (!(typeof crypto !== "undefined" && ((_crypto_subtle = crypto.subtle) === null || _crypto_subtle === void 0 ? void 0 : _crypto_subtle.digest))) return [
1716
2152
  3,
1717
2153
  5
@@ -1735,9 +2171,9 @@ function getBrowserID(clientInfo) {
1735
2171
  case 2:
1736
2172
  _state.sent();
1737
2173
  if (typeof TextEncoder !== "undefined") {
1738
- encodedData = new TextEncoder().encode(fingerprintString);
2174
+ encodedData = new TextEncoder().encode(input);
1739
2175
  } else {
1740
- utf8 = unescape(encodeURIComponent(fingerprintString));
2176
+ utf8 = unescape(encodeURIComponent(input));
1741
2177
  buffer = new Uint8Array(utf8.length);
1742
2178
  for(i = 0; i < utf8.length; i++){
1743
2179
  buffer[i] = utf8.charCodeAt(i);
@@ -1750,13 +2186,11 @@ function getBrowserID(clientInfo) {
1750
2186
  ];
1751
2187
  case 3:
1752
2188
  hashBuffer = _state.sent();
1753
- hashHex = Array.from(new Uint8Array(hashBuffer)).map(function(b) {
1754
- return b.toString(16).padStart(2, "0");
1755
- }).join("");
1756
- cachedBrowserId = hashHex;
1757
2189
  return [
1758
2190
  2,
1759
- hashHex
2191
+ Array.from(new Uint8Array(hashBuffer)).map(function(b) {
2192
+ return b.toString(16).padStart(2, "0");
2193
+ }).join("")
1760
2194
  ];
1761
2195
  case 4:
1762
2196
  unused = _state.sent();
@@ -1767,15 +2201,50 @@ function getBrowserID(clientInfo) {
1767
2201
  ];
1768
2202
  case 5:
1769
2203
  hash = 0;
1770
- for(i1 = 0; i1 < fingerprintString.length; i1++){
1771
- char = fingerprintString.charCodeAt(i1);
2204
+ for(i1 = 0; i1 < input.length; i1++){
2205
+ char = input.charCodeAt(i1);
1772
2206
  hash = (hash << 5) - hash + char;
1773
2207
  hash = hash & hash;
1774
2208
  }
1775
2209
  fallbackHash = Math.abs(hash).toString(16).padStart(8, "0");
1776
2210
  timestamp = Date.now().toString(16).padStart(12, "0");
1777
2211
  random = Math.random().toString(16).substring(2, 14).padStart(12, "0");
1778
- cachedBrowserId = (fallbackHash + timestamp + random).padEnd(64, "0");
2212
+ return [
2213
+ 2,
2214
+ (fallbackHash + timestamp + random).padEnd(64, "0")
2215
+ ];
2216
+ }
2217
+ });
2218
+ })();
2219
+ }
2220
+ function resolvePlayerIdentitySeed(clientInfo) {
2221
+ var nativeDeviceId = resolveNativeDeviceId();
2222
+ if (nativeDeviceId) {
2223
+ return "device:".concat(nativeDeviceId);
2224
+ }
2225
+ var persistedId = getOrCreateStoredUuid(PLAYER_ID_STORAGE_KEY);
2226
+ if (persistedId) {
2227
+ return "persisted:".concat(persistedId);
2228
+ }
2229
+ return "fingerprint:".concat(JSON.stringify(clientInfo));
2230
+ }
2231
+ function getBrowserID(clientInfo) {
2232
+ return _async_to_generator(function() {
2233
+ return _ts_generator(this, function(_state) {
2234
+ switch(_state.label){
2235
+ case 0:
2236
+ if (cachedBrowserId) {
2237
+ return [
2238
+ 2,
2239
+ cachedBrowserId
2240
+ ];
2241
+ }
2242
+ return [
2243
+ 4,
2244
+ sha256Hex(resolvePlayerIdentitySeed(clientInfo))
2245
+ ];
2246
+ case 1:
2247
+ cachedBrowserId = _state.sent();
1779
2248
  return [
1780
2249
  2,
1781
2250
  cachedBrowserId
@@ -1789,19 +2258,26 @@ function canPublish(licenseKey) {
1789
2258
  }
1790
2259
  function buildPlayerMetricEvent() {
1791
2260
  return _async_to_generator(function() {
1792
- var context, flags, _flags_captureAt, _flags_adLoaded, _flags_adDetect, clientInfo, playerId, captureAt;
2261
+ var context, flags, _flags_captureAt, _flags_adLoaded, _flags_adDetect, clientInfo, debugAdTiming, playerId, captureAt;
1793
2262
  var _arguments = arguments;
1794
2263
  return _ts_generator(this, function(_state) {
1795
2264
  switch(_state.label){
1796
2265
  case 0:
1797
2266
  context = _arguments.length > 0 && _arguments[0] !== void 0 ? _arguments[0] : {}, flags = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
1798
2267
  clientInfo = getClientInfo();
2268
+ debugAdTiming = !!context.debugAdTiming;
2269
+ if (debugAdTiming) {
2270
+ console.log("[StormcloudVideoPlayer] clientInfo: ", JSON.stringify(clientInfo, null, 2));
2271
+ }
1799
2272
  return [
1800
2273
  4,
1801
2274
  getBrowserID(clientInfo)
1802
2275
  ];
1803
2276
  case 1:
1804
2277
  playerId = _state.sent();
2278
+ if (debugAdTiming) {
2279
+ console.log("[StormcloudVideoPlayer] playerId: ", playerId);
2280
+ }
1805
2281
  captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
1806
2282
  return [
1807
2283
  2,
@@ -1875,163 +2351,15 @@ function sendInitialTracking(_0) {
1875
2351
  }
1876
2352
  });
1877
2353
  }).apply(this, arguments);
1878
- }
1879
- function sendAdDetectTracking(_0, _1) {
1880
- return _async_to_generator(function(licenseKey, adDetectInfo) {
1881
- var context, error;
1882
- var _arguments = arguments;
1883
- return _ts_generator(this, function(_state) {
1884
- switch(_state.label){
1885
- case 0:
1886
- context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
1887
- _state.label = 1;
1888
- case 1:
1889
- _state.trys.push([
1890
- 1,
1891
- 3,
1892
- ,
1893
- 4
1894
- ]);
1895
- return [
1896
- 4,
1897
- sendHeartbeat(licenseKey, context, {
1898
- adDetect: true,
1899
- captureAt: adDetectInfo.timestamp
1900
- })
1901
- ];
1902
- case 2:
1903
- _state.sent();
1904
- return [
1905
- 3,
1906
- 4
1907
- ];
1908
- case 3:
1909
- error = _state.sent();
1910
- console.error("[StormcloudVideoPlayer] Error sending ad detect tracking:", error);
1911
- return [
1912
- 3,
1913
- 4
1914
- ];
1915
- case 4:
1916
- return [
1917
- 2
1918
- ];
1919
- }
1920
- });
1921
- }).apply(this, arguments);
1922
- }
1923
- function sendAdLoadedTracking(_0, _1) {
1924
- return _async_to_generator(function(licenseKey, adLoadedInfo) {
1925
- var context, error;
1926
- var _arguments = arguments;
1927
- return _ts_generator(this, function(_state) {
1928
- switch(_state.label){
1929
- case 0:
1930
- context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
1931
- _state.label = 1;
1932
- case 1:
1933
- _state.trys.push([
1934
- 1,
1935
- 3,
1936
- ,
1937
- 4
1938
- ]);
1939
- return [
1940
- 4,
1941
- sendHeartbeat(licenseKey, context, {
1942
- adLoaded: true,
1943
- captureAt: adLoadedInfo.timestamp
1944
- })
1945
- ];
1946
- case 2:
1947
- _state.sent();
1948
- return [
1949
- 3,
1950
- 4
1951
- ];
1952
- case 3:
1953
- error = _state.sent();
1954
- console.error("[StormcloudVideoPlayer] Error sending ad loaded tracking:", error);
1955
- return [
1956
- 3,
1957
- 4
1958
- ];
1959
- case 4:
1960
- return [
1961
- 2
1962
- ];
1963
- }
1964
- });
1965
- }).apply(this, arguments);
1966
- }
1967
- function sendAdImpressionTracking(_0, _1) {
1968
- return _async_to_generator(function(licenseKey, adImpressionInfo) {
1969
- var context, metricEvent, error;
1970
- var _arguments = arguments;
1971
- return _ts_generator(this, function(_state) {
1972
- switch(_state.label){
1973
- case 0:
1974
- context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
1975
- if (!canPublish(licenseKey)) return [
1976
- 2
1977
- ];
1978
- _state.label = 1;
1979
- case 1:
1980
- _state.trys.push([
1981
- 1,
1982
- 3,
1983
- ,
1984
- 4
1985
- ]);
1986
- return [
1987
- 4,
1988
- buildPlayerMetricEvent(context, {
1989
- captureAt: adImpressionInfo.timestamp
1990
- })
1991
- ];
1992
- case 2:
1993
- metricEvent = _state.sent();
1994
- publishTracking(licenseKey, "heartbeat", metricEvent);
1995
- publishTracking(licenseKey, "impressions", {
1996
- events: [
1997
- {
1998
- player_id: metricEvent.player_id,
1999
- ad_played_count: 1,
2000
- ad_url: adImpressionInfo.adUrl,
2001
- capture_at: adImpressionInfo.timestamp
2002
- }
2003
- ]
2004
- });
2005
- return [
2006
- 3,
2007
- 4
2008
- ];
2009
- case 3:
2010
- error = _state.sent();
2011
- console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
2012
- return [
2013
- 3,
2014
- 4
2015
- ];
2016
- case 4:
2017
- return [
2018
- 2
2019
- ];
2020
- }
2021
- });
2022
- }).apply(this, arguments);
2023
- }
2024
- function sendHeartbeat(_0) {
2025
- return _async_to_generator(function(licenseKey) {
2026
- var context, flags, heartbeatData, error;
2354
+ }
2355
+ function sendAdDetectTracking(_0, _1) {
2356
+ return _async_to_generator(function(licenseKey, adDetectInfo) {
2357
+ var context, error;
2027
2358
  var _arguments = arguments;
2028
2359
  return _ts_generator(this, function(_state) {
2029
2360
  switch(_state.label){
2030
2361
  case 0:
2031
- context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2032
- if (!canPublish(licenseKey)) return [
2033
- 2
2034
- ];
2362
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2035
2363
  _state.label = 1;
2036
2364
  case 1:
2037
2365
  _state.trys.push([
@@ -2042,18 +2370,20 @@ function sendHeartbeat(_0) {
2042
2370
  ]);
2043
2371
  return [
2044
2372
  4,
2045
- buildPlayerMetricEvent(context, flags)
2373
+ sendHeartbeat(licenseKey, context, {
2374
+ adDetect: true,
2375
+ captureAt: adDetectInfo.timestamp
2376
+ })
2046
2377
  ];
2047
2378
  case 2:
2048
- heartbeatData = _state.sent();
2049
- publishTracking(licenseKey, "heartbeat", heartbeatData);
2379
+ _state.sent();
2050
2380
  return [
2051
2381
  3,
2052
2382
  4
2053
2383
  ];
2054
2384
  case 3:
2055
2385
  error = _state.sent();
2056
- console.error("[StormcloudVideoPlayer] Error sending heartbeat:", error);
2386
+ console.error("[StormcloudVideoPlayer] Error sending ad detect tracking:", error);
2057
2387
  return [
2058
2388
  3,
2059
2389
  4
@@ -2066,666 +2396,404 @@ function sendHeartbeat(_0) {
2066
2396
  });
2067
2397
  }).apply(this, arguments);
2068
2398
  }
2069
- // src/utils/polyfills.ts
2070
- function polyfillURLSearchParams() {
2071
- if (typeof URLSearchParams !== "undefined") {
2072
- return;
2073
- }
2074
- var URLSearchParamsPolyfill = /*#__PURE__*/ function() {
2075
- "use strict";
2076
- function URLSearchParamsPolyfill(init) {
2077
- var _this = this;
2078
- _class_call_check(this, URLSearchParamsPolyfill);
2079
- this.params = /* @__PURE__ */ new Map();
2080
- if (typeof init === "string") {
2081
- this.parseQueryString(init);
2082
- } else if (_instanceof(init, URLSearchParamsPolyfill)) {
2083
- init.forEach(function(value, key) {
2084
- _this.append(key, value);
2085
- });
2086
- }
2087
- }
2088
- _create_class(URLSearchParamsPolyfill, [
2089
- {
2090
- key: "parseQueryString",
2091
- value: function parseQueryString(query) {
2092
- var _this = this;
2093
- var cleanQuery = query.startsWith("?") ? query.slice(1) : query;
2094
- if (!cleanQuery) return;
2095
- cleanQuery.split("&").forEach(function(param) {
2096
- var _param_split = _sliced_to_array(param.split("="), 2), key = _param_split[0], value = _param_split[1];
2097
- if (key) {
2098
- var decodedKey = _this.safeDecodeURIComponent(key);
2099
- var decodedValue = value ? _this.safeDecodeURIComponent(value) : "";
2100
- _this.append(decodedKey, decodedValue);
2101
- }
2102
- });
2103
- }
2104
- },
2105
- {
2106
- key: "safeDecodeURIComponent",
2107
- value: function safeDecodeURIComponent(str) {
2108
- try {
2109
- return decodeURIComponent(str.replace(/\+/g, " "));
2110
- } catch (e) {
2111
- return str;
2112
- }
2113
- }
2114
- },
2115
- {
2116
- key: "append",
2117
- value: function append(name, value) {
2118
- var values = this.params.get(name) || [];
2119
- values.push(String(value));
2120
- this.params.set(name, values);
2121
- }
2122
- },
2123
- {
2124
- key: "delete",
2125
- value: function _delete(name) {
2126
- this.params.delete(name);
2127
- }
2128
- },
2129
- {
2130
- key: "get",
2131
- value: function get(name) {
2132
- var values = this.params.get(name);
2133
- return values && values.length > 0 && values[0] !== void 0 ? values[0] : null;
2134
- }
2135
- },
2136
- {
2137
- key: "getAll",
2138
- value: function getAll(name) {
2139
- return this.params.get(name) || [];
2140
- }
2141
- },
2142
- {
2143
- key: "has",
2144
- value: function has(name) {
2145
- return this.params.has(name);
2146
- }
2147
- },
2148
- {
2149
- key: "set",
2150
- value: function set(name, value) {
2151
- this.params.set(name, [
2152
- String(value)
2153
- ]);
2154
- }
2155
- },
2156
- {
2157
- key: "forEach",
2158
- value: function forEach(callback) {
2159
- var _this = this;
2160
- this.params.forEach(function(values, key) {
2161
- values.forEach(function(value) {
2162
- callback(value, key, _this);
2163
- });
2164
- });
2165
- }
2166
- },
2167
- {
2168
- key: "toString",
2169
- value: function toString() {
2170
- var parts = [];
2171
- this.params.forEach(function(values, key) {
2172
- values.forEach(function(value) {
2173
- parts.push("".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value)));
2174
- });
2175
- });
2176
- return parts.join("&");
2177
- }
2178
- }
2179
- ]);
2180
- return URLSearchParamsPolyfill;
2181
- }();
2182
- window.URLSearchParams = URLSearchParamsPolyfill;
2183
- }
2184
- function polyfillTextEncoder() {
2185
- if (typeof TextEncoder !== "undefined") {
2186
- return;
2187
- }
2188
- var TextEncoderPolyfill = /*#__PURE__*/ function() {
2189
- "use strict";
2190
- function TextEncoderPolyfill() {
2191
- _class_call_check(this, TextEncoderPolyfill);
2192
- this.encoding = "utf-8";
2193
- }
2194
- _create_class(TextEncoderPolyfill, [
2195
- {
2196
- key: "encode",
2197
- value: function encode(str) {
2198
- var utf8 = [];
2199
- for(var i = 0; i < str.length; i++){
2200
- var charcode = str.charCodeAt(i);
2201
- if (charcode < 128) {
2202
- utf8.push(charcode);
2203
- } else if (charcode < 2048) {
2204
- utf8.push(192 | charcode >> 6, 128 | charcode & 63);
2205
- } else if (charcode < 55296 || charcode >= 57344) {
2206
- utf8.push(224 | charcode >> 12, 128 | charcode >> 6 & 63, 128 | charcode & 63);
2207
- } else {
2208
- i++;
2209
- charcode = 65536 + ((charcode & 1023) << 10 | str.charCodeAt(i) & 1023);
2210
- utf8.push(240 | charcode >> 18, 128 | charcode >> 12 & 63, 128 | charcode >> 6 & 63, 128 | charcode & 63);
2211
- }
2212
- }
2213
- return new Uint8Array(utf8);
2214
- }
2215
- }
2216
- ]);
2217
- return TextEncoderPolyfill;
2218
- }();
2219
- window.TextEncoder = TextEncoderPolyfill;
2220
- }
2221
- function polyfillPromiseFinally() {
2222
- if (typeof Promise !== "undefined" && !Promise.prototype.finally) {
2223
- Promise.prototype.finally = function(callback) {
2224
- var constructor = this.constructor;
2225
- return this.then(function(value) {
2226
- return constructor.resolve(callback()).then(function() {
2227
- return value;
2228
- });
2229
- }, function(reason) {
2230
- return constructor.resolve(callback()).then(function() {
2231
- throw reason;
2232
- });
2233
- });
2234
- };
2235
- }
2236
- }
2237
- function polyfillObjectAssign() {
2238
- if (typeof Object.assign !== "function") {
2239
- Object.assign = function(target) {
2240
- for(var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
2241
- sources[_key - 1] = arguments[_key];
2242
- }
2243
- if (target == null) {
2244
- throw new TypeError("Cannot convert undefined or null to object");
2245
- }
2246
- var to = Object(target);
2247
- for(var i = 0; i < sources.length; i++){
2248
- var nextSource = sources[i];
2249
- if (nextSource != null) {
2250
- for(var nextKey in nextSource){
2251
- if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
2252
- to[nextKey] = nextSource[nextKey];
2253
- }
2254
- }
2255
- }
2256
- }
2257
- return to;
2258
- };
2259
- }
2260
- }
2261
- function polyfillArrayFrom() {
2262
- if (!Array.from) {
2263
- Array.from = function(arrayLike, mapFn, thisArg) {
2264
- var items = Object(arrayLike);
2265
- if (arrayLike == null) {
2266
- throw new TypeError("Array.from requires an array-like object");
2267
- }
2268
- var len = items.length >>> 0;
2269
- var result = new Array(len);
2270
- for(var i = 0; i < len; i++){
2271
- if (mapFn) {
2272
- result[i] = mapFn.call(thisArg, items[i], i);
2273
- } else {
2274
- result[i] = items[i];
2275
- }
2276
- }
2277
- return result;
2278
- };
2279
- }
2280
- }
2281
- function polyfillStringStartsWith() {
2282
- if (!String.prototype.startsWith) {
2283
- String.prototype.startsWith = function(search, pos) {
2284
- pos = !pos || pos < 0 ? 0 : +pos;
2285
- return this.substring(pos, pos + search.length) === search;
2286
- };
2287
- }
2288
- }
2289
- function polyfillStringEndsWith() {
2290
- if (!String.prototype.endsWith) {
2291
- String.prototype.endsWith = function(search, length) {
2292
- if (length === void 0 || length > this.length) {
2293
- length = this.length;
2399
+ function sendAdLoadedTracking(_0, _1) {
2400
+ return _async_to_generator(function(licenseKey, adLoadedInfo) {
2401
+ var context, error;
2402
+ var _arguments = arguments;
2403
+ return _ts_generator(this, function(_state) {
2404
+ switch(_state.label){
2405
+ case 0:
2406
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2407
+ _state.label = 1;
2408
+ case 1:
2409
+ _state.trys.push([
2410
+ 1,
2411
+ 3,
2412
+ ,
2413
+ 4
2414
+ ]);
2415
+ return [
2416
+ 4,
2417
+ sendHeartbeat(licenseKey, context, {
2418
+ adLoaded: true,
2419
+ captureAt: adLoadedInfo.timestamp
2420
+ })
2421
+ ];
2422
+ case 2:
2423
+ _state.sent();
2424
+ return [
2425
+ 3,
2426
+ 4
2427
+ ];
2428
+ case 3:
2429
+ error = _state.sent();
2430
+ console.error("[StormcloudVideoPlayer] Error sending ad loaded tracking:", error);
2431
+ return [
2432
+ 3,
2433
+ 4
2434
+ ];
2435
+ case 4:
2436
+ return [
2437
+ 2
2438
+ ];
2294
2439
  }
2295
- return this.substring(length - search.length, length) === search;
2296
- };
2297
- }
2440
+ });
2441
+ }).apply(this, arguments);
2298
2442
  }
2299
- function polyfillStringIncludes() {
2300
- if (!String.prototype.includes) {
2301
- String.prototype.includes = function(search, start) {
2302
- if (typeof start !== "number") {
2303
- start = 0;
2304
- }
2305
- if (start + search.length > this.length) {
2306
- return false;
2443
+ function sendAdImpressionTracking(_0, _1) {
2444
+ return _async_to_generator(function(licenseKey, adImpressionInfo) {
2445
+ var context, metricEvent, error;
2446
+ var _arguments = arguments;
2447
+ return _ts_generator(this, function(_state) {
2448
+ switch(_state.label){
2449
+ case 0:
2450
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2451
+ if (!canPublish(licenseKey)) return [
2452
+ 2
2453
+ ];
2454
+ _state.label = 1;
2455
+ case 1:
2456
+ _state.trys.push([
2457
+ 1,
2458
+ 3,
2459
+ ,
2460
+ 4
2461
+ ]);
2462
+ return [
2463
+ 4,
2464
+ buildPlayerMetricEvent(context, {
2465
+ captureAt: adImpressionInfo.timestamp
2466
+ })
2467
+ ];
2468
+ case 2:
2469
+ metricEvent = _state.sent();
2470
+ publishTracking(licenseKey, "heartbeat", metricEvent);
2471
+ publishTracking(licenseKey, "impressions", {
2472
+ events: [
2473
+ {
2474
+ player_id: metricEvent.player_id,
2475
+ ad_played_count: 1,
2476
+ ad_url: adImpressionInfo.adUrl,
2477
+ capture_at: adImpressionInfo.timestamp
2478
+ }
2479
+ ]
2480
+ });
2481
+ return [
2482
+ 3,
2483
+ 4
2484
+ ];
2485
+ case 3:
2486
+ error = _state.sent();
2487
+ console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
2488
+ return [
2489
+ 3,
2490
+ 4
2491
+ ];
2492
+ case 4:
2493
+ return [
2494
+ 2
2495
+ ];
2307
2496
  }
2308
- return this.indexOf(search, start) !== -1;
2309
- };
2310
- }
2311
- }
2312
- function initializePolyfills() {
2313
- polyfillObjectAssign();
2314
- polyfillArrayFrom();
2315
- polyfillStringStartsWith();
2316
- polyfillStringEndsWith();
2317
- polyfillStringIncludes();
2318
- polyfillURLSearchParams();
2319
- polyfillTextEncoder();
2320
- polyfillPromiseFinally();
2321
- }
2322
- // src/utils/vastEnvironmentSignals.ts
2323
- var AIRY_ANDROID_APP_ID = "com.freeairytv.android";
2324
- var AIRY_WEBOS_APP_ID = "com.freeairytv.webos";
2325
- var AIRY_TIZEN_APP_ID = "com.freeairytv.samsung";
2326
- var AIRY_ROKU_APP_ID = "com.freeairytv.roku";
2327
- var AIRY_APP_NAME = "AiryTV Movies & TV";
2328
- var AIRY_DEFAULT_CONTENT_URL = "https://live.airy.tv";
2329
- var CTV_SESSION_STORAGE_KEY = "stormcloud.ctv.sid";
2330
- var LG_TEST_APP_ID = "com.hulu.plus";
2331
- var LG_TEST_APP_NAME = "Hulu";
2332
- var LG_TEST_CONTENT_URL = "https://www.hulu.com/live-tv";
2333
- var _lgTestDeviceId;
2334
- function getLgTestDeviceId() {
2335
- if (!_lgTestDeviceId) _lgTestDeviceId = createUuid();
2336
- return _lgTestDeviceId;
2337
- }
2338
- function isLgWebOS() {
2339
- if (typeof navigator === "undefined") return false;
2340
- return /Web0S|webOS|LG Browser|LGSTB|LGE/i.test(navigator.userAgent);
2341
- }
2342
- function getDefaultAppId() {
2343
- if (typeof navigator === "undefined") return AIRY_ANDROID_APP_ID;
2344
- var ua = navigator.userAgent;
2345
- if (/Web0S|webOS|LG Browser|LGSTB|LGE/i.test(ua)) return AIRY_WEBOS_APP_ID;
2346
- if (/Tizen|Samsung/i.test(ua)) return AIRY_TIZEN_APP_ID;
2347
- if (/Roku/i.test(ua)) return AIRY_ROKU_APP_ID;
2348
- return AIRY_ANDROID_APP_ID;
2349
- }
2350
- var DEVICE_ID_STORAGE_KEYS = [
2351
- "rdid",
2352
- "ifa",
2353
- "advertisingId",
2354
- "advertising_id",
2355
- "deviceAdvertisingId",
2356
- "aaid",
2357
- "adid",
2358
- "rida",
2359
- "tifa",
2360
- "lgudid"
2361
- ];
2362
- var ANDROID_ID_TYPES = /* @__PURE__ */ new Set([
2363
- "aaid",
2364
- "adid"
2365
- ]);
2366
- function resolveVastEnvironmentSignals(isCtv) {
2367
- var _ref;
2368
- var bridgeSignals = readNativeBridgeSignals();
2369
- var platformDevice = readPlatformNativeDeviceId();
2370
- var lg = isCtv && isLgWebOS();
2371
- var deviceId = bridgeSignals.deviceId || readStoredDeviceId() || platformDevice.deviceId || (lg && platformDevice.limitAdTracking !== true ? getLgTestDeviceId() : void 0);
2372
- var deviceIdType = bridgeSignals.deviceIdType || readStoredString("deviceIdType") || readStoredString("idtype") || platformDevice.deviceIdType || inferDeviceIdType() || (lg ? "lgudid" : void 0);
2373
- var platformLat = bridgeSignals.deviceId ? bridgeSignals.limitAdTracking : platformDevice.limitAdTracking;
2374
- var limitAdTracking = deviceId != null ? (_ref = platformLat !== null && platformLat !== void 0 ? platformLat : readStoredLimitAdTracking()) !== null && _ref !== void 0 ? _ref : false : void 0;
2375
- if (isCtv) {
2376
- return _object_spread_props(_object_spread({
2377
- isCtv: true,
2378
- contentUrl: bridgeSignals.contentUrl || readStoredString("contentUrl") || (lg ? LG_TEST_CONTENT_URL : AIRY_DEFAULT_CONTENT_URL),
2379
- appId: bridgeSignals.appId || readStoredString("appId") || readStoredString("msid") || (lg ? LG_TEST_APP_ID : getDefaultAppId()),
2380
- appName: bridgeSignals.appName || readStoredString("appName") || readStoredString("an") || (lg ? LG_TEST_APP_NAME : AIRY_APP_NAME),
2381
- sessionId: getOrCreateCtvSessionId()
2382
- }, deviceId ? {
2383
- deviceId: deviceId
2384
- } : {}, deviceIdType ? {
2385
- deviceIdType: deviceIdType
2386
- } : {}, limitAdTracking != null ? {
2387
- limitAdTracking: limitAdTracking
2388
- } : {}), {
2389
- deviceTypeHint: 5
2390
2497
  });
2391
- }
2392
- return _object_spread({
2393
- isCtv: false
2394
- }, deviceId ? {
2395
- deviceId: deviceId
2396
- } : {}, deviceIdType ? {
2397
- deviceIdType: deviceIdType
2398
- } : {}, limitAdTracking != null ? {
2399
- limitAdTracking: limitAdTracking
2400
- } : {});
2401
- }
2402
- function inferDeviceIdType() {
2403
- if (typeof navigator === "undefined") {
2404
- return void 0;
2405
- }
2406
- var ua = navigator.userAgent;
2407
- if (/Roku/i.test(ua)) return "rida";
2408
- if (/Tizen|Samsung/i.test(ua)) return "tifa";
2409
- if (/AppleTV|Apple TV/i.test(ua)) return "tvOS";
2410
- if (/AFT|Fire TV|Amazon/i.test(ua)) return "afai";
2411
- if (/Web0S|webOS|LG Browser|LGSTB|LGE/i.test(ua)) return "lgudid";
2412
- if (/Android|Google TV/i.test(ua)) return "aaid";
2413
- if (/iPhone|iPad|iPod/i.test(ua)) return "idfa";
2414
- return void 0;
2415
- }
2416
- function isEquivalentDeviceIdType(tagType, runtimeType) {
2417
- if (!tagType || !runtimeType) return false;
2418
- var tag = tagType.toLowerCase();
2419
- var runtime = runtimeType.toLowerCase();
2420
- if (tag === runtime) return true;
2421
- return ANDROID_ID_TYPES.has(tag) && ANDROID_ID_TYPES.has(runtime);
2498
+ }).apply(this, arguments);
2422
2499
  }
2423
- function getOrCreateCtvSessionId() {
2424
- var existing = readStoredString(CTV_SESSION_STORAGE_KEY);
2425
- if (existing) {
2426
- return existing;
2427
- }
2428
- var sessionId = createUuid();
2429
- try {
2430
- var _window_localStorage;
2431
- (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.setItem(CTV_SESSION_STORAGE_KEY, sessionId);
2432
- } catch (unused) {}
2433
- return sessionId;
2500
+ function sendHeartbeat(_0) {
2501
+ return _async_to_generator(function(licenseKey) {
2502
+ var context, flags, heartbeatData, error;
2503
+ var _arguments = arguments;
2504
+ return _ts_generator(this, function(_state) {
2505
+ switch(_state.label){
2506
+ case 0:
2507
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2508
+ if (!canPublish(licenseKey)) return [
2509
+ 2
2510
+ ];
2511
+ _state.label = 1;
2512
+ case 1:
2513
+ _state.trys.push([
2514
+ 1,
2515
+ 3,
2516
+ ,
2517
+ 4
2518
+ ]);
2519
+ return [
2520
+ 4,
2521
+ buildPlayerMetricEvent(context, flags)
2522
+ ];
2523
+ case 2:
2524
+ heartbeatData = _state.sent();
2525
+ publishTracking(licenseKey, "heartbeat", heartbeatData);
2526
+ return [
2527
+ 3,
2528
+ 4
2529
+ ];
2530
+ case 3:
2531
+ error = _state.sent();
2532
+ console.error("[StormcloudVideoPlayer] Error sending heartbeat:", error);
2533
+ return [
2534
+ 3,
2535
+ 4
2536
+ ];
2537
+ case 4:
2538
+ return [
2539
+ 2
2540
+ ];
2541
+ }
2542
+ });
2543
+ }).apply(this, arguments);
2434
2544
  }
2435
- function createUuid() {
2436
- if (typeof crypto !== "undefined" && typeof crypto.randomUUID === "function") {
2437
- return crypto.randomUUID();
2545
+ // src/utils/polyfills.ts
2546
+ function polyfillURLSearchParams() {
2547
+ if (typeof URLSearchParams !== "undefined") {
2548
+ return;
2438
2549
  }
2439
- return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function(char) {
2440
- var value = Math.floor(Math.random() * 16);
2441
- var nibble = char === "x" ? value : value & 3 | 8;
2442
- return nibble.toString(16);
2443
- });
2444
- }
2445
- function readPlatformNativeDeviceId() {
2446
- if (typeof window === "undefined") return {};
2447
- try {
2448
- var _window_webapis;
2449
- var adinfo = (_window_webapis = window.webapis) === null || _window_webapis === void 0 ? void 0 : _window_webapis.adinfo;
2450
- if (adinfo) {
2451
- var tifa = typeof adinfo.getTIFA === "function" ? adinfo.getTIFA() : adinfo.tifa;
2452
- if (typeof tifa === "string" && tifa && !isMacroPlaceholder(tifa)) {
2453
- var lat = typeof adinfo.isLATEnabled === "function" ? adinfo.isLATEnabled() : void 0;
2454
- return _object_spread({
2455
- deviceId: tifa,
2456
- deviceIdType: "tifa"
2457
- }, typeof lat === "boolean" ? {
2458
- limitAdTracking: lat
2459
- } : {});
2550
+ var URLSearchParamsPolyfill = /*#__PURE__*/ function() {
2551
+ "use strict";
2552
+ function URLSearchParamsPolyfill(init) {
2553
+ var _this = this;
2554
+ _class_call_check(this, URLSearchParamsPolyfill);
2555
+ this.params = /* @__PURE__ */ new Map();
2556
+ if (typeof init === "string") {
2557
+ this.parseQueryString(init);
2558
+ } else if (_instanceof(init, URLSearchParamsPolyfill)) {
2559
+ init.forEach(function(value, key) {
2560
+ _this.append(key, value);
2561
+ });
2460
2562
  }
2461
2563
  }
2462
- } catch (unused) {}
2463
- try {
2464
- var webOSDev = window.webOSDev;
2465
- if (webOSDev) {
2466
- var _webOSDev_lgudid;
2467
- var lgudid = typeof webOSDev.LGUDID === "function" ? webOSDev.LGUDID() : (_webOSDev_lgudid = webOSDev.lgudid) !== null && _webOSDev_lgudid !== void 0 ? _webOSDev_lgudid : webOSDev.LGUDID;
2468
- if (typeof lgudid === "string" && lgudid) {
2469
- if (isZeroedAdId(lgudid)) {
2470
- return {
2471
- deviceIdType: "lgudid",
2472
- limitAdTracking: true
2473
- };
2564
+ _create_class(URLSearchParamsPolyfill, [
2565
+ {
2566
+ key: "parseQueryString",
2567
+ value: function parseQueryString(query) {
2568
+ var _this = this;
2569
+ var cleanQuery = query.startsWith("?") ? query.slice(1) : query;
2570
+ if (!cleanQuery) return;
2571
+ cleanQuery.split("&").forEach(function(param) {
2572
+ var _param_split = _sliced_to_array(param.split("="), 2), key = _param_split[0], value = _param_split[1];
2573
+ if (key) {
2574
+ var decodedKey = _this.safeDecodeURIComponent(key);
2575
+ var decodedValue = value ? _this.safeDecodeURIComponent(value) : "";
2576
+ _this.append(decodedKey, decodedValue);
2577
+ }
2578
+ });
2474
2579
  }
2475
- if (!isMacroPlaceholder(lgudid)) {
2476
- return {
2477
- deviceId: lgudid,
2478
- deviceIdType: "lgudid",
2479
- limitAdTracking: false
2480
- };
2580
+ },
2581
+ {
2582
+ key: "safeDecodeURIComponent",
2583
+ value: function safeDecodeURIComponent(str) {
2584
+ try {
2585
+ return decodeURIComponent(str.replace(/\+/g, " "));
2586
+ } catch (e) {
2587
+ return str;
2588
+ }
2589
+ }
2590
+ },
2591
+ {
2592
+ key: "append",
2593
+ value: function append(name, value) {
2594
+ var values = this.params.get(name) || [];
2595
+ values.push(String(value));
2596
+ this.params.set(name, values);
2597
+ }
2598
+ },
2599
+ {
2600
+ key: "delete",
2601
+ value: function _delete(name) {
2602
+ this.params.delete(name);
2603
+ }
2604
+ },
2605
+ {
2606
+ key: "get",
2607
+ value: function get(name) {
2608
+ var values = this.params.get(name);
2609
+ return values && values.length > 0 && values[0] !== void 0 ? values[0] : null;
2610
+ }
2611
+ },
2612
+ {
2613
+ key: "getAll",
2614
+ value: function getAll(name) {
2615
+ return this.params.get(name) || [];
2616
+ }
2617
+ },
2618
+ {
2619
+ key: "has",
2620
+ value: function has(name) {
2621
+ return this.params.has(name);
2622
+ }
2623
+ },
2624
+ {
2625
+ key: "set",
2626
+ value: function set(name, value) {
2627
+ this.params.set(name, [
2628
+ String(value)
2629
+ ]);
2630
+ }
2631
+ },
2632
+ {
2633
+ key: "forEach",
2634
+ value: function forEach(callback) {
2635
+ var _this = this;
2636
+ this.params.forEach(function(values, key) {
2637
+ values.forEach(function(value) {
2638
+ callback(value, key, _this);
2639
+ });
2640
+ });
2641
+ }
2642
+ },
2643
+ {
2644
+ key: "toString",
2645
+ value: function toString() {
2646
+ var parts = [];
2647
+ this.params.forEach(function(values, key) {
2648
+ values.forEach(function(value) {
2649
+ parts.push("".concat(encodeURIComponent(key), "=").concat(encodeURIComponent(value)));
2650
+ });
2651
+ });
2652
+ return parts.join("&");
2481
2653
  }
2482
2654
  }
2483
- }
2484
- } catch (unused) {}
2485
- try {
2486
- var roku = window.Roku;
2487
- if (roku) {
2488
- var rida = typeof roku.getPublisherUniqueId === "function" ? roku.getPublisherUniqueId() : roku.rida;
2489
- if (typeof rida === "string" && rida && !isMacroPlaceholder(rida)) {
2490
- return {
2491
- deviceId: rida,
2492
- deviceIdType: "rida",
2493
- limitAdTracking: false
2494
- };
2495
- }
2496
- }
2497
- } catch (unused) {}
2498
- return {};
2499
- }
2500
- var ZEROED_AD_ID_PATTERNS = /* @__PURE__ */ new Set([
2501
- "38400000-8cf0-11bd-b23e-10b96e40000d",
2502
- "00000000-0000-0000-0000-000000000000"
2503
- ]);
2504
- function isMacroPlaceholder(value) {
2505
- var t = value.trim();
2506
- return !t || /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/.test(t) || /^(unknown|null|undefined|none|n\/a|\$\{[^}]+\})$/i.test(t) || ZEROED_AD_ID_PATTERNS.has(t.toLowerCase());
2507
- }
2508
- function isZeroedAdId(value) {
2509
- return ZEROED_AD_ID_PATTERNS.has(value.trim().toLowerCase());
2510
- }
2511
- function readNativeBridgeSignals() {
2512
- if (typeof window === "undefined") {
2513
- return {};
2514
- }
2515
- var candidates = [
2516
- window.__STORMCLOUD_CTV_AD_INFO__,
2517
- window.__STORMCLOUD_CTV__,
2518
- window.stormcloudCtv,
2519
- window.AiryTV,
2520
- window.Android,
2521
- window.webOS,
2522
- window.tizen,
2523
- window.amazon
2524
- ].filter(Boolean);
2525
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2526
- try {
2527
- for(var _iterator = candidates[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2528
- var source = _step.value;
2529
- var contentUrl = readBridgeValue(source, [
2530
- "contentUrl",
2531
- "url",
2532
- "videoUrl",
2533
- "canonicalUrl"
2534
- ]) || void 0;
2535
- var appId = readBridgeValue(source, [
2536
- "appId",
2537
- "msid",
2538
- "applicationId",
2539
- "packageName"
2540
- ]) || void 0;
2541
- var appName = readBridgeValue(source, [
2542
- "appName",
2543
- "an",
2544
- "applicationName"
2545
- ]) || void 0;
2546
- var deviceId = readBridgeValue(source, [
2547
- "rdid",
2548
- "ifa",
2549
- "advertisingId",
2550
- "adId",
2551
- "deviceId",
2552
- "lgudid",
2553
- "LGUDID",
2554
- "tifa",
2555
- "rida",
2556
- "afai",
2557
- "aaid"
2558
- ]) || void 0;
2559
- if (!contentUrl && !deviceId && !appId && !appName) continue;
2560
- var deviceIdType = readBridgeValue(source, [
2561
- "idtype",
2562
- "deviceIdType",
2563
- "advertisingIdType",
2564
- "idType"
2565
- ]) || inferDeviceIdType();
2566
- var limitAdTracking = readBridgeBoolean(source, [
2567
- "is_lat",
2568
- "limitAdTracking",
2569
- "limitedAdTracking",
2570
- "lat"
2571
- ]);
2572
- return _object_spread({}, contentUrl ? {
2573
- contentUrl: contentUrl
2574
- } : {}, appId ? {
2575
- appId: appId
2576
- } : {}, appName ? {
2577
- appName: appName
2578
- } : {}, deviceId ? {
2579
- deviceId: deviceId
2580
- } : {}, deviceId && deviceIdType ? {
2581
- deviceIdType: deviceIdType
2582
- } : {}, deviceId && limitAdTracking != null ? {
2583
- limitAdTracking: limitAdTracking
2584
- } : {});
2585
- }
2586
- } catch (err) {
2587
- _didIteratorError = true;
2588
- _iteratorError = err;
2589
- } finally{
2590
- try {
2591
- if (!_iteratorNormalCompletion && _iterator.return != null) {
2592
- _iterator.return();
2593
- }
2594
- } finally{
2595
- if (_didIteratorError) {
2596
- throw _iteratorError;
2597
- }
2598
- }
2599
- }
2600
- return {};
2655
+ ]);
2656
+ return URLSearchParamsPolyfill;
2657
+ }();
2658
+ window.URLSearchParams = URLSearchParamsPolyfill;
2601
2659
  }
2602
- function readBridgeValue(source, keys) {
2603
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2604
- try {
2605
- for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2606
- var key = _step.value;
2607
- var value = source === null || source === void 0 ? void 0 : source[key];
2608
- if (typeof value === "string" && value) {
2609
- return value;
2610
- }
2611
- if (typeof value === "function") {
2612
- try {
2613
- var result = value.call(source);
2614
- if (typeof result === "string" && result) {
2615
- return result;
2616
- }
2617
- } catch (unused) {}
2618
- }
2660
+ function polyfillTextEncoder() {
2661
+ if (typeof TextEncoder !== "undefined") {
2662
+ return;
2663
+ }
2664
+ var TextEncoderPolyfill = /*#__PURE__*/ function() {
2665
+ "use strict";
2666
+ function TextEncoderPolyfill() {
2667
+ _class_call_check(this, TextEncoderPolyfill);
2668
+ this.encoding = "utf-8";
2619
2669
  }
2620
- } catch (err) {
2621
- _didIteratorError = true;
2622
- _iteratorError = err;
2623
- } finally{
2624
- try {
2625
- if (!_iteratorNormalCompletion && _iterator.return != null) {
2626
- _iterator.return();
2627
- }
2628
- } finally{
2629
- if (_didIteratorError) {
2630
- throw _iteratorError;
2670
+ _create_class(TextEncoderPolyfill, [
2671
+ {
2672
+ key: "encode",
2673
+ value: function encode(str) {
2674
+ var utf8 = [];
2675
+ for(var i = 0; i < str.length; i++){
2676
+ var charcode = str.charCodeAt(i);
2677
+ if (charcode < 128) {
2678
+ utf8.push(charcode);
2679
+ } else if (charcode < 2048) {
2680
+ utf8.push(192 | charcode >> 6, 128 | charcode & 63);
2681
+ } else if (charcode < 55296 || charcode >= 57344) {
2682
+ utf8.push(224 | charcode >> 12, 128 | charcode >> 6 & 63, 128 | charcode & 63);
2683
+ } else {
2684
+ i++;
2685
+ charcode = 65536 + ((charcode & 1023) << 10 | str.charCodeAt(i) & 1023);
2686
+ utf8.push(240 | charcode >> 18, 128 | charcode >> 12 & 63, 128 | charcode >> 6 & 63, 128 | charcode & 63);
2687
+ }
2688
+ }
2689
+ return new Uint8Array(utf8);
2690
+ }
2631
2691
  }
2632
- }
2692
+ ]);
2693
+ return TextEncoderPolyfill;
2694
+ }();
2695
+ window.TextEncoder = TextEncoderPolyfill;
2696
+ }
2697
+ function polyfillPromiseFinally() {
2698
+ if (typeof Promise !== "undefined" && !Promise.prototype.finally) {
2699
+ Promise.prototype.finally = function(callback) {
2700
+ var constructor = this.constructor;
2701
+ return this.then(function(value) {
2702
+ return constructor.resolve(callback()).then(function() {
2703
+ return value;
2704
+ });
2705
+ }, function(reason) {
2706
+ return constructor.resolve(callback()).then(function() {
2707
+ throw reason;
2708
+ });
2709
+ });
2710
+ };
2633
2711
  }
2634
- return void 0;
2635
2712
  }
2636
- function readBridgeBoolean(source, keys) {
2637
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2638
- try {
2639
- for(var _iterator = keys[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2640
- var key = _step.value;
2641
- var value = source === null || source === void 0 ? void 0 : source[key];
2642
- var normalized = normalizeBoolean(value);
2643
- if (normalized != null) {
2644
- return normalized;
2645
- }
2646
- if (typeof value === "function") {
2647
- try {
2648
- var result = normalizeBoolean(value.call(source));
2649
- if (result != null) {
2650
- return result;
2651
- }
2652
- } catch (unused) {}
2713
+ function polyfillObjectAssign() {
2714
+ if (typeof Object.assign !== "function") {
2715
+ Object.assign = function(target) {
2716
+ for(var _len = arguments.length, sources = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++){
2717
+ sources[_key - 1] = arguments[_key];
2653
2718
  }
2654
- }
2655
- } catch (err) {
2656
- _didIteratorError = true;
2657
- _iteratorError = err;
2658
- } finally{
2659
- try {
2660
- if (!_iteratorNormalCompletion && _iterator.return != null) {
2661
- _iterator.return();
2719
+ if (target == null) {
2720
+ throw new TypeError("Cannot convert undefined or null to object");
2662
2721
  }
2663
- } finally{
2664
- if (_didIteratorError) {
2665
- throw _iteratorError;
2722
+ var to = Object(target);
2723
+ for(var i = 0; i < sources.length; i++){
2724
+ var nextSource = sources[i];
2725
+ if (nextSource != null) {
2726
+ for(var nextKey in nextSource){
2727
+ if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
2728
+ to[nextKey] = nextSource[nextKey];
2729
+ }
2730
+ }
2731
+ }
2666
2732
  }
2667
- }
2733
+ return to;
2734
+ };
2668
2735
  }
2669
- return void 0;
2670
2736
  }
2671
- function readStoredDeviceId() {
2672
- var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
2673
- try {
2674
- for(var _iterator = DEVICE_ID_STORAGE_KEYS[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
2675
- var key = _step.value;
2676
- var value = readStoredString(key);
2677
- if (value) {
2678
- return value;
2679
- }
2680
- }
2681
- } catch (err) {
2682
- _didIteratorError = true;
2683
- _iteratorError = err;
2684
- } finally{
2685
- try {
2686
- if (!_iteratorNormalCompletion && _iterator.return != null) {
2687
- _iterator.return();
2737
+ function polyfillArrayFrom() {
2738
+ if (!Array.from) {
2739
+ Array.from = function(arrayLike, mapFn, thisArg) {
2740
+ var items = Object(arrayLike);
2741
+ if (arrayLike == null) {
2742
+ throw new TypeError("Array.from requires an array-like object");
2688
2743
  }
2689
- } finally{
2690
- if (_didIteratorError) {
2691
- throw _iteratorError;
2744
+ var len = items.length >>> 0;
2745
+ var result = new Array(len);
2746
+ for(var i = 0; i < len; i++){
2747
+ if (mapFn) {
2748
+ result[i] = mapFn.call(thisArg, items[i], i);
2749
+ } else {
2750
+ result[i] = items[i];
2751
+ }
2692
2752
  }
2693
- }
2753
+ return result;
2754
+ };
2694
2755
  }
2695
- return void 0;
2696
2756
  }
2697
- function readStoredString(key) {
2698
- if (typeof window === "undefined") {
2699
- return void 0;
2700
- }
2701
- try {
2702
- var _window_localStorage;
2703
- var value = (_window_localStorage = window.localStorage) === null || _window_localStorage === void 0 ? void 0 : _window_localStorage.getItem(key);
2704
- return value || void 0;
2705
- } catch (unused) {
2706
- return void 0;
2757
+ function polyfillStringStartsWith() {
2758
+ if (!String.prototype.startsWith) {
2759
+ String.prototype.startsWith = function(search, pos) {
2760
+ pos = !pos || pos < 0 ? 0 : +pos;
2761
+ return this.substring(pos, pos + search.length) === search;
2762
+ };
2707
2763
  }
2708
2764
  }
2709
- function readStoredLimitAdTracking() {
2710
- return normalizeBoolean(readStoredString("limitAdTracking") || readStoredString("limitedAdTracking") || readStoredString("is_lat"));
2711
- }
2712
- function normalizeBoolean(value) {
2713
- if (typeof value === "boolean") {
2714
- return value;
2715
- }
2716
- if (typeof value === "number") {
2717
- return value === 1;
2765
+ function polyfillStringEndsWith() {
2766
+ if (!String.prototype.endsWith) {
2767
+ String.prototype.endsWith = function(search, length) {
2768
+ if (length === void 0 || length > this.length) {
2769
+ length = this.length;
2770
+ }
2771
+ return this.substring(length - search.length, length) === search;
2772
+ };
2718
2773
  }
2719
- if (typeof value === "string") {
2720
- var normalized = value.toLowerCase();
2721
- if (normalized === "1" || normalized === "true" || normalized === "yes") {
2722
- return true;
2723
- }
2724
- if (normalized === "0" || normalized === "false" || normalized === "no") {
2725
- return false;
2726
- }
2774
+ }
2775
+ function polyfillStringIncludes() {
2776
+ if (!String.prototype.includes) {
2777
+ String.prototype.includes = function(search, start) {
2778
+ if (typeof start !== "number") {
2779
+ start = 0;
2780
+ }
2781
+ if (start + search.length > this.length) {
2782
+ return false;
2783
+ }
2784
+ return this.indexOf(search, start) !== -1;
2785
+ };
2727
2786
  }
2728
- return void 0;
2787
+ }
2788
+ function initializePolyfills() {
2789
+ polyfillObjectAssign();
2790
+ polyfillArrayFrom();
2791
+ polyfillStringStartsWith();
2792
+ polyfillStringEndsWith();
2793
+ polyfillStringIncludes();
2794
+ polyfillURLSearchParams();
2795
+ polyfillTextEncoder();
2796
+ polyfillPromiseFinally();
2729
2797
  }
2730
2798
  // src/utils/vastMacros.ts
2731
2799
  var UNEXPANDED_MACRO_PATTERN = /^(\[[^\]]*\]|\{[^}]*\}|%%[^%]*%%)$/;
@@ -4881,7 +4949,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
4881
4949
  key: "initializeTracking",
4882
4950
  value: function initializeTracking() {
4883
4951
  var _this = this;
4884
- sendInitialTracking(this.config.licenseKey).then(function() {
4952
+ sendInitialTracking(this.config.licenseKey, buildAnalyticsContext(this.config)).then(function() {
4885
4953
  _this.heartbeatInterval = window.setInterval(function() {
4886
4954
  _this.sendHeartbeatIfNeeded();
4887
4955
  }, 5e3);
@@ -4902,7 +4970,7 @@ var AdConfigManager = /*#__PURE__*/ function() {
4902
4970
  var now = Date.now();
4903
4971
  if (!this.lastHeartbeatTime || now - this.lastHeartbeatTime > 3e4) {
4904
4972
  this.lastHeartbeatTime = now;
4905
- sendHeartbeat(this.config.licenseKey).catch(function(error) {
4973
+ sendHeartbeat(this.config.licenseKey, buildAnalyticsContext(this.config)).catch(function(error) {
4906
4974
  if (_this.debug) {
4907
4975
  console.warn("[StormcloudVideoPlayer] Failed to send heartbeat:", error);
4908
4976
  }
@@ -6687,6 +6755,12 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6687
6755
  return !!this.host.config.debugAdTiming;
6688
6756
  }
6689
6757
  },
6758
+ {
6759
+ key: "analyticsContext",
6760
+ get: function get() {
6761
+ return buildAnalyticsContext(this.host.config);
6762
+ }
6763
+ },
6690
6764
  {
6691
6765
  // ───────────────────────────────────────────────────────────────
6692
6766
  // IMA event listeners
@@ -6700,7 +6774,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6700
6774
  source: "hls",
6701
6775
  adIndex: _this.timing.currentAdIndex,
6702
6776
  timestamp: /* @__PURE__ */ new Date().toISOString()
6703
- }).catch(function() {});
6777
+ }, _this.analyticsContext).catch(function() {});
6704
6778
  _this.timing.recordPlayedAdDuration(_this.host.getAdPlayer());
6705
6779
  var remaining = _this.timing.getRemainingAdMs();
6706
6780
  _this.timing.consecutiveFailures = 0;
@@ -6762,7 +6836,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6762
6836
  source: "hls",
6763
6837
  adIndex: _this.timing.currentAdIndex,
6764
6838
  timestamp: /* @__PURE__ */ new Date().toISOString()
6765
- }).catch(function() {});
6839
+ }, _this.analyticsContext).catch(function() {});
6766
6840
  if (!_this.host.video.muted) {
6767
6841
  _this.host.video.muted = true;
6768
6842
  if (_this.debug) {
@@ -6909,7 +6983,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
6909
6983
  source: "hls",
6910
6984
  vastUrl: firstAdUrl,
6911
6985
  timestamp: /* @__PURE__ */ new Date().toISOString()
6912
- }).catch(function() {});
6986
+ }, this.analyticsContext).catch(function() {});
6913
6987
  if (this.debug) {
6914
6988
  console.log("[CONTINUOUS-FETCH] Using preloaded ad from pool (preloaded in advance, ready immediately!)");
6915
6989
  }
@@ -7023,7 +7097,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7023
7097
  source: "hls",
7024
7098
  vastUrl: firstAdUrl,
7025
7099
  timestamp: /* @__PURE__ */ new Date().toISOString()
7026
- }).catch(function() {});
7100
+ }, this.analyticsContext).catch(function() {});
7027
7101
  if (this.debug) {
7028
7102
  console.log("[CONTINUOUS-FETCH] First ad request successful, starting playback");
7029
7103
  }
@@ -7487,7 +7561,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7487
7561
  source: "hls",
7488
7562
  vastUrl: preloaded.vastUrl,
7489
7563
  timestamp: /* @__PURE__ */ new Date().toISOString()
7490
- }).catch(function() {});
7564
+ }, this.analyticsContext).catch(function() {});
7491
7565
  _state.label = 1;
7492
7566
  case 1:
7493
7567
  _state.trys.push([
@@ -7720,7 +7794,7 @@ var AdBreakOrchestrator = /*#__PURE__*/ function() {
7720
7794
  source: "hls",
7721
7795
  vastUrl: vastTagUrl,
7722
7796
  timestamp: /* @__PURE__ */ new Date().toISOString()
7723
- }).catch(function() {});
7797
+ }, this.analyticsContext).catch(function() {});
7724
7798
  this.timing.clearAdRequestWatchdog();
7725
7799
  if (this.timing.activeAdRequestToken !== requestToken) return [
7726
7800
  2
@@ -8513,7 +8587,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8513
8587
  sendAdDetectTracking(this.config.licenseKey, _object_spread({
8514
8588
  source: "scte35",
8515
8589
  timestamp: /* @__PURE__ */ new Date().toISOString()
8516
- }, detectPayload)).catch(function() {});
8590
+ }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
8517
8591
  }
8518
8592
  var hasPrefetchedAds = this.adBreak.pendingAdBreak && this.adBreak.pendingAdBreak.vastUrls.length > 0;
8519
8593
  var durationMs = marker.durationSeconds != null ? marker.durationSeconds * 1e3 : ((_this_adBreak_pendingAdBreak = this.adBreak.pendingAdBreak) === null || _this_adBreak_pendingAdBreak === void 0 ? void 0 : _this_adBreak_pendingAdBreak.marker.durationSeconds) != null ? this.adBreak.pendingAdBreak.marker.durationSeconds * 1e3 : void 0;
@@ -8686,7 +8760,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
8686
8760
  sendAdDetectTracking(this.config.licenseKey, _object_spread({
8687
8761
  source: "scte35",
8688
8762
  timestamp: /* @__PURE__ */ new Date().toISOString()
8689
- }, detectPayload)).catch(function() {});
8763
+ }, detectPayload), buildAnalyticsContext(this.config)).catch(function() {});
8690
8764
  if (this.debug) {
8691
8765
  console.log("[PREFETCH] Starting ad prefetch for upcoming ad break");
8692
8766
  console.log("[PREFETCH] Pre-generated ".concat(generatedUrls.length, " VAST URLs"));
@@ -11488,5 +11562,5 @@ var createStormcloudPlayer = function createStormcloudPlayer(playerList, fallbac
11488
11562
  };
11489
11563
  var StormcloudPlayer = createStormcloudPlayer(players_default, players_default[players_default.length - 1]);
11490
11564
  var StormcloudPlayer_default = StormcloudPlayer;
11491
- export { DEFAULT_MQTT_CONFIG, IS_BROWSER, IS_GLOBAL, IS_IOS, IS_SAFARI, MQTT_CA_CERT_FILE, SUPPORTS_DASH, SUPPORTS_HLS, StormcloudPlayer_default as StormcloudPlayer, StormcloudVideoPlayer, StormcloudVideoPlayerComponent, applyMQTTConfig, buildMQTTBrokerUrl, buildPlayerTopic, canPlay, configureMQTT, createHlsAdPlayer, createPalNonceManager, createStormcloudPlayer, StormcloudVideoPlayerComponent as default, detectBrowser, disconnectMQTT, ensureMQTTClient, getBrowserConfigOverrides, getBrowserID, getClientInfo, getMQTTStatus, initMQTTClient, initializePolyfills, isMQTTConfigured, isMQTTConnected, isMQTTEnabled, isMediaStream, lazy, logBrowserInfo, merge, mqttConfig, omit, parseQuery, players_default as players, publishMQTT, randomString, sendAdDetectTracking, sendAdImpressionTracking, sendAdLoadedTracking, sendHeartbeat, sendInitialTracking, supportsFeature, supportsModernJS, supportsWebKitPresentationMode };
11565
+ export { DEFAULT_MQTT_CONFIG, IS_BROWSER, IS_GLOBAL, IS_IOS, IS_SAFARI, MQTT_CA_CERT_FILE, SUPPORTS_DASH, SUPPORTS_HLS, StormcloudPlayer_default as StormcloudPlayer, StormcloudVideoPlayer, StormcloudVideoPlayerComponent, applyMQTTConfig, buildAnalyticsContext, buildMQTTBrokerUrl, buildPlayerTopic, canPlay, configureMQTT, createHlsAdPlayer, createPalNonceManager, createStormcloudPlayer, StormcloudVideoPlayerComponent as default, detectBrowser, disconnectMQTT, ensureMQTTClient, getBrowserConfigOverrides, getBrowserID, getClientInfo, getMQTTStatus, initMQTTClient, initializePolyfills, isMQTTConfigured, isMQTTConnected, isMQTTEnabled, isMediaStream, lazy, logBrowserInfo, merge, mqttConfig, omit, parseQuery, players_default as players, publishMQTT, randomString, sendAdDetectTracking, sendAdImpressionTracking, sendAdLoadedTracking, sendHeartbeat, sendInitialTracking, supportsFeature, supportsModernJS, supportsWebKitPresentationMode };
11492
11566
  //# sourceMappingURL=index.js.map