Crash Reporting Event Handlers for iOS
Covered here is how to set up the event handlers that fire before every crash report is sent so that a specific block of code is executed in your iOS app.
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.
Instabug.willSendReportHandler = { report in
report.appendTag("tag1")
report.logVerbose("Verbose log.")
report.append(toConsoleLogs: "Console log statement.")
report.setUserAttribute("value", withKey: "key")
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;
};
Updated 12 months ago
What’s Next
You can also set custom data, such as user attributes, inside event handlers. Logging user events in event handlers is possible as well.