sentry 4.0.0-beta.1 copy "sentry: ^4.0.0-beta.1" to clipboard
sentry: ^4.0.0-beta.1 copied to clipboard

outdated

A crash reporting library for Dart that sends crash reports to Sentry.io. This library supports Dart VM and Web. For Flutter consider sentry_flutter instead.


Sentry SDK for Dart #

package build pub likes popularity pub points
sentry build pub package likes popularity pub points

Pure Dart SDK used by any Dart application like AngularDart, CLI and server.

Flutter

For Flutter applications there's sentry_flutter which builds on top of this package. That will give you native crash support (for Android and iOS), release health, offline caching and more.

Versions

Versions ^4.0.0-alpha.1 are Prereleases and are under improvements/testing.

The current stable version is the Dart SDK, 3.0.1.

Usage

  • Sign up for a Sentry.io account and get a DSN at http://sentry.io.

  • Follow the installing instructions on pub.dev.

  • The code snippet below reflects the latest Prerelease version.

  • Initialize the Sentry SDK using the DSN issued by Sentry.io:

import 'dart:async';
import 'package:sentry/sentry.dart';

Future<void> main() async {
  await Sentry.init(
    (options) {
      options.dsn = 'https://example@sentry.io/add-your-dsn-here';
    },
    appRunner: initApp, // Init your App.
  );
}

void initApp() {
  // your app code
}

Or, if you want to run your app in your own error zone [runZonedGuarded]:

import 'dart:async';
import 'package:sentry/sentry.dart';

Future<void> main() async {
  await Sentry.init(
    (options) {
      options.dsn = 'https://example@sentry.io/add-your-dsn-here';
    },
  );

  // Init your App.
  initApp();
}

void initApp() {
  // your app code
}
Tips for catching errors
  • Use a try/catch block.
  • Use a catchError block for Futures, examples on dart.dev.
  • The SDK already runs your callback on an error handler, e.g. using runZonedGuarded, events caught by the runZonedGuarded are captured automatically.
  • Current Isolate errors which is the equivalent of a main or UI thread, are captured automatically (Only for non-Web Apps).
  • For your own Isolates, add an Error Listener and call Sentry.captureException.

Resources

  • Documentation
  • Forum
  • Discord
  • Stack Overflow
  • Twitter Follow
498
likes
0
pub points
96%
popularity

Publisher

verified publishersentry.io

A crash reporting library for Dart that sends crash reports to Sentry.io. This library supports Dart VM and Web. For Flutter consider sentry_flutter instead.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

http, meta, stack_trace, uuid

More

Packages that depend on sentry