stormcloud-video-player 0.6.8 → 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.
@@ -1,4 +1,4 @@
1
- import { S as StormcloudVideoPlayerConfig } from '../types-BYwfSJb5.cjs';
1
+ import { S as StormcloudVideoPlayerConfig } from '../types-DSKC4ySr.cjs';
2
2
 
3
3
  declare class StormcloudVideoPlayer {
4
4
  private readonly video;
@@ -21,6 +21,7 @@ declare class StormcloudVideoPlayer {
21
21
  private heartbeatInterval;
22
22
  private currentAdIndex;
23
23
  private totalAdsInBreak;
24
+ private lastServedAdUrl;
24
25
  private showAds;
25
26
  private isLiveStream;
26
27
  private nativeHlsMode;
@@ -58,6 +59,10 @@ declare class StormcloudVideoPlayer {
58
59
  private adRequest;
59
60
  load(): Promise<void>;
60
61
  private getAdSource;
62
+ private getInputStreamType;
63
+ private getAnalyticsContext;
64
+ private getAdUrlFromBids;
65
+ private trackAdLoaded;
61
66
  private attachAdLayerEventListeners;
62
67
  private ensureFillerVideo;
63
68
  private showPlaceholderLayer;
@@ -2193,24 +2193,30 @@ function getBrowserID(clientInfo) {
2193
2193
  });
2194
2194
  })();
2195
2195
  }
2196
- var TRACK_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track";
2196
+ var PLAYER_TRACKING_BASE_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking";
2197
+ var TRACK_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/metrics/ingest");
2198
+ var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
2199
+ var IMPRESSIONS_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/impressions/ingest");
2200
+ function buildHeaders(licenseKey) {
2201
+ var headers = {
2202
+ "Content-Type": "application/json"
2203
+ };
2204
+ if (licenseKey) {
2205
+ headers["Authorization"] = "Bearer ".concat(licenseKey);
2206
+ }
2207
+ return headers;
2208
+ }
2197
2209
  function sendTrackRequest(licenseKey, body) {
2198
2210
  return _async_to_generator(function() {
2199
- var headers, response;
2211
+ var response;
2200
2212
  return _ts_generator(this, function(_state) {
2201
2213
  switch(_state.label){
2202
2214
  case 0:
2203
- headers = {
2204
- "Content-Type": "application/json"
2205
- };
2206
- if (licenseKey) {
2207
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2208
- }
2209
2215
  return [
2210
2216
  4,
2211
2217
  fetch(TRACK_URL, {
2212
2218
  method: "POST",
2213
- headers: headers,
2219
+ headers: buildHeaders(licenseKey),
2214
2220
  body: JSON.stringify(body)
2215
2221
  })
2216
2222
  ];
@@ -2232,14 +2238,86 @@ function sendTrackRequest(licenseKey, body) {
2232
2238
  });
2233
2239
  })();
2234
2240
  }
2235
- function sendInitialTracking(licenseKey) {
2241
+ function postJson(url, licenseKey, body) {
2236
2242
  return _async_to_generator(function() {
2237
- var clientInfo, browserId, trackingData, headers, response, error;
2243
+ var response;
2244
+ return _ts_generator(this, function(_state) {
2245
+ switch(_state.label){
2246
+ case 0:
2247
+ return [
2248
+ 4,
2249
+ fetch(url, {
2250
+ method: "POST",
2251
+ headers: buildHeaders(licenseKey),
2252
+ body: JSON.stringify(body)
2253
+ })
2254
+ ];
2255
+ case 1:
2256
+ response = _state.sent();
2257
+ if (!response.ok) {
2258
+ throw new Error("HTTP error! status: ".concat(response.status));
2259
+ }
2260
+ return [
2261
+ 4,
2262
+ response.json()
2263
+ ];
2264
+ case 2:
2265
+ _state.sent();
2266
+ return [
2267
+ 2
2268
+ ];
2269
+ }
2270
+ });
2271
+ })();
2272
+ }
2273
+ function buildPlayerMetricEvent(_0) {
2274
+ return _async_to_generator(function(licenseKey) {
2275
+ var context, flags, _flags_captureAt, clientInfo, browserId, captureAt;
2276
+ var _arguments = arguments;
2277
+ return _ts_generator(this, function(_state) {
2278
+ switch(_state.label){
2279
+ case 0:
2280
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2281
+ clientInfo = getClientInfo();
2282
+ return [
2283
+ 4,
2284
+ getBrowserID(clientInfo)
2285
+ ];
2286
+ case 1:
2287
+ browserId = _state.sent();
2288
+ captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
2289
+ return [
2290
+ 2,
2291
+ {
2292
+ player_id: browserId,
2293
+ browserId: browserId,
2294
+ device_type: clientInfo.deviceType,
2295
+ deviceType: clientInfo.deviceType,
2296
+ input_stream_type: context.inputStreamType,
2297
+ os: clientInfo.os,
2298
+ ad_loaded: flags.adLoaded,
2299
+ ad_detect: flags.adDetect,
2300
+ license_key: licenseKey,
2301
+ capture_at: captureAt,
2302
+ timestamp: captureAt
2303
+ }
2304
+ ];
2305
+ }
2306
+ });
2307
+ }).apply(this, arguments);
2308
+ }
2309
+ function sendInitialTracking(_0) {
2310
+ return _async_to_generator(function(licenseKey) {
2311
+ var context, clientInfo, browserId, trackingData, error;
2312
+ var _arguments = arguments;
2238
2313
  return _ts_generator(this, function(_state) {
2239
2314
  switch(_state.label){
2240
2315
  case 0:
2316
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
2317
+ _state.label = 1;
2318
+ case 1:
2241
2319
  _state.trys.push([
2242
- 0,
2320
+ 1,
2243
2321
  4,
2244
2322
  ,
2245
2323
  5
@@ -2249,34 +2327,29 @@ function sendInitialTracking(licenseKey) {
2249
2327
  4,
2250
2328
  getBrowserID(clientInfo)
2251
2329
  ];
2252
- case 1:
2330
+ case 2:
2253
2331
  browserId = _state.sent();
2254
2332
  trackingData = _object_spread({
2255
2333
  browserId: browserId
2256
2334
  }, clientInfo);
2257
- headers = {
2258
- "Content-Type": "application/json"
2259
- };
2260
- if (licenseKey) {
2261
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2262
- }
2263
2335
  return [
2264
2336
  4,
2265
- fetch(TRACK_URL, {
2266
- method: "POST",
2267
- headers: headers,
2268
- body: JSON.stringify(trackingData)
2337
+ sendTrackRequest(licenseKey, {
2338
+ events: [
2339
+ {
2340
+ player_id: browserId,
2341
+ device_type: clientInfo.deviceType,
2342
+ input_stream_type: context.inputStreamType,
2343
+ os: clientInfo.os,
2344
+ ad_loaded: false,
2345
+ ad_detect: false,
2346
+ license_key: licenseKey,
2347
+ capture_at: /* @__PURE__ */ new Date().toISOString()
2348
+ }
2349
+ ],
2350
+ trackingData: trackingData
2269
2351
  })
2270
2352
  ];
2271
- case 2:
2272
- response = _state.sent();
2273
- if (!response.ok) {
2274
- throw new Error("HTTP error! status: ".concat(response.status));
2275
- }
2276
- return [
2277
- 4,
2278
- response.json()
2279
- ];
2280
2353
  case 3:
2281
2354
  _state.sent();
2282
2355
  return [
@@ -2296,36 +2369,30 @@ function sendInitialTracking(licenseKey) {
2296
2369
  ];
2297
2370
  }
2298
2371
  });
2299
- })();
2372
+ }).apply(this, arguments);
2300
2373
  }
2301
- function sendAdDetectTracking(licenseKey, adDetectInfo) {
2302
- return _async_to_generator(function() {
2303
- var clientInfo, browserId, trackingData, error;
2374
+ function sendAdDetectTracking(_0, _1) {
2375
+ return _async_to_generator(function(licenseKey, adDetectInfo) {
2376
+ var context, error;
2377
+ var _arguments = arguments;
2304
2378
  return _ts_generator(this, function(_state) {
2305
2379
  switch(_state.label){
2306
2380
  case 0:
2381
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2382
+ _state.label = 1;
2383
+ case 1:
2307
2384
  _state.trys.push([
2308
- 0,
2385
+ 1,
2309
2386
  3,
2310
2387
  ,
2311
2388
  4
2312
2389
  ]);
2313
- clientInfo = getClientInfo();
2314
- return [
2315
- 4,
2316
- getBrowserID(clientInfo)
2317
- ];
2318
- case 1:
2319
- browserId = _state.sent();
2320
- trackingData = _object_spread({
2321
- browserId: browserId
2322
- }, clientInfo);
2323
2390
  return [
2324
2391
  4,
2325
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2326
- licenseKey: licenseKey,
2327
- adDetectInfo: adDetectInfo
2328
- }))
2392
+ sendHeartbeat(licenseKey, context, {
2393
+ adDetect: true,
2394
+ captureAt: adDetectInfo.timestamp
2395
+ })
2329
2396
  ];
2330
2397
  case 2:
2331
2398
  _state.sent();
@@ -2346,36 +2413,30 @@ function sendAdDetectTracking(licenseKey, adDetectInfo) {
2346
2413
  ];
2347
2414
  }
2348
2415
  });
2349
- })();
2416
+ }).apply(this, arguments);
2350
2417
  }
2351
- function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
2352
- return _async_to_generator(function() {
2353
- var clientInfo, browserId, trackingData, error;
2418
+ function sendAdLoadedTracking(_0, _1) {
2419
+ return _async_to_generator(function(licenseKey, adLoadedInfo) {
2420
+ var context, error;
2421
+ var _arguments = arguments;
2354
2422
  return _ts_generator(this, function(_state) {
2355
2423
  switch(_state.label){
2356
2424
  case 0:
2425
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2426
+ _state.label = 1;
2427
+ case 1:
2357
2428
  _state.trys.push([
2358
- 0,
2429
+ 1,
2359
2430
  3,
2360
2431
  ,
2361
2432
  4
2362
2433
  ]);
2363
- clientInfo = getClientInfo();
2364
- return [
2365
- 4,
2366
- getBrowserID(clientInfo)
2367
- ];
2368
- case 1:
2369
- browserId = _state.sent();
2370
- trackingData = _object_spread({
2371
- browserId: browserId
2372
- }, clientInfo);
2373
2434
  return [
2374
2435
  4,
2375
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2376
- licenseKey: licenseKey,
2377
- adLoadedInfo: adLoadedInfo
2378
- }))
2436
+ sendHeartbeat(licenseKey, context, {
2437
+ adLoaded: true,
2438
+ captureAt: adLoadedInfo.timestamp
2439
+ })
2379
2440
  ];
2380
2441
  case 2:
2381
2442
  _state.sent();
@@ -2396,103 +2457,95 @@ function sendAdLoadedTracking(licenseKey, adLoadedInfo) {
2396
2457
  ];
2397
2458
  }
2398
2459
  });
2399
- })();
2460
+ }).apply(this, arguments);
2400
2461
  }
2401
- function sendAdImpressionTracking(licenseKey, adImpressionInfo) {
2402
- return _async_to_generator(function() {
2403
- var clientInfo, browserId, trackingData, error;
2462
+ function sendAdImpressionTracking(_0, _1) {
2463
+ return _async_to_generator(function(licenseKey, adImpressionInfo) {
2464
+ var context, metricEvent, error;
2465
+ var _arguments = arguments;
2404
2466
  return _ts_generator(this, function(_state) {
2405
2467
  switch(_state.label){
2406
2468
  case 0:
2469
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2470
+ _state.label = 1;
2471
+ case 1:
2407
2472
  _state.trys.push([
2408
- 0,
2409
- 3,
2473
+ 1,
2474
+ 4,
2410
2475
  ,
2411
- 4
2476
+ 5
2412
2477
  ]);
2413
- clientInfo = getClientInfo();
2414
2478
  return [
2415
2479
  4,
2416
- getBrowserID(clientInfo)
2480
+ buildPlayerMetricEvent(licenseKey, context, {
2481
+ captureAt: adImpressionInfo.timestamp
2482
+ })
2417
2483
  ];
2418
- case 1:
2419
- browserId = _state.sent();
2420
- trackingData = _object_spread({
2421
- browserId: browserId
2422
- }, clientInfo);
2484
+ case 2:
2485
+ metricEvent = _state.sent();
2423
2486
  return [
2424
2487
  4,
2425
- sendTrackRequest(licenseKey, _object_spread_props(_object_spread({}, trackingData), {
2426
- licenseKey: licenseKey,
2427
- adImpressionInfo: adImpressionInfo
2428
- }))
2488
+ Promise.all([
2489
+ postJson(HEARTBEAT_URL, licenseKey, metricEvent),
2490
+ postJson(IMPRESSIONS_URL, licenseKey, {
2491
+ events: [
2492
+ {
2493
+ player_id: metricEvent.player_id,
2494
+ ad_played_count: 1,
2495
+ ad_url: adImpressionInfo.adUrl,
2496
+ license_key: licenseKey,
2497
+ capture_at: adImpressionInfo.timestamp
2498
+ }
2499
+ ]
2500
+ })
2501
+ ])
2429
2502
  ];
2430
- case 2:
2503
+ case 3:
2431
2504
  _state.sent();
2432
2505
  return [
2433
2506
  3,
2434
- 4
2507
+ 5
2435
2508
  ];
2436
- case 3:
2509
+ case 4:
2437
2510
  error = _state.sent();
2438
2511
  console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
2439
2512
  return [
2440
2513
  3,
2441
- 4
2514
+ 5
2442
2515
  ];
2443
- case 4:
2516
+ case 5:
2444
2517
  return [
2445
2518
  2
2446
2519
  ];
2447
2520
  }
2448
2521
  });
2449
- })();
2522
+ }).apply(this, arguments);
2450
2523
  }
2451
- function sendHeartbeat(licenseKey) {
2452
- return _async_to_generator(function() {
2453
- var clientInfo, browserId, heartbeatData, headers, response, error;
2524
+ function sendHeartbeat(_0) {
2525
+ return _async_to_generator(function(licenseKey) {
2526
+ var context, flags, heartbeatData, error;
2527
+ var _arguments = arguments;
2454
2528
  return _ts_generator(this, function(_state) {
2455
2529
  switch(_state.label){
2456
2530
  case 0:
2531
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
2532
+ _state.label = 1;
2533
+ case 1:
2457
2534
  _state.trys.push([
2458
- 0,
2535
+ 1,
2459
2536
  4,
2460
2537
  ,
2461
2538
  5
2462
2539
  ]);
2463
- clientInfo = getClientInfo();
2464
2540
  return [
2465
2541
  4,
2466
- getBrowserID(clientInfo)
2467
- ];
2468
- case 1:
2469
- browserId = _state.sent();
2470
- heartbeatData = {
2471
- browserId: browserId,
2472
- timestamp: /* @__PURE__ */ new Date().toISOString()
2473
- };
2474
- headers = {
2475
- "Content-Type": "application/json"
2476
- };
2477
- if (licenseKey) {
2478
- headers["Authorization"] = "Bearer ".concat(licenseKey);
2479
- }
2480
- return [
2481
- 4,
2482
- fetch("https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/heartbeat", {
2483
- method: "POST",
2484
- headers: headers,
2485
- body: JSON.stringify(heartbeatData)
2486
- })
2542
+ buildPlayerMetricEvent(licenseKey, context, flags)
2487
2543
  ];
2488
2544
  case 2:
2489
- response = _state.sent();
2490
- if (!response.ok) {
2491
- throw new Error("HTTP error! status: ".concat(response.status));
2492
- }
2545
+ heartbeatData = _state.sent();
2493
2546
  return [
2494
2547
  4,
2495
- response.json()
2548
+ postJson(HEARTBEAT_URL, licenseKey, heartbeatData)
2496
2549
  ];
2497
2550
  case 3:
2498
2551
  _state.sent();
@@ -2513,7 +2566,7 @@ function sendHeartbeat(licenseKey) {
2513
2566
  ];
2514
2567
  }
2515
2568
  });
2516
- })();
2569
+ }).apply(this, arguments);
2517
2570
  }
2518
2571
  // src/utils/polyfills.ts
2519
2572
  function polyfillURLSearchParams() {
@@ -3528,17 +3581,62 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3528
3581
  return "vast";
3529
3582
  }
3530
3583
  },
3584
+ {
3585
+ key: "getInputStreamType",
3586
+ value: function getInputStreamType() {
3587
+ var src = this.config.src.toLowerCase();
3588
+ if (src.includes(".m3u8")) return "hls";
3589
+ if (src.includes(".mpd")) return "dash";
3590
+ if (src.includes(".mp4")) return "mp4";
3591
+ return this.isLiveStream ? "live" : "vod";
3592
+ }
3593
+ },
3594
+ {
3595
+ key: "getAnalyticsContext",
3596
+ value: function getAnalyticsContext() {
3597
+ return {
3598
+ inputStreamType: this.getInputStreamType()
3599
+ };
3600
+ }
3601
+ },
3602
+ {
3603
+ key: "getAdUrlFromBids",
3604
+ value: function getAdUrlFromBids(bids) {
3605
+ var _bids_;
3606
+ return bids === null || bids === void 0 ? void 0 : (_bids_ = bids[0]) === null || _bids_ === void 0 ? void 0 : _bids_.vastUrl;
3607
+ }
3608
+ },
3609
+ {
3610
+ key: "trackAdLoaded",
3611
+ value: function trackAdLoaded(bids) {
3612
+ if (!this.config.licenseKey) return;
3613
+ var adUrl = this.getAdUrlFromBids(bids);
3614
+ if (adUrl) {
3615
+ this.lastServedAdUrl = adUrl;
3616
+ }
3617
+ sendAdLoadedTracking(this.config.licenseKey, _object_spread_props(_object_spread({
3618
+ source: this.getAdSource()
3619
+ }, adUrl ? {
3620
+ vastUrl: adUrl
3621
+ } : {}), {
3622
+ timestamp: /* @__PURE__ */ new Date().toISOString()
3623
+ }), this.getAnalyticsContext());
3624
+ }
3625
+ },
3531
3626
  {
3532
3627
  key: "attachAdLayerEventListeners",
3533
3628
  value: function attachAdLayerEventListeners() {
3534
3629
  var _this = this;
3535
3630
  this.adLayer.on("ad_impression", function() {
3536
3631
  if (_this.config.licenseKey) {
3537
- sendAdImpressionTracking(_this.config.licenseKey, {
3632
+ sendAdImpressionTracking(_this.config.licenseKey, _object_spread_props(_object_spread({
3538
3633
  source: _this.getAdSource(),
3539
- adIndex: _this.currentAdIndex,
3634
+ adIndex: _this.currentAdIndex
3635
+ }, _this.lastServedAdUrl ? {
3636
+ adUrl: _this.lastServedAdUrl
3637
+ } : {}), {
3540
3638
  timestamp: /* @__PURE__ */ new Date().toISOString()
3541
- });
3639
+ }), _this.getAnalyticsContext());
3542
3640
  }
3543
3641
  });
3544
3642
  this.adLayer.on("ad_error", function(errorPayload) {
@@ -3632,6 +3730,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3632
3730
  _this.isInAdTransition = false;
3633
3731
  if (!_this.inAdBreak) return;
3634
3732
  _this.currentAdIndex++;
3733
+ _this.trackAdLoaded();
3635
3734
  _this.adLayer.playPreloaded(token).catch(function(err) {
3636
3735
  if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playPreloaded failed:", err);
3637
3736
  _this.handleAdFailure();
@@ -3661,6 +3760,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
3661
3760
  var freshBids = (_this_pendingNextAdBids = _this.pendingNextAdBids) !== null && _this_pendingNextAdBids !== void 0 ? _this_pendingNextAdBids : bids;
3662
3761
  _this.pendingNextAdBids = null;
3663
3762
  _this.currentAdIndex++;
3763
+ _this.trackAdLoaded(freshBids);
3664
3764
  _this.adLayer.playAd(freshBids).catch(function(err) {
3665
3765
  if (_this.config.debugAdTiming) console.warn("[StormcloudVideoPlayer] playAd(pending) failed:", err);
3666
3766
  _this.handleAdFailure();
@@ -4040,7 +4140,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4040
4140
  }, ((_this_pendingAdBreak1 = this.pendingAdBreak) === null || _this_pendingAdBreak1 === void 0 ? void 0 : _this_pendingAdBreak1.detectedAtFragmentSn) != null && {
4041
4141
  detectedAtFragmentSn: this.pendingAdBreak.detectedAtFragmentSn
4042
4142
  });
4043
- sendAdDetectTracking(this.config.licenseKey, adDetectInfo);
4143
+ sendAdDetectTracking(this.config.licenseKey, adDetectInfo, this.getAnalyticsContext());
4044
4144
  }
4045
4145
  var isManifestMarker = this.isManifestBasedMarker(marker);
4046
4146
  var forceImmediate = (_this_config_immediateManifestAds = this.config.immediateManifestAds) !== null && _this_config_immediateManifestAds !== void 0 ? _this_config_immediateManifestAds : true;
@@ -4109,6 +4209,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4109
4209
  var bids = this.pendingNextAdBids;
4110
4210
  this.pendingNextAdBids = null;
4111
4211
  this.currentAdIndex++;
4212
+ this.trackAdLoaded(bids);
4112
4213
  this.adLayer.playAd(bids).catch(function() {
4113
4214
  return _this.handleAdFailure();
4114
4215
  });
@@ -4363,7 +4464,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4363
4464
  key: "initializeTracking",
4364
4465
  value: function initializeTracking() {
4365
4466
  var _this = this;
4366
- sendInitialTracking(this.config.licenseKey).then(function() {
4467
+ sendInitialTracking(this.config.licenseKey, this.getAnalyticsContext()).then(function() {
4367
4468
  _this.heartbeatInterval = window.setInterval(function() {
4368
4469
  _this.sendHeartbeatIfNeeded();
4369
4470
  }, 5e3);
@@ -4384,7 +4485,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4384
4485
  var now = Date.now();
4385
4486
  if (!this.lastHeartbeatTime || now - this.lastHeartbeatTime > 3e4) {
4386
4487
  this.lastHeartbeatTime = now;
4387
- sendHeartbeat(this.config.licenseKey).catch(function(error) {
4488
+ sendHeartbeat(this.config.licenseKey, this.getAnalyticsContext()).catch(function(error) {
4388
4489
  if (_this.config.debugAdTiming) {
4389
4490
  console.warn("[StormcloudVideoPlayer] Failed to send heartbeat:", error);
4390
4491
  }
@@ -4777,12 +4878,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4777
4878
  10
4778
4879
  ];
4779
4880
  _this.currentAdIndex++;
4780
- if (_this.config.licenseKey) {
4781
- sendAdLoadedTracking(_this.config.licenseKey, {
4782
- source: _this.getAdSource(),
4783
- timestamp: /* @__PURE__ */ new Date().toISOString()
4784
- });
4785
- }
4881
+ _this.trackAdLoaded(bids1);
4786
4882
  return [
4787
4883
  4,
4788
4884
  _this.adLayer.playAd(bids1)
@@ -4887,12 +4983,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
4887
4983
  ];
4888
4984
  case 18:
4889
4985
  _this.currentAdIndex++;
4890
- if (_this.config.licenseKey) {
4891
- sendAdLoadedTracking(_this.config.licenseKey, {
4892
- source: _this.getAdSource(),
4893
- timestamp: /* @__PURE__ */ new Date().toISOString()
4894
- });
4895
- }
4986
+ _this.trackAdLoaded(bids2);
4896
4987
  return [
4897
4988
  4,
4898
4989
  _this.adLayer.playAd(bids2)
@@ -5051,12 +5142,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5051
5142
  6
5052
5143
  ];
5053
5144
  this.currentAdIndex++;
5054
- if (this.config.licenseKey) {
5055
- sendAdLoadedTracking(this.config.licenseKey, {
5056
- source: this.getAdSource(),
5057
- timestamp: /* @__PURE__ */ new Date().toISOString()
5058
- });
5059
- }
5145
+ this.trackAdLoaded();
5060
5146
  _state.label = 1;
5061
5147
  case 1:
5062
5148
  _state.trys.push([
@@ -5250,12 +5336,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5250
5336
  5
5251
5337
  ];
5252
5338
  case 3:
5253
- if (this.config.licenseKey) {
5254
- sendAdLoadedTracking(this.config.licenseKey, {
5255
- source: this.getAdSource(),
5256
- timestamp: /* @__PURE__ */ new Date().toISOString()
5257
- });
5258
- }
5339
+ this.trackAdLoaded(bids);
5259
5340
  return [
5260
5341
  4,
5261
5342
  this.adLayer.playAd(bids)
@@ -5401,6 +5482,7 @@ var StormcloudVideoPlayer = /*#__PURE__*/ function() {
5401
5482
  ,
5402
5483
  7
5403
5484
  ]);
5485
+ this.trackAdLoaded(bids);
5404
5486
  return [
5405
5487
  4,
5406
5488
  this.adLayer.playAd(bids)