Bugsnag.h

Includes:
<Foundation/Foundation.h>
"BugsnagConfiguration.h"
"BugsnagMetaData.h"

Introduction

Use the links in the table of contents to the left to access the documentation.



Methods

+addAttribute:withValue:toTabWithName:
+appDidCrashLastLaunch
+clearBreadcrumbs
+clearTabWithName:
+configuration
+internalClientNotify:withData:block:
+leaveBreadcrumbForNotificationName:
+leaveBreadcrumbWithBlock:
+leaveBreadcrumbWithMessage:
+notify:
+notify:block:
+notify:withData:
+notify:withData:atSeverity:
+notifyError:
+notifyError:block:
+resumeSession
+setBreadcrumbCapacity:
+startBugsnagWithApiKey:
+startBugsnagWithConfiguration:
+startSession
+stopSession

addAttribute:withValue:toTabWithName:


+ (void)addAttribute:(NSString *_Nonnull)attributeName 
        withValue:(id _Nullable)value toTabWithName:(NSString *_Nonnull)tabName;  
Parameters
attributeName

The name of the data.

value

Its value.

tabName

The tab to show it on on the Bugsnag dashboard.

Discussion

Add custom data to send to Bugsnag with every exception. If value is nil, delete the current value for attributeName

See also [Bugsnag configuration].metaData;


appDidCrashLastLaunch


+ (BOOL)appDidCrashLastLaunch;  
Return Value

YES if Bugsnag has been started and the previous launch crashed


clearBreadcrumbs


+ (void)clearBreadcrumbs;  
Discussion

Clear any breadcrumbs that have been left so far.


clearTabWithName:


+ (void)clearTabWithName:(NSString *_Nonnull)tabName;  
Parameters
tabName

The tab to clear.

Discussion

Remove custom data from Bugsnag reports.


configuration


+ (BugsnagConfiguration *_Nullable)configuration;  
Return Value

The configuration, or nil.

Discussion

Get the current Bugsnag configuration.

This method returns nil if called before +startBugsnagWithApiKey: or +startBugsnagWithConfiguration:, and otherwise returns the current configuration for Bugsnag.


internalClientNotify:withData:block:


+ (void)internalClientNotify:(NSException *_Nonnull)exception 
        withData:(NSDictionary *_Nullable)metaData block:(BugsnagNotifyBlock _Nullable)block;  
Discussion

Intended for use by other clients (React Native/Unity). Calling this method directly from iOS is not supported.


leaveBreadcrumbForNotificationName:


+ (void)leaveBreadcrumbForNotificationName:(NSString *_Nonnull)notificationName;  
Parameters
notificationName

name of the notification to capture

Discussion

Leave a "breadcrumb" log message each time a notification with a provided name is received by the application


leaveBreadcrumbWithBlock:


+ (void)leaveBreadcrumbWithBlock: (void (^_Nonnull)(BugsnagBreadcrumb *_Nonnull))block;  
Parameters
block

configuration block

Discussion

Leave a "breadcrumb" log message with additional information about the environment at the time the breadcrumb was captured.


leaveBreadcrumbWithMessage:


+ (void)leaveBreadcrumbWithMessage:(NSString *_Nonnull)message;  
Parameters
message

the log message to leave (max 140 chars)

Discussion

Leave a "breadcrumb" log message, representing an action that occurred in your app, to aid with debugging.


notify:


+ (void)notify:(NSException *_Nonnull)exception;  
Parameters
exception

The exception.

Discussion

Send a custom or caught exception to Bugsnag.

The exception will be sent to Bugsnag in the background allowing your app to continue running.


notify:block:


+ (void)notify:(NSException *_Nonnull)exception block:(BugsnagNotifyBlock _Nullable)block;  
Parameters
exception

The exception

block

A block for optionally configuring the error report

Discussion

Send a custom or caught exception to Bugsnag


notify:withData:


+ (void)notify:(NSException *_Nonnull)exception withData:(NSDictionary *_Nullable)metaData __deprecated_msg("Use notify:block: instead and add the metadata to the " "report directly.");  
Parameters
exception

The exception.

metaData

Any additional information you want to send with the report.

Discussion

Send a custom or caught exception to Bugsnag.

The exception will be sent to Bugsnag in the background allowing your app to continue running.


notify:withData:atSeverity:


+ (void)notify:(NSException *_Nonnull)exception withData:(NSDictionary *_Nullable)metaData 
        atSeverity:(NSString *_Nullable)severity __deprecated_msg("Use notify:block: instead and add the metadata and " "severity to the report directly.");  
Parameters
exception

The exception.

metaData

Any additional information you want to send with the report.

severity

The severity level (default: BugsnagSeverityWarning)

Discussion

Send a custom or caught exception to Bugsnag.

The exception will be sent to Bugsnag in the background allowing your app to continue running.


notifyError:


+ (void)notifyError:(NSError *_Nonnull)error;  
Parameters
error

The error

Discussion

Send an error to Bugsnag


notifyError:block:


+ (void)notifyError:(NSError *_Nonnull)error block:(BugsnagNotifyBlock _Nullable)block;  
Parameters
error

The error

block

A block for optionally configuring the error report

Discussion

Send an error to Bugsnag


resumeSession


+ (BOOL)resumeSession;  
Return Value

true if a previous session was resumed, false if a new session was started.

Discussion

Resumes a session which has previously been stopped, or starts a new session if none exists.

If a session has already been resumed or started and has not been stopped, calling this method will have no effect. You should disable automatic session tracking via shouldAutoCaptureSessions if you call this method.

It's important to note that sessions are stored in memory for the lifetime of the application process and are not persisted on disk. Therefore calling this method on app startup would start a new session, rather than continuing any previous session.

You should call this at the appropriate time in your application when you wish to resume a previously started session. Any subsequent errors which occur in your application will be reported to Bugsnag and will count towards your application's stability score.

See

startSession:

stopSession:


setBreadcrumbCapacity:


+ (void)setBreadcrumbCapacity:(NSUInteger)capacity;  
Parameters
capacity

max number of breadcrumb log messages to send

Discussion

Set the maximum number of breadcrumbs to keep and sent to Bugsnag. By default, we'll keep and send the 20 most recent breadcrumb log messages.


startBugsnagWithApiKey:


+ (void)startBugsnagWithApiKey:(NSString *_Nonnull)apiKey;  
Parameters
apiKey

The API key from your Bugsnag dashboard.

Discussion

Start listening for crashes.

This method initializes Bugsnag with the default configuration. Any uncaught NSExceptions, C++ exceptions, mach exceptions or signals will be logged to disk before your app crashes. The next time your app boots, we send any such reports to Bugsnag.


startBugsnagWithConfiguration:


+ (void)startBugsnagWithConfiguration: (BugsnagConfiguration *_Nonnull)configuration;  
Parameters
configuration

The configuration to use.

Discussion

Start listening for crashes.

This method initializes Bugsnag. Any uncaught NSExceptions, uncaught C++ exceptions, mach exceptions or signals will be logged to disk before your app crashes. The next time your app boots, we send any such reports to Bugsnag.


startSession


+ (void)startSession;  
Discussion

Starts tracking a new session.

By default, sessions are automatically started when the application enters the foreground. If you wish to manually call startSession at the appropriate time in your application instead, the default behaviour can be disabled via shouldAutoCaptureSessions.

Any errors which occur in an active session count towards your application's stability score. You can prevent errors from counting towards your stability score by calling stopSession and resumeSession at the appropriate time in your application.

See

stopSession:

resumeSession:


stopSession


+ (void)stopSession;  
Discussion

Stops tracking a session.

When a session is stopped, errors will not count towards your application's stability score. This can be advantageous if you do not wish these calculations to include a certain type of error, for example, a crash in a background service. You should disable automatic session tracking via shouldAutoCaptureSessions if you call this method.

A stopped session can be resumed by calling resumeSession, which will make any subsequent errors count towards your application's stability score. Alternatively, an entirely new session can be created by calling startSession.

See

startSession:

resumeSession: