BugsnagConfiguration

Objective-C


@interface BugsnagConfiguration
    : NSObject <BugsnagFeatureFlagStore, BugsnagMetadataStore>

Swift

class BugsnagConfiguration : NSObject, BugsnagFeatureFlagStore, BugsnagMetadataStore

Contains user-provided configuration, including API key and endpoints.

  • Create a new configuration from the main bundle’s infoDictionary, using keys nested under the “bugsnag” key.

    Declaration

    Objective-C

    + (nonnull instancetype)loadConfig;

    Swift

    class func loadConfig() -> Self

    Return Value

    a BugsnagConfiguration containing the options set in the plist file

  • Initializes a new configuration object with the provided API key.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithApiKey:(nullable NSString *)apiKey;

    Swift

    init(_ apiKey: String?)
  • Unavailable

    Required declaration to suppress a superclass designated-initializer error

    Declaration

    Objective-C

    - (nonnull instancetype)init;
  • The API key of a Bugsnag project

    Declaration

    Objective-C

    @property (nonatomic, copy) NSString *_Nonnull apiKey;

    Swift

    var apiKey: String { get set }
  • The release stage of the application, such as production, development, beta et cetera

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSString *releaseStage;

    Swift

    var releaseStage: String? { get set }
  • Release stages which are allowed to notify Bugsnag

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSSet<NSString *> *enabledReleaseStages;

    Swift

    var enabledReleaseStages: Set<String>? { get set }
  • Sets which values should be removed from any Metadata objects before sending them to Bugsnag. Use this if you want to ensure you don’t send sensitive data such as passwords, and credit card numbers to our servers. Any keys which contain a match will be filtered.

    By default, redactedKeys is set to [“password”]. Both string literals and regex values can be supplied to this property.

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSSet<id> *redactedKeys;

    Swift

    var redactedKeys: Set<AnyHashable>? { get set }
  • A set of strings and / or NSRegularExpression objects that determine which errors should be discarded based on their errorClass.

    Comparisons are case sensitive.

    OnError / OnSendError blocks will not be called for discarded errors.

    Some examples of errorClass are: Objective-C exception names like “NSRangeException”, signal names like “SIGABRT”, mach exception names like “EXC_BREAKPOINT”, and Swift error names like “Fatal error”.

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSSet<id> *discardClasses;

    Swift

    var discardClasses: Set<AnyHashable>? { get set }
  • A general summary of what was occuring in the application

    Declaration

    Objective-C

    @property (copy, nullable) NSString *context;

    Swift

    var context: String? { get set }
  • The version of the application

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSString *appVersion;

    Swift

    var appVersion: String? { get set }
  • The URL session used to send requests to Bugsnag.

    Declaration

    Objective-C

    @property (nonatomic, strong, nonnull) NSURLSession *session;

    Swift

    var session: URLSession { get set }
  • Controls whether Bugsnag should capture and serialize the state of all threads at the time of an error.

    By default sendThreads is set to BSGThreadSendPolicyAlways. This can be set to BSGThreadSendPolicyNever to disable or BSGThreadSendPolicyUnhandledOnly to only do so for unhandled errors.

    Declaration

    Objective-C

    @property (nonatomic) BSGThreadSendPolicy sendThreads;

    Swift

    var sendThreads: BSGThreadSendPolicy { get set }
  • Optional handler invoked when an error or crash occurs

    Declaration

    Objective-C

    @property (nonatomic, nullable) void (*) (const BSG_KSCrashReportWriter *_Nonnull) onCrashHandler;

    Swift

    var onCrashHandler: ((UnsafePointer<BSG_KSCrashReportWriter>) -> Void)? { get set }
  • YES if uncaught exceptions and other crashes should be reported automatically

    Declaration

    Objective-C

    @property (nonatomic) BOOL autoDetectErrors;

    Swift

    var autoDetectErrors: Bool { get set }
  • The minimum number of milliseconds of main thread unresponsiveness that will trigger the detection and reporting of an app hang.

    Set to BugsnagAppHangThresholdFatalOnly to disable reporting of app hangs that did not end with the app being force quit by the user or terminated by the system watchdog.

    By default this is BugsnagAppHangThresholdFatalOnly, and can be set to a minimum of 250 milliseconds.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger appHangThresholdMillis;

    Swift

    var appHangThresholdMillis: UInt { get set }
  • Whether Bugsnag should report app hangs that occur while the app is in the background.

    By default this is false.

    Declaration

    Objective-C

    @property (nonatomic) BOOL reportBackgroundAppHangs;

    Swift

    var reportBackgroundAppHangs: Bool { get set }
  • Determines whether app sessions should be tracked automatically. By default this value is true. If this value is updated after +[Bugsnag start] is called, only subsequent automatic sessions will be captured.

    Note: automatic session tracking is not available in App Extensions.

    Declaration

    Objective-C

    @property (nonatomic) BOOL autoTrackSessions;

    Swift

    var autoTrackSessions: Bool { get set }
  • The amount of time (in milliseconds) after starting Bugsnag that should be considered part of the app’s launch.

    Events that occur during app launch will have the BugsnagAppWithState.isLaunching property set to true.

    By default this value is 5000 milliseconds.

    Setting this to 0 will cause Bugsnag to consider the app to be launching until +[Bugsnag markLaunchCompleted] or -[BugsnagClient markLaunchCompleted] has been called.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger launchDurationMillis;

    Swift

    var launchDurationMillis: UInt { get set }
  • Determines whether launch crashes should be sent synchronously during +[Bugsnag start].

    If true and the previous run terminated due to a crash during app launch, +[Bugsnag start] will block the calling thread for up to 2 seconds while the crash report is sent.

    By default this value is true.

    Declaration

    Objective-C

    @property (nonatomic) BOOL sendLaunchCrashesSynchronously;

    Swift

    var sendLaunchCrashesSynchronously: Bool { get set }
  • Whether Bugsnag should try to send crashing errors prior to app termination.

    Delivery will only be attempted for uncaught Objective-C exceptions and Mach exceptions, and while in progress will block the crashing thread for up to 3 seconds.

    Delivery will be unreliable due to the necessary short timeout and potential memory corruption that caused the crashing error in the first place.

    If it fails prior to termination, delivery will be reattempted at next launch (the default behavior).

    Use of this feature is discouraged because it:

    • may cause the app to hang while delivery occurs and impact the hang rate reported in Xcode Organizer
    • will result in duplicate crashes in your dashboard for crashes that were fully sent but without receiving an HTTP response within the timeout
    • may prevent other crash reporters from detecting the crash.

    By default this value is false.

    Declaration

    Objective-C

    @property (nonatomic) BOOL attemptDeliveryOnCrash;

    Swift

    var attemptDeliveryOnCrash: Bool { get set }
  • The types of breadcrumbs which will be captured. By default, this is all types.

    Declaration

    Objective-C

    @property (nonatomic) BSGEnabledBreadcrumbType enabledBreadcrumbTypes;

    Swift

    var enabledBreadcrumbTypes: BSGEnabledBreadcrumbType { get set }
  • The app’s bundleVersion, set from the CFBundleVersion. Equivalent to versionCode on Android.

    Declaration

    Objective-C

    @property (nonatomic, copy, nullable) NSString *bundleVersion;

    Swift

    var bundleVersion: String? { get set }
  • Undocumented

    Declaration

    Objective-C

    @property (copy, nullable, nonatomic) NSString *appType

    Swift

    var appType: String? { get set }
  • Sets the maximum number of events which will be stored. Once the threshold is reached, the oldest events will be deleted.

    By default, 32 events are persisted.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger maxPersistedEvents;

    Swift

    var maxPersistedEvents: UInt { get set }
  • Sets the maximum number of sessions which will be stored. Once the threshold is reached, the oldest sessions will be deleted.

    By default, 128 sessions are persisted.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger maxPersistedSessions;

    Swift

    var maxPersistedSessions: UInt { get set }
  • Sets the maximum number of breadcrumbs which will be stored. Once the threshold is reached, the oldest breadcrumbs will be deleted.

    By default, 100 breadcrumbs are stored: this can be amended up to a maximum of 500.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger maxBreadcrumbs;

    Swift

    var maxBreadcrumbs: UInt { get set }
  • The maximum length of breadcrumb messages and metadata string values.

    Values longer than this will be truncated prior to sending, after running any OnSendError blocks.

    The default value is 10000.

    Declaration

    Objective-C

    @property (nonatomic) NSUInteger maxStringValueLength;

    Swift

    var maxStringValueLength: UInt { get set }
  • Whether User information should be persisted to disk between application runs. Defaults to True.

    Declaration

    Objective-C

    @property (nonatomic) BOOL persistUser;

    Swift

    var persistUser: Bool { get set }
  • A class defining the types of error that are reported. By default, all properties are true.

    Declaration

    Objective-C

    @property (nonatomic, strong) BugsnagErrorTypes *_Nonnull enabledErrorTypes;

    Swift

    var enabledErrorTypes: BugsnagErrorTypes { get set }
  • Set the endpoints to send data to. By default we’ll send error reports to https://notify.bugsnag.com, and sessions to https://sessions.bugsnag.com, but you can override this if you are using Bugsnag Enterprise to point to your own Bugsnag endpoint.

    Please note that it is recommended that you set both endpoints. If the notify endpoint is missing, an assertion will be thrown. If the session endpoint is missing, a warning will be logged and sessions will not be sent automatically.

    Declaration

    Objective-C

    @property (nonatomic, copy) BugsnagEndpointConfiguration *_Nonnull endpoints;

    Swift

    @NSCopying var endpoints: BugsnagEndpointConfiguration { get set }
  • The current user

    Declaration

    Objective-C

    @property (nonatomic, retain, readonly, nonnull) BugsnagUser *user;

    Swift

    var user: BugsnagUser { get }
  • Set user metadata

    If user ID is nil, a Bugsnag-generated Device ID is used for the user.id property of events and sessions.

    Declaration

    Objective-C

    - (void)setUser:(NSString *_Nullable)userId
          withEmail:(NSString *_Nullable)email
            andName:(NSString *_Nullable)name;

    Swift

    func setUser(_ userId: String?, withEmail email: String?, andName name: String?)

    Parameters

    userId

    ID of the user

    name

    Name of the user

    email

    Email address of the user

  • Add a callback to be invoked before a session is sent to Bugsnag.

    @returns An opaque reference to the callback which can be passed to removeOnSession:

    Declaration

    Objective-C

    - (nonnull BugsnagOnSessionRef)addOnSessionBlock:
        (nonnull BugsnagOnSessionBlock)block;

    Swift

    func addOnSession(block: @escaping BugsnagOnSessionBlock) -> BugsnagOnSessionRef

    Parameters

    block

    A block which can modify the session

  • Remove a callback that would be invoked before a session is sent to Bugsnag.

    Declaration

    Objective-C

    - (void)removeOnSession:(nonnull BugsnagOnSessionRef)callback;

    Swift

    func removeOnSession(_ callback: BugsnagOnSessionRef)

    Parameters

    callback

    The opaque reference of the callback, returned by addOnSessionBlock:

  • Deprecated

    Deprecated

    Declaration

    Objective-C

    - (void)removeOnSessionBlock:(nonnull BugsnagOnSessionBlock)block;

    Swift

    func removeOnSession(block: @escaping BugsnagOnSessionBlock)
  • Add a callback to be invoked before a report is sent to Bugsnag, to change the report contents as needed

    @returns An opaque reference to the callback which can be passed to removeOnSendError:

    Declaration

    Objective-C

    - (nonnull BugsnagOnSendErrorRef)addOnSendErrorBlock:
        (nonnull BugsnagOnSendErrorBlock)block;

    Swift

    func addOnSendError(block: @escaping BugsnagOnSendErrorBlock) -> BugsnagOnSendErrorRef

    Parameters

    block

    A block which returns YES if the report should be sent

  • Remove the callback that would be invoked before an event is sent.

    Declaration

    Objective-C

    - (void)removeOnSendError:(nonnull BugsnagOnSendErrorRef)callback;

    Swift

    func removeOnSendError(_ callback: BugsnagOnSendErrorRef)

    Parameters

    callback

    The opaque reference of the callback, returned by addOnSendErrorBlock:

  • Deprecated

    Deprecated

    Declaration

    Objective-C

    - (void)removeOnSendErrorBlock:(nonnull BugsnagOnSendErrorBlock)block;

    Swift

    func removeOnSendError(block: @escaping BugsnagOnSendErrorBlock)
  • Add a callback to be invoked when a breadcrumb is captured by Bugsnag, to change the breadcrumb contents as needed

    @returns An opaque reference to the callback which can be passed to removeOnBreadcrumb:

    Declaration

    Objective-C

    - (nonnull BugsnagOnBreadcrumbRef)addOnBreadcrumbBlock:
        (nonnull BugsnagOnBreadcrumbBlock)block;

    Swift

    func addOnBreadcrumb(block: @escaping BugsnagOnBreadcrumbBlock) -> BugsnagOnBreadcrumbRef

    Parameters

    block

    A block which returns YES if the breadcrumb should be captured

  • Remove the callback that would be invoked when a breadcrumb is captured.

    Declaration

    Objective-C

    - (void)removeOnBreadcrumb:(nonnull BugsnagOnBreadcrumbRef)callback;

    Swift

    func removeOnBreadcrumb(_ callback: BugsnagOnBreadcrumbRef)

    Parameters

    callback

    The opaque reference of the callback, returned by addOnBreadcrumbBlock:

  • Deprecated

    Deprecated

    Declaration

    Objective-C

    - (void)removeOnBreadcrumbBlock:(nonnull BugsnagOnBreadcrumbBlock)block;

    Swift

    func removeOnBreadcrumb(block: @escaping BugsnagOnBreadcrumbBlock)
  • The types of telemetry that may be sent to Bugsnag for product improvement purposes.

    By default all types of telemetry are enabled.

    Declaration

    Objective-C

    @property (nonatomic) BSGTelemetryOptions telemetry;

    Swift

    var telemetry: BSGTelemetryOptions { get set }