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.
@@ -1030,7 +1030,6 @@ function createVastAdLayer(contentVideo, options) {
1030
1030
  var tornDown = false;
1031
1031
  var trackingFired = createEmptyTrackingState();
1032
1032
  var adStallTimerId;
1033
- var savedContentVideoStyles;
1034
1033
  var currentAdEventHandlers;
1035
1034
  var preloadSlots = /* @__PURE__ */ new Map();
1036
1035
  function emit(event, payload) {
@@ -1147,7 +1146,7 @@ function createVastAdLayer(contentVideo, options) {
1147
1146
  video.style.top = "0";
1148
1147
  video.style.width = "100%";
1149
1148
  video.style.height = "100%";
1150
- video.style.objectFit = "cover";
1149
+ video.style.objectFit = "contain";
1151
1150
  video.style.backgroundColor = "#000";
1152
1151
  video.playsInline = true;
1153
1152
  video.muted = false;
@@ -1262,31 +1261,12 @@ function createVastAdLayer(contentVideo, options) {
1262
1261
  delete contentVideo.dataset.stormcloudAdPlaying;
1263
1262
  }
1264
1263
  }
1265
- function applyContentVideoAdCoverStyles() {
1266
- if (!singleElementMode) return;
1267
- savedContentVideoStyles = {
1268
- objectFit: contentVideo.style.objectFit,
1269
- width: contentVideo.style.width,
1270
- height: contentVideo.style.height
1271
- };
1272
- contentVideo.style.objectFit = "cover";
1273
- contentVideo.style.width = "100%";
1274
- contentVideo.style.height = "100%";
1275
- }
1276
- function restoreContentVideoStyles() {
1277
- if (!singleElementMode || !savedContentVideoStyles) return;
1278
- contentVideo.style.objectFit = savedContentVideoStyles.objectFit;
1279
- contentVideo.style.width = savedContentVideoStyles.width;
1280
- contentVideo.style.height = savedContentVideoStyles.height;
1281
- savedContentVideoStyles = void 0;
1282
- }
1283
1264
  function handleAdComplete() {
1284
1265
  if (tornDown) return;
1285
1266
  clearAdStallTimer();
1286
1267
  if (debug) console.log("".concat(LOG, " Handling ad completion"));
1287
1268
  adPlaying = false;
1288
1269
  setAdPlayingFlag(false);
1289
- restoreContentVideoStyles();
1290
1270
  if (adContainerEl) {
1291
1271
  adContainerEl.style.display = "none";
1292
1272
  adContainerEl.style.pointerEvents = "none";
@@ -1301,7 +1281,6 @@ function createVastAdLayer(contentVideo, options) {
1301
1281
  if (debug) console.log("".concat(LOG, " Handling ad error"));
1302
1282
  adPlaying = false;
1303
1283
  setAdPlayingFlag(false);
1304
- restoreContentVideoStyles();
1305
1284
  if (adContainerEl) {
1306
1285
  adContainerEl.style.display = "none";
1307
1286
  adContainerEl.style.pointerEvents = "none";
@@ -1472,7 +1451,6 @@ function createVastAdLayer(contentVideo, options) {
1472
1451
  ];
1473
1452
  contentVideo.style.visibility = "visible";
1474
1453
  contentVideo.style.opacity = "1";
1475
- applyContentVideoAdCoverStyles();
1476
1454
  emit("content_pause");
1477
1455
  setupAdEventListeners();
1478
1456
  adVolume2 = originalMutedState ? 1 : originalVolume;
@@ -1711,7 +1689,6 @@ function createVastAdLayer(contentVideo, options) {
1711
1689
  ];
1712
1690
  contentVideo.style.visibility = "visible";
1713
1691
  contentVideo.style.opacity = "1";
1714
- applyContentVideoAdCoverStyles();
1715
1692
  emit("content_pause");
1716
1693
  setupAdEventListeners();
1717
1694
  adVolume2 = originalMutedState ? 1 : originalVolume;
@@ -1862,7 +1839,6 @@ function createVastAdLayer(contentVideo, options) {
1862
1839
  if (debug) console.log("".concat(LOG, " Stopping ad"));
1863
1840
  adPlaying = false;
1864
1841
  setAdPlayingFlag(false);
1865
- restoreContentVideoStyles();
1866
1842
  contentVideo.muted = originalMutedState;
1867
1843
  contentVideo.volume = originalMutedState ? 0 : originalVolume;
1868
1844
  contentVideo.style.visibility = "visible";
@@ -1901,7 +1877,6 @@ function createVastAdLayer(contentVideo, options) {
1901
1877
  destroyed = true;
1902
1878
  adPlaying = false;
1903
1879
  setAdPlayingFlag(false);
1904
- restoreContentVideoStyles();
1905
1880
  contentVideo.muted = originalMutedState;
1906
1881
  contentVideo.volume = originalVolume;
1907
1882
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2254,24 +2229,30 @@ function getBrowserID(clientInfo) {
2254
2229
  });
2255
2230
  })();
2256
2231
  }
2257
- var TRACK_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track";
2232
+ var PLAYER_TRACKING_BASE_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking";
2233
+ var TRACK_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/metrics/ingest");
2234
+ var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
2235
+ var IMPRESSIONS_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/impressions/ingest");
2236
+ function buildHeaders(licenseKey) {
2237
+ var headers = {
2238
+ "Content-Type": "application/json"
2239
+ };
2240
+ if (licenseKey) {
2241
+ headers["Authorization"] = "Bearer ".concat(licenseKey);
2242
+ }
2243
+ return headers;
2244
+ }
2258
2245
  function sendTrackRequest(licenseKey, body) {
2259
2246
  return _async_to_generator(function() {
2260
- var headers, response;
2247
+ var response;
2261
2248
  return _ts_generator(this, function(_state) {
2262
2249
  switch(_state.label){
2263
2250
  case 0:
2264
- headers = {
2265
- "Content-Type": "application/json"
2266
- };
2267
- if (licenseKey) {
2268
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2269
- }
2270
2251
  return [
2271
2252
  4,
2272
2253
  fetch(TRACK_URL, {
2273
2254
  method: "POST",
2274
- headers: headers,
2255
+ headers: buildHeaders(licenseKey),
2275
2256
  body: JSON.stringify(body)
2276
2257
  })
2277
2258
  ];
@@ -2293,14 +2274,86 @@ function sendTrackRequest(licenseKey, body) {
2293
2274
  });
2294
2275
  })();
2295
2276
  }
2296
- function sendInitialTracking(licenseKey) {
2277
+ function postJson(url, licenseKey, body) {
2297
2278
  return _async_to_generator(function() {
2298
- var clientInfo, browserId, trackingData, headers, response, error;
2279
+ var response;
2280
+ return _ts_generator(this, function(_state) {
2281
+ switch(_state.label){
2282
+ case 0:
2283
+ return [
2284
+ 4,
2285
+ fetch(url, {
2286
+ method: "POST",
2287
+ headers: buildHeaders(licenseKey),
2288
+ body: JSON.stringify(body)
2289
+ })
2290
+ ];
2291
+ case 1:
2292
+ response = _state.sent();
2293
+ if (!response.ok) {
2294
+ throw new Error("HTTP error! status: ".concat(response.status));
2295
+ }
2296
+ return [
2297
+ 4,
2298
+ response.json()
2299
+ ];
2300
+ case 2:
2301
+ _state.sent();
2302
+ return [
2303
+ 2
2304
+ ];
2305
+ }
2306
+ });
2307
+ })();
2308
+ }
2309
+ function buildPlayerMetricEvent(_0) {
2310
+ return _async_to_generator(function(licenseKey) {
2311
+ var context, flags, _flags_captureAt, clientInfo, browserId, captureAt;
2312
+ var _arguments = arguments;
2313
+ return _ts_generator(this, function(_state) {
2314
+ switch(_state.label){
2315
+ case 0:
2316
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2317
+ clientInfo = getClientInfo();
2318
+ return [
2319
+ 4,
2320
+ getBrowserID(clientInfo)
2321
+ ];
2322
+ case 1:
2323
+ browserId = _state.sent();
2324
+ captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
2325
+ return [
2326
+ 2,
2327
+ {
2328
+ player_id: browserId,
2329
+ browserId: browserId,
2330
+ device_type: clientInfo.deviceType,
2331
+ deviceType: clientInfo.deviceType,
2332
+ input_stream_type: context.inputStreamType,
2333
+ os: clientInfo.os,
2334
+ ad_loaded: flags.adLoaded,
2335
+ ad_detect: flags.adDetect,
2336
+ license_key: licenseKey,
2337
+ capture_at: captureAt,
2338
+ timestamp: captureAt
2339
+ }
2340
+ ];
2341
+ }
2342
+ });
2343
+ }).apply(this, arguments);
2344
+ }
2345
+ function sendInitialTracking(_0) {
2346
+ return _async_to_generator(function(licenseKey) {
2347
+ var context, clientInfo, browserId, trackingData, error;
2348
+ var _arguments = arguments;
2299
2349
  return _ts_generator(this, function(_state) {
2300
2350
  switch(_state.label){
2301
2351
  case 0:
2352
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
2353
+ _state.label = 1;
2354
+ case 1:
2302
2355
  _state.trys.push([
2303
- 0,
2356
+ 1,
2304
2357
  4,
2305
2358
  ,
2306
2359
  5
@@ -2310,34 +2363,29 @@ function sendInitialTracking(licenseKey) {
2310
2363
  4,
2311
2364
  getBrowserID(clientInfo)
2312
2365
  ];
2313
- case 1:
2366
+ case 2:
2314
2367
  browserId = _state.sent();
2315
2368
  trackingData = _object_spread({
2316
2369
  browserId: browserId
2317
2370
  }, clientInfo);
2318
- headers = {
2319
- "Content-Type": "application/json"
2320
- };
2321
- if (licenseKey) {
2322
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2323
- }
2324
2371
  return [
2325
2372
  4,
2326
- fetch(TRACK_URL, {
2327
- method: "POST",
2328
- headers: headers,
2329
- body: JSON.stringify(trackingData)
2373
+ sendTrackRequest(licenseKey, {
2374
+ events: [
2375
+ {
2376
+ player_id: browserId,
2377
+ device_type: clientInfo.deviceType,
2378
+ input_stream_type: context.inputStreamType,
2379
+ os: clientInfo.os,
2380
+ ad_loaded: false,
2381
+ ad_detect: false,
2382
+ license_key: licenseKey,
2383
+ capture_at: /* @__PURE__ */ new Date().toISOString()
2384
+ }
2385
+ ],
2386
+ trackingData: trackingData
2330
2387
  })
2331
2388
  ];
2332
- case 2:
2333
- response = _state.sent();
2334
- if (!response.ok) {
2335
- throw new Error("HTTP error! status: ".concat(response.status));
2336
- }
2337
- return [
2338
- 4,
2339
- response.json()
2340
- ];
2341
2389
  case 3:
2342
2390
  _state.sent();
2343
2391
  return [
@@ -2357,36 +2405,30 @@ function sendInitialTracking(licenseKey) {
2357
2405
  ];
2358
2406
  }
2359
2407
  });
2360
- })();
2408
+ }).apply(this, arguments);
2361
2409
  }
2362
- function sendAdDetectTracking(licenseKey, adDetectInfo) {
2363
- return _async_to_generator(function() {
2364
- var clientInfo, browserId, trackingData, error;
2410
+ function sendAdDetectTracking(_0, _1) {
2411
+ return _async_to_generator(function(licenseKey, adDetectInfo) {
2412
+ var context, error;
2413
+ var _arguments = arguments;
2365
2414
  return _ts_generator(this, function(_state) {
2366
2415
  switch(_state.label){
2367
2416
  case 0:
2417
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2418
+ _state.label = 1;
2419
+ case 1:
2368
2420
  _state.trys.push([
2369
- 0,
2421
+ 1,
2370
2422
  3,
2371
2423
  ,
2372
2424
  4
2373
2425
  ]);
2374
- clientInfo = getClientInfo();
2375
2426
  return [
2376
2427
  4,
2377
- getBrowserID(clientInfo)
2378
- ];
2379
- case 1:
2380
- browserId = _state.sent();
2381
- trackingData = _object_spread({
2382
- browserId: browserId
2383
- }, clientInfo);
2384
- return [
2385
- 4,
2386
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2387
- licenseKey: licenseKey,
2388
- adDetectInfo: adDetectInfo
2389
- }))
2428
+ sendHeartbeat(licenseKey, context, {
2429
+ adDetect: true,
2430
+ captureAt: adDetectInfo.timestamp
2431
+ })
2390
2432
  ];
2391
2433
  case 2:
2392
2434
  _state.sent();
@@ -2407,36 +2449,30 @@ function sendAdDetectTracking(licenseKey, adDetectInfo) {
2407
2449
  ];
2408
2450
  }
2409
2451
  });
2410
- })();
2452
+ }).apply(this, arguments);
2411
2453
  }
2412
- function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
2413
- return _async_to_generator(function() {
2414
- var clientInfo, browserId, trackingData, error;
2454
+ function sendAdLoadedTracking(_0, _1) {
2455
+ return _async_to_generator(function(licenseKey, adLoadedInfo) {
2456
+ var context, error;
2457
+ var _arguments = arguments;
2415
2458
  return _ts_generator(this, function(_state) {
2416
2459
  switch(_state.label){
2417
2460
  case 0:
2461
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2462
+ _state.label = 1;
2463
+ case 1:
2418
2464
  _state.trys.push([
2419
- 0,
2465
+ 1,
2420
2466
  3,
2421
2467
  ,
2422
2468
  4
2423
2469
  ]);
2424
- clientInfo = getClientInfo();
2425
- return [
2426
- 4,
2427
- getBrowserID(clientInfo)
2428
- ];
2429
- case 1:
2430
- browserId = _state.sent();
2431
- trackingData = _object_spread({
2432
- browserId: browserId
2433
- }, clientInfo);
2434
2470
  return [
2435
2471
  4,
2436
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2437
- licenseKey: licenseKey,
2438
- adLoadedInfo: adLoadedInfo
2439
- }))
2472
+ sendHeartbeat(licenseKey, context, {
2473
+ adLoaded: true,
2474
+ captureAt: adLoadedInfo.timestamp
2475
+ })
2440
2476
  ];
2441
2477
  case 2:
2442
2478
  _state.sent();
@@ -2457,103 +2493,95 @@ function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
2457
2493
  ];
2458
2494
  }
2459
2495
  });
2460
- })();
2496
+ }).apply(this, arguments);
2461
2497
  }
2462
- function sendAdImpressionTracking(licenseKey, adImpressionInfo) {
2463
- return _async_to_generator(function() {
2464
- var clientInfo, browserId, trackingData, error;
2498
+ function sendAdImpressionTracking(_0, _1) {
2499
+ return _async_to_generator(function(licenseKey, adImpressionInfo) {
2500
+ var context, metricEvent, error;
2501
+ var _arguments = arguments;
2465
2502
  return _ts_generator(this, function(_state) {
2466
2503
  switch(_state.label){
2467
2504
  case 0:
2505
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2506
+ _state.label = 1;
2507
+ case 1:
2468
2508
  _state.trys.push([
2469
- 0,
2470
- 3,
2509
+ 1,
2510
+ 4,
2471
2511
  ,
2472
- 4
2512
+ 5
2473
2513
  ]);
2474
- clientInfo = getClientInfo();
2475
2514
  return [
2476
2515
  4,
2477
- getBrowserID(clientInfo)
2516
+ buildPlayerMetricEvent(licenseKey, context, {
2517
+ captureAt: adImpressionInfo.timestamp
2518
+ })
2478
2519
  ];
2479
- case 1:
2480
- browserId = _state.sent();
2481
- trackingData = _object_spread({
2482
- browserId: browserId
2483
- }, clientInfo);
2520
+ case 2:
2521
+ metricEvent = _state.sent();
2484
2522
  return [
2485
2523
  4,
2486
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2487
- licenseKey: licenseKey,
2488
- adImpressionInfo: adImpressionInfo
2489
- }))
2524
+ Promise.all([
2525
+ postJson(HEARTBEAT_URL, licenseKey, metricEvent),
2526
+ postJson(IMPRESSIONS_URL, licenseKey, {
2527
+ events: [
2528
+ {
2529
+ player_id: metricEvent.player_id,
2530
+ ad_played_count: 1,
2531
+ ad_url: adImpressionInfo.adUrl,
2532
+ license_key: licenseKey,
2533
+ capture_at: adImpressionInfo.timestamp
2534
+ }
2535
+ ]
2536
+ })
2537
+ ])
2490
2538
  ];
2491
- case 2:
2539
+ case 3:
2492
2540
  _state.sent();
2493
2541
  return [
2494
2542
  3,
2495
- 4
2543
+ 5
2496
2544
  ];
2497
- case 3:
2545
+ case 4:
2498
2546
  error = _state.sent();
2499
2547
  console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
2500
2548
  return [
2501
2549
  3,
2502
- 4
2550
+ 5
2503
2551
  ];
2504
- case 4:
2552
+ case 5:
2505
2553
  return [
2506
2554
  2
2507
2555
  ];
2508
2556
  }
2509
2557
  });
2510
- })();
2558
+ }).apply(this, arguments);
2511
2559
  }
2512
- function sendHeartbeat(licenseKey) {
2513
- return _async_to_generator(function() {
2514
- var clientInfo, browserId, heartbeatData, headers, response, error;
2560
+ function sendHeartbeat(_0) {
2561
+ return _async_to_generator(function(licenseKey) {
2562
+ var context, flags, heartbeatData, error;
2563
+ var _arguments = arguments;
2515
2564
  return _ts_generator(this, function(_state) {
2516
2565
  switch(_state.label){
2517
2566
  case 0:
2567
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2568
+ _state.label = 1;
2569
+ case 1:
2518
2570
  _state.trys.push([
2519
- 0,
2571
+ 1,
2520
2572
  4,
2521
2573
  ,
2522
2574
  5
2523
2575
  ]);
2524
- clientInfo = getClientInfo();
2525
2576
  return [
2526
2577
  4,
2527
- getBrowserID(clientInfo)
2528
- ];
2529
- case 1:
2530
- browserId = _state.sent();
2531
- heartbeatData = {
2532
- browserId: browserId,
2533
- timestamp: /* @__PURE__ */ new Date().toISOString()
2534
- };
2535
- headers = {
2536
- "Content-Type": "application/json"
2537
- };
2538
- if (licenseKey) {
2539
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2540
- }
2541
- return [
2542
- 4,
2543
- fetch("https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/heartbeat", {
2544
- method: "POST",
2545
- headers: headers,
2546
- body: JSON.stringify(heartbeatData)
2547
- })
2578
+ buildPlayerMetricEvent(licenseKey, context, flags)
2548
2579
  ];
2549
2580
  case 2:
2550
- response = _state.sent();
2551
- if (!response.ok) {
2552
- throw new Error("HTTP error! status: ".concat(response.status));
2553
- }
2581
+ heartbeatData = _state.sent();
2554
2582
  return [
2555
2583
  4,
2556
- response.json()
2584
+ postJson(HEARTBEAT_URL, licenseKey, heartbeatData)
2557
2585
  ];
2558
2586
  case 3:
2559
2587
  _state.sent();
@@ -2574,7 +2602,7 @@ function sendHeartbeat(licenseKey) {
2574
2602
  ];
2575
2603
  }
2576
2604
  });
2577
- })();
2605
+ }).apply(this, arguments);
2578
2606
  }
2579
2607
  // src/utils/polyfills.ts
2580
2608
  function polyfillURLSearchParams() {
@@ -3589,17 +3617,62 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3589
3617
  return "vast";
3590
3618
  }
3591
3619
  },
3620
+ {
3621
+ key: "getInputStreamType",
3622
+ value: function getInputStreamType() {
3623
+ var src = this.config.src.toLowerCase();
3624
+ if (src.includes(".m3u8")) return "hls";
3625
+ if (src.includes(".mpd")) return "dash";
3626
+ if (src.includes(".mp4")) return "mp4";
3627
+ return this.isLiveStream ? "live" : "vod";
3628
+ }
3629
+ },
3630
+ {
3631
+ key: "getAnalyticsContext",
3632
+ value: function getAnalyticsContext() {
3633
+ return {
3634
+ inputStreamType: this.getInputStreamType()
3635
+ };
3636
+ }
3637
+ },
3638
+ {
3639
+ key: "getAdUrlFromBids",
3640
+ value: function getAdUrlFromBids(bids) {
3641
+ var _bids_;
3642
+ return bids === null || bids === void 0 ? void 0 : (_bids_ = bids[0]) === null || _bids_ === void 0 ? void 0 : _bids_.vastUrl;
3643
+ }
3644
+ },
3645
+ {
3646
+ key: "trackAdLoaded",
3647
+ value: function trackAdLoaded(bids) {
3648
+ if (!this.config.licenseKey) return;
3649
+ var adUrl = this.getAdUrlFromBids(bids);
3650
+ if (adUrl) {
3651
+ this.lastServedAdUrl = adUrl;
3652
+ }
3653
+ sendAdLoadedTracking(this.config.licenseKey, _object_spread_props(_object_spread({
3654
+ source: this.getAdSource()
3655
+ }, adUrl ? {
3656
+ vastUrl: adUrl
3657
+ } : {}), {
3658
+ timestamp: /* @__PURE__ */ new Date().toISOString()
3659
+ }), this.getAnalyticsContext());
3660
+ }
3661
+ },
3592
3662
  {
3593
3663
  key: "attachAdLayerEventListeners",
3594
3664
  value: function attachAdLayerEventListeners() {
3595
3665
  var _this = this;
3596
3666
  this.adLayer.on("ad_impression", function() {
3597
3667
  if (_this.config.licenseKey) {
3598
- sendAdImpressionTracking(_this.config.licenseKey, {
3668
+ sendAdImpressionTracking(_this.config.licenseKey, _object_spread_props(_object_spread({
3599
3669
  source: _this.getAdSource(),
3600
- adIndex: _this.currentAdIndex,
3670
+ adIndex: _this.currentAdIndex
3671
+ }, _this.lastServedAdUrl ? {
3672
+ adUrl: _this.lastServedAdUrl
3673
+ } : {}), {
3601
3674
  timestamp: /* @__PURE__ */ new Date().toISOString()
3602
- });
3675
+ }), _this.getAnalyticsContext());
3603
3676
  }
3604
3677
  });
3605
3678
  this.adLayer.on("ad_error", function(errorPayload) {
@@ -3693,6 +3766,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3693
3766
  _this.isInAdTransition = false;
3694
3767
  if (!_this.inAdBreak) return;
3695
3768
  _this.currentAdIndex++;
3769
+ _this.trackAdLoaded();
3696
3770
  _this.adLayer.playPreloaded(token).catch(function(err) {
3697
3771
  if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playPreloaded failed:", err);
3698
3772
  _this.handleAdFailure();
@@ -3722,6 +3796,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3722
3796
  var freshBids = (_this_pendingNextAdBids = _this.pendingNextAdBids) !== null && _this_pendingNextAdBids !== void 0 ? _this_pendingNextAdBids : bids;
3723
3797
  _this.pendingNextAdBids = null;
3724
3798
  _this.currentAdIndex++;
3799
+ _this.trackAdLoaded(freshBids);
3725
3800
  _this.adLayer.playAd(freshBids).catch(function(err) {
3726
3801
  if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playAd(pending) failed:", err);
3727
3802
  _this.handleAdFailure();
@@ -4101,7 +4176,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4101
4176
  }, ((_this_pendingAdBreak1 = this.pendingAdBreak) === null || _this_pendingAdBreak1 === void 0 ? void 0 : _this_pendingAdBreak1.detectedAtFragmentSn) != null && {
4102
4177
  detectedAtFragmentSn: this.pendingAdBreak.detectedAtFragmentSn
4103
4178
  });
4104
- sendAdDetectTracking(this.config.licenseKey, adDetectInfo);
4179
+ sendAdDetectTracking(this.config.licenseKey, adDetectInfo, this.getAnalyticsContext());
4105
4180
  }
4106
4181
  var isManifestMarker = this.isManifestBasedMarker(marker);
4107
4182
  var forceImmediate = (_this_config_immediateManifestAds = this.config.immediateManifestAds) !== null && _this_config_immediateManifestAds !== void 0 ? _this_config_immediateManifestAds : true;
@@ -4170,6 +4245,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4170
4245
  var bids = this.pendingNextAdBids;
4171
4246
  this.pendingNextAdBids = null;
4172
4247
  this.currentAdIndex++;
4248
+ this.trackAdLoaded(bids);
4173
4249
  this.adLayer.playAd(bids).catch(function() {
4174
4250
  return _this.handleAdFailure();
4175
4251
  });
@@ -4424,7 +4500,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4424
4500
  key: "initializeTracking",
4425
4501
  value: function initializeTracking() {
4426
4502
  var _this = this;
4427
- sendInitialTracking(this.config.licenseKey).then(function() {
4503
+ sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
4428
4504
  _this.heartbeatInterval = window.setInterval(function() {
4429
4505
  _this.sendHeartbeatIfNeeded();
4430
4506
  }, 5e3);
@@ -4445,7 +4521,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4445
4521
  var now = Date.now();
4446
4522
  if (!this.lastHeartbeatTime || now - this.lastHeartbeatTime > 3e4) {
4447
4523
  this.lastHeartbeatTime = now;
4448
- sendHeartbeat(this.config.licenseKey).catch(function(error) {
4524
+ sendHeartbeat(this.config.licenseKey, this.getAnalyticsContext()).catch(function(error) {
4449
4525
  if (_this.config.debugAdTiming) {
4450
4526
  console.warn("[StormcloudVideoPlayer] Failed to send heartbeat:", error);
4451
4527
  }
@@ -4838,12 +4914,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4838
4914
  10
4839
4915
  ];
4840
4916
  _this.currentAdIndex++;
4841
- if (_this.config.licenseKey) {
4842
- sendAdLoadedTracking(_this.config.licenseKey, {
4843
- source: _this.getAdSource(),
4844
- timestamp: /* @__PURE__ */ new Date().toISOString()
4845
- });
4846
- }
4917
+ _this.trackAdLoaded(bids1);
4847
4918
  return [
4848
4919
  4,
4849
4920
  _this.adLayer.playAd(bids1)
@@ -4948,12 +5019,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4948
5019
  ];
4949
5020
  case 18:
4950
5021
  _this.currentAdIndex++;
4951
- if (_this.config.licenseKey) {
4952
- sendAdLoadedTracking(_this.config.licenseKey, {
4953
- source: _this.getAdSource(),
4954
- timestamp: /* @__PURE__ */ new Date().toISOString()
4955
- });
4956
- }
5022
+ _this.trackAdLoaded(bids2);
4957
5023
  return [
4958
5024
  4,
4959
5025
  _this.adLayer.playAd(bids2)
@@ -5112,12 +5178,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5112
5178
  6
5113
5179
  ];
5114
5180
  this.currentAdIndex++;
5115
- if (this.config.licenseKey) {
5116
- sendAdLoadedTracking(this.config.licenseKey, {
5117
- source: this.getAdSource(),
5118
- timestamp: /* @__PURE__ */ new Date().toISOString()
5119
- });
5120
- }
5181
+ this.trackAdLoaded();
5121
5182
  _state.label = 1;
5122
5183
  case 1:
5123
5184
  _state.trys.push([
@@ -5311,12 +5372,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5311
5372
  5
5312
5373
  ];
5313
5374
  case 3:
5314
- if (this.config.licenseKey) {
5315
- sendAdLoadedTracking(this.config.licenseKey, {
5316
- source: this.getAdSource(),
5317
- timestamp: /* @__PURE__ */ new Date().toISOString()
5318
- });
5319
- }
5375
+ this.trackAdLoaded(bids);
5320
5376
  return [
5321
5377
  4,
5322
5378
  this.adLayer.playAd(bids)
@@ -5462,6 +5518,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5462
5518
  ,
5463
5519
  7
5464
5520
  ]);
5521
+ this.trackAdLoaded(bids);
5465
5522
  return [
5466
5523
  4,
5467
5524
  this.adLayer.playAd(bids)