Migration Guide

In addition to the changes introduced in sentry:

API changes:

  • Sentry's Flutter SDK version 7.0.0 and above requires Flutter 3.0.0.
  • sentry_dio, version 7.0.0 requires dio 5.0.0
  • The Sentry Cocoa SDK was upgraded to 8.0.0 which introduces breaking changes, see the migration guide.
  • The following fields have been removed from the SentryFlutterOptions class and replaced:
    • enableAutoPerformanceTracking replaced with enableAutoPerformanceTracing.
    • enableOutOfMemoryTracking replaced with enableWatchdogTerminationTracking.
    • anrTimeoutIntervalMillis replaced with anrTimeoutInterval.
    • autoSessionTrackingIntervalMillis replaced with autoSessionTrackingInterval.
  • The enableNdkScopeSync feature is now enabled by default.

The SDK already runs your init callback on an error handler, such as runZonedGuarded on Flutter versions prior to 3.3, or PlatformDispatcher.onError on Flutter versions 3.3 and higher, so that errors are automatically captured. No code changes are needed on your part.

There are no Flutter-specific breaking changes. However, there are some in sentry for Dart.

To build a Flutter app for Android, Kotlin 1.5.31 or higher is required. If your app uses a lower version, you will receive the following error message.

There are no Flutter specific breaking changes. However there are some in sentry for Dart.

You may remove android:extractNativeLibs="true" meta-data in the AndroidManifest file or android.bundle.enableUncompressedNativeLibs=false in the gradle.properties file if you're using the Android Native Development Kit. Sentry can now symbolicate events with the default value of extractNativeLibs and android.bundle.enableUncompressedNativeLibs.

A random generated installationId replaces Settings.Secure.ANDROID_ID, which has been removed. This may affect the number of unique users displayed on the the Issues page and Alerts. If you always set a custom user using Sentry.setUser(customUser), the behavior has not changed. While you don't have to make any update, if you want to maintain the old behavior, use the following code snippet. It makes use of the device_info_plus plugin:

Copied
import 'package:flutter/foundation.dart';
import 'package:device_info_plus/device_info_plus.dart';
import 'package:sentry_flutter/sentry_flutter.dart';

Future<void> main() async {
  await SentryFlutter.init(
    (options) {
      options.dsn = 'https://examplePublicKey@o0.ingest.sentry.io/0';
      // revert to old behavior on Android
      if (defaultTargetPlatform == TargetPlatform.android && !kIsWeb) {
        options.addEventProcessor(addAndroidDeviceId);
      }
    },
    // Init your App.
    appRunner: () => runApp(MyApp()),
  );
}

FutureOr<SentryEvent?> addAndroidId(
  SentryEvent event, {
  Hint? hint,
}) async {
  var info = await DeviceInfoPlugin().androidInfo;
  var user = (event.user ?? SentryUser()).copyWith(id: info.androidId);

  return event.copyWith(
    user: user,
  );
}

In addition to the changes introduced in sentry:

  • SentryFlutterOptions.enableLifecycleBreadcrumbs was replaced with SentryFlutterOptions.enableAppLifecycleBreadcrumbs.
  • The Web Plugin Registrant import changed from import 'package:sentry_flutter/src/sentry_flutter_web.dart'; to import 'package:sentry_flutter/sentry_flutter_web.dart';
    • This change may lead to breaking changes. In most cases, however, this change won't lead to breaking changes since the referencing file is auto-generated.
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").