From 4a20f6c17bf94df022646b772adbd91d67d494d1 Mon Sep 17 00:00:00 2001 From: DevHossamHassan Date: Thu, 11 May 2017 17:10:32 +0200 Subject: [PATCH 01/10] Remove names attribute from setReportCategories API --- index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/index.js b/index.js index 3cc2050..f5f268c 100644 --- a/index.js +++ b/index.js @@ -519,7 +519,6 @@ module.exports = { * Use this method to give users a list of choices of categories their bug report or feedback might be related * to. Selected category will be shown as a tag on your dashboard. * @param {array} titles titles to be shown in the list. - * @param {array} name names of icons to be shown along with titles. Use the same names you would use */ setReportCategories: function (titles) { if (Platform.OS == 'ios') { From c64c217dfae8b7b2f37b7eef7f37d8eadf1638c7 Mon Sep 17 00:00:00 2001 From: DevHossamHassan Date: Thu, 11 May 2017 18:48:08 +0200 Subject: [PATCH 02/10] Add ReportCategories API --- .../RNInstabugReactnativeModule.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 5bab973..b0fc252 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -8,11 +8,13 @@ import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactMethod; import com.facebook.react.bridge.ReadableArray; import com.facebook.react.bridge.ReadableMap; + import com.instabug.library.Instabug; import com.instabug.library.internal.module.InstabugLocale; import com.instabug.library.invocation.InstabugInvocationEvent; import com.instabug.library.invocation.InstabugInvocationMode; import com.instabug.library.logging.InstabugLog; +import com.instabug.library.bugreporting.model.ReportCategory; import java.util.ArrayList; import java.util.HashMap; @@ -617,6 +619,20 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { } } + public void setReportCategories(String... categoriesTitles) { + try { + ArrayList bugCategories = new ArrayList<>(); + + for (String category : categoriesTitles) { + bugCategories.add(ReportCategory.getInstance().withLabel(category); + } + + Instabug.setReportCategories(bugCategories); + } catch (Exception e) { + e.printStackTrace(); + } + } + private Locale getLocaleByKey(String instabugLocale) { String localeInLowerCase = instabugLocale.toLowerCase(); switch (localeInLowerCase) { From 87dcd8f35e61d7150c382cbcf096ccaf8c7e7c97 Mon Sep 17 00:00:00 2001 From: DevHossamHassan Date: Thu, 11 May 2017 18:51:23 +0200 Subject: [PATCH 03/10] Truncate code lines that exceeded 80 character --- .../RNInstabugReactnativeModule.java | 75 ++++++++++++------- 1 file changed, 50 insertions(+), 25 deletions(-) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index b0fc252..ebe8d26 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -66,7 +66,8 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { * @param reactContext the react context * @param mInstabug the m instabug */ - public RNInstabugReactnativeModule(ReactApplicationContext reactContext, Application androidApplication) { + public RNInstabugReactnativeModule(ReactApplicationContext reactContext, Application + androidApplication) { super(reactContext); this.androidApplication = androidApplication; } @@ -168,7 +169,8 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { } /** - * The file at filePath will be uploaded along upcoming reports with the name fileNameWithExtension + * The file at filePath will be uploaded along upcoming reports with the name + * fileNameWithExtension * * @param fileUri the file uri * @param fileNameWithExtension the file name with extension @@ -244,7 +246,8 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { * Set the primary color that the SDK will use to tint certain UI elements in the SDK * * @param primaryColorValue The value of the primary color , - * whatever this color was parsed from a resource color or hex color or RGB color values + * whatever this color was parsed from a resource color or hex color + * or RGB color values */ @ReactMethod public void setPrimaryColor(int primaryColor) { @@ -265,9 +268,11 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { * @param {boolean} screenRecording A boolean to enable or disable screen recording attachments. */ @ReactMethod - public void setAttachmentTypesEnabled(boolean screenshot, boolean extraScreenshot, boolean galleryImage, boolean voiceNote, boolean screenRecording) { + public void setAttachmentTypesEnabled(boolean screenshot, boolean extraScreenshot, boolean + galleryImage, boolean voiceNote, boolean screenRecording) { try { - mInstabug.setAttachmentTypesEnabled(screenshot, extraScreenshot, galleryImage, voiceNote, screenRecording); + mInstabug.setAttachmentTypesEnabled(screenshot, extraScreenshot, galleryImage, + voiceNote, screenRecording); } catch (Exception e) { e.printStackTrace(); } @@ -276,8 +281,10 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { /** * Appends a log message to Instabug internal log *

- * These logs are then sent along the next uploaded report. All log messages are timestamped
- * Logs aren't cleared per single application run. If you wish to reset the logs, use {@link #clearLog()} + * These logs are then sent along the next uploaded report. All log messages are timestamped + *
+ * Logs aren't cleared per single application run. If you wish to reset the logs, use + * {@link #clearLog()} *

* Note: logs passed to this method are NOT printed to Logcat * @@ -480,7 +487,8 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { String fileName = frame.getString("file"); int lineNumber = frame.getInt("lineNumber"); - stackTraceElements[i] = new StackTraceElement(fileName, methodName, fileName, lineNumber); + stackTraceElements[i] = new StackTraceElement(fileName, methodName, fileName, + lineNumber); } Throwable throwable = new Throwable(message); throwable.setStackTrace(stackTraceElements); @@ -637,39 +645,56 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { String localeInLowerCase = instabugLocale.toLowerCase(); switch (localeInLowerCase) { case LOCALE_ARABIC: - return new Locale(InstabugLocale.ARABIC.getCode(), InstabugLocale.ARABIC.getCountry()); + return new Locale(InstabugLocale.ARABIC.getCode(), InstabugLocale.ARABIC + .getCountry()); case LOCALE_ENGLISH: - return new Locale(InstabugLocale.ENGLISH.getCode(), InstabugLocale.ENGLISH.getCountry()); + return new Locale(InstabugLocale.ENGLISH.getCode(), InstabugLocale.ENGLISH + .getCountry()); case LOCALE_CZECH: - return new Locale(InstabugLocale.CZECH.getCode(), InstabugLocale.CZECH.getCountry()); + return new Locale(InstabugLocale.CZECH.getCode(), InstabugLocale.CZECH.getCountry + ()); case LOCALE_FRENCH: - return new Locale(InstabugLocale.FRENCH.getCode(), InstabugLocale.FRENCH.getCountry()); + return new Locale(InstabugLocale.FRENCH.getCode(), InstabugLocale.FRENCH + .getCountry()); case LOCALE_GERMAN: - return new Locale(InstabugLocale.GERMAN.getCode(), InstabugLocale.GERMAN.getCountry()); + return new Locale(InstabugLocale.GERMAN.getCode(), InstabugLocale.GERMAN + .getCountry()); case LOCALE_ITALIAN: - return new Locale(InstabugLocale.ITALIAN.getCode(), InstabugLocale.ITALIAN.getCountry()); + return new Locale(InstabugLocale.ITALIAN.getCode(), InstabugLocale.ITALIAN + .getCountry()); case LOCALE_JAPANESE: - return new Locale(InstabugLocale.JAPANESE.getCode(), InstabugLocale.JAPANESE.getCountry()); + return new Locale(InstabugLocale.JAPANESE.getCode(), InstabugLocale.JAPANESE + .getCountry()); case LOCALE_POLISH: - return new Locale(InstabugLocale.POLISH.getCode(), InstabugLocale.POLISH.getCountry()); + return new Locale(InstabugLocale.POLISH.getCode(), InstabugLocale.POLISH + .getCountry()); case LOCALE_RUSSIAN: - return new Locale(InstabugLocale.RUSSIAN.getCode(), InstabugLocale.RUSSIAN.getCountry()); + return new Locale(InstabugLocale.RUSSIAN.getCode(), InstabugLocale.RUSSIAN + .getCountry()); case LOCALE_SPANISH: - return new Locale(InstabugLocale.SPANISH.getCode(), InstabugLocale.SPANISH.getCountry()); + return new Locale(InstabugLocale.SPANISH.getCode(), InstabugLocale.SPANISH + .getCountry()); case LOCALE_SWEDISH: - return new Locale(InstabugLocale.SWEDISH.getCode(), InstabugLocale.SWEDISH.getCountry()); + return new Locale(InstabugLocale.SWEDISH.getCode(), InstabugLocale.SWEDISH + .getCountry()); case LOCALE_TURKISH: - return new Locale(InstabugLocale.TURKISH.getCode(), InstabugLocale.TURKISH.getCountry()); + return new Locale(InstabugLocale.TURKISH.getCode(), InstabugLocale.TURKISH + .getCountry()); case LOCALE_PORTUGUESE_BRAZIL: - return new Locale(InstabugLocale.PORTUGUESE_BRAZIL.getCode(), InstabugLocale.PORTUGUESE_BRAZIL.getCountry()); + return new Locale(InstabugLocale.PORTUGUESE_BRAZIL.getCode(), InstabugLocale + .PORTUGUESE_BRAZIL.getCountry()); case LOCALE_CHINESE_SIMPLIFIED: - return new Locale(InstabugLocale.SIMPLIFIED_CHINESE.getCode(), InstabugLocale.SIMPLIFIED_CHINESE.getCountry()); + return new Locale(InstabugLocale.SIMPLIFIED_CHINESE.getCode(), InstabugLocale + .SIMPLIFIED_CHINESE.getCountry()); case LOCALE_CHINESE_TRADITIONAL: - return new Locale(InstabugLocale.TRADITIONAL_CHINESE.getCode(), InstabugLocale.TRADITIONAL_CHINESE.getCountry()); + return new Locale(InstabugLocale.TRADITIONAL_CHINESE.getCode(), InstabugLocale + .TRADITIONAL_CHINESE.getCountry()); case LOCALE_KOREAN: - return new Locale(InstabugLocale.KOREAN.getCode(), InstabugLocale.KOREAN.getCountry()); + return new Locale(InstabugLocale.KOREAN.getCode(), InstabugLocale.KOREAN + .getCountry()); default: - return new Locale(InstabugLocale.ENGLISH.getCode(), InstabugLocale.ENGLISH.getCountry()); + return new Locale(InstabugLocale.ENGLISH.getCode(), InstabugLocale.ENGLISH + .getCountry()); } } From 9d8d6df7b59aaa482553125e968ee658b25c4f10 Mon Sep 17 00:00:00 2001 From: DevHossamHassan Date: Thu, 11 May 2017 18:57:14 +0200 Subject: [PATCH 04/10] Remove redundant docs --- index.js | 35 ----------------------------------- 1 file changed, 35 deletions(-) diff --git a/index.js b/index.js index f5f268c..43d21c4 100644 --- a/index.js +++ b/index.js @@ -94,11 +94,6 @@ module.exports = { Instabug.setUserStepsEnabled(isUserStepsEnabled); }, - /** - * A callback that gets executed before sending each bug report. - * @callback preSendingHandler - */ - /** * Sets a block of code to be executed before sending each report. * This block is executed in the background before sending each report. Could @@ -118,13 +113,6 @@ module.exports = { } }, - /** - * Sets a block of code to be executed just before the SDK's UI is presented. - * This block is executed on the UI thread. Could be used for performing any - * UI changes before the SDK's UI is shown. - * @callback preSendingHandler - */ - /** * Sets a block of code to be executed just before the SDK's UI is presented. * This block is executed on the UI thread. Could be used for performing any @@ -408,11 +396,6 @@ module.exports = { Instabug.setChatNotificationEnabled(isChatNotificationEnabled); }, - /** - * A callback that gets executed when a new message is received. - * @callback onNewMessgaeHandler - */ - /** * Sets a block of code that gets executed when a new message is received. * @param {onNewMessgaeHandler} onNewMessageHandler - A callback that gets @@ -447,12 +430,6 @@ module.exports = { Instabug.setPromptOptions(isBugReportingEnabled, isFeedbackReportingEnabled, isChatEnabled); }, - /** - * return callback - * @callback isInstabugNotificationCallback - * @param {boolean} isInstabugNotification - */ - /** * Checks if a notification is from Instabug. * If you are using push notifications, use this method to check whether an @@ -713,12 +690,6 @@ module.exports = { } }, - /** - * return callback - * @callback userAttributeCallback - * @param {string} value for key in user attributes. - */ - /** * Returns the user attribute associated with a given key. aKey @@ -745,12 +716,6 @@ module.exports = { } }, - /** - * return callback - * @callback userAttributesCallback - * @param{Object} userAttributes Dictionary of the user attributes. - */ - /** * @summary Returns all user attributes. * @param {userAttributesCallback} userAttributesCallback callback with argument A new dictionary containing all the currently set user attributes, From f78b91c9f3fcbef11470cbad320272caf10e9f43 Mon Sep 17 00:00:00 2001 From: DevHossamHassan Date: Thu, 11 May 2017 19:00:18 +0200 Subject: [PATCH 05/10] Add ReportCategories API to index.js --- index.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/index.js b/index.js index 43d21c4..2e0e266 100644 --- a/index.js +++ b/index.js @@ -500,6 +500,8 @@ module.exports = { setReportCategories: function (titles) { if (Platform.OS == 'ios') { Instabug.setReportCategories(titles, null); + }else if(Platform.OS == 'android') { + Instabug.setReportCategories(titles); } }, From f1d3267aabf64c40a91b0866ef7267ae3d268a2e Mon Sep 17 00:00:00 2001 From: DevHossamHassan Date: Thu, 11 May 2017 19:03:15 +0200 Subject: [PATCH 06/10] Adjust spaces in index.js --- index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index 2e0e266..810410e 100644 --- a/index.js +++ b/index.js @@ -1,4 +1,4 @@ -import {NativeModules, NativeAppEventEmitter, Platform} from 'react-native'; +import {NativeModules, NativeAppEventEmitter, Platform} from "react-native"; let {Instabug} = NativeModules; /** @@ -18,7 +18,7 @@ module.exports = { * the SDK's UI. */ startWithToken: function (token, invocationEvent) { - Instabug.startWithToken(token, invocationEvent); + Instabug.startWithToken(token, invocationEvent); }, /** @@ -500,7 +500,7 @@ module.exports = { setReportCategories: function (titles) { if (Platform.OS == 'ios') { Instabug.setReportCategories(titles, null); - }else if(Platform.OS == 'android') { + } else if (Platform.OS == 'android') { Instabug.setReportCategories(titles); } }, From 9a693900cb5f651ec98ce0af82f74ea3ca8c36d3 Mon Sep 17 00:00:00 2001 From: DevHossamHassan Date: Thu, 11 May 2017 20:05:32 +0200 Subject: [PATCH 07/10] Add missing close braces --- .../com/instabug/reactlibrary/RNInstabugReactnativeModule.java | 2 +- .../com/instabug/reactlibrary/RNInstabugReactnativePackage.java | 2 +- 2 files changed, 2 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 ebe8d26..8001f6e 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -632,7 +632,7 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { ArrayList bugCategories = new ArrayList<>(); for (String category : categoriesTitles) { - bugCategories.add(ReportCategory.getInstance().withLabel(category); + bugCategories.add(ReportCategory.getInstance().withLabel(category)); } Instabug.setReportCategories(bugCategories); diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java index 15600e5..57c54f5 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativePackage.java @@ -34,7 +34,7 @@ public class RNInstabugReactnativePackage implements ReactPackage { } @Deprecated - public RNInstabugReactnativePackage(String androidApplicationToken, Application application + public RNInstabugReactnativePackage(String androidApplicationToken, Application application, String invocationEventValue) { this(androidApplicationToken, application, invocationEventValue, "light"); } From 7604cbae0e3cfbf4eb04d8b0dc215aa224bd0acd Mon Sep 17 00:00:00 2001 From: DevHossamHassan Date: Thu, 11 May 2017 20:10:37 +0200 Subject: [PATCH 08/10] Fix typo in setUsername method --- .../com/instabug/reactlibrary/RNInstabugReactnativeModule.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 8001f6e..1bf7d0e 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -208,7 +208,7 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { @ReactMethod public void setUserName(String username) { try { - mInstabug.setUserName(username); + mInstabug.setUsername(username); } catch (Exception e) { e.printStackTrace(); } From 135b6219f0817c182b75ef6e19d41a7b7354ee09 Mon Sep 17 00:00:00 2001 From: DevHossamHassan Date: Thu, 11 May 2017 20:22:04 +0200 Subject: [PATCH 09/10] Add @ReactMethod annotation and docs to ReportCategoriesAPI --- .../reactlibrary/RNInstabugReactnativeModule.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index 1bf7d0e..cc01bfa 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -627,6 +627,15 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { } } + /** + * Allows you to show a predefined set of categories for users to choose + * from when reporting a bug or sending feedback. Selected category + * shows up on your Instabug dashboard as a tag to make filtering + * through issues easier. + * + * @param reportCategories the report categories list which is a list of ReportCategory model + */ + @ReactMethod public void setReportCategories(String... categoriesTitles) { try { ArrayList bugCategories = new ArrayList<>(); From 36e99be64c254133ab05b82f998f14105b00d853 Mon Sep 17 00:00:00 2001 From: DevHossamHassan Date: Mon, 15 May 2017 04:16:45 +0200 Subject: [PATCH 10/10] Update setReportCategories API params To accept one or more category as an array --- .../reactlibrary/RNInstabugReactnativeModule.java | 9 +++++---- index.js | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java index cc01bfa..35ecf5c 100644 --- a/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java +++ b/android/src/main/java/com/instabug/reactlibrary/RNInstabugReactnativeModule.java @@ -636,12 +636,13 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule { * @param reportCategories the report categories list which is a list of ReportCategory model */ @ReactMethod - public void setReportCategories(String... categoriesTitles) { + public void setReportCategories(ReadableArray categoriesTitles) { try { ArrayList bugCategories = new ArrayList<>(); - - for (String category : categoriesTitles) { - bugCategories.add(ReportCategory.getInstance().withLabel(category)); + int size = categoriesTitles != null ? categoriesTitles.size() : 0; + if (size == 0) return; + for (int i = 0; i < size; i++) { + bugCategories.add(ReportCategory.getInstance().withLabel(categoriesTitles.getString(i))); } Instabug.setReportCategories(bugCategories); diff --git a/index.js b/index.js index 810410e..f763a7e 100644 --- a/index.js +++ b/index.js @@ -497,7 +497,7 @@ module.exports = { * to. Selected category will be shown as a tag on your dashboard. * @param {array} titles titles to be shown in the list. */ - setReportCategories: function (titles) { + setReportCategories: function (... titles) { if (Platform.OS == 'ios') { Instabug.setReportCategories(titles, null); } else if (Platform.OS == 'android') {