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.
“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.
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")
You can clear the contents of an entire tab using:
[Bugsnag clearTabWithName:@"user"];
Bugsnag.clearTab(withName: "user")
A breadcrumb is a notable event leading up to a crash.
By default, BugSnag captures common events including:
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.
NSNotification
eventsTo 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.