Skip to content

Commit 72c666c

Browse files
committed
✨ setExtendedBugReportMode API for Android
1 parent 08e28a8 commit 72c666c

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import com.facebook.react.modules.core.DeviceEventManagerModule;
2222
import com.instabug.library.Feature;
2323
import com.instabug.library.Instabug;
24+
import com.instabug.library.extendedbugreport.ExtendedBugReport;
2425
import com.instabug.library.internal.module.InstabugLocale;
2526
import com.instabug.library.invocation.InstabugInvocationEvent;
2627
import com.instabug.library.invocation.InstabugInvocationMode;
@@ -87,6 +88,11 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
8788
private final String BOTTOM_RIGHT = "bottomRight";
8889
private final String BOTTOM_LEFT = "bottomLeft";
8990

91+
//Instabug extended bug report modes
92+
private final String EXTENDED_BUG_REPORT_REQUIRED_FIELDS = "enabledWithRequiredFields";
93+
private final String EXTENDED_BUG_REPORT_OPTIONAL_FIELDS = "enabledWithOptionalFields";
94+
private final String EXTENDED_BUG_REPORT_DISABLED = "disabled";
95+
9096
//Theme colors
9197
private final String COLOR_THEME_LIGHT = "light";
9298
private final String COLOR_THEME_DARK = "dark";
@@ -205,6 +211,8 @@ public void invokeWithInvocationMode(String invocationMode) {
205211
}
206212

207213

214+
215+
208216
/**
209217
* Dismisses all visible Instabug views
210218
*/
@@ -279,6 +287,33 @@ public void changeLocale(String instabugLocale) {
279287
}
280288
}
281289

290+
/**
291+
* Sets whether the extended bug report mode should be disabled,
292+
* enabled with required fields, or enabled with optional fields.
293+
*
294+
* @param extendedBugReportMode
295+
*/
296+
@ReactMethod
297+
public void setExtendedBugReportMode(String extendedBugReportMode) {
298+
try {
299+
switch(extendedBugReportMode) {
300+
case EXTENDED_BUG_REPORT_REQUIRED_FIELDS:
301+
Instabug.setExtendedBugReportState(ExtendedBugReport.State.ENABLED_WITH_REQUIRED_FIELDS);
302+
break;
303+
case EXTENDED_BUG_REPORT_OPTIONAL_FIELDS:
304+
Instabug.setExtendedBugReportState(ExtendedBugReport.State.ENABLED_WITH_OPTIONAL_FIELDS);
305+
break;
306+
case EXTENDED_BUG_REPORT_DISABLED:
307+
Instabug.setExtendedBugReportState(ExtendedBugReport.State.DISABLED);
308+
break;
309+
default:
310+
Instabug.setExtendedBugReportState(ExtendedBugReport.State.DISABLED);
311+
}
312+
} catch (Exception e) {
313+
e.printStackTrace();
314+
}
315+
}
316+
282317
@ReactMethod
283318
public void setViewHierarchyEnabled(boolean enabled) {
284319
try {
@@ -1435,6 +1470,10 @@ public Map<String, Object> getConstants() {
14351470
constants.put("bottomRight", BOTTOM_RIGHT);
14361471
constants.put("bottomLeft", BOTTOM_LEFT);
14371472

1473+
constants.put("enabledWithRequiredFields", EXTENDED_BUG_REPORT_REQUIRED_FIELDS);
1474+
constants.put("enabledWithOptionalFields", EXTENDED_BUG_REPORT_OPTIONAL_FIELDS);
1475+
constants.put("disabled", EXTENDED_BUG_REPORT_DISABLED);
1476+
14381477
constants.put("shakeHint", SHAKE_HINT);
14391478
constants.put("swipeHint", SWIPE_HINT);
14401479
constants.put("invalidEmailMessage", INVALID_EMAIL_MESSAGE);

0 commit comments

Comments
 (0)