Migration Guide
Migrate between versions of Sentry's SDK for Dart.
API changes:
- Sentry's Dart SDK version 7.0.0 and above requires Dart
2.17.0. - Sentry's
sentry_filepackage version 7.0.0 and above requires Dart2.19.0. - Methods that used to take a
dynamic hintoptional parameter now takeHint? hintinstead. - The following deprecated fields have been removed from the
SentryDeviceclass and replaced:screenResolutionreplaced withscreenHeightPixelsandscreenWidthPixels.timezonereplaced withSentryCulture#timezone.languagereplaced withSentryCulture#locale.themereplaced withSentryOperatingSystem#theme.
- The following deprecated field has been removed from the
Contexts#dart_contextdatabag and replaced:isolatereplaced withSentryThread#name.
- The following fields have been removed from the
Scopeclass and replaced:user(SentryUser? user)replaced withsetUser(SentryUser? user).attachementsreplaced withattachments.
- Classes or methods that used to take the below optional parameters, have been moved to the
SentryOptionsclass and replaced:captureFailedRequestsreplaced withSentryOptions#captureFailedRequests.sendDefaultPiireplaced withSentryOptions#sendDefaultPii.maxRequestBodySizereplaced withSentryOptions#maxRequestBodySize.networkTracingreplaced withSentryOptions#tracesSampleRateorSentryOptions#tracesSampler.recordBreadcrumbsreplaced withSentryOptions#recordHttpBreadcrumbs.
- The following
SentryMeasurementUnitsare now strongly typed:DurationSentryMeasurementUnitInformationSentryMeasurementUnitFractionSentryMeasurementUnitCustomSentryMeasurementUnitNoneSentryMeasurementUnit
Behavior changes:
- Sentry's Dart SDK version 7.0.0 and above supports Dart
3.0.0. - When an unhandled error happens and there's a running transaction, the transaction status will be set to
internal_error. - The
captureFailedRequestsfeature is now enabled by default. - The
enableStructuredDataTracingfeature is now enabled by default. - The
enableUserInteractionTracingfeature is now enabled by default.
SentryOptions#sendClientReportsis now enabled by default. To disable it, use the code snippet below:
Copied
import 'package:sentry/sentry.dart';
Future<void> main() async {
await Sentry.init((options) => options.sendClientReports = false;
}
The
Scope.usersetter was deprecated in favor ofScope.setUser, and it will be removed in a future update.The
Scope.attachementsgetter was deprecated in favor ofattachments, and it will be removed in a future update.The following
Scopemethods now returnFuture<void>instead ofvoid:setContextsremoveContextssetUseraddBreadcrumbclearBreadcrumbssetExtraremoveExtrasetTagremoveTag
- Starting with version
6.6.0ofsentry, Sentry's version >= v21.9.0 is required or you have to manually disable sending client reports via thesendClientReportsoption. This only applies to self-hosted Sentry. If you are using sentry.io, no action is needed.
Sentry.currentHubwas removed. Please use the static methods onSentrySentryOptions.cacheDirSizewas renamed toSentryOptions.maxCacheItemsEventProcessorwas changed from a callback to an interface- The data type from the following options was changed from
inttoDuration. The old options are still present but deprecated and will be removed in a future version.SentryOptions.autoSessionTrackingIntervalMillistoSentryOptions.autoSessionTrackingIntervalSentryOptions.anrTimeoutIntervalMillistoSentryOptions.anrTimeoutInterval
- The
beforeSendcallback now accepts async code. The method signature changed fromSentryEvent? Function(SentryEvent event, {dynamic hint});toFutureOr<SentryEvent?> Function(SentryEvent event, {dynamic hint});. While this is technically a breaking change, your code probably is still valid. - Sentry accepts multiple exceptions and multiple threads. If you haven't set exceptions, there's no need to do anything.
- Starting with version
6.0.0of thesentry, Sentry's version >= v20.6.0 is required. This only applies to self-hosted Sentry. If you are using sentry.io, no action is needed.
- Sentry's Dart SDK version 5.0.0 and above requires Dart 1.12.0
- Fix: Prefix classes with Sentry
- A couple of classes were often conflicting with user's code. As a result, this change renames the following classes:
App->SentryAppBrowser->SentryBrowserDevice->SentryDeviceGpu->SentryGpuIntegration->SentryIntegrationMessage->SentryMessageOperatingSystem->SentryOperatingSystemOrientation->SentryOrientationRequest->SentryRequestUser->SentryUser
- A couple of classes were often conflicting with user's code. As a result, this change renames the following classes:
- Return type of
Sentry.close()changed fromvoidtoFuture<void>andIntegration.close()changed fromvoidtoFutureOr<void>
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").
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").