Bug Reporting Callbacks for Android
Covered here are callbacks that you can use to have a block of code executed when a certain action is triggered for your Android apps.
Avoiding Memory Leaks
These APIs hold the callbacks in a strong reference, so we strongly suggest to avoid registering callbacks without unregistering them when needed, as it may cause a memory leak.
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.setOnInvokeCallback {
//do something
}
BugReporting.setOnInvokeCallback(new OnInvokeCallback() {
@Override
public void onInvoke() {
//do something
}
});
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.
Available Data: tags, consoleLog, filesAttachments, userAttributes, userData, appending data to consoleLog, attaching files, and adding tags.
Instabug.onReportSubmitHandler{report -> }
Instabug.onReportSubmitHandler(new Report.OnReportCreatedListener() {
@Override
public void onReportCreated(Report report) {
}
});
By writing
report.
in the callback, 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.setOnDismissCallback { issueState, reportType -> }
BugReporting.setOnDismissCallback(new OnSdkDismissCallback() {
@Override
public void call(DismissType issueState, ReportType reportType) {
}
});
You can find the following parameters within the setOnDismissCallback
callback.
DismissType
DismissType
Returns how the SDK was dismissed. It can be set to one of the three following possibilities:
SUBMIT
: Indicates that the issue was submitted and will be uploadedCANCEL
: Indicates that the user closed the Instabug view without report submissionADD_ATTACHMENT
: Indicates that the issue is in the process of being reported (for example, user is taking another screenshot)
ReportType
ReportType
The type of report that was sent. If the SDK was dismissed without selecting a report type, it will be set to bug
, so you might need to check issueState
before ReportType
. The possible different types are bug
, feedback
, question
, and other
.
Disabling Callbacks
To disable any previously created callbacks, you'll simply need to set the method to null
as shown below:
BugReporting.setOnInvokeCallback(null)
Instabug.onReportSubmitHandler(null)
BugReporting.setOnDismissCallback(null)
BugReporting.setOnInvokeCallback(null);
Instabug.onReportSubmitHandler(null);
BugReporting.setOnDismissCallback(null);
Updated 6 months 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 callbacks above! You can also set custom data, such as a user attribute, at any time, including inside callbacks. Logging user events in callbacks is also possible.