sentry_flutter 4.0.0-alpha.2 copy "sentry_flutter: ^4.0.0-alpha.2" to clipboard
sentry_flutter: ^4.0.0-alpha.2 copied to clipboard

outdated

Sentry SDK for Flutter. This package aims to support different Flutter targets by relying on the many platforms supported by Sentry with native SDKs.


Sentry SDK for Flutter and its Native integrations (Android/Apple) #

package build
sentry_flutter build

Versions

Versions ^4.0.0 are Prereleases and are under improvements/testing.

Versions ^4.0.0 integrate our Native SDKs (Android and Apple), so you are able to capture errors on Native code as well (Java/Kotlin/C/C++ for Android and Objective-C/Swift for Apple).

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 'package:flutter/widgets.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

Future<void> main() async {
  await SentryFlutter.init(
    (options) {
      options.dsn = 'https://example@sentry.io/add-your-dsn-here';
      // For better groupping, change the 'example' below with your own App's package.
      options.addInAppInclude('sentry_flutter_example');
    },
    () {
      // Init your App.
      runApp(MyApp()),
    },
  );

  try {
    aMethodThatMightFail();
  } catch (exception, stackTrace) {
    await Sentry.captureException(
      exception,
      stackTrace: stackTrace,
    );
  }
}

void aMethodThatMightFail() {
  throw null;
}
Known limitations
  • We don't support the Flutter split-debug-info yet, if this feature is enabled, it'll give useless stack traces.
  • For the Flutter obfuscate feature, you'll need to upload the Debug symbols manually yet, See the section below.
Debug Symbols for the Native integrations (Android and Apple)

Uploading Debug Symbols for Apple.

Uploading Proguard Mappings and Debug Symbols for Android.

Tips for catching errors
  • Use a try/catch block, like in the example above.
  • 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.
  • Flutter-specific errors (such as layout failures) are captured automatically.
  • Current Isolate errors which is the equivalent of a main or UI thread, are captured automatically.
  • For your own Isolates, add an Error Listener and call Sentry.captureException.

Resources

  • Documentation
  • Forum
  • Discord
  • Stack Overflow
  • Twitter Follow
890
likes
0
pub points
100%
popularity

Publisher

verified publishersentry.io

Sentry SDK for Flutter. This package aims to support different Flutter targets by relying on the many platforms supported by Sentry with native SDKs.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_web_plugins, package_info, sentry

More

Packages that depend on sentry_flutter