Customizing error reports

This documentation is for version 5 of the BugSnag iOS notifier. We recommend upgrading to the latest release using our Upgrade guide. Documentation for the current release can be found here.

In order to quickly reproduce and fix errors, it is often helpful to send additional application-specific diagnostic data to BugSnag.

Adding custom diagnostics

“Tabs” are additional groups of debugging information which can be added to error reports.

If you want to add a tab to your BugSnag error report, you can call addAttribute and specify the new tab name:

[Bugsnag addAttribute:@"favorite-tea" withValue:@"chamomile" toTabWithName:@"user"];
[Bugsnag addAttribute:@"registered-user" withValue:@"yes" toTabWithName:@"user"];
Bugsnag.addAttribute("favorite-tea", withValue:"chamomile", toTabWithName:"user")
Bugsnag.addAttribute("registered-user", withValue:"yes", toTabWithName:"user")

This will add a user tab to any error report sent to bugsnag.com that contains the username and whether the user was registered or not.

Removing values from tabs

You can clear a single attribute on a tab by calling:

[Bugsnag addAttribute:@"dessert" withValue:nil toTabWithName:@"food"];
Bugsnag.addAttribute("dessert", withValue:nil, toTabWithName:"food")

Clearing an entire tab

You can clear the contents of an entire tab using:

[Bugsnag clearTabWithName:@"user"];
Bugsnag.clearTab(withName: "user")

Adding detailed breadcrumbs

A breadcrumb is a notable event leading up to a crash.

By default, BugSnag captures common events including:

  • Low memory warnings
  • Device rotation
  • Menu presentation
  • Screenshot capture (not the screenshot itself)
  • Undo and redo
  • Table view selection
  • Window visibility changes
  • Non-fatal errors

Customizing individual breadcrumbs

You can add additional breadcrumbs with information about the app environment by calling leaveBreadcrumbWithBlock. Some common types of events captured include network requests, user authentication, presenting views modally, and button presses:

[Bugsnag leaveBreadcrumbWithBlock:^(BugsnagBreadcrumb *crumb) {
    crumb.name = @"Popup Menu Visible";
    crumb.type = BSGBreadcrumbTypeNavigation;
    crumb.metadata = @{
        @"title": @"Select an example type"
    };
}];
Bugsnag.leaveBreadcrumb { crumb in
    crumb.name = "Popup Menu Visible";
    crumb.type = .navigation;
    crumb.metadata = ["title": "Select an example type"]
}

Individual breadcrumb size is limited to 4kb after serialization. Any larger breadcrumbs will be dropped from the payload while logging a warning.

Capturing NSNotification events

To add breadcrumbs for every instance of a NSNotification being sent, use leaveBreadcrumbForNotificationName:

[Bugsnag leaveBreadcrumbForNotificationName:@"XYZControllerPushed"];
Bugsnag.leaveBreadcrumb(forNotificationName: "XYZControllerPushed")

This can be useful for instrumenting your own notification pipelines for notable events more quickly.