Bug Reporting Event Handlers for iOS
Covered here are event handlers that you can use to have a block of code executed when a certain action is triggered for your iOS apps.
Before Invoking Instabug
This block is executed on the UI thread. You can use it to perform any UI changes before the SDK's UI is shown.
BugReporting.willInvokeHandler = {
someObject.setSomeState()
}
IBGBugReporting.willInvokeHandler = ^{
[someObject setSomeState];
};
Before Sending a Report
This block is executed in the background before sending each report. You can use it to attach logs and extra data to reports. You can also use this API to run some logic after the bug is reported and before it gets synced with the backend in case you need to access some data to take specific actions.
Data Available: tags, instabugLogs, consoleLogs, userAttributes, fileLocations, userData
Instabug.willSendReportHandler = { report in
report.appendTag("tag1")
report.logVerbose("Verbose log.")
report.append(toConsoleLogs: "Console log statement.")
report.setUserAttribute("value", withKey: "key")
let data = "Data".data(using: .utf8)
report.addFileAttachment(with: data)
return report
}
Instabug.willSendReportHandler = ^IBGReport * _Nonnull(IBGReport * _Nonnull report) {
[report appendTag:@"tag1"];
[report logVerbose:@"Verbose log."];
[report appendToConsoleLogs:@"Console log statement"];
[report setUserAttribute:@"value" withKey:@"key"];
return report;
};
By writing
report.
in the Event Handler, the IDE autocomplete feature will show all of the mentioned operations that you can do or access on the report automatically.
After Dismissing Instabug
This block is executed on the UI thread. You can use it to perform any UI changes after the SDK's UI has been dismissed.
BugReporting.didDismissHandler = { (dismissType, reportType) in
someObject.setSomeState()
}
IBGBugReporting.didDismissHandler = ^(IBGDismissType dismissType, IBGReportType reportType) {
[someObject setSomeState];
};
The didDismissHandler
block has the following parameters:
IBGDismissType
IBGDismissType
Returns how the SDK was dismissed. It can be set to one of the three following possibilities:
//Indicates that the issue was submitted and will be uploaded
submit
//Indicates that the user closed the Instabug view without report submission
cancel
//Indicates that the issue was submitted and will be uploaded
IBGDismissTypeSubmit
//Indicates that the user closed the Instabug view without report submission
IBGDismissTypeCancel
IBGReportType
IBGReportType
The type of report that was sent. If the SDK was dismissed without selecting a report type, it will be set to IBGReportTypeBug
, so you might need to check issueState
before IBGReportType
. The possible different types are below:
bug
feedback
question
other
IBGReportTypeBug
IBGReportTypeFeedback
IBGReportTypeQuestion
IBGReportTypeOther
Updated about 1 year ago
Check out our attachments section for details on how to attach your own file. You can even attach a file in one of the handlers above! You can also set custom data, such as a user attribute, at any time, including inside event handlers. Logging user events in event handlers is also possible.