Skip to content

Commit afbc511

Browse files
DavidMina96HeshamMegid
authored andcommitted
[MOB-11704] Add more Customization APIs (#176)
Adds `setDisclaimerText` and `setCommentMinimumCharacterCount` APIs
1 parent f40b6dc commit afbc511

File tree

4 files changed

+108
-0
lines changed

4 files changed

+108
-0
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
* Bumps Instabug Android SDK to `v11.8.0`
44
* Bumps Instabug iOS SDK to `v11.7.0`
5+
* Adds `BugReporting.setDisclaimerText` API
6+
* Adds `BugReporting.setCommentMinimumCharacterCount` API
57
* Adds support for more locales:
68
* czech
79
* finnish

src/android/IBGPlugin.java

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -984,6 +984,39 @@ public void setVideoRecordingFloatingButtonPosition(final CallbackContext callba
984984
}
985985
}
986986

987+
/**
988+
* Adds a disclaimer text within the bug reporting form, which can include hyperlinked text.
989+
* @param callbackContext Used when calling back into JavaScript
990+
* @param args [text: String]
991+
*/
992+
public void setDisclaimerText(final CallbackContext callbackContext, JSONArray args) {
993+
final String text = args.optString(0);
994+
try {
995+
BugReporting.setDisclaimerText(text);
996+
997+
callbackContext.success();
998+
} catch (Exception e) {
999+
callbackContext.error(e.getMessage());
1000+
}
1001+
}
1002+
1003+
/**
1004+
* Sets a minimum number of characters as a requirement for the comments field in the different report types.
1005+
* @param callbackContext Used when calling back into JavaScript
1006+
* @param args [limit: int, reportTypes: reportTypes[]]
1007+
*/
1008+
public void setCommentMinimumCharacterCount(final CallbackContext callbackContext, JSONArray args) {
1009+
final int limit = args.optInt(0);
1010+
final JSONArray reportTypes = args.optJSONArray(1);
1011+
final String[] stringArrayOfReportTypes = toStringArray(reportTypes);
1012+
try {
1013+
int [] parsedReportTypes = stringArrayOfReportTypes == null ? new int[0] : Util.parseReportTypes(stringArrayOfReportTypes);
1014+
BugReporting.setCommentMinimumCharacterCount(limit, parsedReportTypes);
1015+
} catch (Exception e) {
1016+
callbackContext.error(e.getMessage());
1017+
}
1018+
}
1019+
9871020
/**
9881021
* Customize the attachment options available to users to send with a bug reeport.
9891022
*

src/ios/IBGPlugin.m

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,49 @@ - (void) setVideoRecordingFloatingButtonPosition:(CDVInvokedUrlCommand*)command
392392
callbackId:[command callbackId]];
393393
}
394394

395+
/**
396+
* Adds a disclaimer text within the bug reporting form, which can include hyperlinked text.
397+
* @param {CDVInvokedUrlCommand*} command
398+
* The command sent from JavaScript
399+
*/
400+
- (void)setDisclaimerText:(CDVInvokedUrlCommand*)command
401+
{
402+
NSString* text = [command argumentAtIndex:0];
403+
404+
[IBGBugReporting setDisclaimerText:text];
405+
406+
[self.commandDelegate sendPluginResult:[CDVPluginResult resultWithStatus:CDVCommandStatus_OK]
407+
callbackId:[command callbackId]];
408+
}
409+
410+
/**
411+
* Sets a minimum number of characters as a requirement for the comments field in the different report types.
412+
* @param {CDVInvokedUrlCommand*} command
413+
* The command sent from JavaScript
414+
*/
415+
- (void)setCommentMinimumCharacterCount:(CDVInvokedUrlCommand*)command
416+
{
417+
CDVPluginResult* result;
418+
NSNumber* limit = [command argumentAtIndex:0];
419+
NSArray* reportTypes = [command argumentAtIndex:1];
420+
IBGBugReportingReportType parsedTypes = 0;
421+
422+
if (![reportTypes count]) {
423+
parsedTypes = ([self parseBugReportingReportType:@"bug"] | [self parseBugReportingReportType:@"feedback"] | [self parseBugReportingReportType:@"question"]);
424+
}
425+
else {
426+
for (NSString* type in reportTypes) {
427+
parsedTypes |= [self parseBugReportingReportType:type];
428+
}
429+
}
430+
431+
[IBGBugReporting setCommentMinimumCharacterCountForReportTypes:parsedTypes withLimit:limit.intValue];
432+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
433+
[self.commandDelegate sendPluginResult:result callbackId:[command callbackId]];
434+
435+
}
436+
437+
395438
/**
396439
* Attaches a new copy of this file with each bug report sent
397440
* with a maximum size of 1 MB. Calling this method several

src/modules/BugReporting.ts

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,5 +286,35 @@ namespace BugReporting {
286286
error
287287
);
288288
};
289+
290+
/**
291+
* Adds a disclaimer text within the bug reporting form, which can include hyperlinked text.
292+
* @param text a String of the disclaimer text.
293+
* @param success callback on function success.
294+
* @param error callback on function error.
295+
*/
296+
export const setDisclaimerText = (
297+
text: string,
298+
success?: () => void,
299+
error?: (err: any) => void
300+
) => {
301+
exec("IBGPlugin", "setDisclaimerText", [text], success, error);
302+
};
303+
304+
/**
305+
* Sets a minimum number of characters as a requirement for the comments field in the different report types.
306+
* @param limit an integer number of characters.
307+
* @param reportTypes an optional an array of reportType. If it's not passed, the limit will apply to all report types.
308+
* @param success callback on function success.
309+
* @param error callback on function error.
310+
*/
311+
export const setCommentMinimumCharacterCount = (
312+
limit: number,
313+
reportTypes?: reportType[],
314+
success?: () => void,
315+
error?: (err: any) => void
316+
) => {
317+
exec("IBGPlugin", "setCommentMinimumCharacterCount", [limit, reportTypes], success, error);
318+
};
289319
}
290320
export = BugReporting;

0 commit comments

Comments
 (0)