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.
LoadImagesListIntegration
has been renamed toLoadNativeDebugImagesIntegration
.- The
enableTracing
option has been removed. Useoptions.traceSampleRate
oroptions.tracesSampler
instead. BeforeSendTransactionCallback
now has aHint
parameter.- Usage of
dart:html
has been removed in favor ofpackage:web
. The SDK is now packaged with thepackage:web
dependency for better interoperability with web APIs. - The
segment
field fromSentryUser
has been removed.
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
}
The old user feedback API has been removed and replaced by Sentry.captureFeedback
.
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_file
package version 7.0.0 and above requires Dart2.19.0
. - Methods that used to take a
dynamic hint
optional parameter now takeHint? hint
instead. - The following deprecated fields have been removed from the
SentryDevice
class and replaced:screenResolution
replaced withscreenHeightPixels
andscreenWidthPixels
.timezone
replaced withSentryCulture#timezone
.language
replaced withSentryCulture#locale
.theme
replaced withSentryOperatingSystem#theme
.
- The following deprecated field has been removed from the
Contexts#dart_context
databag and replaced:isolate
replaced withSentryThread#name
.
- The following fields have been removed from the
Scope
class and replaced:user(SentryUser? user)
replaced withsetUser(SentryUser? user)
.attachements
replaced withattachments
.
- Classes or methods that used to take the below optional parameters, have been moved to the
SentryOptions
class and replaced:captureFailedRequests
replaced withSentryOptions#captureFailedRequests
.sendDefaultPii
replaced withSentryOptions#sendDefaultPii
.maxRequestBodySize
replaced withSentryOptions#maxRequestBodySize
.networkTracing
replaced withSentryOptions#tracesSampleRate
orSentryOptions#tracesSampler
.recordBreadcrumbs
replaced withSentryOptions#recordHttpBreadcrumbs
.
- The following
SentryMeasurementUnits
are now strongly typed:DurationSentryMeasurementUnit
InformationSentryMeasurementUnit
FractionSentryMeasurementUnit
CustomSentryMeasurementUnit
NoneSentryMeasurementUnit
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
captureFailedRequests
feature is now enabled by default. - The
enableStructuredDataTracing
feature is now enabled by default. - The
enableUserInteractionTracing
feature is now enabled by default.
SentryOptions#sendClientReports
is 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.user
setter was deprecated in favor ofScope.setUser
, and it will be removed in a future update.The
Scope.attachements
getter was deprecated in favor ofattachments
, and it will be removed in a future update.The following
Scope
methods now returnFuture<void>
instead ofvoid
:setContexts
removeContexts
setUser
addBreadcrumb
clearBreadcrumbs
setExtra
removeExtra
setTag
removeTag
- Starting with version
6.6.0
ofsentry
, Sentry's version >= v21.9.0 is required or you have to manually disable sending client reports via thesendClientReports
option. This only applies to self-hosted Sentry. If you are using sentry.io, no action is needed.
Sentry.currentHub
was removed. Please use the static methods onSentry
SentryOptions.cacheDirSize
was renamed toSentryOptions.maxCacheItems
EventProcessor
was changed from a callback to an interface- The data type from the following options was changed from
int
toDuration
. The old options are still present but deprecated and will be removed in a future version.SentryOptions.autoSessionTrackingIntervalMillis
toSentryOptions.autoSessionTrackingInterval
SentryOptions.anrTimeoutIntervalMillis
toSentryOptions.anrTimeoutInterval
- The
beforeSend
callback 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.0
of 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
->SentryApp
Browser
->SentryBrowser
Device
->SentryDevice
Gpu
->SentryGpu
Integration
->SentryIntegration
Message
->SentryMessage
OperatingSystem
->SentryOperatingSystem
Orientation
->SentryOrientation
Request
->SentryRequest
User
->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 fromvoid
toFuture<void>
andIntegration.close()
changed fromvoid
toFutureOr<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").