diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 9c901cb7a5..b636eb9400 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -1274,4 +1274,21 @@ public Map getConstants() { return constants; } + /** + * Enables or disables user steps tracking. + * @param isEnabled A boolean to enable/disable Instabug. + */ + @ReactMethod + public void setTrackUserSteps(final boolean isEnabled) { + MainThreadHandler.runOnMainThread(new Runnable() { + @Override + public void run() { + try { + Instabug.setTrackingUserStepsState(isEnabled ? Feature.State.ENABLED : Feature.State.DISABLED); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } } diff --git a/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java b/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java index e8aad5b0c5..f61a062fba 100644 --- a/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java +++ b/android/src/test/java/com/instabug/reactlibrary/RNInstabugReactnativeModuleTest.java @@ -662,4 +662,18 @@ public void testW3CCaughtHeaderFlag(){ boolean expected=internalAPM._isFeatureEnabled(CoreFeature.W3C_ATTACHING_CAPTURED_HEADER); verify(promise).resolve(expected); } + @Test + public void TestEnablingSetTrackerUserSteps() { + rnModule.setTrackUserSteps(true); + verify(Instabug.class, times(1)); + Instabug.setTrackingUserStepsState(Feature.State.ENABLED); + } + + @Test + public void TestDesablingSetTrackerUserSteps() { + + rnModule.setTrackUserSteps(false); + verify(Instabug.class, times(1)); + Instabug.setTrackingUserStepsState(Feature.State.DISABLED); + } } diff --git a/src/modules/Instabug.ts b/src/modules/Instabug.ts index 91f6c5c127..4cdba2713f 100644 --- a/src/modules/Instabug.ts +++ b/src/modules/Instabug.ts @@ -132,9 +132,7 @@ export const setUserData = (data: string) => { * @param isEnabled A boolean to set user steps tracking to being enabled or disabled. */ export const setTrackUserSteps = (isEnabled: boolean) => { - if (Platform.OS === 'ios') { - NativeInstabug.setTrackUserSteps(isEnabled); - } + NativeInstabug.setTrackUserSteps(isEnabled); }; /** diff --git a/test/modules/Instabug.spec.ts b/test/modules/Instabug.spec.ts index d1bca25c90..909eb797e5 100644 --- a/test/modules/Instabug.spec.ts +++ b/test/modules/Instabug.spec.ts @@ -375,20 +375,12 @@ describe('Instabug Module', () => { }); it('should call the native method setTrackUserSteps', () => { - Platform.OS = 'ios'; Instabug.setTrackUserSteps(true); expect(NativeInstabug.setTrackUserSteps).toBeCalledTimes(1); expect(NativeInstabug.setTrackUserSteps).toBeCalledWith(true); }); - it('should not call the native method setTrackUserSteps when platform is android', () => { - Platform.OS = 'android'; - Instabug.setTrackUserSteps(true); - - expect(NativeInstabug.setTrackUserSteps).not.toBeCalled(); - }); - it('should call the native method setIBGLogPrintsToConsole', () => { Platform.OS = 'ios'; Instabug.setIBGLogPrintsToConsole(true);