@@ -648,6 +648,102 @@ describe('Tests the SDK functionality', () => {
648
648
649
649
expect ( actualIntegrations ) . toEqual ( expect . arrayContaining ( [ expect . objectContaining ( { name : 'ExpoContext' } ) ] ) ) ;
650
650
} ) ;
651
+
652
+ it ( 'adds mobile replay integration when _experiments.replaysOnErrorSampleRate is set' , ( ) => {
653
+ init ( {
654
+ _experiments : {
655
+ replaysOnErrorSampleRate : 1.0 ,
656
+ } ,
657
+ } ) ;
658
+
659
+ const actualOptions = usedOptions ( ) ;
660
+ const actualIntegrations = actualOptions ?. integrations ;
661
+ expect ( actualIntegrations ) . toEqual ( expect . arrayContaining ( [ expect . objectContaining ( { name : 'MobileReplay' } ) ] ) ) ;
662
+ } ) ;
663
+
664
+ it ( 'adds mobile replay integration when _experiments.replaysSessionSampleRate is set' , ( ) => {
665
+ init ( {
666
+ _experiments : {
667
+ replaysSessionSampleRate : 1.0 ,
668
+ } ,
669
+ } ) ;
670
+
671
+ const actualOptions = usedOptions ( ) ;
672
+ const actualIntegrations = actualOptions ?. integrations ;
673
+ expect ( actualIntegrations ) . toEqual ( expect . arrayContaining ( [ expect . objectContaining ( { name : 'MobileReplay' } ) ] ) ) ;
674
+ } ) ;
675
+
676
+ it ( 'does not add mobile replay integration when no replay sample rates are set' , ( ) => {
677
+ init ( {
678
+ _experiments : { } ,
679
+ } ) ;
680
+
681
+ const actualOptions = usedOptions ( ) ;
682
+ const actualIntegrations = actualOptions ?. integrations ;
683
+ expect ( actualIntegrations ) . toEqual ( expect . not . arrayContaining ( [ expect . objectContaining ( { name : 'MobileReplay' } ) ] ) ) ;
684
+ } ) ;
685
+
686
+ it ( 'does not add any replay integration when on web even with on error sample rate' , ( ) => {
687
+ ( notWeb as jest . Mock ) . mockImplementation ( ( ) => false ) ;
688
+ init ( {
689
+ _experiments : {
690
+ replaysOnErrorSampleRate : 1.0 ,
691
+ } ,
692
+ } ) ;
693
+
694
+ const actualOptions = usedOptions ( ) ;
695
+ const actualIntegrations = actualOptions ?. integrations ;
696
+ expect ( actualIntegrations ) . toEqual ( expect . not . arrayContaining ( [ expect . objectContaining ( { name : 'Replay' } ) ] ) ) ;
697
+ expect ( actualIntegrations ) . toEqual (
698
+ expect . not . arrayContaining ( [ expect . objectContaining ( { name : 'MobileReplay' } ) ] ) ,
699
+ ) ;
700
+ } ) ;
701
+
702
+ it ( 'does not add any replay integration when on web even with session sample rate' , ( ) => {
703
+ ( notWeb as jest . Mock ) . mockImplementation ( ( ) => false ) ;
704
+ init ( {
705
+ _experiments : {
706
+ replaysSessionSampleRate : 1.0 ,
707
+ } ,
708
+ } ) ;
709
+
710
+ const actualOptions = usedOptions ( ) ;
711
+ const actualIntegrations = actualOptions ?. integrations ;
712
+ expect ( actualIntegrations ) . toEqual ( expect . not . arrayContaining ( [ expect . objectContaining ( { name : 'Replay' } ) ] ) ) ;
713
+ expect ( actualIntegrations ) . toEqual (
714
+ expect . not . arrayContaining ( [ expect . objectContaining ( { name : 'MobileReplay' } ) ] ) ,
715
+ ) ;
716
+ } ) ;
717
+
718
+ it ( 'does not add any replay integration when on web' , ( ) => {
719
+ ( notWeb as jest . Mock ) . mockImplementation ( ( ) => false ) ;
720
+ init ( { } ) ;
721
+
722
+ const actualOptions = usedOptions ( ) ;
723
+ const actualIntegrations = actualOptions ?. integrations ;
724
+ expect ( actualIntegrations ) . toEqual ( expect . not . arrayContaining ( [ expect . objectContaining ( { name : 'Replay' } ) ] ) ) ;
725
+ expect ( actualIntegrations ) . toEqual (
726
+ expect . not . arrayContaining ( [ expect . objectContaining ( { name : 'MobileReplay' } ) ] ) ,
727
+ ) ;
728
+ } ) ;
729
+
730
+ it ( 'converts experimental replay options to standard web options when on web' , ( ) => {
731
+ ( notWeb as jest . Mock ) . mockImplementation ( ( ) => false ) ;
732
+ init ( {
733
+ _experiments : {
734
+ replaysOnErrorSampleRate : 0.5 ,
735
+ replaysSessionSampleRate : 0.1 ,
736
+ } ,
737
+ } ) ;
738
+
739
+ const actualOptions = usedOptions ( ) ;
740
+ expect ( actualOptions ) . toEqual (
741
+ expect . objectContaining ( {
742
+ replaysOnErrorSampleRate : 0.5 ,
743
+ replaysSessionSampleRate : 0.1 ,
744
+ } ) ,
745
+ ) ;
746
+ } ) ;
651
747
} ) ;
652
748
653
749
function createMockedIntegration ( { name } : { name ?: string } = { } ) : Integration {
0 commit comments