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.
@@ -942,7 +942,6 @@ function createVastAdLayer(contentVideo, options) {
942
942
  var tornDown = false;
943
943
  var trackingFired = createEmptyTrackingState();
944
944
  var adStallTimerId;
945
- var savedContentVideoStyles;
946
945
  var currentAdEventHandlers;
947
946
  var preloadSlots = /* @__PURE__ */ new Map();
948
947
  function emit(event, payload) {
@@ -1059,7 +1058,7 @@ function createVastAdLayer(contentVideo, options) {
1059
1058
  video.style.top = "0";
1060
1059
  video.style.width = "100%";
1061
1060
  video.style.height = "100%";
1062
- video.style.objectFit = "cover";
1061
+ video.style.objectFit = "contain";
1063
1062
  video.style.backgroundColor = "#000";
1064
1063
  video.playsInline = true;
1065
1064
  video.muted = false;
@@ -1174,31 +1173,12 @@ function createVastAdLayer(contentVideo, options) {
1174
1173
  delete contentVideo.dataset.stormcloudAdPlaying;
1175
1174
  }
1176
1175
  }
1177
- function applyContentVideoAdCoverStyles() {
1178
- if (!singleElementMode) return;
1179
- savedContentVideoStyles = {
1180
- objectFit: contentVideo.style.objectFit,
1181
- width: contentVideo.style.width,
1182
- height: contentVideo.style.height
1183
- };
1184
- contentVideo.style.objectFit = "cover";
1185
- contentVideo.style.width = "100%";
1186
- contentVideo.style.height = "100%";
1187
- }
1188
- function restoreContentVideoStyles() {
1189
- if (!singleElementMode || !savedContentVideoStyles) return;
1190
- contentVideo.style.objectFit = savedContentVideoStyles.objectFit;
1191
- contentVideo.style.width = savedContentVideoStyles.width;
1192
- contentVideo.style.height = savedContentVideoStyles.height;
1193
- savedContentVideoStyles = void 0;
1194
- }
1195
1176
  function handleAdComplete() {
1196
1177
  if (tornDown) return;
1197
1178
  clearAdStallTimer();
1198
1179
  if (debug) console.log("".concat(LOG, " Handling ad completion"));
1199
1180
  adPlaying = false;
1200
1181
  setAdPlayingFlag(false);
1201
- restoreContentVideoStyles();
1202
1182
  if (adContainerEl) {
1203
1183
  adContainerEl.style.display = "none";
1204
1184
  adContainerEl.style.pointerEvents = "none";
@@ -1213,7 +1193,6 @@ function createVastAdLayer(contentVideo, options) {
1213
1193
  if (debug) console.log("".concat(LOG, " Handling ad error"));
1214
1194
  adPlaying = false;
1215
1195
  setAdPlayingFlag(false);
1216
- restoreContentVideoStyles();
1217
1196
  if (adContainerEl) {
1218
1197
  adContainerEl.style.display = "none";
1219
1198
  adContainerEl.style.pointerEvents = "none";
@@ -1384,7 +1363,6 @@ function createVastAdLayer(contentVideo, options) {
1384
1363
  ];
1385
1364
  contentVideo.style.visibility = "visible";
1386
1365
  contentVideo.style.opacity = "1";
1387
- applyContentVideoAdCoverStyles();
1388
1366
  emit("content_pause");
1389
1367
  setupAdEventListeners();
1390
1368
  adVolume2 = originalMutedState ? 1 : originalVolume;
@@ -1623,7 +1601,6 @@ function createVastAdLayer(contentVideo, options) {
1623
1601
  ];
1624
1602
  contentVideo.style.visibility = "visible";
1625
1603
  contentVideo.style.opacity = "1";
1626
- applyContentVideoAdCoverStyles();
1627
1604
  emit("content_pause");
1628
1605
  setupAdEventListeners();
1629
1606
  adVolume2 = originalMutedState ? 1 : originalVolume;
@@ -1774,7 +1751,6 @@ function createVastAdLayer(contentVideo, options) {
1774
1751
  if (debug) console.log("".concat(LOG, " Stopping ad"));
1775
1752
  adPlaying = false;
1776
1753
  setAdPlayingFlag(false);
1777
- restoreContentVideoStyles();
1778
1754
  contentVideo.muted = originalMutedState;
1779
1755
  contentVideo.volume = originalMutedState ? 0 : originalVolume;
1780
1756
  contentVideo.style.visibility = "visible";
@@ -1813,7 +1789,6 @@ function createVastAdLayer(contentVideo, options) {
1813
1789
  destroyed = true;
1814
1790
  adPlaying = false;
1815
1791
  setAdPlayingFlag(false);
1816
- restoreContentVideoStyles();
1817
1792
  contentVideo.muted = originalMutedState;
1818
1793
  contentVideo.volume = originalVolume;
1819
1794
  var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
@@ -2166,24 +2141,30 @@ function getBrowserID(clientInfo) {
2166
2141
  });
2167
2142
  })();
2168
2143
  }
2169
- var TRACK_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track";
2144
+ var PLAYER_TRACKING_BASE_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking";
2145
+ var TRACK_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/metrics/ingest");
2146
+ var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
2147
+ var IMPRESSIONS_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/impressions/ingest");
2148
+ function buildHeaders(licenseKey) {
2149
+ var headers = {
2150
+ "Content-Type": "application/json"
2151
+ };
2152
+ if (licenseKey) {
2153
+ headers["Authorization"] = "Bearer ".concat(licenseKey);
2154
+ }
2155
+ return headers;
2156
+ }
2170
2157
  function sendTrackRequest(licenseKey, body) {
2171
2158
  return _async_to_generator(function() {
2172
- var headers, response;
2159
+ var response;
2173
2160
  return _ts_generator(this, function(_state) {
2174
2161
  switch(_state.label){
2175
2162
  case 0:
2176
- headers = {
2177
- "Content-Type": "application/json"
2178
- };
2179
- if (licenseKey) {
2180
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2181
- }
2182
2163
  return [
2183
2164
  4,
2184
2165
  fetch(TRACK_URL, {
2185
2166
  method: "POST",
2186
- headers: headers,
2167
+ headers: buildHeaders(licenseKey),
2187
2168
  body: JSON.stringify(body)
2188
2169
  })
2189
2170
  ];
@@ -2205,14 +2186,86 @@ function sendTrackRequest(licenseKey, body) {
2205
2186
  });
2206
2187
  })();
2207
2188
  }
2208
- function sendInitialTracking(licenseKey) {
2189
+ function postJson(url, licenseKey, body) {
2209
2190
  return _async_to_generator(function() {
2210
- var clientInfo, browserId, trackingData, headers, response, error;
2191
+ var response;
2192
+ return _ts_generator(this, function(_state) {
2193
+ switch(_state.label){
2194
+ case 0:
2195
+ return [
2196
+ 4,
2197
+ fetch(url, {
2198
+ method: "POST",
2199
+ headers: buildHeaders(licenseKey),
2200
+ body: JSON.stringify(body)
2201
+ })
2202
+ ];
2203
+ case 1:
2204
+ response = _state.sent();
2205
+ if (!response.ok) {
2206
+ throw new Error("HTTP error! status: ".concat(response.status));
2207
+ }
2208
+ return [
2209
+ 4,
2210
+ response.json()
2211
+ ];
2212
+ case 2:
2213
+ _state.sent();
2214
+ return [
2215
+ 2
2216
+ ];
2217
+ }
2218
+ });
2219
+ })();
2220
+ }
2221
+ function buildPlayerMetricEvent(_0) {
2222
+ return _async_to_generator(function(licenseKey) {
2223
+ var context, flags, _flags_captureAt, clientInfo, browserId, captureAt;
2224
+ var _arguments = arguments;
2225
+ return _ts_generator(this, function(_state) {
2226
+ switch(_state.label){
2227
+ case 0:
2228
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2229
+ clientInfo = getClientInfo();
2230
+ return [
2231
+ 4,
2232
+ getBrowserID(clientInfo)
2233
+ ];
2234
+ case 1:
2235
+ browserId = _state.sent();
2236
+ captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
2237
+ return [
2238
+ 2,
2239
+ {
2240
+ player_id: browserId,
2241
+ browserId: browserId,
2242
+ device_type: clientInfo.deviceType,
2243
+ deviceType: clientInfo.deviceType,
2244
+ input_stream_type: context.inputStreamType,
2245
+ os: clientInfo.os,
2246
+ ad_loaded: flags.adLoaded,
2247
+ ad_detect: flags.adDetect,
2248
+ license_key: licenseKey,
2249
+ capture_at: captureAt,
2250
+ timestamp: captureAt
2251
+ }
2252
+ ];
2253
+ }
2254
+ });
2255
+ }).apply(this, arguments);
2256
+ }
2257
+ function sendInitialTracking(_0) {
2258
+ return _async_to_generator(function(licenseKey) {
2259
+ var context, clientInfo, browserId, trackingData, error;
2260
+ var _arguments = arguments;
2211
2261
  return _ts_generator(this, function(_state) {
2212
2262
  switch(_state.label){
2213
2263
  case 0:
2264
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
2265
+ _state.label = 1;
2266
+ case 1:
2214
2267
  _state.trys.push([
2215
- 0,
2268
+ 1,
2216
2269
  4,
2217
2270
  ,
2218
2271
  5
@@ -2222,34 +2275,29 @@ function sendInitialTracking(licenseKey) {
2222
2275
  4,
2223
2276
  getBrowserID(clientInfo)
2224
2277
  ];
2225
- case 1:
2278
+ case 2:
2226
2279
  browserId = _state.sent();
2227
2280
  trackingData = _object_spread({
2228
2281
  browserId: browserId
2229
2282
  }, clientInfo);
2230
- headers = {
2231
- "Content-Type": "application/json"
2232
- };
2233
- if (licenseKey) {
2234
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2235
- }
2236
2283
  return [
2237
2284
  4,
2238
- fetch(TRACK_URL, {
2239
- method: "POST",
2240
- headers: headers,
2241
- body: JSON.stringify(trackingData)
2285
+ sendTrackRequest(licenseKey, {
2286
+ events: [
2287
+ {
2288
+ player_id: browserId,
2289
+ device_type: clientInfo.deviceType,
2290
+ input_stream_type: context.inputStreamType,
2291
+ os: clientInfo.os,
2292
+ ad_loaded: false,
2293
+ ad_detect: false,
2294
+ license_key: licenseKey,
2295
+ capture_at: /* @__PURE__ */ new Date().toISOString()
2296
+ }
2297
+ ],
2298
+ trackingData: trackingData
2242
2299
  })
2243
2300
  ];
2244
- case 2:
2245
- response = _state.sent();
2246
- if (!response.ok) {
2247
- throw new Error("HTTP error! status: ".concat(response.status));
2248
- }
2249
- return [
2250
- 4,
2251
- response.json()
2252
- ];
2253
2301
  case 3:
2254
2302
  _state.sent();
2255
2303
  return [
@@ -2269,36 +2317,30 @@ function sendInitialTracking(licenseKey) {
2269
2317
  ];
2270
2318
  }
2271
2319
  });
2272
- })();
2320
+ }).apply(this, arguments);
2273
2321
  }
2274
- function sendAdDetectTracking(licenseKey, adDetectInfo) {
2275
- return _async_to_generator(function() {
2276
- var clientInfo, browserId, trackingData, error;
2322
+ function sendAdDetectTracking(_0, _1) {
2323
+ return _async_to_generator(function(licenseKey, adDetectInfo) {
2324
+ var context, error;
2325
+ var _arguments = arguments;
2277
2326
  return _ts_generator(this, function(_state) {
2278
2327
  switch(_state.label){
2279
2328
  case 0:
2329
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2330
+ _state.label = 1;
2331
+ case 1:
2280
2332
  _state.trys.push([
2281
- 0,
2333
+ 1,
2282
2334
  3,
2283
2335
  ,
2284
2336
  4
2285
2337
  ]);
2286
- clientInfo = getClientInfo();
2287
2338
  return [
2288
2339
  4,
2289
- getBrowserID(clientInfo)
2290
- ];
2291
- case 1:
2292
- browserId = _state.sent();
2293
- trackingData = _object_spread({
2294
- browserId: browserId
2295
- }, clientInfo);
2296
- return [
2297
- 4,
2298
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2299
- licenseKey: licenseKey,
2300
- adDetectInfo: adDetectInfo
2301
- }))
2340
+ sendHeartbeat(licenseKey, context, {
2341
+ adDetect: true,
2342
+ captureAt: adDetectInfo.timestamp
2343
+ })
2302
2344
  ];
2303
2345
  case 2:
2304
2346
  _state.sent();
@@ -2319,36 +2361,30 @@ function sendAdDetectTracking(licenseKey, adDetectInfo) {
2319
2361
  ];
2320
2362
  }
2321
2363
  });
2322
- })();
2364
+ }).apply(this, arguments);
2323
2365
  }
2324
- function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
2325
- return _async_to_generator(function() {
2326
- var clientInfo, browserId, trackingData, error;
2366
+ function sendAdLoadedTracking(_0, _1) {
2367
+ return _async_to_generator(function(licenseKey, adLoadedInfo) {
2368
+ var context, error;
2369
+ var _arguments = arguments;
2327
2370
  return _ts_generator(this, function(_state) {
2328
2371
  switch(_state.label){
2329
2372
  case 0:
2373
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2374
+ _state.label = 1;
2375
+ case 1:
2330
2376
  _state.trys.push([
2331
- 0,
2377
+ 1,
2332
2378
  3,
2333
2379
  ,
2334
2380
  4
2335
2381
  ]);
2336
- clientInfo = getClientInfo();
2337
- return [
2338
- 4,
2339
- getBrowserID(clientInfo)
2340
- ];
2341
- case 1:
2342
- browserId = _state.sent();
2343
- trackingData = _object_spread({
2344
- browserId: browserId
2345
- }, clientInfo);
2346
2382
  return [
2347
2383
  4,
2348
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2349
- licenseKey: licenseKey,
2350
- adLoadedInfo: adLoadedInfo
2351
- }))
2384
+ sendHeartbeat(licenseKey, context, {
2385
+ adLoaded: true,
2386
+ captureAt: adLoadedInfo.timestamp
2387
+ })
2352
2388
  ];
2353
2389
  case 2:
2354
2390
  _state.sent();
@@ -2369,103 +2405,95 @@ function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
2369
2405
  ];
2370
2406
  }
2371
2407
  });
2372
- })();
2408
+ }).apply(this, arguments);
2373
2409
  }
2374
- function sendAdImpressionTracking(licenseKey, adImpressionInfo) {
2375
- return _async_to_generator(function() {
2376
- var clientInfo, browserId, trackingData, error;
2410
+ function sendAdImpressionTracking(_0, _1) {
2411
+ return _async_to_generator(function(licenseKey, adImpressionInfo) {
2412
+ var context, metricEvent, error;
2413
+ var _arguments = arguments;
2377
2414
  return _ts_generator(this, function(_state) {
2378
2415
  switch(_state.label){
2379
2416
  case 0:
2417
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2418
+ _state.label = 1;
2419
+ case 1:
2380
2420
  _state.trys.push([
2381
- 0,
2382
- 3,
2421
+ 1,
2422
+ 4,
2383
2423
  ,
2384
- 4
2424
+ 5
2385
2425
  ]);
2386
- clientInfo = getClientInfo();
2387
2426
  return [
2388
2427
  4,
2389
- getBrowserID(clientInfo)
2428
+ buildPlayerMetricEvent(licenseKey, context, {
2429
+ captureAt: adImpressionInfo.timestamp
2430
+ })
2390
2431
  ];
2391
- case 1:
2392
- browserId = _state.sent();
2393
- trackingData = _object_spread({
2394
- browserId: browserId
2395
- }, clientInfo);
2432
+ case 2:
2433
+ metricEvent = _state.sent();
2396
2434
  return [
2397
2435
  4,
2398
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2399
- licenseKey: licenseKey,
2400
- adImpressionInfo: adImpressionInfo
2401
- }))
2436
+ Promise.all([
2437
+ postJson(HEARTBEAT_URL, licenseKey, metricEvent),
2438
+ postJson(IMPRESSIONS_URL, licenseKey, {
2439
+ events: [
2440
+ {
2441
+ player_id: metricEvent.player_id,
2442
+ ad_played_count: 1,
2443
+ ad_url: adImpressionInfo.adUrl,
2444
+ license_key: licenseKey,
2445
+ capture_at: adImpressionInfo.timestamp
2446
+ }
2447
+ ]
2448
+ })
2449
+ ])
2402
2450
  ];
2403
- case 2:
2451
+ case 3:
2404
2452
  _state.sent();
2405
2453
  return [
2406
2454
  3,
2407
- 4
2455
+ 5
2408
2456
  ];
2409
- case 3:
2457
+ case 4:
2410
2458
  error = _state.sent();
2411
2459
  console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
2412
2460
  return [
2413
2461
  3,
2414
- 4
2462
+ 5
2415
2463
  ];
2416
- case 4:
2464
+ case 5:
2417
2465
  return [
2418
2466
  2
2419
2467
  ];
2420
2468
  }
2421
2469
  });
2422
- })();
2470
+ }).apply(this, arguments);
2423
2471
  }
2424
- function sendHeartbeat(licenseKey) {
2425
- return _async_to_generator(function() {
2426
- var clientInfo, browserId, heartbeatData, headers, response, error;
2472
+ function sendHeartbeat(_0) {
2473
+ return _async_to_generator(function(licenseKey) {
2474
+ var context, flags, heartbeatData, error;
2475
+ var _arguments = arguments;
2427
2476
  return _ts_generator(this, function(_state) {
2428
2477
  switch(_state.label){
2429
2478
  case 0:
2479
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2480
+ _state.label = 1;
2481
+ case 1:
2430
2482
  _state.trys.push([
2431
- 0,
2483
+ 1,
2432
2484
  4,
2433
2485
  ,
2434
2486
  5
2435
2487
  ]);
2436
- clientInfo = getClientInfo();
2437
2488
  return [
2438
2489
  4,
2439
- getBrowserID(clientInfo)
2440
- ];
2441
- case 1:
2442
- browserId = _state.sent();
2443
- heartbeatData = {
2444
- browserId: browserId,
2445
- timestamp: /* @__PURE__ */ new Date().toISOString()
2446
- };
2447
- headers = {
2448
- "Content-Type": "application/json"
2449
- };
2450
- if (licenseKey) {
2451
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2452
- }
2453
- return [
2454
- 4,
2455
- fetch("https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/heartbeat", {
2456
- method: "POST",
2457
- headers: headers,
2458
- body: JSON.stringify(heartbeatData)
2459
- })
2490
+ buildPlayerMetricEvent(licenseKey, context, flags)
2460
2491
  ];
2461
2492
  case 2:
2462
- response = _state.sent();
2463
- if (!response.ok) {
2464
- throw new Error("HTTP error! status: ".concat(response.status));
2465
- }
2493
+ heartbeatData = _state.sent();
2466
2494
  return [
2467
2495
  4,
2468
- response.json()
2496
+ postJson(HEARTBEAT_URL, licenseKey, heartbeatData)
2469
2497
  ];
2470
2498
  case 3:
2471
2499
  _state.sent();
@@ -2486,7 +2514,7 @@ function sendHeartbeat(licenseKey) {
2486
2514
  ];
2487
2515
  }
2488
2516
  });
2489
- })();
2517
+ }).apply(this, arguments);
2490
2518
  }
2491
2519
  // src/utils/polyfills.ts
2492
2520
  function polyfillURLSearchParams() {
@@ -3501,17 +3529,62 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3501
3529
  return "vast";
3502
3530
  }
3503
3531
  },
3532
+ {
3533
+ key: "getInputStreamType",
3534
+ value: function getInputStreamType() {
3535
+ var src = this.config.src.toLowerCase();
3536
+ if (src.includes(".m3u8")) return "hls";
3537
+ if (src.includes(".mpd")) return "dash";
3538
+ if (src.includes(".mp4")) return "mp4";
3539
+ return this.isLiveStream ? "live" : "vod";
3540
+ }
3541
+ },
3542
+ {
3543
+ key: "getAnalyticsContext",
3544
+ value: function getAnalyticsContext() {
3545
+ return {
3546
+ inputStreamType: this.getInputStreamType()
3547
+ };
3548
+ }
3549
+ },
3550
+ {
3551
+ key: "getAdUrlFromBids",
3552
+ value: function getAdUrlFromBids(bids) {
3553
+ var _bids_;
3554
+ return bids === null || bids === void 0 ? void 0 : (_bids_ = bids[0]) === null || _bids_ === void 0 ? void 0 : _bids_.vastUrl;
3555
+ }
3556
+ },
3557
+ {
3558
+ key: "trackAdLoaded",
3559
+ value: function trackAdLoaded(bids) {
3560
+ if (!this.config.licenseKey) return;
3561
+ var adUrl = this.getAdUrlFromBids(bids);
3562
+ if (adUrl) {
3563
+ this.lastServedAdUrl = adUrl;
3564
+ }
3565
+ sendAdLoadedTracking(this.config.licenseKey, _object_spread_props(_object_spread({
3566
+ source: this.getAdSource()
3567
+ }, adUrl ? {
3568
+ vastUrl: adUrl
3569
+ } : {}), {
3570
+ timestamp: /* @__PURE__ */ new Date().toISOString()
3571
+ }), this.getAnalyticsContext());
3572
+ }
3573
+ },
3504
3574
  {
3505
3575
  key: "attachAdLayerEventListeners",
3506
3576
  value: function attachAdLayerEventListeners() {
3507
3577
  var _this = this;
3508
3578
  this.adLayer.on("ad_impression", function() {
3509
3579
  if (_this.config.licenseKey) {
3510
- sendAdImpressionTracking(_this.config.licenseKey, {
3580
+ sendAdImpressionTracking(_this.config.licenseKey, _object_spread_props(_object_spread({
3511
3581
  source: _this.getAdSource(),
3512
- adIndex: _this.currentAdIndex,
3582
+ adIndex: _this.currentAdIndex
3583
+ }, _this.lastServedAdUrl ? {
3584
+ adUrl: _this.lastServedAdUrl
3585
+ } : {}), {
3513
3586
  timestamp: /* @__PURE__ */ new Date().toISOString()
3514
- });
3587
+ }), _this.getAnalyticsContext());
3515
3588
  }
3516
3589
  });
3517
3590
  this.adLayer.on("ad_error", function(errorPayload) {
@@ -3605,6 +3678,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3605
3678
  _this.isInAdTransition = false;
3606
3679
  if (!_this.inAdBreak) return;
3607
3680
  _this.currentAdIndex++;
3681
+ _this.trackAdLoaded();
3608
3682
  _this.adLayer.playPreloaded(token).catch(function(err) {
3609
3683
  if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playPreloaded failed:", err);
3610
3684
  _this.handleAdFailure();
@@ -3634,6 +3708,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3634
3708
  var freshBids = (_this_pendingNextAdBids = _this.pendingNextAdBids) !== null && _this_pendingNextAdBids !== void 0 ? _this_pendingNextAdBids : bids;
3635
3709
  _this.pendingNextAdBids = null;
3636
3710
  _this.currentAdIndex++;
3711
+ _this.trackAdLoaded(freshBids);
3637
3712
  _this.adLayer.playAd(freshBids).catch(function(err) {
3638
3713
  if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playAd(pending) failed:", err);
3639
3714
  _this.handleAdFailure();
@@ -4013,7 +4088,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4013
4088
  }, ((_this_pendingAdBreak1 = this.pendingAdBreak) === null || _this_pendingAdBreak1 === void 0 ? void 0 : _this_pendingAdBreak1.detectedAtFragmentSn) != null && {
4014
4089
  detectedAtFragmentSn: this.pendingAdBreak.detectedAtFragmentSn
4015
4090
  });
4016
- sendAdDetectTracking(this.config.licenseKey, adDetectInfo);
4091
+ sendAdDetectTracking(this.config.licenseKey, adDetectInfo, this.getAnalyticsContext());
4017
4092
  }
4018
4093
  var isManifestMarker = this.isManifestBasedMarker(marker);
4019
4094
  var forceImmediate = (_this_config_immediateManifestAds = this.config.immediateManifestAds) !== null && _this_config_immediateManifestAds !== void 0 ? _this_config_immediateManifestAds : true;
@@ -4082,6 +4157,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4082
4157
  var bids = this.pendingNextAdBids;
4083
4158
  this.pendingNextAdBids = null;
4084
4159
  this.currentAdIndex++;
4160
+ this.trackAdLoaded(bids);
4085
4161
  this.adLayer.playAd(bids).catch(function() {
4086
4162
  return _this.handleAdFailure();
4087
4163
  });
@@ -4336,7 +4412,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4336
4412
  key: "initializeTracking",
4337
4413
  value: function initializeTracking() {
4338
4414
  var _this = this;
4339
- sendInitialTracking(this.config.licenseKey).then(function() {
4415
+ sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
4340
4416
  _this.heartbeatInterval = window.setInterval(function() {
4341
4417
  _this.sendHeartbeatIfNeeded();
4342
4418
  }, 5e3);
@@ -4357,7 +4433,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4357
4433
  var now = Date.now();
4358
4434
  if (!this.lastHeartbeatTime || now - this.lastHeartbeatTime > 3e4) {
4359
4435
  this.lastHeartbeatTime = now;
4360
- sendHeartbeat(this.config.licenseKey).catch(function(error) {
4436
+ sendHeartbeat(this.config.licenseKey, this.getAnalyticsContext()).catch(function(error) {
4361
4437
  if (_this.config.debugAdTiming) {
4362
4438
  console.warn("[StormcloudVideoPlayer] Failed to send heartbeat:", error);
4363
4439
  }
@@ -4750,12 +4826,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4750
4826
  10
4751
4827
  ];
4752
4828
  _this.currentAdIndex++;
4753
- if (_this.config.licenseKey) {
4754
- sendAdLoadedTracking(_this.config.licenseKey, {
4755
- source: _this.getAdSource(),
4756
- timestamp: /* @__PURE__ */ new Date().toISOString()
4757
- });
4758
- }
4829
+ _this.trackAdLoaded(bids1);
4759
4830
  return [
4760
4831
  4,
4761
4832
  _this.adLayer.playAd(bids1)
@@ -4860,12 +4931,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4860
4931
  ];
4861
4932
  case 18:
4862
4933
  _this.currentAdIndex++;
4863
- if (_this.config.licenseKey) {
4864
- sendAdLoadedTracking(_this.config.licenseKey, {
4865
- source: _this.getAdSource(),
4866
- timestamp: /* @__PURE__ */ new Date().toISOString()
4867
- });
4868
- }
4934
+ _this.trackAdLoaded(bids2);
4869
4935
  return [
4870
4936
  4,
4871
4937
  _this.adLayer.playAd(bids2)
@@ -5024,12 +5090,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5024
5090
  6
5025
5091
  ];
5026
5092
  this.currentAdIndex++;
5027
- if (this.config.licenseKey) {
5028
- sendAdLoadedTracking(this.config.licenseKey, {
5029
- source: this.getAdSource(),
5030
- timestamp: /* @__PURE__ */ new Date().toISOString()
5031
- });
5032
- }
5093
+ this.trackAdLoaded();
5033
5094
  _state.label = 1;
5034
5095
  case 1:
5035
5096
  _state.trys.push([
@@ -5223,12 +5284,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5223
5284
  5
5224
5285
  ];
5225
5286
  case 3:
5226
- if (this.config.licenseKey) {
5227
- sendAdLoadedTracking(this.config.licenseKey, {
5228
- source: this.getAdSource(),
5229
- timestamp: /* @__PURE__ */ new Date().toISOString()
5230
- });
5231
- }
5287
+ this.trackAdLoaded(bids);
5232
5288
  return [
5233
5289
  4,
5234
5290
  this.adLayer.playAd(bids)
@@ -5374,6 +5430,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5374
5430
  ,
5375
5431
  7
5376
5432
  ]);
5433
+ this.trackAdLoaded(bids);
5377
5434
  return [
5378
5435
  4,
5379
5436
  this.adLayer.playAd(bids)