@@ -648,6 +648,96 @@ 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 ( expect . not . arrayContaining ( [ expect . objectContaining ( { name : 'MobileReplay' } ) ] ) ) ;
698
+ } ) ;
699
+
700
+ it ( 'does not add any replay integration when on web even with session sample rate' , ( ) => {
701
+ ( notWeb as jest . Mock ) . mockImplementation ( ( ) => false ) ;
702
+ init ( {
703
+ _experiments : {
704
+ replaysSessionSampleRate : 1.0 ,
705
+ } ,
706
+ } ) ;
707
+
708
+ const actualOptions = usedOptions ( ) ;
709
+ const actualIntegrations = actualOptions ?. integrations ;
710
+ expect ( actualIntegrations ) . toEqual ( expect . not . arrayContaining ( [ expect . objectContaining ( { name : 'Replay' } ) ] ) ) ;
711
+ expect ( actualIntegrations ) . toEqual ( expect . not . arrayContaining ( [ expect . objectContaining ( { name : 'MobileReplay' } ) ] ) ) ;
712
+ } ) ;
713
+
714
+ it ( 'does not add any replay integration when on web' , ( ) => {
715
+ ( notWeb as jest . Mock ) . mockImplementation ( ( ) => false ) ;
716
+ init ( { } ) ;
717
+
718
+ const actualOptions = usedOptions ( ) ;
719
+ const actualIntegrations = actualOptions ?. integrations ;
720
+ expect ( actualIntegrations ) . toEqual ( expect . not . arrayContaining ( [ expect . objectContaining ( { name : 'Replay' } ) ] ) ) ;
721
+ expect ( actualIntegrations ) . toEqual ( expect . not . arrayContaining ( [ expect . objectContaining ( { name : 'MobileReplay' } ) ] ) ) ;
722
+ } ) ;
723
+
724
+ it ( 'converts experimental replay options to standard web options when on web' , ( ) => {
725
+ ( notWeb as jest . Mock ) . mockImplementation ( ( ) => false ) ;
726
+ init ( {
727
+ _experiments : {
728
+ replaysOnErrorSampleRate : 0.5 ,
729
+ replaysSessionSampleRate : 0.1 ,
730
+ } ,
731
+ } ) ;
732
+
733
+ const actualOptions = usedOptions ( ) ;
734
+ expect ( actualOptions ) . toEqual (
735
+ expect . objectContaining ( {
736
+ replaysOnErrorSampleRate : 0.5 ,
737
+ replaysSessionSampleRate : 0.1 ,
738
+ } ) ,
739
+ ) ;
740
+ } ) ;
651
741
} ) ;
652
742
653
743
function createMockedIntegration ( { name } : { name ?: string } = { } ) : Integration {
0 commit comments