HomeDocumentationAPI Reference
Getting StartedAPI ReferenceHelp CenterVideo Tours

Set Pre-Sending Handler

Use this handler to run any code right before sending a bug or crash report

This block is executed in the background before sending each report and could be used for attaching logs and extra data to reports, for example.

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;
};
Instabug.onReportSubmitHandler(new Report.OnReportCreatedListener() {
            @Override
            public void onReportCreated(Report report) {
                
            }
        };
BugReporting.onReportSubmitHandler(function () {
    // Attach logs and extra data to reports.
});
//iOS
Instabug.WillSendReportHandler = (IBGReport report) =>
{
  report.LogVerbose("Verbos log");
  report.SetUserAttribute("User Attirbute Value", "Key");
  return report;
};

//Android
Instabug.OnReportSubmitHandler(new BeforeSendingReportCallback());

public class BeforeSendingReportCallback : Java.Lang.Object, Report.IOnReportCreatedListener
{
  public void OnReportCreated(Report report)
  {
    report.AddTag("Tag");
    report.LogVerbose("Verbose Log");
    report.AppendToConsoleLogs("Console Log");
    report.SetUserAttribute("User Attribute Value", "Key");
  }
}