stormcloud-video-player 0.6.7 → 0.6.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.cjs CHANGED
@@ -1124,7 +1124,6 @@ function createVastAdLayer(contentVideo, options) {
1124
1124
  var tornDown = false;
1125
1125
  var trackingFired = createEmptyTrackingState();
1126
1126
  var adStallTimerId;
1127
- var savedContentVideoStyles;
1128
1127
  var currentAdEventHandlers;
1129
1128
  var preloadSlots = /* @__PURE__ */ new Map();
1130
1129
  function emit(event, payload) {
@@ -1241,7 +1240,7 @@ function createVastAdLayer(contentVideo, options) {
1241
1240
  video.style.top = "0";
1242
1241
  video.style.width = "100%";
1243
1242
  video.style.height = "100%";
1244
- video.style.objectFit = "cover";
1243
+ video.style.objectFit = "contain";
1245
1244
  video.style.backgroundColor = "#000";
1246
1245
  video.playsInline = true;
1247
1246
  video.muted = false;
@@ -1356,31 +1355,12 @@ function createVastAdLayer(contentVideo, options) {
1356
1355
  delete contentVideo.dataset.stormcloudAdPlaying;
1357
1356
  }
1358
1357
  }
1359
- function applyContentVideoAdCoverStyles() {
1360
- if (!singleElementMode) return;
1361
- savedContentVideoStyles = {
1362
- objectFit: contentVideo.style.objectFit,
1363
- width: contentVideo.style.width,
1364
- height: contentVideo.style.height
1365
- };
1366
- contentVideo.style.objectFit = "cover";
1367
- contentVideo.style.width = "100%";
1368
- contentVideo.style.height = "100%";
1369
- }
1370
- function restoreContentVideoStyles() {
1371
- if (!singleElementMode || !savedContentVideoStyles) return;
1372
- contentVideo.style.objectFit = savedContentVideoStyles.objectFit;
1373
- contentVideo.style.width = savedContentVideoStyles.width;
1374
- contentVideo.style.height = savedContentVideoStyles.height;
1375
- savedContentVideoStyles = void 0;
1376
- }
1377
1358
  function handleAdComplete() {
1378
1359
  if (tornDown) return;
1379
1360
  clearAdStallTimer();
1380
1361
  if (debug) console.log("".concat(LOG, " Handling ad completion"));
1381
1362
  adPlaying = false;
1382
1363
  setAdPlayingFlag(false);
1383
- restoreContentVideoStyles();
1384
1364
  if (adContainerEl) {
1385
1365
  adContainerEl.style.display = "none";
1386
1366
  adContainerEl.style.pointerEvents = "none";
@@ -1395,7 +1375,6 @@ function createVastAdLayer(contentVideo, options) {
1395
1375
  if (debug) console.log("".concat(LOG, " Handling ad error"));
1396
1376
  adPlaying = false;
1397
1377
  setAdPlayingFlag(false);
1398
- restoreContentVideoStyles();
1399
1378
  if (adContainerEl) {
1400
1379
  adContainerEl.style.display = "none";
1401
1380
  adContainerEl.style.pointerEvents = "none";
@@ -1566,7 +1545,6 @@ function createVastAdLayer(contentVideo, options) {
1566
1545
  ];
1567
1546
  contentVideo.style.visibility = "visible";
1568
1547
  contentVideo.style.opacity = "1";
1569
- applyContentVideoAdCoverStyles();
1570
1548
  emit("content_pause");
1571
1549
  setupAdEventListeners();
1572
1550
  adVolume2 = originalMutedState ? 1 : originalVolume;
@@ -1805,7 +1783,6 @@ function createVastAdLayer(contentVideo, options) {
1805
1783
  ];
1806
1784
  contentVideo.style.visibility = "visible";
1807
1785
  contentVideo.style.opacity = "1";
1808
- applyContentVideoAdCoverStyles();
1809
1786
  emit("content_pause");
1810
1787
  setupAdEventListeners();
1811
1788
  adVolume2 = originalMutedState ? 1 : originalVolume;
@@ -1956,7 +1933,6 @@ function createVastAdLayer(contentVideo, options) {
1956
1933
  if (debug) console.log("".concat(LOG, " Stopping ad"));
1957
1934
  adPlaying = false;
1958
1935
  setAdPlayingFlag(false);
1959
- restoreContentVideoStyles();
1960
1936
  contentVideo.muted = originalMutedState;
1961
1937
  contentVideo.volume = originalMutedState ? 0 : originalVolume;
1962
1938
  contentVideo.style.visibility = "visible";
@@ -1995,7 +1971,6 @@ function createVastAdLayer(contentVideo, options) {
1995
1971
  destroyed = true;
1996
1972
  adPlaying = false;
1997
1973
  setAdPlayingFlag(false);
1998
- restoreContentVideoStyles();
1999
1974
  contentVideo.muted = originalMutedState;
2000
1975
  contentVideo.volume = originalVolume;
2001
1976
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2348,24 +2323,30 @@ function getBrowserID(clientInfo) {
2348
2323
  });
2349
2324
  })();
2350
2325
  }
2351
- var TRACK_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track";
2326
+ var PLAYER_TRACKING_BASE_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking";
2327
+ var TRACK_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/metrics/ingest");
2328
+ var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
2329
+ var IMPRESSIONS_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/impressions/ingest");
2330
+ function buildHeaders(licenseKey) {
2331
+ var headers = {
2332
+ "Content-Type": "application/json"
2333
+ };
2334
+ if (licenseKey) {
2335
+ headers["Authorization"] = "Bearer ".concat(licenseKey);
2336
+ }
2337
+ return headers;
2338
+ }
2352
2339
  function sendTrackRequest(licenseKey, body) {
2353
2340
  return _async_to_generator(function() {
2354
- var headers, response;
2341
+ var response;
2355
2342
  return _ts_generator(this, function(_state) {
2356
2343
  switch(_state.label){
2357
2344
  case 0:
2358
- headers = {
2359
- "Content-Type": "application/json"
2360
- };
2361
- if (licenseKey) {
2362
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2363
- }
2364
2345
  return [
2365
2346
  4,
2366
2347
  fetch(TRACK_URL, {
2367
2348
  method: "POST",
2368
- headers: headers,
2349
+ headers: buildHeaders(licenseKey),
2369
2350
  body: JSON.stringify(body)
2370
2351
  })
2371
2352
  ];
@@ -2387,14 +2368,86 @@ function sendTrackRequest(licenseKey, body) {
2387
2368
  });
2388
2369
  })();
2389
2370
  }
2390
- function sendInitialTracking(licenseKey) {
2371
+ function postJson(url, licenseKey, body) {
2391
2372
  return _async_to_generator(function() {
2392
- var clientInfo, browserId, trackingData, headers, response, error;
2373
+ var response;
2374
+ return _ts_generator(this, function(_state) {
2375
+ switch(_state.label){
2376
+ case 0:
2377
+ return [
2378
+ 4,
2379
+ fetch(url, {
2380
+ method: "POST",
2381
+ headers: buildHeaders(licenseKey),
2382
+ body: JSON.stringify(body)
2383
+ })
2384
+ ];
2385
+ case 1:
2386
+ response = _state.sent();
2387
+ if (!response.ok) {
2388
+ throw new Error("HTTP error! status: ".concat(response.status));
2389
+ }
2390
+ return [
2391
+ 4,
2392
+ response.json()
2393
+ ];
2394
+ case 2:
2395
+ _state.sent();
2396
+ return [
2397
+ 2
2398
+ ];
2399
+ }
2400
+ });
2401
+ })();
2402
+ }
2403
+ function buildPlayerMetricEvent(_0) {
2404
+ return _async_to_generator(function(licenseKey) {
2405
+ var context, flags, _flags_captureAt, clientInfo, browserId, captureAt;
2406
+ var _arguments = arguments;
2407
+ return _ts_generator(this, function(_state) {
2408
+ switch(_state.label){
2409
+ case 0:
2410
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2411
+ clientInfo = getClientInfo();
2412
+ return [
2413
+ 4,
2414
+ getBrowserID(clientInfo)
2415
+ ];
2416
+ case 1:
2417
+ browserId = _state.sent();
2418
+ captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
2419
+ return [
2420
+ 2,
2421
+ {
2422
+ player_id: browserId,
2423
+ browserId: browserId,
2424
+ device_type: clientInfo.deviceType,
2425
+ deviceType: clientInfo.deviceType,
2426
+ input_stream_type: context.inputStreamType,
2427
+ os: clientInfo.os,
2428
+ ad_loaded: flags.adLoaded,
2429
+ ad_detect: flags.adDetect,
2430
+ license_key: licenseKey,
2431
+ capture_at: captureAt,
2432
+ timestamp: captureAt
2433
+ }
2434
+ ];
2435
+ }
2436
+ });
2437
+ }).apply(this, arguments);
2438
+ }
2439
+ function sendInitialTracking(_0) {
2440
+ return _async_to_generator(function(licenseKey) {
2441
+ var context, clientInfo, browserId, trackingData, error;
2442
+ var _arguments = arguments;
2393
2443
  return _ts_generator(this, function(_state) {
2394
2444
  switch(_state.label){
2395
2445
  case 0:
2446
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
2447
+ _state.label = 1;
2448
+ case 1:
2396
2449
  _state.trys.push([
2397
- 0,
2450
+ 1,
2398
2451
  4,
2399
2452
  ,
2400
2453
  5
@@ -2404,34 +2457,29 @@ function sendInitialTracking(licenseKey) {
2404
2457
  4,
2405
2458
  getBrowserID(clientInfo)
2406
2459
  ];
2407
- case 1:
2460
+ case 2:
2408
2461
  browserId = _state.sent();
2409
2462
  trackingData = _object_spread({
2410
2463
  browserId: browserId
2411
2464
  }, clientInfo);
2412
- headers = {
2413
- "Content-Type": "application/json"
2414
- };
2415
- if (licenseKey) {
2416
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2417
- }
2418
2465
  return [
2419
2466
  4,
2420
- fetch(TRACK_URL, {
2421
- method: "POST",
2422
- headers: headers,
2423
- body: JSON.stringify(trackingData)
2467
+ sendTrackRequest(licenseKey, {
2468
+ events: [
2469
+ {
2470
+ player_id: browserId,
2471
+ device_type: clientInfo.deviceType,
2472
+ input_stream_type: context.inputStreamType,
2473
+ os: clientInfo.os,
2474
+ ad_loaded: false,
2475
+ ad_detect: false,
2476
+ license_key: licenseKey,
2477
+ capture_at: /* @__PURE__ */ new Date().toISOString()
2478
+ }
2479
+ ],
2480
+ trackingData: trackingData
2424
2481
  })
2425
2482
  ];
2426
- case 2:
2427
- response = _state.sent();
2428
- if (!response.ok) {
2429
- throw new Error("HTTP error! status: ".concat(response.status));
2430
- }
2431
- return [
2432
- 4,
2433
- response.json()
2434
- ];
2435
2483
  case 3:
2436
2484
  _state.sent();
2437
2485
  return [
@@ -2451,36 +2499,30 @@ function sendInitialTracking(licenseKey) {
2451
2499
  ];
2452
2500
  }
2453
2501
  });
2454
- })();
2502
+ }).apply(this, arguments);
2455
2503
  }
2456
- function sendAdDetectTracking(licenseKey, adDetectInfo) {
2457
- return _async_to_generator(function() {
2458
- var clientInfo, browserId, trackingData, error;
2504
+ function sendAdDetectTracking(_0, _1) {
2505
+ return _async_to_generator(function(licenseKey, adDetectInfo) {
2506
+ var context, error;
2507
+ var _arguments = arguments;
2459
2508
  return _ts_generator(this, function(_state) {
2460
2509
  switch(_state.label){
2461
2510
  case 0:
2511
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2512
+ _state.label = 1;
2513
+ case 1:
2462
2514
  _state.trys.push([
2463
- 0,
2515
+ 1,
2464
2516
  3,
2465
2517
  ,
2466
2518
  4
2467
2519
  ]);
2468
- clientInfo = getClientInfo();
2469
2520
  return [
2470
2521
  4,
2471
- getBrowserID(clientInfo)
2472
- ];
2473
- case 1:
2474
- browserId = _state.sent();
2475
- trackingData = _object_spread({
2476
- browserId: browserId
2477
- }, clientInfo);
2478
- return [
2479
- 4,
2480
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2481
- licenseKey: licenseKey,
2482
- adDetectInfo: adDetectInfo
2483
- }))
2522
+ sendHeartbeat(licenseKey, context, {
2523
+ adDetect: true,
2524
+ captureAt: adDetectInfo.timestamp
2525
+ })
2484
2526
  ];
2485
2527
  case 2:
2486
2528
  _state.sent();
@@ -2501,36 +2543,30 @@ function sendAdDetectTracking(licenseKey, adDetectInfo) {
2501
2543
  ];
2502
2544
  }
2503
2545
  });
2504
- })();
2546
+ }).apply(this, arguments);
2505
2547
  }
2506
- function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
2507
- return _async_to_generator(function() {
2508
- var clientInfo, browserId, trackingData, error;
2548
+ function sendAdLoadedTracking(_0, _1) {
2549
+ return _async_to_generator(function(licenseKey, adLoadedInfo) {
2550
+ var context, error;
2551
+ var _arguments = arguments;
2509
2552
  return _ts_generator(this, function(_state) {
2510
2553
  switch(_state.label){
2511
2554
  case 0:
2555
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2556
+ _state.label = 1;
2557
+ case 1:
2512
2558
  _state.trys.push([
2513
- 0,
2559
+ 1,
2514
2560
  3,
2515
2561
  ,
2516
2562
  4
2517
2563
  ]);
2518
- clientInfo = getClientInfo();
2519
- return [
2520
- 4,
2521
- getBrowserID(clientInfo)
2522
- ];
2523
- case 1:
2524
- browserId = _state.sent();
2525
- trackingData = _object_spread({
2526
- browserId: browserId
2527
- }, clientInfo);
2528
2564
  return [
2529
2565
  4,
2530
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2531
- licenseKey: licenseKey,
2532
- adLoadedInfo: adLoadedInfo
2533
- }))
2566
+ sendHeartbeat(licenseKey, context, {
2567
+ adLoaded: true,
2568
+ captureAt: adLoadedInfo.timestamp
2569
+ })
2534
2570
  ];
2535
2571
  case 2:
2536
2572
  _state.sent();
@@ -2551,103 +2587,95 @@ function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
2551
2587
  ];
2552
2588
  }
2553
2589
  });
2554
- })();
2590
+ }).apply(this, arguments);
2555
2591
  }
2556
- function sendAdImpressionTracking(licenseKey, adImpressionInfo) {
2557
- return _async_to_generator(function() {
2558
- var clientInfo, browserId, trackingData, error;
2592
+ function sendAdImpressionTracking(_0, _1) {
2593
+ return _async_to_generator(function(licenseKey, adImpressionInfo) {
2594
+ var context, metricEvent, error;
2595
+ var _arguments = arguments;
2559
2596
  return _ts_generator(this, function(_state) {
2560
2597
  switch(_state.label){
2561
2598
  case 0:
2599
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2600
+ _state.label = 1;
2601
+ case 1:
2562
2602
  _state.trys.push([
2563
- 0,
2564
- 3,
2603
+ 1,
2604
+ 4,
2565
2605
  ,
2566
- 4
2606
+ 5
2567
2607
  ]);
2568
- clientInfo = getClientInfo();
2569
2608
  return [
2570
2609
  4,
2571
- getBrowserID(clientInfo)
2610
+ buildPlayerMetricEvent(licenseKey, context, {
2611
+ captureAt: adImpressionInfo.timestamp
2612
+ })
2572
2613
  ];
2573
- case 1:
2574
- browserId = _state.sent();
2575
- trackingData = _object_spread({
2576
- browserId: browserId
2577
- }, clientInfo);
2614
+ case 2:
2615
+ metricEvent = _state.sent();
2578
2616
  return [
2579
2617
  4,
2580
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2581
- licenseKey: licenseKey,
2582
- adImpressionInfo: adImpressionInfo
2583
- }))
2618
+ Promise.all([
2619
+ postJson(HEARTBEAT_URL, licenseKey, metricEvent),
2620
+ postJson(IMPRESSIONS_URL, licenseKey, {
2621
+ events: [
2622
+ {
2623
+ player_id: metricEvent.player_id,
2624
+ ad_played_count: 1,
2625
+ ad_url: adImpressionInfo.adUrl,
2626
+ license_key: licenseKey,
2627
+ capture_at: adImpressionInfo.timestamp
2628
+ }
2629
+ ]
2630
+ })
2631
+ ])
2584
2632
  ];
2585
- case 2:
2633
+ case 3:
2586
2634
  _state.sent();
2587
2635
  return [
2588
2636
  3,
2589
- 4
2637
+ 5
2590
2638
  ];
2591
- case 3:
2639
+ case 4:
2592
2640
  error = _state.sent();
2593
2641
  console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
2594
2642
  return [
2595
2643
  3,
2596
- 4
2644
+ 5
2597
2645
  ];
2598
- case 4:
2646
+ case 5:
2599
2647
  return [
2600
2648
  2
2601
2649
  ];
2602
2650
  }
2603
2651
  });
2604
- })();
2652
+ }).apply(this, arguments);
2605
2653
  }
2606
- function sendHeartbeat(licenseKey) {
2607
- return _async_to_generator(function() {
2608
- var clientInfo, browserId, heartbeatData, headers, response, error;
2654
+ function sendHeartbeat(_0) {
2655
+ return _async_to_generator(function(licenseKey) {
2656
+ var context, flags, heartbeatData, error;
2657
+ var _arguments = arguments;
2609
2658
  return _ts_generator(this, function(_state) {
2610
2659
  switch(_state.label){
2611
2660
  case 0:
2661
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2662
+ _state.label = 1;
2663
+ case 1:
2612
2664
  _state.trys.push([
2613
- 0,
2665
+ 1,
2614
2666
  4,
2615
2667
  ,
2616
2668
  5
2617
2669
  ]);
2618
- clientInfo = getClientInfo();
2619
2670
  return [
2620
2671
  4,
2621
- getBrowserID(clientInfo)
2622
- ];
2623
- case 1:
2624
- browserId = _state.sent();
2625
- heartbeatData = {
2626
- browserId: browserId,
2627
- timestamp: /* @__PURE__ */ new Date().toISOString()
2628
- };
2629
- headers = {
2630
- "Content-Type": "application/json"
2631
- };
2632
- if (licenseKey) {
2633
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2634
- }
2635
- return [
2636
- 4,
2637
- fetch("https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/heartbeat", {
2638
- method: "POST",
2639
- headers: headers,
2640
- body: JSON.stringify(heartbeatData)
2641
- })
2672
+ buildPlayerMetricEvent(licenseKey, context, flags)
2642
2673
  ];
2643
2674
  case 2:
2644
- response = _state.sent();
2645
- if (!response.ok) {
2646
- throw new Error("HTTP error! status: ".concat(response.status));
2647
- }
2675
+ heartbeatData = _state.sent();
2648
2676
  return [
2649
2677
  4,
2650
- response.json()
2678
+ postJson(HEARTBEAT_URL, licenseKey, heartbeatData)
2651
2679
  ];
2652
2680
  case 3:
2653
2681
  _state.sent();
@@ -2668,7 +2696,7 @@ function sendHeartbeat(licenseKey) {
2668
2696
  ];
2669
2697
  }
2670
2698
  });
2671
- })();
2699
+ }).apply(this, arguments);
2672
2700
  }
2673
2701
  // src/utils/polyfills.ts
2674
2702
  function polyfillURLSearchParams() {
@@ -3708,17 +3736,62 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3708
3736
  return "vast";
3709
3737
  }
3710
3738
  },
3739
+ {
3740
+ key: "getInputStreamType",
3741
+ value: function getInputStreamType() {
3742
+ var src = this.config.src.toLowerCase();
3743
+ if (src.includes(".m3u8")) return "hls";
3744
+ if (src.includes(".mpd")) return "dash";
3745
+ if (src.includes(".mp4")) return "mp4";
3746
+ return this.isLiveStream ? "live" : "vod";
3747
+ }
3748
+ },
3749
+ {
3750
+ key: "getAnalyticsContext",
3751
+ value: function getAnalyticsContext() {
3752
+ return {
3753
+ inputStreamType: this.getInputStreamType()
3754
+ };
3755
+ }
3756
+ },
3757
+ {
3758
+ key: "getAdUrlFromBids",
3759
+ value: function getAdUrlFromBids(bids) {
3760
+ var _bids_;
3761
+ return bids === null || bids === void 0 ? void 0 : (_bids_ = bids[0]) === null || _bids_ === void 0 ? void 0 : _bids_.vastUrl;
3762
+ }
3763
+ },
3764
+ {
3765
+ key: "trackAdLoaded",
3766
+ value: function trackAdLoaded(bids) {
3767
+ if (!this.config.licenseKey) return;
3768
+ var adUrl = this.getAdUrlFromBids(bids);
3769
+ if (adUrl) {
3770
+ this.lastServedAdUrl = adUrl;
3771
+ }
3772
+ sendAdLoadedTracking(this.config.licenseKey, _object_spread_props(_object_spread({
3773
+ source: this.getAdSource()
3774
+ }, adUrl ? {
3775
+ vastUrl: adUrl
3776
+ } : {}), {
3777
+ timestamp: /* @__PURE__ */ new Date().toISOString()
3778
+ }), this.getAnalyticsContext());
3779
+ }
3780
+ },
3711
3781
  {
3712
3782
  key: "attachAdLayerEventListeners",
3713
3783
  value: function attachAdLayerEventListeners() {
3714
3784
  var _this = this;
3715
3785
  this.adLayer.on("ad_impression", function() {
3716
3786
  if (_this.config.licenseKey) {
3717
- sendAdImpressionTracking(_this.config.licenseKey, {
3787
+ sendAdImpressionTracking(_this.config.licenseKey, _object_spread_props(_object_spread({
3718
3788
  source: _this.getAdSource(),
3719
- adIndex: _this.currentAdIndex,
3789
+ adIndex: _this.currentAdIndex
3790
+ }, _this.lastServedAdUrl ? {
3791
+ adUrl: _this.lastServedAdUrl
3792
+ } : {}), {
3720
3793
  timestamp: /* @__PURE__ */ new Date().toISOString()
3721
- });
3794
+ }), _this.getAnalyticsContext());
3722
3795
  }
3723
3796
  });
3724
3797
  this.adLayer.on("ad_error", function(errorPayload) {
@@ -3812,6 +3885,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3812
3885
  _this.isInAdTransition = false;
3813
3886
  if (!_this.inAdBreak) return;
3814
3887
  _this.currentAdIndex++;
3888
+ _this.trackAdLoaded();
3815
3889
  _this.adLayer.playPreloaded(token).catch(function(err) {
3816
3890
  if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playPreloaded failed:", err);
3817
3891
  _this.handleAdFailure();
@@ -3841,6 +3915,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3841
3915
  var freshBids = (_this_pendingNextAdBids = _this.pendingNextAdBids) !== null && _this_pendingNextAdBids !== void 0 ? _this_pendingNextAdBids : bids;
3842
3916
  _this.pendingNextAdBids = null;
3843
3917
  _this.currentAdIndex++;
3918
+ _this.trackAdLoaded(freshBids);
3844
3919
  _this.adLayer.playAd(freshBids).catch(function(err) {
3845
3920
  if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playAd(pending) failed:", err);
3846
3921
  _this.handleAdFailure();
@@ -4220,7 +4295,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4220
4295
  }, ((_this_pendingAdBreak1 = this.pendingAdBreak) === null || _this_pendingAdBreak1 === void 0 ? void 0 : _this_pendingAdBreak1.detectedAtFragmentSn) != null && {
4221
4296
  detectedAtFragmentSn: this.pendingAdBreak.detectedAtFragmentSn
4222
4297
  });
4223
- sendAdDetectTracking(this.config.licenseKey, adDetectInfo);
4298
+ sendAdDetectTracking(this.config.licenseKey, adDetectInfo, this.getAnalyticsContext());
4224
4299
  }
4225
4300
  var isManifestMarker = this.isManifestBasedMarker(marker);
4226
4301
  var forceImmediate = (_this_config_immediateManifestAds = this.config.immediateManifestAds) !== null && _this_config_immediateManifestAds !== void 0 ? _this_config_immediateManifestAds : true;
@@ -4289,6 +4364,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4289
4364
  var bids = this.pendingNextAdBids;
4290
4365
  this.pendingNextAdBids = null;
4291
4366
  this.currentAdIndex++;
4367
+ this.trackAdLoaded(bids);
4292
4368
  this.adLayer.playAd(bids).catch(function() {
4293
4369
  return _this.handleAdFailure();
4294
4370
  });
@@ -4543,7 +4619,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4543
4619
  key: "initializeTracking",
4544
4620
  value: function initializeTracking() {
4545
4621
  var _this = this;
4546
- sendInitialTracking(this.config.licenseKey).then(function() {
4622
+ sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
4547
4623
  _this.heartbeatInterval = window.setInterval(function() {
4548
4624
  _this.sendHeartbeatIfNeeded();
4549
4625
  }, 5e3);
@@ -4564,7 +4640,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4564
4640
  var now = Date.now();
4565
4641
  if (!this.lastHeartbeatTime || now - this.lastHeartbeatTime > 3e4) {
4566
4642
  this.lastHeartbeatTime = now;
4567
- sendHeartbeat(this.config.licenseKey).catch(function(error) {
4643
+ sendHeartbeat(this.config.licenseKey, this.getAnalyticsContext()).catch(function(error) {
4568
4644
  if (_this.config.debugAdTiming) {
4569
4645
  console.warn("[StormcloudVideoPlayer] Failed to send heartbeat:", error);
4570
4646
  }
@@ -4957,12 +5033,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4957
5033
  10
4958
5034
  ];
4959
5035
  _this.currentAdIndex++;
4960
- if (_this.config.licenseKey) {
4961
- sendAdLoadedTracking(_this.config.licenseKey, {
4962
- source: _this.getAdSource(),
4963
- timestamp: /* @__PURE__ */ new Date().toISOString()
4964
- });
4965
- }
5036
+ _this.trackAdLoaded(bids1);
4966
5037
  return [
4967
5038
  4,
4968
5039
  _this.adLayer.playAd(bids1)
@@ -5067,12 +5138,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5067
5138
  ];
5068
5139
  case 18:
5069
5140
  _this.currentAdIndex++;
5070
- if (_this.config.licenseKey) {
5071
- sendAdLoadedTracking(_this.config.licenseKey, {
5072
- source: _this.getAdSource(),
5073
- timestamp: /* @__PURE__ */ new Date().toISOString()
5074
- });
5075
- }
5141
+ _this.trackAdLoaded(bids2);
5076
5142
  return [
5077
5143
  4,
5078
5144
  _this.adLayer.playAd(bids2)
@@ -5231,12 +5297,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5231
5297
  6
5232
5298
  ];
5233
5299
  this.currentAdIndex++;
5234
- if (this.config.licenseKey) {
5235
- sendAdLoadedTracking(this.config.licenseKey, {
5236
- source: this.getAdSource(),
5237
- timestamp: /* @__PURE__ */ new Date().toISOString()
5238
- });
5239
- }
5300
+ this.trackAdLoaded();
5240
5301
  _state.label = 1;
5241
5302
  case 1:
5242
5303
  _state.trys.push([
@@ -5430,12 +5491,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5430
5491
  5
5431
5492
  ];
5432
5493
  case 3:
5433
- if (this.config.licenseKey) {
5434
- sendAdLoadedTracking(this.config.licenseKey, {
5435
- source: this.getAdSource(),
5436
- timestamp: /* @__PURE__ */ new Date().toISOString()
5437
- });
5438
- }
5494
+ this.trackAdLoaded(bids);
5439
5495
  return [
5440
5496
  4,
5441
5497
  this.adLayer.playAd(bids)
@@ -5581,6 +5637,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5581
5637
  ,
5582
5638
  7
5583
5639
  ]);
5640
+ this.trackAdLoaded(bids);
5584
5641
  return [
5585
5642
  4,
5586
5643
  this.adLayer.playAd(bids)