Bugsnag class

The primary Client. Typically this class is not accessed directly, and is instead accessed using the bugsnag global:

Future<void> main() async {
  await bugsnag.start(apiKey: 'your-api-key');
  runApp(MyApplication());
}

See also:

Inheritance
Available Extensions

Properties

client BugsnagClient
getter/setter pairinherited
errorHandler → void Function(dynamic error, StackTrace? stack)
An utility error handling function that will send reported errors to Bugsnag as unhandled. The errorHandler is suitable for use with common Dart error callbacks such as runZonedGuarded or Future.onError.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

addFeatureFlag(String name, [String? variant]) Future<void>
Add a single feature flag with an optional variant. If there is an existing feature flag with the same name, it will be overwritten with the new variant.
inherited
addFeatureFlags(List<BugsnagFeatureFlag> featureFlags) Future<void>
Add a collection of feature flags. This has the same effect as calling addFeatureFlag for each value passed, but it typically faster when there are more than one FeatureFlag.
inherited
addMetadata(String section, Map<String, Object> metadata) Future<void>
Adds a map of multiple metadata key-value pairs to the specified section.
inherited
addOnError(BugsnagOnErrorCallback onError) → void
Add a "on error" callback, to execute code at the point where an error report is captured in Bugsnag.
inherited
attach({List<BugsnagOnErrorCallback> onError = const []}) Future<void>
Attach Bugsnag to an already initialised native notifier, optionally adding to its existing configuration. Use start if your application is entirely built in Flutter.
clearFeatureFlag(String name) Future<void>
Remove a single feature flag regardless of its current status. This will stop the specified feature flag from being reported. If the named feature flag does not exist this will have no effect.
inherited
clearFeatureFlags() Future<void>
Clear all of the feature flags. This will stop all feature flags from being reported.
inherited
clearMetadata(String section, [String? key]) Future<void>
If key is not null: removes data with the specified key from the specified section. Otherwise remove all the data from the specified section.
inherited
getBreadcrumbs() Future<List<BugsnagBreadcrumb>>
Returns the current buffer of breadcrumbs that will be sent with captured events. This ordered list represents the most recent breadcrumbs to be captured up to the limit set in start.
inherited
getContext() Future<String?>
Bugsnag uses the concept of “contexts” to help display and group your errors. The context represents what was happening in your application at the time an error occurs and is given high visual prominence in the dashboard.
inherited
getLastRunInfo() Future<BugsnagLastRunInfo?>
Retrieves information about the last launch of the application, if it has been run before.
inherited
getMetadata(String section) Future<Map<String, Object>?>
Returns a map of data in the specified section.
inherited
getUser() Future<BugsnagUser>
Returns the currently set User information.
inherited
leaveBreadcrumb(String message, {Map<String, Object>? metadata, BugsnagBreadcrumbType type = BugsnagBreadcrumbType.manual}) Future<void>
Leave a "breadcrumb" log message, representing an action that occurred in your app, to aid with debugging.
inherited
markLaunchCompleted() Future<void>
Informs Bugsnag that the application has finished launching. Once this has resolved BugsnagAppWithState.isLaunching will always be false in any new error reports, and synchronous delivery will not be attempted on the next launch for any fatal crashes.
inherited
networkInstrumentation(dynamic data) → dynamic
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notify(dynamic error, StackTrace? stackTrace, {BugsnagOnErrorCallback? callback}) Future<void>
Notify Bugsnag of a handled exception.
inherited
pauseSession() Future<void>
Pauses tracking of a session. You should disable automatic session by setting autoTrackSessions to false in start.
inherited
removeOnError(BugsnagOnErrorCallback onError) → void
Removes a previously added "on error" callback.
inherited
resumeSession() Future<bool>
Resumes a session which has previously been paused, or starts a new session if none exists. If a session has already been resumed or started and has not been paused, calling this method will have no effect. You should disable automatic session by setting autoTrackSessions to false in start if you call this method.
inherited
setContext(String? context) Future<void>
Bugsnag uses the concept of “contexts” to help display and group your errors. The context represents what was happening in your application at the time an error occurs and is given high visual prominence in the dashboard.
inherited
setUser({String? id, String? email, String? name}) Future<void>
Sets the user information to be associated with events
inherited
start({String? apiKey, BugsnagUser? user, bool persistUser = true, String? context, String? appType, String? appVersion, String? bundleVersion, String? releaseStage, BugsnagEnabledErrorTypes enabledErrorTypes = BugsnagEnabledErrorTypes.all, BugsnagEndpointConfiguration endpoints = BugsnagEndpointConfiguration.bugsnag, int maxBreadcrumbs = 50, int maxPersistedSessions = 128, int maxPersistedEvents = 32, int maxStringValueLength = 10000, bool autoTrackSessions = true, bool autoDetectErrors = true, BugsnagThreadSendPolicy sendThreads = BugsnagThreadSendPolicy.always, int launchDurationMillis = 5000, bool sendLaunchCrashesSynchronously = true, int appHangThresholdMillis = appHangThresholdFatalOnly, Set<String> redactedKeys = const {'password'}, Set<String> discardClasses = const {}, Set<String>? enabledReleaseStages, Set<BugsnagEnabledBreadcrumbType>? enabledBreadcrumbTypes, BugsnagProjectPackages projectPackages = const BugsnagProjectPackages.withDefaults({}), Map<String, Map<String, Object>>? metadata, List<BugsnagFeatureFlag>? featureFlags, List<BugsnagOnErrorCallback> onError = const [], BugsnagTelemetryTypes telemetry = BugsnagTelemetryTypes.all, Directory? persistenceDirectory, int? versionCode}) Future<void>
Initialize the Bugsnag notifier with the configuration options specified. Use attach if you are building a Hybrid application where Bugsnag is initialised by the Native layer.
startSession() Future<void>
Starts tracking a new session. You should disable automatic session by setting autoTrackSessions to false in start.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Constants

appHangThresholdFatalOnly → const int