Skip to content

Commit

Permalink
🤝 Merge pull request #107 from Instabug/refactoring
Browse files Browse the repository at this point in the history
📝 Adjusted code styles
  • Loading branch information
salmatarzi authored Feb 4, 2018
2 parents ea8d3e2 + b2ec43f commit 81f119d
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 57 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ public class RNInstabugReactnativeModule extends ReactContextBaseJavaModule {
private final String ADD_EXTRA_SCREENSHOT = "addExtraScreenshot";
private final String ADD_VIDEO = "addVideoMessage";

private final String AUDIO_RECORDING_PERMISSION_DENIED =
"audioRecordingPermissionDeniedMessage";
private final String AUDIO_RECORDING_PERMISSION_DENIED = "audioRecordingPermissionDeniedMessage";

private final String VOICE_MESSAGE_PRESS_AND_HOLD_TO_RECORD = "recordingMessageToHoldText";
private final String VOICE_MESSAGE_RELEASE_TO_ATTACH = "recordingMessageToReleaseText";
Expand Down Expand Up @@ -237,7 +236,7 @@ public void appendTags(ReadableArray tags) {
/**
* Change Locale of Instabug UI elements(defaults to English)
*
* @param String instabugLocale
* @param instabugLocale
*/
@ReactMethod
public void changeLocale(String instabugLocale) {
Expand Down Expand Up @@ -353,7 +352,7 @@ public void showIntroMessage() {
/**
* 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 ,
* @param primaryColor The value of the primary color ,
* whatever this color was parsed from a resource color or hex color
* or RGB color values
*/
Expand Down Expand Up @@ -387,12 +386,8 @@ public void setEnabledAttachmentTypes(boolean screenshot, boolean extraScreensho

/**
* Appends a log message to Instabug internal log
* <p>
* These logs are then sent along the next uploaded report. All log messages are timestamped
* <br/>
* Logs aren't cleared per single application run. If you wish to reset the logs, use
* {@link #clearLog()}
* </p>
* Note: logs passed to this method are <b>NOT</b> printed to Logcat
*
* @param message log message
Expand All @@ -409,7 +404,7 @@ public void IBGLog(String message) {
/**
* Gets tags.
*
* @return all tags added using {@link #addTags(String...)}
* @return all tags added
* @see #resetTags()
*/
@ReactMethod
Expand All @@ -432,8 +427,8 @@ public void getTags(Callback tagsCallback) {
* Set the user identity.
* Instabug will pre-fill the user email in reports.
*
* @param username Username.
* @param email User's default email
* @param userName Username.
* @param userEmail User's default email
*/
@ReactMethod
public void identifyUser(String userName, String userEmail) {
Expand All @@ -445,7 +440,7 @@ public void identifyUser(String userName, String userEmail) {
}

/**
* Reset ALL tags added using {@link #addTags(String...)}
* Reset ALL tags added
*/
@ReactMethod
public void resetTags() {
Expand Down Expand Up @@ -601,7 +596,9 @@ public void setDebugEnabled(boolean isDebugEnabled) {
/**
* Report a caught exception to Instabug dashboard
*
* @param throwable the exception to be reported
* @param stack the exception to be reported
* @param message the message of the exception to be reported
* @param errorIdentifier used to group issues manually reported
*/
@ReactMethod
public void reportJsException(ReadableArray stack, String message, String errorIdentifier) {
Expand Down Expand Up @@ -640,7 +637,6 @@ public void reportJsException(ReadableArray stack, String message, String errorI
* </p>
* Note: logs passed to this method are <b>NOT</b> printed to Logcat
*
* @param logMessage The message you would like logged
* @param level the level
* @param message the message
*/
Expand Down Expand Up @@ -825,7 +821,7 @@ public void setColorTheme(String theme) {
* 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
* @param categoriesTitles the report categories list which is a list of ReportCategory model
*/
@ReactMethod
public void setReportCategories(ReadableArray categoriesTitles) {
Expand All @@ -849,7 +845,7 @@ public void setReportCategories(ReadableArray categoriesTitles) {
* sending reports.
* Defaults to YES.
*
* @param {boolean} isEmailFieldRequired A boolean to indicate whether email
* @param isEmailFieldRequired A boolean to indicate whether email
* field is required or not.
*/
@ReactMethod
Expand All @@ -865,7 +861,7 @@ public void setEmailFieldRequired(boolean isEmailFieldRequired) {
* Sets whether users are required to enter a comment or not when sending reports.
* Defaults to NO.
*
* @param {boolean} isCommentFieldRequired A boolean to indicate whether comment
* @param isCommentFieldRequired A boolean to indicate whether comment
* field is required or not.
*/
@ReactMethod
Expand All @@ -881,8 +877,8 @@ public void setCommentFieldRequired(boolean isCommentFieldRequired) {
* Overrides any of the strings shown in the SDK with custom ones.
* Allows you to customize any of the strings shown to users in the SDK.
*
* @param {string} string String value to override the default one.
* @param {strings} key Key of string to override.
* @param string String value to override the default one.
* @param key Key of string to override.
*/
@ReactMethod
public void setString(String string, String key) {
Expand Down Expand Up @@ -914,7 +910,7 @@ public void logOut() {
* By default, screenshot view is shown when reporting a bug, but not when
* sending feedback.
*
* @param {boolean} willSkipScreenshotAnnotation sets whether screenshot view is
* @param willSkipScreenshotAnnotation sets whether screenshot view is
* shown or not. Passing YES will show screenshot view for both feedback and
* bug reporting, while passing NO will disable it for both.
*/
Expand All @@ -931,7 +927,7 @@ public void setWillSkipScreenshotAnnotation(boolean willSkipScreenshotAnnotation
* Logs a user event that happens through the lifecycle of the application.
* Logged user events are going to be sent with each report, as well as at the end of a session.
*
* @param {string} name Event name.
* @param name Event name.
*/
@ReactMethod
public void logUserEventWithName(String name) {
Expand All @@ -947,8 +943,8 @@ public void logUserEventWithName(String name) {
* Logged user events are going to be sent with each report, as well as at the end of a
* session.
*
* @param {string} name Event name.
* @param {ReadableMap} params An optional ReadableMap to be associated with the event.
* @param name Event name.
* @param params An optional ReadableMap to be associated with the event.
*/
@ReactMethod
public void logUserEventWithNameAndParams(String name, ReadableMap params) {
Expand All @@ -975,7 +971,7 @@ public void logUserEventWithNameAndParams(String name, ReadableMap params) {
* This block is executed on the UI thread. Could be used for performing any
* UI changes before the SDK's UI is shown.
*
* @param {preInvocationHandler} preInvocationHandler - A callback that gets executed before
* @param preInvocationHandler - A callback that gets executed before
* invoking the SDK
*/
@ReactMethod
Expand All @@ -998,7 +994,7 @@ public void run() {
* This block is executed in the background before sending each report. Could
* be used for attaching logs and extra data to reports.
*
* @param {preSendingHandler} preSendingHandler - A callback that gets executed before
* @param preSendingHandler - A callback that gets executed before
* sending each bug
* report.
*/
Expand All @@ -1022,7 +1018,7 @@ public void run() {
* This block is executed on the UI thread. Could be used for performing any
* UI changes after the SDK's UI is dismissed.
*
* @param {postInvocationHandler} postInvocationHandler - A callback to get executed after
* @param postInvocationHandler - A callback to get executed after
* dismissing the SDK.
*/
@ReactMethod
Expand All @@ -1047,7 +1043,7 @@ public void onSdkDismissed(DismissType issueState, Bug.Type bugType) {
/**
* Show any valid survey if exist
*
* @return return true if a valid survey was shown otherwise false
* @return true if a valid survey was shown otherwise false
*/
@ReactMethod
public void showSurveysIfAvailable() {
Expand All @@ -1061,7 +1057,7 @@ public void showSurveysIfAvailable() {
/**
* Show any valid survey if exist
*
* @return return true if a valid survey was shown otherwise false
* @return true if a valid survey was shown otherwise false
*/
@ReactMethod
public void setSurveysEnabled(boolean surveysEnabled) {
Expand Down Expand Up @@ -1091,7 +1087,7 @@ public void setIntroMessageEnabled(boolean enabled) {
* WARNING: This runs on your application's main UI thread. Please do not include
* any blocking operations to avoid ANRs.
*
* @param preShowingSurveyRunnable to run on the UI thread before showing any valid survey
* @param willShowSurveyHandler to run on the UI thread before showing any valid survey
*/
@ReactMethod
public void setWillShowSurveyHandler(final Callback willShowSurveyHandler) {
Expand All @@ -1113,7 +1109,7 @@ public void run() {
* WARNING: This runs on your application's main UI thread. Please do not include
* any blocking operations to avoid ANRs.
*
* @param afterShowingSurveyRunnable to run on the UI thread after showing any valid survey
* @param didDismissSurveyHandler to run on the UI thread after showing any valid survey
*/
@ReactMethod
public void setDidDismissSurveyHandler(final Callback didDismissSurveyHandler) {
Expand All @@ -1137,9 +1133,9 @@ public void run() {
* none is enabled, Bug
* reporting becomes the default invocation option.
*
* @param {boolean} chat weather Talk to us is enable or not
* @param {boolean} bug weather Report a Problem is enable or not
* @param {boolean} feedback weather General Feedback is enable or not
* @param chat weather Talk to us is enable or not
* @param bug weather Report a Problem is enable or not
* @param feedback weather General Feedback is enable or not
*/
@ReactMethod
public void setPromptOptionsEnabled(boolean chat, boolean bug, boolean feedback) {
Expand Down Expand Up @@ -1169,7 +1165,7 @@ public void clearFileAttachment() {
* you could increase the shaking difficulty level by
* increasing the `350` value and vice versa.
*
* @param {number} androidThreshold Threshold for android devices.
* @param androidThreshold Threshold for android devices.
*/
@ReactMethod
public void setShakingThresholdForAndroid(int androidThreshold) {
Expand All @@ -1183,7 +1179,7 @@ public void setShakingThresholdForAndroid(int androidThreshold) {
/**
* Sets a block of code that gets executed when a new message is received.
*
* @param {onNewMessageHandler} onNewMessageHandler - A callback that gets
* @param onNewMessageHandler - A callback that gets
* executed when a new message is received.
*/
@ReactMethod
Expand Down
53 changes: 31 additions & 22 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ module.exports = {
* voiceNote attachments.
* @param {boolean} screenRecording A boolean to enable or disable screen recording attachments.
*/

setAttachmentTypesEnabled: function (screenshot, extraScreenshot, galleryImage, voiceNote, screenRecording) {
Instabug.setEnabledAttachmentTypes(screenshot, extraScreenshot, galleryImage, screenRecording);
},
Expand Down Expand Up @@ -471,7 +472,8 @@ module.exports = {
/**
* Sets the default value of the user's email and hides the email field from the reporting UI
* and set the user's name to be included with all reports.
* It also reset the chats on device to that email and removes user attributes, user data and completed surveys.
* It also reset the chats on device to that email and removes user attributes,
* user data and completed surveys.
* @param {string} email Email address to be set as the user's email.
* @param {string} name Name of the user to be set.
*/
Expand All @@ -484,18 +486,19 @@ module.exports = {
},

/**
* Sets the default value of the user's email to nil and show email field and remove user name from all reports
* Sets the default value of the user's email to nil and show email field and remove user name
* from all reports
* It also reset the chats on device and removes user attributes, user data and completed surveys.
*/
logOut: function () {
Instabug.logOut();
},

/**
* Sets an array of report categories to be shown for users to select from before reporting a bug or sending
* feedback.
* 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.
* Sets an array of report categories to be shown for users to select from before reporting a
* bug or sending feedback.
* 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.
*/
setReportCategories: function (...titles) {
Expand Down Expand Up @@ -671,8 +674,8 @@ module.exports = {

/**
* @summary Returns all user attributes.
* @param {function} userAttributesCallback callback with argument A new dictionary containing all the currently set user attributes,
* or an empty dictionary if no user attributes have been set.
* @param {function} userAttributesCallback callback with argument A new dictionary containing
* all the currently set user attributes, or an empty dictionary if no user attributes have been set.
*/
getAllUserAttributes: function (userAttributesCallback) {
Instabug.getAllUserAttributes(userAttributesCallback);
Expand All @@ -687,7 +690,8 @@ module.exports = {

/**
* @summary Enables/disables inspect view hierarchy when reporting a bug/feedback.
* @param {boolean} viewHierarchyEnabled A boolean to set whether view hierarchy are enabled or disabled.
* @param {boolean} viewHierarchyEnabled A boolean to set whether view hierarchy are enabled
* or disabled.
*/
setViewHierarchyEnabled: function (viewHierarchyEnabled) {
Instabug.setViewHierarchyEnabled(viewHierarchyEnabled);
Expand All @@ -696,7 +700,8 @@ module.exports = {
/**
* @summary Sets whether surveys are enabled or not.
* If you disable surveys on the SDK but still have active surveys on your Instabug dashboard,
* those surveys are still going to be sent to the device, but are not going to be shown automatically.
* those surveys are still going to be sent to the device, but are not going to be
* shown automatically.
* To manually display any available surveys, call `Instabug.showSurveyIfAvailable()`.
* Defaults to `true`.
* @param {boolean} surveysEnabled A boolean to set whether Instabug Surveys is enabled or disabled.
Expand All @@ -706,8 +711,10 @@ module.exports = {
},

/**
* @summary Shows one of the surveys that were not shown before, that also have conditions that match the current device/user.
* Does nothing if there are no available surveys or if a survey has already been shown in the current session.
* @summary Shows one of the surveys that were not shown before, that also have conditions
* that match the current device/user.
* Does nothing if there are no available surveys or if a survey has already been shown
* in the current session.
*/
showSurveysIfAvailable: function () {
Instabug.showSurveysIfAvailable()
Expand All @@ -717,8 +724,8 @@ module.exports = {
* @summary Sets a block of code to be executed just before the survey's UI is presented.
* This block is executed on the UI thread. Could be used for performing any UI changes before
* the survey's UI is shown.
* @param {function} willShowSurveyHandler - A block of code that gets executed before presenting the survey's UI.
* report.
* @param {function} willShowSurveyHandler - A block of code that gets executed before
* presenting the survey's UI.
*/
setWillShowSurveyHandler: function (willShowSurveyHandler) {
if (Platform.OS === 'ios') {
Expand All @@ -737,9 +744,10 @@ module.exports = {

/**
* @summary Sets a block of code to be executed right after the survey's UI is dismissed.
* This block is executed on the UI thread. Could be used for performing any UI changes after the survey's UI
* is dismissed.
* @param {function} didDismissSurveyHandler - A block of code that gets executed after the survey's UI is dismissed.
* This block is executed on the UI thread. Could be used for performing any UI
* changes after the survey's UI is dismissed.
* @param {function} didDismissSurveyHandler - A block of code that gets executed after
* the survey's UI is dismissed.
*/
setDidDismissSurveyHandler: function (didDismissSurveyHandler) {
if (Platform.OS === 'ios') {
Expand Down Expand Up @@ -806,8 +814,8 @@ module.exports = {
/**
* @summary Checks whether app is development/Beta testing OR live
* Note: This API is iOS only
* It returns in the callback false if in development or beta testing on Test Flight, and true if app is live on the
* app store.
* It returns in the callback false if in development or beta testing on Test Flight, and
* true if app is live on the app store.
* @param {function} runningLiveCallBack callback with argument as return value 'isLive'
*/
isRunningLive: function(runningLiveCallBack) {
Expand Down Expand Up @@ -838,11 +846,12 @@ module.exports = {
},

/**
* Sets the default position at which the Instabug screen recording button will be shown. Different orientations are already handled.
*
* Sets the default position at which the Instabug screen recording button will be shown.
* Different orientations are already handled.
* (Default for `position` is `bottomRight`)
*
* @param position is of type IBGPosition `topLeft` to show on the top left of screen , or `bottomRight` to show on the bottom right of scrren.
* @param position is of type IBGPosition `topLeft` to show on the top left of screen,
* or `bottomRight` to show on the bottom right of scrren.
*/
setVideoRecordingFloatingButtonPosition: function(position) {
Instabug.setVideoRecordingFloatingButtonPosition(position);
Expand Down

0 comments on commit 81f119d

Please sign in to comment.