From 1047530771d4e1f73e1ad63efd5e7fa3307d6afb Mon Sep 17 00:00:00 2001 From: AbdElHamid Nasser Date: Mon, 25 Sep 2023 20:41:25 +0300 Subject: [PATCH] feat: add session replay mode argument to reprosteps api --- .../java/com/instabug/flutter/modules/InstabugApi.java | 7 ++++++- .../test/java/com/instabug/flutter/InstabugApiTest.java | 4 +++- example/ios/InstabugTests/ApmApiTests.m | 6 +++--- example/ios/InstabugTests/InstabugApiTests.m | 4 +++- ios/Classes/Modules/InstabugApi.m | 7 ++++++- lib/src/modules/instabug.dart | 8 +++++++- pigeons/instabug.api.dart | 6 +++++- test/instabug_test.dart | 7 +++++-- 8 files changed, 38 insertions(+), 11 deletions(-) diff --git a/android/src/main/java/com/instabug/flutter/modules/InstabugApi.java b/android/src/main/java/com/instabug/flutter/modules/InstabugApi.java index d10434b22..38e5d5cc5 100644 --- a/android/src/main/java/com/instabug/flutter/modules/InstabugApi.java +++ b/android/src/main/java/com/instabug/flutter/modules/InstabugApi.java @@ -276,7 +276,7 @@ public void run() { } @Override - public void setReproStepsConfig(@Nullable String bugMode, @Nullable String crashMode) { + public void setReproStepsConfig(@Nullable String bugMode, @Nullable String crashMode, @Nullable String sessionReplayMode) { try { final ReproConfigurations.Builder builder = new ReproConfigurations.Builder(); @@ -290,6 +290,11 @@ public void setReproStepsConfig(@Nullable String bugMode, @Nullable String crash builder.setIssueMode(IssueType.Crash, resolvedCrashMode); } + if (sessionReplayMode != null) { + final Integer resolvedSessionReplayMode = ArgsRegistry.reproModes.get(sessionReplayMode); + builder.setIssueMode(IssueType.SessionReplay, resolvedSessionReplayMode); + } + final ReproConfigurations config = builder.build(); Instabug.setReproConfigurations(config); diff --git a/android/src/test/java/com/instabug/flutter/InstabugApiTest.java b/android/src/test/java/com/instabug/flutter/InstabugApiTest.java index 82b92e3c3..5e4e9d27e 100644 --- a/android/src/test/java/com/instabug/flutter/InstabugApiTest.java +++ b/android/src/test/java/com/instabug/flutter/InstabugApiTest.java @@ -379,6 +379,7 @@ public void testGetUserAttributes() { public void testSetReproStepsConfig() { String bug = "ReproStepsMode.enabled"; String crash = "ReproStepsMode.disabled"; + String sessionReplay = "ReproStepsMode.disabled"; ReproConfigurations config = mock(ReproConfigurations.class); MockedConstruction mReproConfigurationsBuilder = mockConstruction(ReproConfigurations.Builder.class, (mock, context) -> { @@ -386,12 +387,13 @@ public void testSetReproStepsConfig() { when(mock.build()).thenReturn(config); }); - api.setReproStepsConfig(bug, crash); + api.setReproStepsConfig(bug, crash, sessionReplay); ReproConfigurations.Builder builder = mReproConfigurationsBuilder.constructed().get(0); verify(builder).setIssueMode(IssueType.Bug, ReproMode.EnableWithScreenshots); verify(builder).setIssueMode(IssueType.Crash, ReproMode.Disable); + verify(builder).setIssueMode(IssueType.SessionReplay, ReproMode.Disable); verify(builder).build(); mInstabug.verify(() -> Instabug.setReproConfigurations(config)); diff --git a/example/ios/InstabugTests/ApmApiTests.m b/example/ios/InstabugTests/ApmApiTests.m index f853295d1..f7d1efd55 100644 --- a/example/ios/InstabugTests/ApmApiTests.m +++ b/example/ios/InstabugTests/ApmApiTests.m @@ -61,11 +61,11 @@ - (void)testStartExecutionTraceWhenTraceNotNil { NSString *name = @"trace-name"; XCTestExpectation *expectation = [self expectationWithDescription:@"Call completion handler"]; - OCMStub([self.mAPM startExecutionTraceWithName:name]).andReturn([IBGExecutionTrace new]); + OCMStub([self.mAPM startExecutionTraceWithName:name]).andReturn([IBGAPM startExecutionTraceWithName:name]); [self.api startExecutionTraceId:expectedId name:name completion:^(NSString *actualId, FlutterError *error) { [expectation fulfill]; - XCTAssertEqual(actualId, expectedId); + XCTAssertEqualObjects(actualId, expectedId); XCTAssertNil(error); }]; @@ -124,7 +124,7 @@ - (void)testStartUITrace { - (void)testEndUITrace { FlutterError *error; - + [self.api endUITraceWithError:&error]; OCMVerify([self.mAPM endUITrace]); diff --git a/example/ios/InstabugTests/InstabugApiTests.m b/example/ios/InstabugTests/InstabugApiTests.m index 2e61a8175..5d916d665 100644 --- a/example/ios/InstabugTests/InstabugApiTests.m +++ b/example/ios/InstabugTests/InstabugApiTests.m @@ -285,12 +285,14 @@ - (void)testGetUserAttributes { - (void)testSetReproStepsConfig { NSString *bugMode = @"ReproStepsMode.enabled"; NSString *crashMode = @"ReproStepsMode.disabled"; + NSString *sessioNReplayMode = @"ReproStepsMode.disabled"; FlutterError *error; - [self.api setReproStepsConfigBugMode:bugMode crashMode:crashMode error:&error]; + [self.api setReproStepsConfigBugMode:bugMode crashMode:crashMode sessionReplayMode:sessioNReplayMode error:&error]; OCMVerify([self.mInstabug setReproStepsFor:IBGIssueTypeBug withMode:IBGUserStepsModeEnable]); OCMVerify([self.mInstabug setReproStepsFor:IBGIssueTypeCrash withMode:IBGUserStepsModeDisable]); + OCMVerify([self.mInstabug setReproStepsFor:IBGIssueTypeSessionReplay withMode:IBGUserStepsModeDisable]); } - (void)testReportScreenChange { diff --git a/ios/Classes/Modules/InstabugApi.m b/ios/Classes/Modules/InstabugApi.m index a9736275a..4c3ae92d8 100644 --- a/ios/Classes/Modules/InstabugApi.m +++ b/ios/Classes/Modules/InstabugApi.m @@ -149,7 +149,7 @@ - (void)getUserAttributesWithCompletion:(nonnull void (^)(NSDictionary setReproStepsConfig({ ReproStepsMode? bug, ReproStepsMode? crash, + ReproStepsMode? sessionReplay, ReproStepsMode? all, }) async { var bugMode = bug; var crashMode = crash; + var sessionReplayMode = sessionReplay; if (all != null) { bugMode = all; crashMode = all; + sessionReplayMode = all; } // There's an issue with crashes repro steps with screenshots in the iOS SDK @@ -389,6 +394,7 @@ class Instabug { return _host.setReproStepsConfig( bugMode.toString(), crashMode.toString(), + sessionReplayMode.toString(), ); } diff --git a/pigeons/instabug.api.dart b/pigeons/instabug.api.dart index 2ed666f2c..e1d0dfc1e 100644 --- a/pigeons/instabug.api.dart +++ b/pigeons/instabug.api.dart @@ -39,7 +39,11 @@ abstract class InstabugHostApi { @async Map? getUserAttributes(); - void setReproStepsConfig(String? bugMode, String? crashMode); + void setReproStepsConfig( + String? bugMode, + String? crashMode, + String? sessionReplayMode, + ); void reportScreenChange(String screenName); void setCustomBrandingImage(String light, String dark); diff --git a/test/instabug_test.dart b/test/instabug_test.dart index ee10d3c2e..19784f0d7 100644 --- a/test/instabug_test.dart +++ b/test/instabug_test.dart @@ -276,16 +276,19 @@ void main() { test('[setReproStepsConfig] should call host method', () async { const bug = ReproStepsMode.enabled; const crash = ReproStepsMode.enabledWithNoScreenshots; + const sessionReplay = ReproStepsMode.disabled; when(mBuildInfo.isIOS).thenReturn(false); await Instabug.setReproStepsConfig( bug: bug, crash: crash, + sessionReplay: sessionReplay, ); verify( - mHost.setReproStepsConfig(bug.toString(), crash.toString()), + mHost.setReproStepsConfig( + bug.toString(), crash.toString(), sessionReplay.toString()), ).called(1); }); @@ -297,7 +300,7 @@ void main() { await Instabug.setReproStepsConfig(all: all); verify( - mHost.setReproStepsConfig(all.toString(), all.toString()), + mHost.setReproStepsConfig(all.toString(), all.toString(), all.toString()), ).called(1); });