Migration Guide
Migrate between versions of Sentry's SDK for Dart.
The required minimium Dart version is now 3.5.0. This change allows us to use safer APIs and better support for features such as WASM compilation.
LoadImagesListIntegrationhas been renamed toLoadNativeDebugImagesIntegration.- The
enableTracingoption has been removed. Useoptions.traceSampleRateoroptions.tracesSamplerinstead. BeforeSendTransactionCallbacknow has aHintparameter.- Usage of
dart:htmlhas been removed in favor ofpackage:web. The SDK is now packaged with thepackage:webdependency for better interoperability with web APIs. - The
segmentfield fromSentryUserhas been removed. - The old user feedback API has been removed and replaced by
Sentry.captureFeedback.
The default log level is now warning when debug = true. This can be adjusted by setting options.diagnosticLevel = SentryLevel.info in Sentry.init.
SDK data classes are now mutable which makes it easier to manipulate them. For backwards-compatibility, copyWith and clone can still be used but are officially deprecated.
// old
options.beforeSend = (event, hint) {
event = event.copyWith(release: 'my-release')
return event
}
// new
options.beforeSend = (event, hint) {
event.release = 'my-release'
return event
}
Due to PII concerns, response bodies will no longer be added to Sentry events by the SDK automatically. Responses are now attached to the Hint object, which can be read in beforeSend/beforeSendTransaction callbacks via hint.response so you can manually attach the response to your event. Response bodies with a size greater than 0.15MB are not added to the hint object. Currently as of version 9.0.0, only the dio integration is supported.
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:
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>
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").