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.js CHANGED
@@ -964,7 +964,6 @@ function createVastAdLayer(contentVideo, options) {
964
964
  var tornDown = false;
965
965
  var trackingFired = createEmptyTrackingState();
966
966
  var adStallTimerId;
967
- var savedContentVideoStyles;
968
967
  var currentAdEventHandlers;
969
968
  var preloadSlots = /* @__PURE__ */ new Map();
970
969
  function emit(event, payload) {
@@ -1081,7 +1080,7 @@ function createVastAdLayer(contentVideo, options) {
1081
1080
  video.style.top = "0";
1082
1081
  video.style.width = "100%";
1083
1082
  video.style.height = "100%";
1084
- video.style.objectFit = "cover";
1083
+ video.style.objectFit = "contain";
1085
1084
  video.style.backgroundColor = "#000";
1086
1085
  video.playsInline = true;
1087
1086
  video.muted = false;
@@ -1196,31 +1195,12 @@ function createVastAdLayer(contentVideo, options) {
1196
1195
  delete contentVideo.dataset.stormcloudAdPlaying;
1197
1196
  }
1198
1197
  }
1199
- function applyContentVideoAdCoverStyles() {
1200
- if (!singleElementMode) return;
1201
- savedContentVideoStyles = {
1202
- objectFit: contentVideo.style.objectFit,
1203
- width: contentVideo.style.width,
1204
- height: contentVideo.style.height
1205
- };
1206
- contentVideo.style.objectFit = "cover";
1207
- contentVideo.style.width = "100%";
1208
- contentVideo.style.height = "100%";
1209
- }
1210
- function restoreContentVideoStyles() {
1211
- if (!singleElementMode || !savedContentVideoStyles) return;
1212
- contentVideo.style.objectFit = savedContentVideoStyles.objectFit;
1213
- contentVideo.style.width = savedContentVideoStyles.width;
1214
- contentVideo.style.height = savedContentVideoStyles.height;
1215
- savedContentVideoStyles = void 0;
1216
- }
1217
1198
  function handleAdComplete() {
1218
1199
  if (tornDown) return;
1219
1200
  clearAdStallTimer();
1220
1201
  if (debug) console.log("".concat(LOG, " Handling ad completion"));
1221
1202
  adPlaying = false;
1222
1203
  setAdPlayingFlag(false);
1223
- restoreContentVideoStyles();
1224
1204
  if (adContainerEl) {
1225
1205
  adContainerEl.style.display = "none";
1226
1206
  adContainerEl.style.pointerEvents = "none";
@@ -1235,7 +1215,6 @@ function createVastAdLayer(contentVideo, options) {
1235
1215
  if (debug) console.log("".concat(LOG, " Handling ad error"));
1236
1216
  adPlaying = false;
1237
1217
  setAdPlayingFlag(false);
1238
- restoreContentVideoStyles();
1239
1218
  if (adContainerEl) {
1240
1219
  adContainerEl.style.display = "none";
1241
1220
  adContainerEl.style.pointerEvents = "none";
@@ -1406,7 +1385,6 @@ function createVastAdLayer(contentVideo, options) {
1406
1385
  ];
1407
1386
  contentVideo.style.visibility = "visible";
1408
1387
  contentVideo.style.opacity = "1";
1409
- applyContentVideoAdCoverStyles();
1410
1388
  emit("content_pause");
1411
1389
  setupAdEventListeners();
1412
1390
  adVolume2 = originalMutedState ? 1 : originalVolume;
@@ -1645,7 +1623,6 @@ function createVastAdLayer(contentVideo, options) {
1645
1623
  ];
1646
1624
  contentVideo.style.visibility = "visible";
1647
1625
  contentVideo.style.opacity = "1";
1648
- applyContentVideoAdCoverStyles();
1649
1626
  emit("content_pause");
1650
1627
  setupAdEventListeners();
1651
1628
  adVolume2 = originalMutedState ? 1 : originalVolume;
@@ -1796,7 +1773,6 @@ function createVastAdLayer(contentVideo, options) {
1796
1773
  if (debug) console.log("".concat(LOG, " Stopping ad"));
1797
1774
  adPlaying = false;
1798
1775
  setAdPlayingFlag(false);
1799
- restoreContentVideoStyles();
1800
1776
  contentVideo.muted = originalMutedState;
1801
1777
  contentVideo.volume = originalMutedState ? 0 : originalVolume;
1802
1778
  contentVideo.style.visibility = "visible";
@@ -1835,7 +1811,6 @@ function createVastAdLayer(contentVideo, options) {
1835
1811
  destroyed = true;
1836
1812
  adPlaying = false;
1837
1813
  setAdPlayingFlag(false);
1838
- restoreContentVideoStyles();
1839
1814
  contentVideo.muted = originalMutedState;
1840
1815
  contentVideo.volume = originalVolume;
1841
1816
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2188,24 +2163,30 @@ function getBrowserID(clientInfo) {
2188
2163
  });
2189
2164
  })();
2190
2165
  }
2191
- var TRACK_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track";
2166
+ var PLAYER_TRACKING_BASE_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking";
2167
+ var TRACK_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/metrics/ingest");
2168
+ var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
2169
+ var IMPRESSIONS_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/impressions/ingest");
2170
+ function buildHeaders(licenseKey) {
2171
+ var headers = {
2172
+ "Content-Type": "application/json"
2173
+ };
2174
+ if (licenseKey) {
2175
+ headers["Authorization"] = "Bearer ".concat(licenseKey);
2176
+ }
2177
+ return headers;
2178
+ }
2192
2179
  function sendTrackRequest(licenseKey, body) {
2193
2180
  return _async_to_generator(function() {
2194
- var headers, response;
2181
+ var response;
2195
2182
  return _ts_generator(this, function(_state) {
2196
2183
  switch(_state.label){
2197
2184
  case 0:
2198
- headers = {
2199
- "Content-Type": "application/json"
2200
- };
2201
- if (licenseKey) {
2202
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2203
- }
2204
2185
  return [
2205
2186
  4,
2206
2187
  fetch(TRACK_URL, {
2207
2188
  method: "POST",
2208
- headers: headers,
2189
+ headers: buildHeaders(licenseKey),
2209
2190
  body: JSON.stringify(body)
2210
2191
  })
2211
2192
  ];
@@ -2227,14 +2208,86 @@ function sendTrackRequest(licenseKey, body) {
2227
2208
  });
2228
2209
  })();
2229
2210
  }
2230
- function sendInitialTracking(licenseKey) {
2211
+ function postJson(url, licenseKey, body) {
2231
2212
  return _async_to_generator(function() {
2232
- var clientInfo, browserId, trackingData, headers, response, error;
2213
+ var response;
2214
+ return _ts_generator(this, function(_state) {
2215
+ switch(_state.label){
2216
+ case 0:
2217
+ return [
2218
+ 4,
2219
+ fetch(url, {
2220
+ method: "POST",
2221
+ headers: buildHeaders(licenseKey),
2222
+ body: JSON.stringify(body)
2223
+ })
2224
+ ];
2225
+ case 1:
2226
+ response = _state.sent();
2227
+ if (!response.ok) {
2228
+ throw new Error("HTTP error! status: ".concat(response.status));
2229
+ }
2230
+ return [
2231
+ 4,
2232
+ response.json()
2233
+ ];
2234
+ case 2:
2235
+ _state.sent();
2236
+ return [
2237
+ 2
2238
+ ];
2239
+ }
2240
+ });
2241
+ })();
2242
+ }
2243
+ function buildPlayerMetricEvent(_0) {
2244
+ return _async_to_generator(function(licenseKey) {
2245
+ var context, flags, _flags_captureAt, clientInfo, browserId, captureAt;
2246
+ var _arguments = arguments;
2247
+ return _ts_generator(this, function(_state) {
2248
+ switch(_state.label){
2249
+ case 0:
2250
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2251
+ clientInfo = getClientInfo();
2252
+ return [
2253
+ 4,
2254
+ getBrowserID(clientInfo)
2255
+ ];
2256
+ case 1:
2257
+ browserId = _state.sent();
2258
+ captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
2259
+ return [
2260
+ 2,
2261
+ {
2262
+ player_id: browserId,
2263
+ browserId: browserId,
2264
+ device_type: clientInfo.deviceType,
2265
+ deviceType: clientInfo.deviceType,
2266
+ input_stream_type: context.inputStreamType,
2267
+ os: clientInfo.os,
2268
+ ad_loaded: flags.adLoaded,
2269
+ ad_detect: flags.adDetect,
2270
+ license_key: licenseKey,
2271
+ capture_at: captureAt,
2272
+ timestamp: captureAt
2273
+ }
2274
+ ];
2275
+ }
2276
+ });
2277
+ }).apply(this, arguments);
2278
+ }
2279
+ function sendInitialTracking(_0) {
2280
+ return _async_to_generator(function(licenseKey) {
2281
+ var context, clientInfo, browserId, trackingData, error;
2282
+ var _arguments = arguments;
2233
2283
  return _ts_generator(this, function(_state) {
2234
2284
  switch(_state.label){
2235
2285
  case 0:
2286
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
2287
+ _state.label = 1;
2288
+ case 1:
2236
2289
  _state.trys.push([
2237
- 0,
2290
+ 1,
2238
2291
  4,
2239
2292
  ,
2240
2293
  5
@@ -2244,34 +2297,29 @@ function sendInitialTracking(licenseKey) {
2244
2297
  4,
2245
2298
  getBrowserID(clientInfo)
2246
2299
  ];
2247
- case 1:
2300
+ case 2:
2248
2301
  browserId = _state.sent();
2249
2302
  trackingData = _object_spread({
2250
2303
  browserId: browserId
2251
2304
  }, clientInfo);
2252
- headers = {
2253
- "Content-Type": "application/json"
2254
- };
2255
- if (licenseKey) {
2256
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2257
- }
2258
2305
  return [
2259
2306
  4,
2260
- fetch(TRACK_URL, {
2261
- method: "POST",
2262
- headers: headers,
2263
- body: JSON.stringify(trackingData)
2307
+ sendTrackRequest(licenseKey, {
2308
+ events: [
2309
+ {
2310
+ player_id: browserId,
2311
+ device_type: clientInfo.deviceType,
2312
+ input_stream_type: context.inputStreamType,
2313
+ os: clientInfo.os,
2314
+ ad_loaded: false,
2315
+ ad_detect: false,
2316
+ license_key: licenseKey,
2317
+ capture_at: /* @__PURE__ */ new Date().toISOString()
2318
+ }
2319
+ ],
2320
+ trackingData: trackingData
2264
2321
  })
2265
2322
  ];
2266
- case 2:
2267
- response = _state.sent();
2268
- if (!response.ok) {
2269
- throw new Error("HTTP error! status: ".concat(response.status));
2270
- }
2271
- return [
2272
- 4,
2273
- response.json()
2274
- ];
2275
2323
  case 3:
2276
2324
  _state.sent();
2277
2325
  return [
@@ -2291,36 +2339,30 @@ function sendInitialTracking(licenseKey) {
2291
2339
  ];
2292
2340
  }
2293
2341
  });
2294
- })();
2342
+ }).apply(this, arguments);
2295
2343
  }
2296
- function sendAdDetectTracking(licenseKey, adDetectInfo) {
2297
- return _async_to_generator(function() {
2298
- var clientInfo, browserId, trackingData, error;
2344
+ function sendAdDetectTracking(_0, _1) {
2345
+ return _async_to_generator(function(licenseKey, adDetectInfo) {
2346
+ var context, error;
2347
+ var _arguments = arguments;
2299
2348
  return _ts_generator(this, function(_state) {
2300
2349
  switch(_state.label){
2301
2350
  case 0:
2351
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2352
+ _state.label = 1;
2353
+ case 1:
2302
2354
  _state.trys.push([
2303
- 0,
2355
+ 1,
2304
2356
  3,
2305
2357
  ,
2306
2358
  4
2307
2359
  ]);
2308
- clientInfo = getClientInfo();
2309
2360
  return [
2310
2361
  4,
2311
- getBrowserID(clientInfo)
2312
- ];
2313
- case 1:
2314
- browserId = _state.sent();
2315
- trackingData = _object_spread({
2316
- browserId: browserId
2317
- }, clientInfo);
2318
- return [
2319
- 4,
2320
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2321
- licenseKey: licenseKey,
2322
- adDetectInfo: adDetectInfo
2323
- }))
2362
+ sendHeartbeat(licenseKey, context, {
2363
+ adDetect: true,
2364
+ captureAt: adDetectInfo.timestamp
2365
+ })
2324
2366
  ];
2325
2367
  case 2:
2326
2368
  _state.sent();
@@ -2341,36 +2383,30 @@ function sendAdDetectTracking(licenseKey, adDetectInfo) {
2341
2383
  ];
2342
2384
  }
2343
2385
  });
2344
- })();
2386
+ }).apply(this, arguments);
2345
2387
  }
2346
- function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
2347
- return _async_to_generator(function() {
2348
- var clientInfo, browserId, trackingData, error;
2388
+ function sendAdLoadedTracking(_0, _1) {
2389
+ return _async_to_generator(function(licenseKey, adLoadedInfo) {
2390
+ var context, error;
2391
+ var _arguments = arguments;
2349
2392
  return _ts_generator(this, function(_state) {
2350
2393
  switch(_state.label){
2351
2394
  case 0:
2395
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2396
+ _state.label = 1;
2397
+ case 1:
2352
2398
  _state.trys.push([
2353
- 0,
2399
+ 1,
2354
2400
  3,
2355
2401
  ,
2356
2402
  4
2357
2403
  ]);
2358
- clientInfo = getClientInfo();
2359
- return [
2360
- 4,
2361
- getBrowserID(clientInfo)
2362
- ];
2363
- case 1:
2364
- browserId = _state.sent();
2365
- trackingData = _object_spread({
2366
- browserId: browserId
2367
- }, clientInfo);
2368
2404
  return [
2369
2405
  4,
2370
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2371
- licenseKey: licenseKey,
2372
- adLoadedInfo: adLoadedInfo
2373
- }))
2406
+ sendHeartbeat(licenseKey, context, {
2407
+ adLoaded: true,
2408
+ captureAt: adLoadedInfo.timestamp
2409
+ })
2374
2410
  ];
2375
2411
  case 2:
2376
2412
  _state.sent();
@@ -2391,103 +2427,95 @@ function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
2391
2427
  ];
2392
2428
  }
2393
2429
  });
2394
- })();
2430
+ }).apply(this, arguments);
2395
2431
  }
2396
- function sendAdImpressionTracking(licenseKey, adImpressionInfo) {
2397
- return _async_to_generator(function() {
2398
- var clientInfo, browserId, trackingData, error;
2432
+ function sendAdImpressionTracking(_0, _1) {
2433
+ return _async_to_generator(function(licenseKey, adImpressionInfo) {
2434
+ var context, metricEvent, error;
2435
+ var _arguments = arguments;
2399
2436
  return _ts_generator(this, function(_state) {
2400
2437
  switch(_state.label){
2401
2438
  case 0:
2439
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2440
+ _state.label = 1;
2441
+ case 1:
2402
2442
  _state.trys.push([
2403
- 0,
2404
- 3,
2443
+ 1,
2444
+ 4,
2405
2445
  ,
2406
- 4
2446
+ 5
2407
2447
  ]);
2408
- clientInfo = getClientInfo();
2409
2448
  return [
2410
2449
  4,
2411
- getBrowserID(clientInfo)
2450
+ buildPlayerMetricEvent(licenseKey, context, {
2451
+ captureAt: adImpressionInfo.timestamp
2452
+ })
2412
2453
  ];
2413
- case 1:
2414
- browserId = _state.sent();
2415
- trackingData = _object_spread({
2416
- browserId: browserId
2417
- }, clientInfo);
2454
+ case 2:
2455
+ metricEvent = _state.sent();
2418
2456
  return [
2419
2457
  4,
2420
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2421
- licenseKey: licenseKey,
2422
- adImpressionInfo: adImpressionInfo
2423
- }))
2458
+ Promise.all([
2459
+ postJson(HEARTBEAT_URL, licenseKey, metricEvent),
2460
+ postJson(IMPRESSIONS_URL, licenseKey, {
2461
+ events: [
2462
+ {
2463
+ player_id: metricEvent.player_id,
2464
+ ad_played_count: 1,
2465
+ ad_url: adImpressionInfo.adUrl,
2466
+ license_key: licenseKey,
2467
+ capture_at: adImpressionInfo.timestamp
2468
+ }
2469
+ ]
2470
+ })
2471
+ ])
2424
2472
  ];
2425
- case 2:
2473
+ case 3:
2426
2474
  _state.sent();
2427
2475
  return [
2428
2476
  3,
2429
- 4
2477
+ 5
2430
2478
  ];
2431
- case 3:
2479
+ case 4:
2432
2480
  error = _state.sent();
2433
2481
  console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
2434
2482
  return [
2435
2483
  3,
2436
- 4
2484
+ 5
2437
2485
  ];
2438
- case 4:
2486
+ case 5:
2439
2487
  return [
2440
2488
  2
2441
2489
  ];
2442
2490
  }
2443
2491
  });
2444
- })();
2492
+ }).apply(this, arguments);
2445
2493
  }
2446
- function sendHeartbeat(licenseKey) {
2447
- return _async_to_generator(function() {
2448
- var clientInfo, browserId, heartbeatData, headers, response, error;
2494
+ function sendHeartbeat(_0) {
2495
+ return _async_to_generator(function(licenseKey) {
2496
+ var context, flags, heartbeatData, error;
2497
+ var _arguments = arguments;
2449
2498
  return _ts_generator(this, function(_state) {
2450
2499
  switch(_state.label){
2451
2500
  case 0:
2501
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2502
+ _state.label = 1;
2503
+ case 1:
2452
2504
  _state.trys.push([
2453
- 0,
2505
+ 1,
2454
2506
  4,
2455
2507
  ,
2456
2508
  5
2457
2509
  ]);
2458
- clientInfo = getClientInfo();
2459
2510
  return [
2460
2511
  4,
2461
- getBrowserID(clientInfo)
2462
- ];
2463
- case 1:
2464
- browserId = _state.sent();
2465
- heartbeatData = {
2466
- browserId: browserId,
2467
- timestamp: /* @__PURE__ */ new Date().toISOString()
2468
- };
2469
- headers = {
2470
- "Content-Type": "application/json"
2471
- };
2472
- if (licenseKey) {
2473
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2474
- }
2475
- return [
2476
- 4,
2477
- fetch("https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/heartbeat", {
2478
- method: "POST",
2479
- headers: headers,
2480
- body: JSON.stringify(heartbeatData)
2481
- })
2512
+ buildPlayerMetricEvent(licenseKey, context, flags)
2482
2513
  ];
2483
2514
  case 2:
2484
- response = _state.sent();
2485
- if (!response.ok) {
2486
- throw new Error("HTTP error! status: ".concat(response.status));
2487
- }
2515
+ heartbeatData = _state.sent();
2488
2516
  return [
2489
2517
  4,
2490
- response.json()
2518
+ postJson(HEARTBEAT_URL, licenseKey, heartbeatData)
2491
2519
  ];
2492
2520
  case 3:
2493
2521
  _state.sent();
@@ -2508,7 +2536,7 @@ function sendHeartbeat(licenseKey) {
2508
2536
  ];
2509
2537
  }
2510
2538
  });
2511
- })();
2539
+ }).apply(this, arguments);
2512
2540
  }
2513
2541
  // src/utils/polyfills.ts
2514
2542
  function polyfillURLSearchParams() {
@@ -3551,17 +3579,62 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3551
3579
  return "vast";
3552
3580
  }
3553
3581
  },
3582
+ {
3583
+ key: "getInputStreamType",
3584
+ value: function getInputStreamType() {
3585
+ var src = this.config.src.toLowerCase();
3586
+ if (src.includes(".m3u8")) return "hls";
3587
+ if (src.includes(".mpd")) return "dash";
3588
+ if (src.includes(".mp4")) return "mp4";
3589
+ return this.isLiveStream ? "live" : "vod";
3590
+ }
3591
+ },
3592
+ {
3593
+ key: "getAnalyticsContext",
3594
+ value: function getAnalyticsContext() {
3595
+ return {
3596
+ inputStreamType: this.getInputStreamType()
3597
+ };
3598
+ }
3599
+ },
3600
+ {
3601
+ key: "getAdUrlFromBids",
3602
+ value: function getAdUrlFromBids(bids) {
3603
+ var _bids_;
3604
+ return bids === null || bids === void 0 ? void 0 : (_bids_ = bids[0]) === null || _bids_ === void 0 ? void 0 : _bids_.vastUrl;
3605
+ }
3606
+ },
3607
+ {
3608
+ key: "trackAdLoaded",
3609
+ value: function trackAdLoaded(bids) {
3610
+ if (!this.config.licenseKey) return;
3611
+ var adUrl = this.getAdUrlFromBids(bids);
3612
+ if (adUrl) {
3613
+ this.lastServedAdUrl = adUrl;
3614
+ }
3615
+ sendAdLoadedTracking(this.config.licenseKey, _object_spread_props(_object_spread({
3616
+ source: this.getAdSource()
3617
+ }, adUrl ? {
3618
+ vastUrl: adUrl
3619
+ } : {}), {
3620
+ timestamp: /* @__PURE__ */ new Date().toISOString()
3621
+ }), this.getAnalyticsContext());
3622
+ }
3623
+ },
3554
3624
  {
3555
3625
  key: "attachAdLayerEventListeners",
3556
3626
  value: function attachAdLayerEventListeners() {
3557
3627
  var _this = this;
3558
3628
  this.adLayer.on("ad_impression", function() {
3559
3629
  if (_this.config.licenseKey) {
3560
- sendAdImpressionTracking(_this.config.licenseKey, {
3630
+ sendAdImpressionTracking(_this.config.licenseKey, _object_spread_props(_object_spread({
3561
3631
  source: _this.getAdSource(),
3562
- adIndex: _this.currentAdIndex,
3632
+ adIndex: _this.currentAdIndex
3633
+ }, _this.lastServedAdUrl ? {
3634
+ adUrl: _this.lastServedAdUrl
3635
+ } : {}), {
3563
3636
  timestamp: /* @__PURE__ */ new Date().toISOString()
3564
- });
3637
+ }), _this.getAnalyticsContext());
3565
3638
  }
3566
3639
  });
3567
3640
  this.adLayer.on("ad_error", function(errorPayload) {
@@ -3655,6 +3728,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3655
3728
  _this.isInAdTransition = false;
3656
3729
  if (!_this.inAdBreak) return;
3657
3730
  _this.currentAdIndex++;
3731
+ _this.trackAdLoaded();
3658
3732
  _this.adLayer.playPreloaded(token).catch(function(err) {
3659
3733
  if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playPreloaded failed:", err);
3660
3734
  _this.handleAdFailure();
@@ -3684,6 +3758,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3684
3758
  var freshBids = (_this_pendingNextAdBids = _this.pendingNextAdBids) !== null && _this_pendingNextAdBids !== void 0 ? _this_pendingNextAdBids : bids;
3685
3759
  _this.pendingNextAdBids = null;
3686
3760
  _this.currentAdIndex++;
3761
+ _this.trackAdLoaded(freshBids);
3687
3762
  _this.adLayer.playAd(freshBids).catch(function(err) {
3688
3763
  if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playAd(pending) failed:", err);
3689
3764
  _this.handleAdFailure();
@@ -4063,7 +4138,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4063
4138
  }, ((_this_pendingAdBreak1 = this.pendingAdBreak) === null || _this_pendingAdBreak1 === void 0 ? void 0 : _this_pendingAdBreak1.detectedAtFragmentSn) != null && {
4064
4139
  detectedAtFragmentSn: this.pendingAdBreak.detectedAtFragmentSn
4065
4140
  });
4066
- sendAdDetectTracking(this.config.licenseKey, adDetectInfo);
4141
+ sendAdDetectTracking(this.config.licenseKey, adDetectInfo, this.getAnalyticsContext());
4067
4142
  }
4068
4143
  var isManifestMarker = this.isManifestBasedMarker(marker);
4069
4144
  var forceImmediate = (_this_config_immediateManifestAds = this.config.immediateManifestAds) !== null && _this_config_immediateManifestAds !== void 0 ? _this_config_immediateManifestAds : true;
@@ -4132,6 +4207,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4132
4207
  var bids = this.pendingNextAdBids;
4133
4208
  this.pendingNextAdBids = null;
4134
4209
  this.currentAdIndex++;
4210
+ this.trackAdLoaded(bids);
4135
4211
  this.adLayer.playAd(bids).catch(function() {
4136
4212
  return _this.handleAdFailure();
4137
4213
  });
@@ -4386,7 +4462,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4386
4462
  key: "initializeTracking",
4387
4463
  value: function initializeTracking() {
4388
4464
  var _this = this;
4389
- sendInitialTracking(this.config.licenseKey).then(function() {
4465
+ sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
4390
4466
  _this.heartbeatInterval = window.setInterval(function() {
4391
4467
  _this.sendHeartbeatIfNeeded();
4392
4468
  }, 5e3);
@@ -4407,7 +4483,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4407
4483
  var now = Date.now();
4408
4484
  if (!this.lastHeartbeatTime || now - this.lastHeartbeatTime > 3e4) {
4409
4485
  this.lastHeartbeatTime = now;
4410
- sendHeartbeat(this.config.licenseKey).catch(function(error) {
4486
+ sendHeartbeat(this.config.licenseKey, this.getAnalyticsContext()).catch(function(error) {
4411
4487
  if (_this.config.debugAdTiming) {
4412
4488
  console.warn("[StormcloudVideoPlayer] Failed to send heartbeat:", error);
4413
4489
  }
@@ -4800,12 +4876,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4800
4876
  10
4801
4877
  ];
4802
4878
  _this.currentAdIndex++;
4803
- if (_this.config.licenseKey) {
4804
- sendAdLoadedTracking(_this.config.licenseKey, {
4805
- source: _this.getAdSource(),
4806
- timestamp: /* @__PURE__ */ new Date().toISOString()
4807
- });
4808
- }
4879
+ _this.trackAdLoaded(bids1);
4809
4880
  return [
4810
4881
  4,
4811
4882
  _this.adLayer.playAd(bids1)
@@ -4910,12 +4981,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4910
4981
  ];
4911
4982
  case 18:
4912
4983
  _this.currentAdIndex++;
4913
- if (_this.config.licenseKey) {
4914
- sendAdLoadedTracking(_this.config.licenseKey, {
4915
- source: _this.getAdSource(),
4916
- timestamp: /* @__PURE__ */ new Date().toISOString()
4917
- });
4918
- }
4984
+ _this.trackAdLoaded(bids2);
4919
4985
  return [
4920
4986
  4,
4921
4987
  _this.adLayer.playAd(bids2)
@@ -5074,12 +5140,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5074
5140
  6
5075
5141
  ];
5076
5142
  this.currentAdIndex++;
5077
- if (this.config.licenseKey) {
5078
- sendAdLoadedTracking(this.config.licenseKey, {
5079
- source: this.getAdSource(),
5080
- timestamp: /* @__PURE__ */ new Date().toISOString()
5081
- });
5082
- }
5143
+ this.trackAdLoaded();
5083
5144
  _state.label = 1;
5084
5145
  case 1:
5085
5146
  _state.trys.push([
@@ -5273,12 +5334,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5273
5334
  5
5274
5335
  ];
5275
5336
  case 3:
5276
- if (this.config.licenseKey) {
5277
- sendAdLoadedTracking(this.config.licenseKey, {
5278
- source: this.getAdSource(),
5279
- timestamp: /* @__PURE__ */ new Date().toISOString()
5280
- });
5281
- }
5337
+ this.trackAdLoaded(bids);
5282
5338
  return [
5283
5339
  4,
5284
5340
  this.adLayer.playAd(bids)
@@ -5424,6 +5480,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5424
5480
  ,
5425
5481
  7
5426
5482
  ]);
5483
+ this.trackAdLoaded(bids);
5427
5484
  return [
5428
5485
  4,
5429
5486
  this.adLayer.playAd(bids)