Skip to content

Commit 04324ea

Browse files
committed
updates for iOS for react native
1 parent 185a689 commit 04324ea

File tree

3 files changed

+178
-27
lines changed

3 files changed

+178
-27
lines changed

index.js

Lines changed: 166 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -516,6 +516,127 @@ module.exports = {
516516
instabugUtils.captureJsErrors();
517517
},
518518

519+
/**
520+
* Add file to attached files with each report being sent.
521+
* A new copy of the file at fileURL will be attached with each bug report being sent. The file is only copied
522+
* at the time of sending the report, so you could safely call this API whenever the file is available on disk, and the copy
523+
* attached to your bug reports will always contain that latest changes at the time of sending the report.
524+
*
525+
* Each call to this method adds the file to the files attached, until a maximum of 3 then it overrides the first file.
526+
* The file has to be available locally at the provided path when the report is being sent.
527+
* @param {string} stringURL Path to a file that's going to be attached to each report.
528+
*/
529+
530+
// addFileAttachment: function(stringURL) {
531+
// if (Platform.OS == 'ios') {
532+
// Instabug.addFileAttachment(stringURL);
533+
// }
534+
// },
535+
536+
/**
537+
* Clear list of files to be attached with each report.
538+
* This method doesn't delete any files from the file system. It will just removes them for the list of files
539+
* to be attached with each report.
540+
*/
541+
542+
// clearFileAttachments: function() {
543+
// if (Platform.OS == 'ios') {
544+
// Instabug.clearFileAttachments();
545+
// }
546+
// },
547+
548+
/**
549+
* Shows/Hides email field.
550+
* Defaults to show email field.
551+
* @param {boolean} shouldShowEmailField true to show the email field, false to hide it.
552+
*/
553+
setShowEmailField: function(shouldShowEmailField) {
554+
if (Platform.OS == 'ios') {
555+
Instabug.setShowEmailField();
556+
}
557+
},
558+
559+
/**
560+
* Sets the default value of the user's email and hides the email field from the reporting UI
561+
* and set the user's name to be included with all reports.
562+
* It also reset the chats on device to that email and removes user attributes, user data and completed surveys.
563+
* @param {string} email Email address to be set as the user's email.
564+
* @param {string} name Name of the user to be set.
565+
*/
566+
identifyUserWithEmail: function(email, name) {
567+
if (Platform.OS == 'ios') {
568+
Instabug.identifyUserWithEmail(email, name);
569+
}
570+
},
571+
572+
/**
573+
* Sets the default value of the user's email to nil and show email field and remove user name from all reports
574+
* It also reset the chats on device and removes user attributes, user data and completed surveys.
575+
*/
576+
logOut: function() {
577+
if (Platform.OS == 'ios') {
578+
Instabug.logOut();
579+
}
580+
},
581+
582+
/**
583+
* Sets whether to show a "Thank You" dialog after a bug report is sent or not.
584+
* Defaults to YES.
585+
* @param {boolean} isPostSendingDialogEnabled A boolean to indicate whether the dialog is enabled or not.
586+
*/
587+
setPostSendingDialogEnabled: function(isPostSendingDialogEnabled) {
588+
if (Platform.OS == 'ios') {
589+
Instabug.setPostSendingDialogEnabled(isPostSendingDialogEnabled);
590+
}
591+
},
592+
593+
/**
594+
* Sets an array of report categories to be shown for users to select from before reporting a bug or sending
595+
* feedback.
596+
* Use this method to give users a list of choices of categories their bug report or feedback might be related
597+
* to. Selected category will be shown as a tag on your dashboard.
598+
* @param {array} titles titles to be shown in the list.
599+
* @param {array} name names of icons to be shown along with titles. Use the same names you would use
600+
*/
601+
setReportCategories: function(titles, names) {
602+
if (Platform.OS == 'ios') {
603+
Instabug.setReportCategories(titles, names);
604+
}
605+
},
606+
607+
/**
608+
* Enables/disables inspect view hierarchy when reporting a bug/feedback.
609+
* @param {boolean} viewHierarchyEnabled A boolean to set whether view hierarchy are enabled or disabled.
610+
*/
611+
setViewHierarchyEnabled: function(viewHierarchyEnabled) {
612+
if (Platform.OS == 'ios') {
613+
Instabug.setViewHierarchyEnabled(viewHierarchyEnabled);
614+
}
615+
},
616+
617+
/**
618+
* Logs a user event that happens through the lifecycle of the application.
619+
* Logged user events are going to be sent with each report, as well as at the end of a session.
620+
* @param {string} name Event name.
621+
*/
622+
logUserEventWithName: function(name) {
623+
if (Platform.OS == 'ios') {
624+
Instabug.logUserEventWithName(name);
625+
}
626+
},
627+
628+
/**
629+
* Logs a user event that happens through the lifecycle of the application.
630+
* Logged user events are going to be sent with each report, as well as at the end of a session.
631+
* @param {string} name Event name.
632+
* @param {Object} params An optional dictionary or parameters to be associated with the event.
633+
*/
634+
logUserEventWithNameAndParams: function(name, params) {
635+
if (Platform.OS == 'ios') {
636+
Instabug.logUserEventWithNameAndParams(name, params);
637+
}
638+
},
639+
519640
/**
520641
* Appends a log message to Instabug internal log
521642
* <p>
@@ -529,10 +650,12 @@ module.exports = {
529650
*
530651
* @param message the message
531652
*/
532-
logV(message){
653+
logVerbose: function(message){
533654
if (!message)return;
534655
if (Platform.OS === 'android') {
535656
Instabug.log("v", message);
657+
} else {
658+
Instabug.logVerbose(message);
536659
}
537660
},
538661

@@ -549,10 +672,12 @@ module.exports = {
549672
*
550673
* @param message the message
551674
*/
552-
logI(message){
675+
logInfo: function(message){
553676
if (!message)return;
554677
if (Platform.OS === 'android') {
555678
Instabug.log("i", message);
679+
} else {
680+
Instabug.logInfo(message);
556681
}
557682
},
558683

@@ -569,10 +694,12 @@ module.exports = {
569694
*
570695
* @param message the message
571696
*/
572-
logD(message){
697+
logDebug: function(message){
573698
if (!message)return;
574699
if (Platform.OS === 'android') {
575700
Instabug.log("d", message);
701+
} else {
702+
Instabug.logDebug(message);
576703
}
577704
},
578705

@@ -589,10 +716,12 @@ module.exports = {
589716
*
590717
* @param message the message
591718
*/
592-
logE(message){
719+
logError: function(message){
593720
if (!message)return;
594721
if (Platform.OS === 'android') {
595722
Instabug.log("e", message);
723+
} else {
724+
Instabug.logError(message);
596725
}
597726
},
598727

@@ -609,10 +738,12 @@ module.exports = {
609738
*
610739
* @param message the message
611740
*/
612-
logW(message){
741+
logWarn: function(message){
613742
if (!message)return;
614743
if (Platform.OS === 'android') {
615744
Instabug.log("w", message);
745+
} else {
746+
Instabug.logWarn(message);
616747
}
617748
},
618749

@@ -640,7 +771,7 @@ module.exports = {
640771
* Clears Instabug internal log
641772
*
642773
*/
643-
clearLogs(){
774+
clearLogs: function(){
644775
if (Platform.OS === 'android') {
645776
Instabug.clearLogs();
646777
}
@@ -652,7 +783,7 @@ module.exports = {
652783
* @param key the attribute
653784
* @param value the value
654785
*/
655-
setUserAttribute(key, value){
786+
setUserAttribute: function(key, value){
656787
if (!key || !value || typeof key !== "string" || typeof value !== "string")
657788
throw new TypeError("Invalid param, Expected String");
658789
if (Platform.OS === 'android') {
@@ -661,16 +792,20 @@ module.exports = {
661792
},
662793

663794
/**
664-
* Gets specific user attribute.
665-
*
666-
* @param key the attribute key as string
667-
* @return the desired user attribute
795+
* return callback
796+
* @callback userAttributeCallback
797+
* @param {string} value for key in user attributes.
668798
*/
669-
getUserAttribute(key){
670-
if (!key || typeof key !== "string")
671-
throw new TypeError("Invalid param, Expected String");
672-
if (Platform.OS === 'android') {
673-
return Instabug.getUserAttribute(key);
799+
800+
/**
801+
* Returns the user attribute associated with a given key.
802+
aKey
803+
* @param {string} key The attribute key as string
804+
* @param {userAttributeCallback} userAttributeCallback callback with argument as the desired user attribute value
805+
*/
806+
getUserAttribute: function(key, userAttributeCallback){
807+
if (Platform.OS === 'ios') {
808+
return Instabug.getUserAttribute(key, userAttributeCallback);
674809
}
675810
},
676811

@@ -680,7 +815,7 @@ module.exports = {
680815
* @param key the attribute key as string
681816
* @see #setUserAttribute(String, String)
682817
*/
683-
removeUserAttribute(key){
818+
removeUserAttribute: function(key){
684819
if (!key || typeof key !== "string")
685820
throw new TypeError("Invalid param, Expected String");
686821
if (Platform.OS === 'android') {
@@ -689,20 +824,26 @@ module.exports = {
689824
},
690825

691826
/**
692-
* Gets all saved user attributes.
693-
*
694-
* @return all user attributes as HashMap<String, String>
827+
* return callback
828+
* @callback userAttributesCallback
829+
* @param{Object} userAttributes Dictionary of the user attributes.
695830
*/
696-
getAllUserAttributes(){
697-
if (Platform.OS === 'android') {
698-
return Instabug.getAllUserAttributes();
831+
832+
/**
833+
* @summary Returns all user attributes.
834+
* @param {userAttributesCallback} userAttributesCallback callback with argument A new dictionary containing all the currently set user attributes,
835+
* or an empty dictionary if no user attributes have been set.
836+
*/
837+
getAllUserAttributes: function(userAttributesCallback){
838+
if (Platform.OS === 'ios') {
839+
return Instabug.getAllUserAttributes(userAttributesCallback);
699840
}
700841
},
701842

702843
/**
703844
* Clears all user attributes if exists.
704845
*/
705-
clearAllUserAttributes(){
846+
clearAllUserAttributes: function(){
706847
if (Platform.OS === 'android') {
707848
Instabug.clearAllUserAttributes();
708849
}
@@ -717,7 +858,7 @@ module.exports = {
717858
none: Instabug.invocationEventNone,
718859
shake: Instabug.invocationEventShake,
719860
screenshot: Instabug.invocationEventScreenshot,
720-
twoFingersSwipe: Instabug.invocationEventTwoFingersSwipe,
861+
twoFingersSwipe: Instabug.invocationEventTwoFingersSwipeLeft,
721862
floatingButton: Instabug.invocationEventFloatingButton
722863
},
723864

ios/RNInstabug/InstabugReactBridge.m

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ - (dispatch_queue_t)methodQueue {
163163
}
164164

165165
RCT_EXPORT_METHOD(setString:(NSString*)value toKey:(IBGString)key) {
166-
[Instabug setValue:value forStringWithKey:key];
166+
[Instabug setString:value toKey:key];
167167
}
168168

169169
RCT_EXPORT_METHOD(setAttachmentTypesEnabled:(BOOL)screenShot
@@ -204,7 +204,7 @@ - (dispatch_queue_t)methodQueue {
204204
callBack(@[@([Instabug isInstabugNotification:notification])]);
205205
}
206206

207-
RCT_EXPORT_METHOD(addFileAttachmentWithURL:(NSString *)fileURLString) {
207+
RCT_EXPORT_METHOD(addFileAttachment:(NSString *)fileURLString) {
208208
[Instabug addFileAttachmentWithURL:[NSURL URLWithString:fileURLString]];
209209
}
210210

@@ -373,6 +373,11 @@ - (NSDictionary *)constantsToExport
373373
@"audio": @(IBGStringAudio),
374374
@"screenRecording": @(IBGStringScreenRecording),
375375
@"image": @(IBGStringImage),
376+
@"surveyEnterYourAnswer": @(IBGStringSurveyEnterYourAnswerPlaceholder),
377+
@"surveyNoAnswerTitle": @(kIBGStringSurveyNoAnswerTitle),
378+
@"surveyNoAnswerMessage": @(kIBGStringSurveyNoAnswerMessage),
379+
@"surveySubmitTitle": @(kIBGStringSurveySubmitTitle),
380+
@"videPressRecord": @(kIBGStringVideoPressRecordTitle)
376381
};
377382
};
378383

ios/RNInstabug/RCTConvert+InstabugEnums.m

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,5 +107,10 @@ @implementation RCTConvert (InstabugEnums)
107107
@"audio": @(IBGStringAudio),
108108
@"screenRecording": @(IBGStringScreenRecording),
109109
@"image": @(IBGStringImage),
110+
@"surveyEnterYourAnswer": @(IBGStringSurveyEnterYourAnswerPlaceholder),
111+
@"surveyNoAnswerTitle": @(kIBGStringSurveyNoAnswerTitle),
112+
@"surveyNoAnswerMessage": @(kIBGStringSurveyNoAnswerMessage),
113+
@"surveySubmitTitle": @(kIBGStringSurveySubmitTitle),
114+
@"videPressRecord": @(kIBGStringVideoPressRecordTitle)
110115
}), IBGStringShakeHint, integerValue);
111116
@end

0 commit comments

Comments
 (0)