@@ -444,7 +444,7 @@ internal class SessionReplayFeatureTest {
444
444
// Then
445
445
mockInternalLogger.verifyLog(
446
446
InternalLogger .Level .WARN ,
447
- InternalLogger .Target .USER ,
447
+ InternalLogger .Target .MAINTAINER ,
448
448
SessionReplayFeature .REQUIRES_APPLICATION_CONTEXT_WARN_MESSAGE
449
449
)
450
450
verifyNoInteractions(mockRecorder)
@@ -519,7 +519,7 @@ internal class SessionReplayFeatureTest {
519
519
mockInternalLogger.verifyLog(
520
520
InternalLogger .Level .INFO ,
521
521
InternalLogger .Target .USER ,
522
- SessionReplayFeature .SESSION_SAMPLED_OUT_MESSAGE
522
+ SessionReplayFeature .SESSION_NOT_KEPT_MESSAGE
523
523
)
524
524
}
525
525
@@ -621,7 +621,7 @@ internal class SessionReplayFeatureTest {
621
621
mockInternalLogger.verifyLog(
622
622
InternalLogger .Level .INFO ,
623
623
InternalLogger .Target .USER ,
624
- SessionReplayFeature .SESSION_SAMPLED_OUT_MESSAGE
624
+ SessionReplayFeature .SESSION_NOT_KEPT_MESSAGE
625
625
)
626
626
}
627
627
@@ -701,7 +701,7 @@ internal class SessionReplayFeatureTest {
701
701
mockInternalLogger.verifyLog(
702
702
InternalLogger .Level .INFO ,
703
703
InternalLogger .Target .USER ,
704
- SessionReplayFeature .SESSION_SAMPLED_OUT_MESSAGE
704
+ SessionReplayFeature .SESSION_NOT_KEPT_MESSAGE
705
705
)
706
706
}
707
707
@@ -801,6 +801,126 @@ internal class SessionReplayFeatureTest {
801
801
verifyNoInteractions(mockRecorder)
802
802
}
803
803
804
+ @Test
805
+ fun `M not resume recording in new session W user call stopRecording {startRecordingImmediately = true}` (
806
+ @Forgery fakeUUID2 : UUID
807
+ ) {
808
+ // Given
809
+ val fakeSessionId2 = fakeUUID2.toString()
810
+ whenever(mockSampler.sample(any())).thenReturn(true )
811
+ testedFeature = SessionReplayFeature (
812
+ sdkCore = mockSdkCore,
813
+ customEndpointUrl = fakeConfiguration.customEndpointUrl,
814
+ privacy = fakeConfiguration.privacy,
815
+ textAndInputPrivacy = fakeConfiguration.textAndInputPrivacy,
816
+ imagePrivacy = fakeConfiguration.imagePrivacy,
817
+ touchPrivacy = fakeConfiguration.touchPrivacy,
818
+ startRecordingImmediately = true ,
819
+ rateBasedSampler = mockSampler
820
+ ) { _, _, _, _ -> mockRecorder }
821
+ testedFeature.onInitialize(appContext.mockInstance)
822
+ val rumSessionUpdateBusMessage1 = mapOf (
823
+ SessionReplayFeature .SESSION_REPLAY_BUS_MESSAGE_TYPE_KEY to
824
+ SessionReplayFeature .RUM_SESSION_RENEWED_BUS_MESSAGE ,
825
+ SessionReplayFeature .RUM_KEEP_SESSION_BUS_MESSAGE_KEY to
826
+ true ,
827
+ SessionReplayFeature .RUM_SESSION_ID_BUS_MESSAGE_KEY to
828
+ fakeSessionId
829
+ )
830
+ val rumSessionUpdateBusMessage2 = mapOf (
831
+ SessionReplayFeature .SESSION_REPLAY_BUS_MESSAGE_TYPE_KEY to
832
+ SessionReplayFeature .RUM_SESSION_RENEWED_BUS_MESSAGE ,
833
+ SessionReplayFeature .RUM_KEEP_SESSION_BUS_MESSAGE_KEY to
834
+ true ,
835
+ SessionReplayFeature .RUM_SESSION_ID_BUS_MESSAGE_KEY to
836
+ fakeSessionId2
837
+ )
838
+
839
+ // When
840
+ testedFeature.onReceive(rumSessionUpdateBusMessage1)
841
+ testedFeature.manuallyStopRecording()
842
+ testedFeature.onReceive(rumSessionUpdateBusMessage2)
843
+
844
+ // Then
845
+ inOrder(mockRecorder) {
846
+ verify(mockRecorder).registerCallbacks()
847
+ verify(mockRecorder).resumeRecorders()
848
+ verify(mockRecorder).stopRecorders()
849
+ }
850
+ verifyNoMoreInteractions(mockRecorder)
851
+ }
852
+
853
+ @Test
854
+ fun `M resume recording in new session W user call startRecording {startRecordingImmediately = false}` (
855
+ @Forgery fakeUUID3 : UUID ,
856
+ @Forgery fakeUUID4 : UUID
857
+ ) {
858
+ // Given
859
+ val fakeSessionId3 = fakeUUID3.toString()
860
+ val fakeSessionId4 = fakeUUID4.toString()
861
+ whenever(mockSampler.sample(any())).thenReturn(true )
862
+ testedFeature = SessionReplayFeature (
863
+ sdkCore = mockSdkCore,
864
+ customEndpointUrl = fakeConfiguration.customEndpointUrl,
865
+ privacy = fakeConfiguration.privacy,
866
+ textAndInputPrivacy = fakeConfiguration.textAndInputPrivacy,
867
+ imagePrivacy = fakeConfiguration.imagePrivacy,
868
+ touchPrivacy = fakeConfiguration.touchPrivacy,
869
+ startRecordingImmediately = false ,
870
+ rateBasedSampler = mockSampler
871
+ ) { _, _, _, _ -> mockRecorder }
872
+ testedFeature.onInitialize(appContext.mockInstance)
873
+ val rumSessionUpdateBusMessage1 = mapOf (
874
+ SessionReplayFeature .SESSION_REPLAY_BUS_MESSAGE_TYPE_KEY to
875
+ SessionReplayFeature .RUM_SESSION_RENEWED_BUS_MESSAGE ,
876
+ SessionReplayFeature .RUM_KEEP_SESSION_BUS_MESSAGE_KEY to
877
+ true ,
878
+ SessionReplayFeature .RUM_SESSION_ID_BUS_MESSAGE_KEY to
879
+ fakeSessionId
880
+ )
881
+ val rumSessionUpdateBusMessage2 = mapOf (
882
+ SessionReplayFeature .SESSION_REPLAY_BUS_MESSAGE_TYPE_KEY to
883
+ SessionReplayFeature .RUM_SESSION_RENEWED_BUS_MESSAGE ,
884
+ SessionReplayFeature .RUM_KEEP_SESSION_BUS_MESSAGE_KEY to
885
+ true ,
886
+ SessionReplayFeature .RUM_SESSION_ID_BUS_MESSAGE_KEY to
887
+ fakeSessionId
888
+ )
889
+ val rumSessionUpdateBusMessage3 = mapOf (
890
+ SessionReplayFeature .SESSION_REPLAY_BUS_MESSAGE_TYPE_KEY to
891
+ SessionReplayFeature .RUM_SESSION_RENEWED_BUS_MESSAGE ,
892
+ SessionReplayFeature .RUM_KEEP_SESSION_BUS_MESSAGE_KEY to
893
+ false ,
894
+ SessionReplayFeature .RUM_SESSION_ID_BUS_MESSAGE_KEY to
895
+ fakeSessionId3
896
+ )
897
+ val rumSessionUpdateBusMessage4 = mapOf (
898
+ SessionReplayFeature .SESSION_REPLAY_BUS_MESSAGE_TYPE_KEY to
899
+ SessionReplayFeature .RUM_SESSION_RENEWED_BUS_MESSAGE ,
900
+ SessionReplayFeature .RUM_KEEP_SESSION_BUS_MESSAGE_KEY to
901
+ true ,
902
+ SessionReplayFeature .RUM_SESSION_ID_BUS_MESSAGE_KEY to
903
+ fakeSessionId4
904
+ )
905
+
906
+ // When
907
+ testedFeature.onReceive(rumSessionUpdateBusMessage1)
908
+ testedFeature.manuallyStartRecording()
909
+ // send an event with same session id to process manual start recording.
910
+ testedFeature.onReceive(rumSessionUpdateBusMessage2)
911
+ testedFeature.onReceive(rumSessionUpdateBusMessage3)
912
+ testedFeature.onReceive(rumSessionUpdateBusMessage4)
913
+
914
+ // Then
915
+ inOrder(mockRecorder) {
916
+ verify(mockRecorder).registerCallbacks()
917
+ verify(mockRecorder).resumeRecorders()
918
+ verify(mockRecorder).stopRecorders()
919
+ verify(mockRecorder).resumeRecorders()
920
+ }
921
+ verifyNoMoreInteractions(mockRecorder)
922
+ }
923
+
804
924
@Test
805
925
fun `M start recording W rum session is initialized after first message` () {
806
926
// Given
@@ -895,15 +1015,15 @@ internal class SessionReplayFeatureTest {
895
1015
// Then
896
1016
mockInternalLogger.verifyLog(
897
1017
InternalLogger .Level .WARN ,
898
- InternalLogger .Target .USER ,
1018
+ InternalLogger .Target .MAINTAINER ,
899
1019
SessionReplayFeature .EVENT_MISSING_MANDATORY_FIELDS
900
1020
)
901
1021
902
1022
verify(mockRecorder, never()).resumeRecorders()
903
1023
}
904
1024
905
1025
@Test
906
- fun `M log warning and do nothing W onReceive() { missing keep state field }` (
1026
+ fun `M log warning and do nothing W onReceive() { missing keep state field }` (
907
1027
@Mock fakeContext : Application
908
1028
) {
909
1029
// Given
@@ -920,7 +1040,7 @@ internal class SessionReplayFeatureTest {
920
1040
// Then
921
1041
mockInternalLogger.verifyLog(
922
1042
InternalLogger .Level .WARN ,
923
- InternalLogger .Target .USER ,
1043
+ InternalLogger .Target .MAINTAINER ,
924
1044
SessionReplayFeature .EVENT_MISSING_MANDATORY_FIELDS
925
1045
)
926
1046
@@ -946,7 +1066,7 @@ internal class SessionReplayFeatureTest {
946
1066
// Then
947
1067
mockInternalLogger.verifyLog(
948
1068
InternalLogger .Level .WARN ,
949
- InternalLogger .Target .USER ,
1069
+ InternalLogger .Target .MAINTAINER ,
950
1070
SessionReplayFeature .EVENT_MISSING_MANDATORY_FIELDS
951
1071
)
952
1072
@@ -975,7 +1095,7 @@ internal class SessionReplayFeatureTest {
975
1095
// Then
976
1096
mockInternalLogger.verifyLog(
977
1097
InternalLogger .Level .WARN ,
978
- InternalLogger .Target .USER ,
1098
+ InternalLogger .Target .MAINTAINER ,
979
1099
SessionReplayFeature .EVENT_MISSING_MANDATORY_FIELDS
980
1100
)
981
1101
@@ -1146,6 +1266,63 @@ internal class SessionReplayFeatureTest {
1146
1266
verify(mockRecorder).stopRecorders()
1147
1267
}
1148
1268
1269
+ @Test
1270
+ fun `M resume recordings W keepSession changes from false to true` (
1271
+ @Mock fakeContext : Application ,
1272
+ @Forgery fakeUUID1 : UUID ,
1273
+ @Forgery fakeUUID2 : UUID ,
1274
+ @Forgery fakeUUID3 : UUID
1275
+ ) {
1276
+ // Given
1277
+ val event1 = mapOf (
1278
+ SessionReplayFeature .SESSION_REPLAY_BUS_MESSAGE_TYPE_KEY to
1279
+ SessionReplayFeature .RUM_SESSION_RENEWED_BUS_MESSAGE ,
1280
+ SessionReplayFeature .RUM_KEEP_SESSION_BUS_MESSAGE_KEY to true ,
1281
+ SessionReplayFeature .RUM_SESSION_ID_BUS_MESSAGE_KEY to fakeUUID1.toString()
1282
+ )
1283
+
1284
+ whenever(mockSampler.sample(any())).thenReturn(true )
1285
+
1286
+ // When
1287
+ testedFeature = SessionReplayFeature (
1288
+ sdkCore = mockSdkCore,
1289
+ customEndpointUrl = fakeConfiguration.customEndpointUrl,
1290
+ privacy = fakeConfiguration.privacy,
1291
+ textAndInputPrivacy = fakeConfiguration.textAndInputPrivacy,
1292
+ imagePrivacy = fakeConfiguration.imagePrivacy,
1293
+ touchPrivacy = fakeConfiguration.touchPrivacy,
1294
+ startRecordingImmediately = true ,
1295
+ rateBasedSampler = mockSampler
1296
+ ) { _, _, _, _ -> mockRecorder }
1297
+ testedFeature.onInitialize(fakeContext)
1298
+ testedFeature.onReceive(event1)
1299
+
1300
+ // When
1301
+ val event2 = mapOf (
1302
+ SessionReplayFeature .SESSION_REPLAY_BUS_MESSAGE_TYPE_KEY to
1303
+ SessionReplayFeature .RUM_SESSION_RENEWED_BUS_MESSAGE ,
1304
+ SessionReplayFeature .RUM_KEEP_SESSION_BUS_MESSAGE_KEY to false ,
1305
+ SessionReplayFeature .RUM_SESSION_ID_BUS_MESSAGE_KEY to fakeUUID2.toString()
1306
+ )
1307
+ testedFeature.onReceive(event2)
1308
+
1309
+ // When
1310
+ val event3 = mapOf (
1311
+ SessionReplayFeature .SESSION_REPLAY_BUS_MESSAGE_TYPE_KEY to
1312
+ SessionReplayFeature .RUM_SESSION_RENEWED_BUS_MESSAGE ,
1313
+ SessionReplayFeature .RUM_KEEP_SESSION_BUS_MESSAGE_KEY to true ,
1314
+ SessionReplayFeature .RUM_SESSION_ID_BUS_MESSAGE_KEY to fakeUUID3.toString()
1315
+ )
1316
+ testedFeature.onReceive(event3)
1317
+
1318
+ // Then
1319
+ inOrder(mockRecorder) {
1320
+ verify(mockRecorder).resumeRecorders()
1321
+ verify(mockRecorder).stopRecorders()
1322
+ verify(mockRecorder).resumeRecorders()
1323
+ }
1324
+ }
1325
+
1149
1326
// endregion
1150
1327
1151
1328
internal data class SessionRecordingScenario (
0 commit comments