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.
@@ -980,7 +980,6 @@ function createVastAdLayer(contentVideo, options) {
980
980
  var tornDown = false;
981
981
  var trackingFired = createEmptyTrackingState();
982
982
  var adStallTimerId;
983
- var savedContentVideoStyles;
984
983
  var currentAdEventHandlers;
985
984
  var preloadSlots = /* @__PURE__ */ new Map();
986
985
  function emit(event, payload) {
@@ -1097,7 +1096,7 @@ function createVastAdLayer(contentVideo, options) {
1097
1096
  video.style.top = "0";
1098
1097
  video.style.width = "100%";
1099
1098
  video.style.height = "100%";
1100
- video.style.objectFit = "cover";
1099
+ video.style.objectFit = "contain";
1101
1100
  video.style.backgroundColor = "#000";
1102
1101
  video.playsInline = true;
1103
1102
  video.muted = false;
@@ -1212,31 +1211,12 @@ function createVastAdLayer(contentVideo, options) {
1212
1211
  delete contentVideo.dataset.stormcloudAdPlaying;
1213
1212
  }
1214
1213
  }
1215
- function applyContentVideoAdCoverStyles() {
1216
- if (!singleElementMode) return;
1217
- savedContentVideoStyles = {
1218
- objectFit: contentVideo.style.objectFit,
1219
- width: contentVideo.style.width,
1220
- height: contentVideo.style.height
1221
- };
1222
- contentVideo.style.objectFit = "cover";
1223
- contentVideo.style.width = "100%";
1224
- contentVideo.style.height = "100%";
1225
- }
1226
- function restoreContentVideoStyles() {
1227
- if (!singleElementMode || !savedContentVideoStyles) return;
1228
- contentVideo.style.objectFit = savedContentVideoStyles.objectFit;
1229
- contentVideo.style.width = savedContentVideoStyles.width;
1230
- contentVideo.style.height = savedContentVideoStyles.height;
1231
- savedContentVideoStyles = void 0;
1232
- }
1233
1214
  function handleAdComplete() {
1234
1215
  if (tornDown) return;
1235
1216
  clearAdStallTimer();
1236
1217
  if (debug) console.log("".concat(LOG, " Handling ad completion"));
1237
1218
  adPlaying = false;
1238
1219
  setAdPlayingFlag(false);
1239
- restoreContentVideoStyles();
1240
1220
  if (adContainerEl) {
1241
1221
  adContainerEl.style.display = "none";
1242
1222
  adContainerEl.style.pointerEvents = "none";
@@ -1251,7 +1231,6 @@ function createVastAdLayer(contentVideo, options) {
1251
1231
  if (debug) console.log("".concat(LOG, " Handling ad error"));
1252
1232
  adPlaying = false;
1253
1233
  setAdPlayingFlag(false);
1254
- restoreContentVideoStyles();
1255
1234
  if (adContainerEl) {
1256
1235
  adContainerEl.style.display = "none";
1257
1236
  adContainerEl.style.pointerEvents = "none";
@@ -1422,7 +1401,6 @@ function createVastAdLayer(contentVideo, options) {
1422
1401
  ];
1423
1402
  contentVideo.style.visibility = "visible";
1424
1403
  contentVideo.style.opacity = "1";
1425
- applyContentVideoAdCoverStyles();
1426
1404
  emit("content_pause");
1427
1405
  setupAdEventListeners();
1428
1406
  adVolume2 = originalMutedState ? 1 : originalVolume;
@@ -1661,7 +1639,6 @@ function createVastAdLayer(contentVideo, options) {
1661
1639
  ];
1662
1640
  contentVideo.style.visibility = "visible";
1663
1641
  contentVideo.style.opacity = "1";
1664
- applyContentVideoAdCoverStyles();
1665
1642
  emit("content_pause");
1666
1643
  setupAdEventListeners();
1667
1644
  adVolume2 = originalMutedState ? 1 : originalVolume;
@@ -1812,7 +1789,6 @@ function createVastAdLayer(contentVideo, options) {
1812
1789
  if (debug) console.log("".concat(LOG, " Stopping ad"));
1813
1790
  adPlaying = false;
1814
1791
  setAdPlayingFlag(false);
1815
- restoreContentVideoStyles();
1816
1792
  contentVideo.muted = originalMutedState;
1817
1793
  contentVideo.volume = originalMutedState ? 0 : originalVolume;
1818
1794
  contentVideo.style.visibility = "visible";
@@ -1851,7 +1827,6 @@ function createVastAdLayer(contentVideo, options) {
1851
1827
  destroyed = true;
1852
1828
  adPlaying = false;
1853
1829
  setAdPlayingFlag(false);
1854
- restoreContentVideoStyles();
1855
1830
  contentVideo.muted = originalMutedState;
1856
1831
  contentVideo.volume = originalVolume;
1857
1832
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2204,24 +2179,30 @@ function getBrowserID(clientInfo) {
2204
2179
  });
2205
2180
  })();
2206
2181
  }
2207
- var TRACK_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track";
2182
+ var PLAYER_TRACKING_BASE_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking";
2183
+ var TRACK_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/metrics/ingest");
2184
+ var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
2185
+ var IMPRESSIONS_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/impressions/ingest");
2186
+ function buildHeaders(licenseKey) {
2187
+ var headers = {
2188
+ "Content-Type": "application/json"
2189
+ };
2190
+ if (licenseKey) {
2191
+ headers["Authorization"] = "Bearer ".concat(licenseKey);
2192
+ }
2193
+ return headers;
2194
+ }
2208
2195
  function sendTrackRequest(licenseKey, body) {
2209
2196
  return _async_to_generator(function() {
2210
- var headers, response;
2197
+ var response;
2211
2198
  return _ts_generator(this, function(_state) {
2212
2199
  switch(_state.label){
2213
2200
  case 0:
2214
- headers = {
2215
- "Content-Type": "application/json"
2216
- };
2217
- if (licenseKey) {
2218
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2219
- }
2220
2201
  return [
2221
2202
  4,
2222
2203
  fetch(TRACK_URL, {
2223
2204
  method: "POST",
2224
- headers: headers,
2205
+ headers: buildHeaders(licenseKey),
2225
2206
  body: JSON.stringify(body)
2226
2207
  })
2227
2208
  ];
@@ -2243,14 +2224,86 @@ function sendTrackRequest(licenseKey, body) {
2243
2224
  });
2244
2225
  })();
2245
2226
  }
2246
- function sendInitialTracking(licenseKey) {
2227
+ function postJson(url, licenseKey, body) {
2247
2228
  return _async_to_generator(function() {
2248
- var clientInfo, browserId, trackingData, headers, response, error;
2229
+ var response;
2230
+ return _ts_generator(this, function(_state) {
2231
+ switch(_state.label){
2232
+ case 0:
2233
+ return [
2234
+ 4,
2235
+ fetch(url, {
2236
+ method: "POST",
2237
+ headers: buildHeaders(licenseKey),
2238
+ body: JSON.stringify(body)
2239
+ })
2240
+ ];
2241
+ case 1:
2242
+ response = _state.sent();
2243
+ if (!response.ok) {
2244
+ throw new Error("HTTP error! status: ".concat(response.status));
2245
+ }
2246
+ return [
2247
+ 4,
2248
+ response.json()
2249
+ ];
2250
+ case 2:
2251
+ _state.sent();
2252
+ return [
2253
+ 2
2254
+ ];
2255
+ }
2256
+ });
2257
+ })();
2258
+ }
2259
+ function buildPlayerMetricEvent(_0) {
2260
+ return _async_to_generator(function(licenseKey) {
2261
+ var context, flags, _flags_captureAt, clientInfo, browserId, captureAt;
2262
+ var _arguments = arguments;
2263
+ return _ts_generator(this, function(_state) {
2264
+ switch(_state.label){
2265
+ case 0:
2266
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2267
+ clientInfo = getClientInfo();
2268
+ return [
2269
+ 4,
2270
+ getBrowserID(clientInfo)
2271
+ ];
2272
+ case 1:
2273
+ browserId = _state.sent();
2274
+ captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
2275
+ return [
2276
+ 2,
2277
+ {
2278
+ player_id: browserId,
2279
+ browserId: browserId,
2280
+ device_type: clientInfo.deviceType,
2281
+ deviceType: clientInfo.deviceType,
2282
+ input_stream_type: context.inputStreamType,
2283
+ os: clientInfo.os,
2284
+ ad_loaded: flags.adLoaded,
2285
+ ad_detect: flags.adDetect,
2286
+ license_key: licenseKey,
2287
+ capture_at: captureAt,
2288
+ timestamp: captureAt
2289
+ }
2290
+ ];
2291
+ }
2292
+ });
2293
+ }).apply(this, arguments);
2294
+ }
2295
+ function sendInitialTracking(_0) {
2296
+ return _async_to_generator(function(licenseKey) {
2297
+ var context, clientInfo, browserId, trackingData, error;
2298
+ var _arguments = arguments;
2249
2299
  return _ts_generator(this, function(_state) {
2250
2300
  switch(_state.label){
2251
2301
  case 0:
2302
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
2303
+ _state.label = 1;
2304
+ case 1:
2252
2305
  _state.trys.push([
2253
- 0,
2306
+ 1,
2254
2307
  4,
2255
2308
  ,
2256
2309
  5
@@ -2260,34 +2313,29 @@ function sendInitialTracking(licenseKey) {
2260
2313
  4,
2261
2314
  getBrowserID(clientInfo)
2262
2315
  ];
2263
- case 1:
2316
+ case 2:
2264
2317
  browserId = _state.sent();
2265
2318
  trackingData = _object_spread({
2266
2319
  browserId: browserId
2267
2320
  }, clientInfo);
2268
- headers = {
2269
- "Content-Type": "application/json"
2270
- };
2271
- if (licenseKey) {
2272
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2273
- }
2274
2321
  return [
2275
2322
  4,
2276
- fetch(TRACK_URL, {
2277
- method: "POST",
2278
- headers: headers,
2279
- body: JSON.stringify(trackingData)
2323
+ sendTrackRequest(licenseKey, {
2324
+ events: [
2325
+ {
2326
+ player_id: browserId,
2327
+ device_type: clientInfo.deviceType,
2328
+ input_stream_type: context.inputStreamType,
2329
+ os: clientInfo.os,
2330
+ ad_loaded: false,
2331
+ ad_detect: false,
2332
+ license_key: licenseKey,
2333
+ capture_at: /* @__PURE__ */ new Date().toISOString()
2334
+ }
2335
+ ],
2336
+ trackingData: trackingData
2280
2337
  })
2281
2338
  ];
2282
- case 2:
2283
- response = _state.sent();
2284
- if (!response.ok) {
2285
- throw new Error("HTTP error! status: ".concat(response.status));
2286
- }
2287
- return [
2288
- 4,
2289
- response.json()
2290
- ];
2291
2339
  case 3:
2292
2340
  _state.sent();
2293
2341
  return [
@@ -2307,36 +2355,30 @@ function sendInitialTracking(licenseKey) {
2307
2355
  ];
2308
2356
  }
2309
2357
  });
2310
- })();
2358
+ }).apply(this, arguments);
2311
2359
  }
2312
- function sendAdDetectTracking(licenseKey, adDetectInfo) {
2313
- return _async_to_generator(function() {
2314
- var clientInfo, browserId, trackingData, error;
2360
+ function sendAdDetectTracking(_0, _1) {
2361
+ return _async_to_generator(function(licenseKey, adDetectInfo) {
2362
+ var context, error;
2363
+ var _arguments = arguments;
2315
2364
  return _ts_generator(this, function(_state) {
2316
2365
  switch(_state.label){
2317
2366
  case 0:
2367
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2368
+ _state.label = 1;
2369
+ case 1:
2318
2370
  _state.trys.push([
2319
- 0,
2371
+ 1,
2320
2372
  3,
2321
2373
  ,
2322
2374
  4
2323
2375
  ]);
2324
- clientInfo = getClientInfo();
2325
2376
  return [
2326
2377
  4,
2327
- getBrowserID(clientInfo)
2328
- ];
2329
- case 1:
2330
- browserId = _state.sent();
2331
- trackingData = _object_spread({
2332
- browserId: browserId
2333
- }, clientInfo);
2334
- return [
2335
- 4,
2336
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2337
- licenseKey: licenseKey,
2338
- adDetectInfo: adDetectInfo
2339
- }))
2378
+ sendHeartbeat(licenseKey, context, {
2379
+ adDetect: true,
2380
+ captureAt: adDetectInfo.timestamp
2381
+ })
2340
2382
  ];
2341
2383
  case 2:
2342
2384
  _state.sent();
@@ -2357,36 +2399,30 @@ function sendAdDetectTracking(licenseKey, adDetectInfo) {
2357
2399
  ];
2358
2400
  }
2359
2401
  });
2360
- })();
2402
+ }).apply(this, arguments);
2361
2403
  }
2362
- function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
2363
- return _async_to_generator(function() {
2364
- var clientInfo, browserId, trackingData, error;
2404
+ function sendAdLoadedTracking(_0, _1) {
2405
+ return _async_to_generator(function(licenseKey, adLoadedInfo) {
2406
+ var context, error;
2407
+ var _arguments = arguments;
2365
2408
  return _ts_generator(this, function(_state) {
2366
2409
  switch(_state.label){
2367
2410
  case 0:
2411
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2412
+ _state.label = 1;
2413
+ case 1:
2368
2414
  _state.trys.push([
2369
- 0,
2415
+ 1,
2370
2416
  3,
2371
2417
  ,
2372
2418
  4
2373
2419
  ]);
2374
- clientInfo = getClientInfo();
2375
- return [
2376
- 4,
2377
- getBrowserID(clientInfo)
2378
- ];
2379
- case 1:
2380
- browserId = _state.sent();
2381
- trackingData = _object_spread({
2382
- browserId: browserId
2383
- }, clientInfo);
2384
2420
  return [
2385
2421
  4,
2386
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2387
- licenseKey: licenseKey,
2388
- adLoadedInfo: adLoadedInfo
2389
- }))
2422
+ sendHeartbeat(licenseKey, context, {
2423
+ adLoaded: true,
2424
+ captureAt: adLoadedInfo.timestamp
2425
+ })
2390
2426
  ];
2391
2427
  case 2:
2392
2428
  _state.sent();
@@ -2407,103 +2443,95 @@ function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
2407
2443
  ];
2408
2444
  }
2409
2445
  });
2410
- })();
2446
+ }).apply(this, arguments);
2411
2447
  }
2412
- function sendAdImpressionTracking(licenseKey, adImpressionInfo) {
2413
- return _async_to_generator(function() {
2414
- var clientInfo, browserId, trackingData, error;
2448
+ function sendAdImpressionTracking(_0, _1) {
2449
+ return _async_to_generator(function(licenseKey, adImpressionInfo) {
2450
+ var context, metricEvent, error;
2451
+ var _arguments = arguments;
2415
2452
  return _ts_generator(this, function(_state) {
2416
2453
  switch(_state.label){
2417
2454
  case 0:
2455
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2456
+ _state.label = 1;
2457
+ case 1:
2418
2458
  _state.trys.push([
2419
- 0,
2420
- 3,
2459
+ 1,
2460
+ 4,
2421
2461
  ,
2422
- 4
2462
+ 5
2423
2463
  ]);
2424
- clientInfo = getClientInfo();
2425
2464
  return [
2426
2465
  4,
2427
- getBrowserID(clientInfo)
2466
+ buildPlayerMetricEvent(licenseKey, context, {
2467
+ captureAt: adImpressionInfo.timestamp
2468
+ })
2428
2469
  ];
2429
- case 1:
2430
- browserId = _state.sent();
2431
- trackingData = _object_spread({
2432
- browserId: browserId
2433
- }, clientInfo);
2470
+ case 2:
2471
+ metricEvent = _state.sent();
2434
2472
  return [
2435
2473
  4,
2436
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2437
- licenseKey: licenseKey,
2438
- adImpressionInfo: adImpressionInfo
2439
- }))
2474
+ Promise.all([
2475
+ postJson(HEARTBEAT_URL, licenseKey, metricEvent),
2476
+ postJson(IMPRESSIONS_URL, licenseKey, {
2477
+ events: [
2478
+ {
2479
+ player_id: metricEvent.player_id,
2480
+ ad_played_count: 1,
2481
+ ad_url: adImpressionInfo.adUrl,
2482
+ license_key: licenseKey,
2483
+ capture_at: adImpressionInfo.timestamp
2484
+ }
2485
+ ]
2486
+ })
2487
+ ])
2440
2488
  ];
2441
- case 2:
2489
+ case 3:
2442
2490
  _state.sent();
2443
2491
  return [
2444
2492
  3,
2445
- 4
2493
+ 5
2446
2494
  ];
2447
- case 3:
2495
+ case 4:
2448
2496
  error = _state.sent();
2449
2497
  console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
2450
2498
  return [
2451
2499
  3,
2452
- 4
2500
+ 5
2453
2501
  ];
2454
- case 4:
2502
+ case 5:
2455
2503
  return [
2456
2504
  2
2457
2505
  ];
2458
2506
  }
2459
2507
  });
2460
- })();
2508
+ }).apply(this, arguments);
2461
2509
  }
2462
- function sendHeartbeat(licenseKey) {
2463
- return _async_to_generator(function() {
2464
- var clientInfo, browserId, heartbeatData, headers, response, error;
2510
+ function sendHeartbeat(_0) {
2511
+ return _async_to_generator(function(licenseKey) {
2512
+ var context, flags, heartbeatData, error;
2513
+ var _arguments = arguments;
2465
2514
  return _ts_generator(this, function(_state) {
2466
2515
  switch(_state.label){
2467
2516
  case 0:
2517
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2518
+ _state.label = 1;
2519
+ case 1:
2468
2520
  _state.trys.push([
2469
- 0,
2521
+ 1,
2470
2522
  4,
2471
2523
  ,
2472
2524
  5
2473
2525
  ]);
2474
- clientInfo = getClientInfo();
2475
2526
  return [
2476
2527
  4,
2477
- getBrowserID(clientInfo)
2478
- ];
2479
- case 1:
2480
- browserId = _state.sent();
2481
- heartbeatData = {
2482
- browserId: browserId,
2483
- timestamp: /* @__PURE__ */ new Date().toISOString()
2484
- };
2485
- headers = {
2486
- "Content-Type": "application/json"
2487
- };
2488
- if (licenseKey) {
2489
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2490
- }
2491
- return [
2492
- 4,
2493
- fetch("https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/heartbeat", {
2494
- method: "POST",
2495
- headers: headers,
2496
- body: JSON.stringify(heartbeatData)
2497
- })
2528
+ buildPlayerMetricEvent(licenseKey, context, flags)
2498
2529
  ];
2499
2530
  case 2:
2500
- response = _state.sent();
2501
- if (!response.ok) {
2502
- throw new Error("HTTP error! status: ".concat(response.status));
2503
- }
2531
+ heartbeatData = _state.sent();
2504
2532
  return [
2505
2533
  4,
2506
- response.json()
2534
+ postJson(HEARTBEAT_URL, licenseKey, heartbeatData)
2507
2535
  ];
2508
2536
  case 3:
2509
2537
  _state.sent();
@@ -2524,7 +2552,7 @@ function sendHeartbeat(licenseKey) {
2524
2552
  ];
2525
2553
  }
2526
2554
  });
2527
- })();
2555
+ }).apply(this, arguments);
2528
2556
  }
2529
2557
  // src/utils/polyfills.ts
2530
2558
  function polyfillURLSearchParams() {
@@ -3539,17 +3567,62 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3539
3567
  return "vast";
3540
3568
  }
3541
3569
  },
3570
+ {
3571
+ key: "getInputStreamType",
3572
+ value: function getInputStreamType() {
3573
+ var src = this.config.src.toLowerCase();
3574
+ if (src.includes(".m3u8")) return "hls";
3575
+ if (src.includes(".mpd")) return "dash";
3576
+ if (src.includes(".mp4")) return "mp4";
3577
+ return this.isLiveStream ? "live" : "vod";
3578
+ }
3579
+ },
3580
+ {
3581
+ key: "getAnalyticsContext",
3582
+ value: function getAnalyticsContext() {
3583
+ return {
3584
+ inputStreamType: this.getInputStreamType()
3585
+ };
3586
+ }
3587
+ },
3588
+ {
3589
+ key: "getAdUrlFromBids",
3590
+ value: function getAdUrlFromBids(bids) {
3591
+ var _bids_;
3592
+ return bids === null || bids === void 0 ? void 0 : (_bids_ = bids[0]) === null || _bids_ === void 0 ? void 0 : _bids_.vastUrl;
3593
+ }
3594
+ },
3595
+ {
3596
+ key: "trackAdLoaded",
3597
+ value: function trackAdLoaded(bids) {
3598
+ if (!this.config.licenseKey) return;
3599
+ var adUrl = this.getAdUrlFromBids(bids);
3600
+ if (adUrl) {
3601
+ this.lastServedAdUrl = adUrl;
3602
+ }
3603
+ sendAdLoadedTracking(this.config.licenseKey, _object_spread_props(_object_spread({
3604
+ source: this.getAdSource()
3605
+ }, adUrl ? {
3606
+ vastUrl: adUrl
3607
+ } : {}), {
3608
+ timestamp: /* @__PURE__ */ new Date().toISOString()
3609
+ }), this.getAnalyticsContext());
3610
+ }
3611
+ },
3542
3612
  {
3543
3613
  key: "attachAdLayerEventListeners",
3544
3614
  value: function attachAdLayerEventListeners() {
3545
3615
  var _this = this;
3546
3616
  this.adLayer.on("ad_impression", function() {
3547
3617
  if (_this.config.licenseKey) {
3548
- sendAdImpressionTracking(_this.config.licenseKey, {
3618
+ sendAdImpressionTracking(_this.config.licenseKey, _object_spread_props(_object_spread({
3549
3619
  source: _this.getAdSource(),
3550
- adIndex: _this.currentAdIndex,
3620
+ adIndex: _this.currentAdIndex
3621
+ }, _this.lastServedAdUrl ? {
3622
+ adUrl: _this.lastServedAdUrl
3623
+ } : {}), {
3551
3624
  timestamp: /* @__PURE__ */ new Date().toISOString()
3552
- });
3625
+ }), _this.getAnalyticsContext());
3553
3626
  }
3554
3627
  });
3555
3628
  this.adLayer.on("ad_error", function(errorPayload) {
@@ -3643,6 +3716,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3643
3716
  _this.isInAdTransition = false;
3644
3717
  if (!_this.inAdBreak) return;
3645
3718
  _this.currentAdIndex++;
3719
+ _this.trackAdLoaded();
3646
3720
  _this.adLayer.playPreloaded(token).catch(function(err) {
3647
3721
  if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playPreloaded failed:", err);
3648
3722
  _this.handleAdFailure();
@@ -3672,6 +3746,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3672
3746
  var freshBids = (_this_pendingNextAdBids = _this.pendingNextAdBids) !== null && _this_pendingNextAdBids !== void 0 ? _this_pendingNextAdBids : bids;
3673
3747
  _this.pendingNextAdBids = null;
3674
3748
  _this.currentAdIndex++;
3749
+ _this.trackAdLoaded(freshBids);
3675
3750
  _this.adLayer.playAd(freshBids).catch(function(err) {
3676
3751
  if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playAd(pending) failed:", err);
3677
3752
  _this.handleAdFailure();
@@ -4051,7 +4126,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4051
4126
  }, ((_this_pendingAdBreak1 = this.pendingAdBreak) === null || _this_pendingAdBreak1 === void 0 ? void 0 : _this_pendingAdBreak1.detectedAtFragmentSn) != null && {
4052
4127
  detectedAtFragmentSn: this.pendingAdBreak.detectedAtFragmentSn
4053
4128
  });
4054
- sendAdDetectTracking(this.config.licenseKey, adDetectInfo);
4129
+ sendAdDetectTracking(this.config.licenseKey, adDetectInfo, this.getAnalyticsContext());
4055
4130
  }
4056
4131
  var isManifestMarker = this.isManifestBasedMarker(marker);
4057
4132
  var forceImmediate = (_this_config_immediateManifestAds = this.config.immediateManifestAds) !== null && _this_config_immediateManifestAds !== void 0 ? _this_config_immediateManifestAds : true;
@@ -4120,6 +4195,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4120
4195
  var bids = this.pendingNextAdBids;
4121
4196
  this.pendingNextAdBids = null;
4122
4197
  this.currentAdIndex++;
4198
+ this.trackAdLoaded(bids);
4123
4199
  this.adLayer.playAd(bids).catch(function() {
4124
4200
  return _this.handleAdFailure();
4125
4201
  });
@@ -4374,7 +4450,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4374
4450
  key: "initializeTracking",
4375
4451
  value: function initializeTracking() {
4376
4452
  var _this = this;
4377
- sendInitialTracking(this.config.licenseKey).then(function() {
4453
+ sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
4378
4454
  _this.heartbeatInterval = window.setInterval(function() {
4379
4455
  _this.sendHeartbeatIfNeeded();
4380
4456
  }, 5e3);
@@ -4395,7 +4471,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4395
4471
  var now = Date.now();
4396
4472
  if (!this.lastHeartbeatTime || now - this.lastHeartbeatTime > 3e4) {
4397
4473
  this.lastHeartbeatTime = now;
4398
- sendHeartbeat(this.config.licenseKey).catch(function(error) {
4474
+ sendHeartbeat(this.config.licenseKey, this.getAnalyticsContext()).catch(function(error) {
4399
4475
  if (_this.config.debugAdTiming) {
4400
4476
  console.warn("[StormcloudVideoPlayer] Failed to send heartbeat:", error);
4401
4477
  }
@@ -4788,12 +4864,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4788
4864
  10
4789
4865
  ];
4790
4866
  _this.currentAdIndex++;
4791
- if (_this.config.licenseKey) {
4792
- sendAdLoadedTracking(_this.config.licenseKey, {
4793
- source: _this.getAdSource(),
4794
- timestamp: /* @__PURE__ */ new Date().toISOString()
4795
- });
4796
- }
4867
+ _this.trackAdLoaded(bids1);
4797
4868
  return [
4798
4869
  4,
4799
4870
  _this.adLayer.playAd(bids1)
@@ -4898,12 +4969,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4898
4969
  ];
4899
4970
  case 18:
4900
4971
  _this.currentAdIndex++;
4901
- if (_this.config.licenseKey) {
4902
- sendAdLoadedTracking(_this.config.licenseKey, {
4903
- source: _this.getAdSource(),
4904
- timestamp: /* @__PURE__ */ new Date().toISOString()
4905
- });
4906
- }
4972
+ _this.trackAdLoaded(bids2);
4907
4973
  return [
4908
4974
  4,
4909
4975
  _this.adLayer.playAd(bids2)
@@ -5062,12 +5128,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5062
5128
  6
5063
5129
  ];
5064
5130
  this.currentAdIndex++;
5065
- if (this.config.licenseKey) {
5066
- sendAdLoadedTracking(this.config.licenseKey, {
5067
- source: this.getAdSource(),
5068
- timestamp: /* @__PURE__ */ new Date().toISOString()
5069
- });
5070
- }
5131
+ this.trackAdLoaded();
5071
5132
  _state.label = 1;
5072
5133
  case 1:
5073
5134
  _state.trys.push([
@@ -5261,12 +5322,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5261
5322
  5
5262
5323
  ];
5263
5324
  case 3:
5264
- if (this.config.licenseKey) {
5265
- sendAdLoadedTracking(this.config.licenseKey, {
5266
- source: this.getAdSource(),
5267
- timestamp: /* @__PURE__ */ new Date().toISOString()
5268
- });
5269
- }
5325
+ this.trackAdLoaded(bids);
5270
5326
  return [
5271
5327
  4,
5272
5328
  this.adLayer.playAd(bids)
@@ -5412,6 +5468,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5412
5468
  ,
5413
5469
  7
5414
5470
  ]);
5471
+ this.trackAdLoaded(bids);
5415
5472
  return [
5416
5473
  4,
5417
5474
  this.adLayer.playAd(bids)