stormcloud-video-player 0.3.59 → 0.3.61

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,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { StormcloudVideoPlayer } from '../player/StormcloudVideoPlayer.cjs';
3
- import { S as StormcloudVideoPlayerConfig } from '../types-Vj55FghO.cjs';
3
+ import { S as StormcloudVideoPlayerConfig } from '../types-XKUJJhlG.cjs';
4
4
 
5
5
  type StormcloudVideoPlayerProps = Omit<StormcloudVideoPlayerConfig, "videoElement"> & React.VideoHTMLAttributes<HTMLVideoElement> & {
6
6
  onReady?: (player: StormcloudVideoPlayer) => void;
@@ -56,30 +56,6 @@ function _object_spread(target) {
56
56
  }
57
57
  return target;
58
58
  }
59
- function ownKeys(object, enumerableOnly) {
60
- var keys = Object.keys(object);
61
- if (Object.getOwnPropertySymbols) {
62
- var symbols = Object.getOwnPropertySymbols(object);
63
- if (enumerableOnly) {
64
- symbols = symbols.filter(function(sym) {
65
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
66
- });
67
- }
68
- keys.push.apply(keys, symbols);
69
- }
70
- return keys;
71
- }
72
- function _object_spread_props(target, source) {
73
- source = source != null ? source : {};
74
- if (Object.getOwnPropertyDescriptors) {
75
- Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
76
- } else {
77
- ownKeys(Object(source)).forEach(function(key) {
78
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
79
- });
80
- }
81
- return target;
82
- }
83
59
  function _type_of(obj) {
84
60
  "@swc/helpers - typeof";
85
61
  return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
@@ -484,40 +460,66 @@ function getBrowserID(clientInfo) {
484
460
  });
485
461
  })();
486
462
  }
487
- function sendInitialTracking(licenseKey) {
463
+ var PLAYER_TRACKING_BASE_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking";
464
+ var TRACK_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/metrics/ingest");
465
+ var HEARTBEAT_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/heartbeat");
466
+ var IMPRESSIONS_URL = "".concat(PLAYER_TRACKING_BASE_URL, "/impressions/ingest");
467
+ function buildHeaders(licenseKey) {
468
+ var headers = {
469
+ "Content-Type": "application/json"
470
+ };
471
+ if (licenseKey) {
472
+ headers["Authorization"] = "Bearer ".concat(licenseKey);
473
+ }
474
+ return headers;
475
+ }
476
+ function sendTrackRequest(licenseKey, body) {
488
477
  return _async_to_generator(function() {
489
- var clientInfo, browserId, trackingData, headers, response, error;
478
+ var response;
490
479
  return _ts_generator(this, function(_state) {
491
480
  switch(_state.label){
492
481
  case 0:
493
- _state.trys.push([
494
- 0,
495
- 4,
496
- ,
497
- 5
498
- ]);
499
- clientInfo = getClientInfo();
500
482
  return [
501
483
  4,
502
- getBrowserID(clientInfo)
484
+ fetch(TRACK_URL, {
485
+ method: "POST",
486
+ headers: buildHeaders(licenseKey),
487
+ body: JSON.stringify(body)
488
+ })
503
489
  ];
504
490
  case 1:
505
- browserId = _state.sent();
506
- trackingData = _object_spread({
507
- browserId: browserId
508
- }, clientInfo);
509
- headers = {
510
- "Content-Type": "application/json"
511
- };
491
+ response = _state.sent();
492
+ if (!response.ok) {
493
+ throw new Error("HTTP error! status: ".concat(response.status));
494
+ }
495
+ return [
496
+ 4,
497
+ response.json()
498
+ ];
499
+ case 2:
500
+ _state.sent();
501
+ return [
502
+ 2
503
+ ];
504
+ }
505
+ });
506
+ })();
507
+ }
508
+ function postJson(url, licenseKey, body) {
509
+ return _async_to_generator(function() {
510
+ var response;
511
+ return _ts_generator(this, function(_state) {
512
+ switch(_state.label){
513
+ case 0:
512
514
  return [
513
515
  4,
514
- fetch("https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track", {
516
+ fetch(url, {
515
517
  method: "POST",
516
- headers: headers,
517
- body: JSON.stringify(trackingData)
518
+ headers: buildHeaders(licenseKey),
519
+ body: JSON.stringify(body)
518
520
  })
519
521
  ];
520
- case 2:
522
+ case 1:
521
523
  response = _state.sent();
522
524
  if (!response.ok) {
523
525
  throw new Error("HTTP error! status: ".concat(response.status));
@@ -526,35 +528,63 @@ function sendInitialTracking(licenseKey) {
526
528
  4,
527
529
  response.json()
528
530
  ];
529
- case 3:
531
+ case 2:
530
532
  _state.sent();
531
533
  return [
532
- 3,
533
- 5
534
+ 2
534
535
  ];
535
- case 4:
536
- error = _state.sent();
537
- console.error("[StormcloudVideoPlayer] Error sending initial tracking data:", error);
536
+ }
537
+ });
538
+ })();
539
+ }
540
+ function buildPlayerMetricEvent(_0) {
541
+ return _async_to_generator(function(licenseKey) {
542
+ var context, flags, _flags_captureAt, clientInfo, browserId, captureAt;
543
+ var _arguments = arguments;
544
+ return _ts_generator(this, function(_state) {
545
+ switch(_state.label){
546
+ case 0:
547
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
548
+ clientInfo = getClientInfo();
538
549
  return [
539
- 3,
540
- 5
550
+ 4,
551
+ getBrowserID(clientInfo)
541
552
  ];
542
- case 5:
553
+ case 1:
554
+ browserId = _state.sent();
555
+ captureAt = (_flags_captureAt = flags.captureAt) !== null && _flags_captureAt !== void 0 ? _flags_captureAt : /* @__PURE__ */ new Date().toISOString();
543
556
  return [
544
- 2
557
+ 2,
558
+ {
559
+ player_id: browserId,
560
+ browserId: browserId,
561
+ device_type: clientInfo.deviceType,
562
+ deviceType: clientInfo.deviceType,
563
+ input_stream_type: context.inputStreamType,
564
+ os: clientInfo.os,
565
+ ad_loaded: flags.adLoaded,
566
+ ad_detect: flags.adDetect,
567
+ license_key: licenseKey,
568
+ capture_at: captureAt,
569
+ timestamp: captureAt
570
+ }
545
571
  ];
546
572
  }
547
573
  });
548
- })();
574
+ }).apply(this, arguments);
549
575
  }
550
- function sendHeartbeat(licenseKey) {
551
- return _async_to_generator(function() {
552
- var clientInfo, browserId, heartbeatData, headers, response, error;
576
+ function sendInitialTracking(_0) {
577
+ return _async_to_generator(function(licenseKey) {
578
+ var context, clientInfo, browserId, trackingData, error;
579
+ var _arguments = arguments;
553
580
  return _ts_generator(this, function(_state) {
554
581
  switch(_state.label){
555
582
  case 0:
583
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {};
584
+ _state.label = 1;
585
+ case 1:
556
586
  _state.trys.push([
557
- 0,
587
+ 1,
558
588
  4,
559
589
  ,
560
590
  5
@@ -564,35 +594,29 @@ function sendHeartbeat(licenseKey) {
564
594
  4,
565
595
  getBrowserID(clientInfo)
566
596
  ];
567
- case 1:
597
+ case 2:
568
598
  browserId = _state.sent();
569
- heartbeatData = {
570
- browserId: browserId,
571
- timestamp: /* @__PURE__ */ new Date().toISOString()
572
- };
573
- headers = {
574
- "Content-Type": "application/json"
575
- };
576
- if (licenseKey) {
577
- headers["Authorization"] = "Bearer ".concat(licenseKey);
578
- }
599
+ trackingData = _object_spread({
600
+ browserId: browserId
601
+ }, clientInfo);
579
602
  return [
580
603
  4,
581
- fetch("https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/heartbeat", {
582
- method: "POST",
583
- headers: headers,
584
- body: JSON.stringify(heartbeatData)
604
+ sendTrackRequest(licenseKey, {
605
+ events: [
606
+ {
607
+ player_id: browserId,
608
+ device_type: clientInfo.deviceType,
609
+ input_stream_type: context.inputStreamType,
610
+ os: clientInfo.os,
611
+ ad_loaded: false,
612
+ ad_detect: false,
613
+ license_key: licenseKey,
614
+ capture_at: /* @__PURE__ */ new Date().toISOString()
615
+ }
616
+ ],
617
+ trackingData: trackingData
585
618
  })
586
619
  ];
587
- case 2:
588
- response = _state.sent();
589
- if (!response.ok) {
590
- throw new Error("HTTP error! status: ".concat(response.status));
591
- }
592
- return [
593
- 4,
594
- response.json()
595
- ];
596
620
  case 3:
597
621
  _state.sent();
598
622
  return [
@@ -601,7 +625,7 @@ function sendHeartbeat(licenseKey) {
601
625
  ];
602
626
  case 4:
603
627
  error = _state.sent();
604
- console.error("[StormcloudVideoPlayer] Error sending heartbeat:", error);
628
+ console.error("[StormcloudVideoPlayer] Error sending initial tracking data:", error);
605
629
  return [
606
630
  3,
607
631
  5
@@ -612,95 +636,74 @@ function sendHeartbeat(licenseKey) {
612
636
  ];
613
637
  }
614
638
  });
615
- })();
639
+ }).apply(this, arguments);
616
640
  }
617
- var TRACK_API_URL = "https://adstorm.co/api-adstorm-dev/adstorm/player-tracking/track";
618
- function mapToAdTrackingSource(source, adPlayerType) {
619
- if (source === "prebid" || source === "ima" || source === "hls") {
620
- return source;
621
- }
622
- if (source === "preload" || source === "ssp") {
623
- return source === "ssp" ? "prebid" : "ima";
624
- }
625
- return adPlayerType === "hls" ? "hls" : "ima";
626
- }
627
- function postAdTracking(licenseKey, body) {
628
- return _async_to_generator(function() {
629
- var headers, response;
641
+ function sendAdDetectTracking(_0, _1) {
642
+ return _async_to_generator(function(licenseKey, adDetectInfo) {
643
+ var context, error;
644
+ var _arguments = arguments;
630
645
  return _ts_generator(this, function(_state) {
631
646
  switch(_state.label){
632
647
  case 0:
633
- headers = {
634
- "Content-Type": "application/json"
635
- };
636
- if (licenseKey) {
637
- headers["Authorization"] = "Bearer ".concat(licenseKey);
638
- }
639
- return [
640
- 4,
641
- fetch(TRACK_API_URL, {
642
- method: "POST",
643
- headers: headers,
644
- body: JSON.stringify(body)
645
- })
646
- ];
648
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
649
+ _state.label = 1;
647
650
  case 1:
648
- response = _state.sent();
649
- if (!response.ok) {
650
- throw new Error("HTTP error! status: ".concat(response.status));
651
- }
651
+ _state.trys.push([
652
+ 1,
653
+ 3,
654
+ ,
655
+ 4
656
+ ]);
652
657
  return [
653
658
  4,
654
- response.json()
659
+ sendHeartbeat(licenseKey, context, {
660
+ adDetect: true,
661
+ captureAt: adDetectInfo.timestamp
662
+ })
655
663
  ];
656
664
  case 2:
657
665
  _state.sent();
666
+ return [
667
+ 3,
668
+ 4
669
+ ];
670
+ case 3:
671
+ error = _state.sent();
672
+ console.error("[StormcloudVideoPlayer] Error sending ad detect tracking:", error);
673
+ return [
674
+ 3,
675
+ 4
676
+ ];
677
+ case 4:
658
678
  return [
659
679
  2
660
680
  ];
661
681
  }
662
682
  });
663
- })();
683
+ }).apply(this, arguments);
664
684
  }
665
- function sendAdDetectTracking(licenseKey, payload) {
666
- return _async_to_generator(function() {
667
- var _payload_source, _payload_timestamp, clientInfo, browserId, adDetectInfo, body, error;
685
+ function sendAdLoadedTracking(_0, _1) {
686
+ return _async_to_generator(function(licenseKey, adLoadedInfo) {
687
+ var context, error;
688
+ var _arguments = arguments;
668
689
  return _ts_generator(this, function(_state) {
669
690
  switch(_state.label){
670
691
  case 0:
692
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
693
+ _state.label = 1;
694
+ case 1:
671
695
  _state.trys.push([
672
- 0,
696
+ 1,
673
697
  3,
674
698
  ,
675
699
  4
676
700
  ]);
677
- clientInfo = getClientInfo();
678
- return [
679
- 4,
680
- getBrowserID(clientInfo)
681
- ];
682
- case 1:
683
- browserId = _state.sent();
684
- adDetectInfo = _object_spread({
685
- source: (_payload_source = payload.source) !== null && _payload_source !== void 0 ? _payload_source : "scte35",
686
- timestamp: (_payload_timestamp = payload.timestamp) !== null && _payload_timestamp !== void 0 ? _payload_timestamp : /* @__PURE__ */ new Date().toISOString()
687
- }, payload.durationSeconds != null && {
688
- durationSeconds: payload.durationSeconds
689
- }, payload.ptsSeconds != null && {
690
- ptsSeconds: payload.ptsSeconds
691
- }, payload.detectedAtFragmentSn != null && {
692
- detectedAtFragmentSn: payload.detectedAtFragmentSn
693
- });
694
- body = _object_spread_props(_object_spread({
695
- browserId: browserId
696
- }, clientInfo, licenseKey && {
697
- licenseKey: licenseKey
698
- }), {
699
- adDetectInfo: adDetectInfo
700
- });
701
701
  return [
702
702
  4,
703
- postAdTracking(licenseKey, body)
703
+ sendHeartbeat(licenseKey, context, {
704
+ adLoaded: true,
705
+ captureAt: adLoadedInfo.timestamp
706
+ })
704
707
  ];
705
708
  case 2:
706
709
  _state.sent();
@@ -710,7 +713,7 @@ function sendAdDetectTracking(licenseKey, payload) {
710
713
  ];
711
714
  case 3:
712
715
  error = _state.sent();
713
- console.error("[StormcloudVideoPlayer] Error sending ad-detect tracking:", error);
716
+ console.error("[StormcloudVideoPlayer] Error sending ad loaded tracking:", error);
714
717
  return [
715
718
  3,
716
719
  4
@@ -721,126 +724,116 @@ function sendAdDetectTracking(licenseKey, payload) {
721
724
  ];
722
725
  }
723
726
  });
724
- })();
727
+ }).apply(this, arguments);
725
728
  }
726
- function sendAdLoadedTracking(licenseKey, payload, adPlayerType) {
727
- return _async_to_generator(function() {
728
- var clientInfo, browserId, source, adLoadedInfo, body, error;
729
+ function sendAdImpressionTracking(_0, _1) {
730
+ return _async_to_generator(function(licenseKey, adImpressionInfo) {
731
+ var context, metricEvent, error;
732
+ var _arguments = arguments;
729
733
  return _ts_generator(this, function(_state) {
730
734
  switch(_state.label){
731
735
  case 0:
736
+ context = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
737
+ _state.label = 1;
738
+ case 1:
732
739
  _state.trys.push([
733
- 0,
734
- 3,
740
+ 1,
741
+ 4,
735
742
  ,
736
- 4
743
+ 5
737
744
  ]);
738
- clientInfo = getClientInfo();
739
745
  return [
740
746
  4,
741
- getBrowserID(clientInfo)
747
+ buildPlayerMetricEvent(licenseKey, context, {
748
+ captureAt: adImpressionInfo.timestamp
749
+ })
742
750
  ];
743
- case 1:
744
- browserId = _state.sent();
745
- source = mapToAdTrackingSource(payload.source, adPlayerType);
746
- adLoadedInfo = _object_spread({
747
- source: source,
748
- timestamp: /* @__PURE__ */ new Date().toISOString()
749
- }, payload.vastUrl != null && {
750
- vastUrl: payload.vastUrl
751
- }, payload.durationSeconds != null && {
752
- durationSeconds: payload.durationSeconds
753
- });
754
- body = _object_spread_props(_object_spread({
755
- browserId: browserId
756
- }, clientInfo, licenseKey && {
757
- licenseKey: licenseKey
758
- }), {
759
- adLoadedInfo: adLoadedInfo
760
- });
751
+ case 2:
752
+ metricEvent = _state.sent();
761
753
  return [
762
754
  4,
763
- postAdTracking(licenseKey, body)
755
+ Promise.all([
756
+ postJson(HEARTBEAT_URL, licenseKey, metricEvent),
757
+ postJson(IMPRESSIONS_URL, licenseKey, {
758
+ events: [
759
+ {
760
+ player_id: metricEvent.player_id,
761
+ ad_played_count: 1,
762
+ ad_url: adImpressionInfo.adUrl,
763
+ license_key: licenseKey,
764
+ capture_at: adImpressionInfo.timestamp
765
+ }
766
+ ]
767
+ })
768
+ ])
764
769
  ];
765
- case 2:
770
+ case 3:
766
771
  _state.sent();
767
772
  return [
768
773
  3,
769
- 4
774
+ 5
770
775
  ];
771
- case 3:
776
+ case 4:
772
777
  error = _state.sent();
773
- console.error("[StormcloudVideoPlayer] Error sending ad-loaded tracking:", error);
778
+ console.error("[StormcloudVideoPlayer] Error sending ad impression tracking:", error);
774
779
  return [
775
780
  3,
776
- 4
781
+ 5
777
782
  ];
778
- case 4:
783
+ case 5:
779
784
  return [
780
785
  2
781
786
  ];
782
787
  }
783
788
  });
784
- })();
789
+ }).apply(this, arguments);
785
790
  }
786
- function sendAdImpressionTracking(licenseKey, payload, adPlayerType) {
787
- return _async_to_generator(function() {
788
- var clientInfo, browserId, source, adImpressionInfo, body, error;
791
+ function sendHeartbeat(_0) {
792
+ return _async_to_generator(function(licenseKey) {
793
+ var context, flags, heartbeatData, error;
794
+ var _arguments = arguments;
789
795
  return _ts_generator(this, function(_state) {
790
796
  switch(_state.label){
791
797
  case 0:
798
+ context = _arguments.length > 1 && _arguments[1] !== void 0 ? _arguments[1] : {}, flags = _arguments.length > 2 && _arguments[2] !== void 0 ? _arguments[2] : {};
799
+ _state.label = 1;
800
+ case 1:
792
801
  _state.trys.push([
793
- 0,
794
- 3,
802
+ 1,
803
+ 4,
795
804
  ,
796
- 4
805
+ 5
797
806
  ]);
798
- clientInfo = getClientInfo();
799
807
  return [
800
808
  4,
801
- getBrowserID(clientInfo)
809
+ buildPlayerMetricEvent(licenseKey, context, flags)
802
810
  ];
803
- case 1:
804
- browserId = _state.sent();
805
- source = mapToAdTrackingSource(payload.source, adPlayerType);
806
- adImpressionInfo = _object_spread({
807
- source: source,
808
- adIndex: payload.adIndex,
809
- timestamp: /* @__PURE__ */ new Date().toISOString()
810
- }, payload.durationSeconds != null && {
811
- durationSeconds: payload.durationSeconds
812
- });
813
- body = _object_spread_props(_object_spread({
814
- browserId: browserId
815
- }, clientInfo, licenseKey && {
816
- licenseKey: licenseKey
817
- }), {
818
- adImpressionInfo: adImpressionInfo
819
- });
811
+ case 2:
812
+ heartbeatData = _state.sent();
820
813
  return [
821
814
  4,
822
- postAdTracking(licenseKey, body)
815
+ postJson(HEARTBEAT_URL, licenseKey, heartbeatData)
823
816
  ];
824
- case 2:
817
+ case 3:
825
818
  _state.sent();
826
819
  return [
827
820
  3,
828
- 4
821
+ 5
829
822
  ];
830
- case 3:
823
+ case 4:
831
824
  error = _state.sent();
832
- console.error("[StormcloudVideoPlayer] Error sending ad-impression tracking:", error);
825
+ console.error("[StormcloudVideoPlayer] Error sending heartbeat:", error);
833
826
  return [
834
827
  3,
835
- 4
828
+ 5
836
829
  ];
837
- case 4:
830
+ case 5:
838
831
  return [
839
832
  2
840
833
  ];
841
834
  }
842
835
  });
843
- })();
836
+ }).apply(this, arguments);
844
837
  }
845
838
  // Annotate the CommonJS export names for ESM import in node:
846
839
  0 && (module.exports = {