From 68f4ec41cc7e887e2c2be0dd2714e6f16737e6b1 Mon Sep 17 00:00:00 2001 From: Salma ElTarzi Date: Mon, 5 Mar 2018 15:54:48 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20setReproStepsMode=20API=20for=20And?= =?UTF-8?q?roid=20and=20iOS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../RNInstabugReactnativeModule.java | 38 +++++++++++++++++++ index.js | 10 +++++ ios/RNInstabug/InstabugReactBridge.m | 4 +- 3 files changed, 50 insertions(+), 2 deletions(-) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 862d48d..08576a2 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -33,6 +33,7 @@ import com.instabug.library.InstabugCustomTextPlaceHolder; import com.instabug.library.user.UserEventParam; import com.instabug.library.OnSdkDismissedCallback; import com.instabug.library.bugreporting.model.Bug; +import com.instabug.library.visualusersteps.State; import com.instabug.survey.InstabugSurvey; import com.instabug.reactlibrary.utils.ArrayUtil; @@ -93,6 +94,11 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { private final String EXTENDED_BUG_REPORT_OPTIONAL_FIELDS = "enabledWithOptionalFields"; private final String EXTENDED_BUG_REPORT_DISABLED = "disabled"; + //Instabug repro step modes + private final String ENABLED_WITH_NO_SCREENSHOT = "enabledWithNoScreenshot"; + private final String ENABLED = "enabled"; + private final String DISABLED = "disabled"; + //Theme colors private final String COLOR_THEME_LIGHT = "light"; private final String COLOR_THEME_DARK = "dark"; @@ -1226,6 +1232,34 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { } } + /** + * Sets whether user steps tracking is visual, non visula or disabled. + * + * @param reproStepsMode A string to set user steps tracking to be + * enabled, non visual or disabled. + */ + @ReactMethod + public void setReproStepsMode(String reproStepsMode) { + try { + switch(reproStepsMode) { + case ENABLED_WITH_NO_SCREENSHOT: + Instabug.setReproStepsState(State.ENABLED_WITH_NO_SCREENSHOTS); + break; + case ENABLED: + Instabug.setReproStepsState(State.ENABLED); + break; + case DISABLED: + Instabug.setReproStepsState(State.DISABLED); + break; + default: + Instabug.setReproStepsState(State.ENABLED); + } + + } catch (Exception e) { + e.printStackTrace(); + } + } + /** * Sets the threshold value of the shake gesture for android devices. * Default for android is an integer value equals 350. @@ -1474,6 +1508,10 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { constants.put("enabledWithOptionalFields", EXTENDED_BUG_REPORT_OPTIONAL_FIELDS); constants.put("disabled", EXTENDED_BUG_REPORT_DISABLED); + constants.put("reproStepsEnabledWithNoScreenshot", ENABLED_WITH_NO_SCREENSHOT); + constants.put("reproStepsEnabled", ENABLED); + constants.put("reproStepsDisabled", DISABLED); + constants.put("shakeHint", SHAKE_HINT); constants.put("swipeHint", SWIPE_HINT); constants.put("invalidEmailMessage", INVALID_EMAIL_MESSAGE); diff --git a/index.js b/index.js index 48475f1..e435a5b 100644 --- a/index.js +++ b/index.js @@ -670,6 +670,16 @@ module.exports = { } }, + /** + * Sets whether user steps tracking is visual, non visula or disabled. + * + * @param {reproStepsMode} reproStepsMode An enum to set user steps tracking to be + * enabled, non visual or disabled. + */ + setReproStepsMode: function (reproStepsMode) { + Instabug.setReproStepsMode(reproStepsMode); + }, + /** * Sets user attribute to overwrite it's value or create a new one if it doesn't exist. * diff --git a/ios/RNInstabug/InstabugReactBridge.m b/ios/RNInstabug/InstabugReactBridge.m index 7bcb30a..e6a5d1d 100644 --- a/ios/RNInstabug/InstabugReactBridge.m +++ b/ios/RNInstabug/InstabugReactBridge.m @@ -405,8 +405,8 @@ RCT_EXPORT_METHOD(isRunningLive:(RCTResponseSenderBlock)callback) { @"dismissTypeAddAtttachment": @(IBGDismissTypeAddAttachment), @"reproStepsEnabled": @(IBGUserStepsModeEnable), - @"reproStepsDisabled": @(IBGUserStepsModeEnabledWithNoScreenshots), - @"reproStepsEnabledWithNoScreenshot": @(IBGUserStepsModeDisable), + @"reproStepsDisabled": @(IBGUserStepsModeDisable), + @"reproStepsEnabledWithNoScreenshot": @(IBGUserStepsModeEnabledWithNoScreenshots), @"reportTypeBug": @(IBGReportTypeBug), @"reportTypeFeedback": @(IBGReportTypeFeedback),