-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Upgrade the Dart/Flutter SDK to v4 (#2599)
- Loading branch information
1 parent
5cb82c1
commit 013c875
Showing
54 changed files
with
515 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
Breadcrumb beforeBreadcrumb(Breadcrumb breadcrumb, dynamic hint) { | ||
return 'a.spammy.Logger' == breadcrumb.category ? null : breadcrumb; | ||
} | ||
Future<void> main() async { | ||
await Sentry.init((options) => options.beforeBreadcrumb = beforeBreadcrumb); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
Sentry.addBreadcrumb(Breadcrumb(message: 'Authenticated user')); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
In Dart you can capture any exception object that you caught: | ||
|
||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
try { | ||
aMethodThatMightFail(); | ||
} catch (exception, stackTrace) { | ||
await Sentry.captureException( | ||
exception, | ||
stackTrace: stackTrace, | ||
); | ||
} | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
await Sentry.captureMessage('Something went wrong'); | ||
``` |
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
src/includes/configuration/auto-session-tracking/flutter.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
```dart | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:sentry_flutter/sentry_flutter.dart'; | ||
Future<void> main() async { | ||
await SentryFlutter.init( | ||
(options) => options.enableAutoSessionTracking = true, // it's enabled by default | ||
() { | ||
// Run your App | ||
runApp(MyApp()); | ||
}, | ||
); | ||
} | ||
``` |
11 changes: 11 additions & 0 deletions
11
src/includes/configuration/before-breadcrumb-hint/dart.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
Breadcrumb beforeBreadcrumb(Breadcrumb crumb, dynamic hint) { | ||
return hint is MyHint ? null : crumb; | ||
} | ||
Future<void> main() async { | ||
await Sentry.init((options) => options.beforeBreadcrumb = beforeBreadcrumb); | ||
} | ||
``` |
14 changes: 14 additions & 0 deletions
14
src/includes/configuration/before-send-fingerprint/dart.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
SentryEvent beforeSend(SentryEvent event, dynamic hint) { | ||
if (event.exception is DatabaseException) { | ||
event = event.copyWith(fingerprint: ['database-connection-error']); | ||
} | ||
return event; | ||
} | ||
Future<void> main() async { | ||
await Sentry.init((options) => options.beforeSend = beforeSend); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
A `BiFunction<SentryEvent, Object, SentryEvent>` can be used to mutate, discard (return null), or return a completely new event. | ||
|
||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
SentryEvent beforeSend(SentryEvent event, dynamic hint) { | ||
return hint is MyHint ? null : event; | ||
} | ||
Future<void> main() async { | ||
await Sentry.init((options) => options.beforeSend = beforeSend); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
A `BiFunction<SentryEvent, Object, SentryEvent>` can be used to mutate, discard (return null), or return a completely new event. | ||
|
||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
SentryEvent beforeSend(SentryEvent event, dynamic hint) { | ||
// Modify the event here: | ||
event = event.copyWith(serverName: null); // Don't send server names. | ||
return event; | ||
} | ||
Future<void> main() async { | ||
await Sentry.init((options) => options.beforeSend = beforeSend); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
Options are passed to the `Sentry.init` method: | ||
|
||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
Future<void> main() async { | ||
await Sentry.init((options) => options | ||
..dsn = '___PUBLIC_DSN___' | ||
..release = 'my-project-name@2.3.12' | ||
..environment = 'staging'); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
Options are passed to the `SentryClient()` class: | ||
Options are passed to the `SentryFlutter.init` method: | ||
|
||
```dart | ||
final sentry = SentryClient( | ||
dsn: '___PUBLIC_DSN___', | ||
environmentAttributes: const Event( | ||
release: 'my-project-name@2.3.12', | ||
environment: 'production', | ||
) | ||
); | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:sentry_flutter/sentry_flutter.dart'; | ||
Future<void> main() async { | ||
await SentryFlutter.init( | ||
(options) => options | ||
..dsn = '___PUBLIC_DSN___' | ||
..release = 'my-project-name@2.3.12' | ||
..environment = 'staging', | ||
() { | ||
// Run your App | ||
runApp(MyApp()); | ||
}, | ||
); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
The Flutter SDK for Android and iOS stores the Sentry events on the device's disk before shutdown. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
Future<void> main() async { | ||
// Capture only 25% of events | ||
await Sentry.init((options) => options.sampleRate = 0.25); | ||
} | ||
``` |
14 changes: 14 additions & 0 deletions
14
src/includes/configuration/session-tracking-interval/flutter.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
```dart | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:sentry_flutter/sentry_flutter.dart'; | ||
Future<void> main() async { | ||
await SentryFlutter.init( | ||
(options) => options.autoSessionTrackingIntervalMillis = 10000, // it's 30000 millis by default | ||
() { | ||
// Run your App | ||
runApp(MyApp()); | ||
}, | ||
); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
Sentry.configureScope((scope) => scope | ||
..setTag('my-tag', 'my value') | ||
..user = User(id: '42', email: 'john.doe@example.com')); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
Future<void> main() async { | ||
await Sentry.init((options) => options.dsn = '___PUBLIC_DSN___'); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
```dart | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:sentry_flutter/sentry_flutter.dart'; | ||
Future<void> main() async { | ||
await SentryFlutter.init( | ||
(options) => options.dsn = '___PUBLIC_DSN___', | ||
() { | ||
// Run your App | ||
runApp(MyApp()); | ||
}, | ||
); | ||
// or define SENTRY_DSN via Dart environment variable (--dart-define) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
```yml {filename:pubspec.yaml} | ||
dependencies: | ||
sentry: ^4.0.0 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
```yml {filename:pubspec.yaml} | ||
dependencies: | ||
sentry_flutter: ^4.0.0 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<Note> | ||
|
||
_Pure Dart SDK used by any Dart application like AngularDart, CLI and Server, it enables reporting messages and errors._ | ||
|
||
</Note> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<Note> | ||
|
||
_Sentry's Flutter SDK enables capturing sessions for Release Health, offline caching as well as reporting messages and errors._ | ||
|
||
_Sentry's Flutter SDK depends on the [Dart SDK](/platforms/dart/) and includes support to native crashes through Sentry's native SDKs (Android and iOS), It'll capture errors in the native layer, including Java, Kotlin, C and C++ code for `Android` and ObjC, Swift and C for `iOS`._ | ||
|
||
</Note> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
try { | ||
aMethodThatMightFail(); | ||
} catch (exception, stackTrace) { | ||
await Sentry.captureException( | ||
exception, | ||
stackTrace: stackTrace, | ||
); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
Sentry.configureScope((scope) => scope.setTag( | ||
'birthday', | ||
checksumOrHash('08/12/1990'), | ||
)); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
Sentry.configureScope((scope) => scope.user = User( | ||
id: clientUser.id, | ||
username: clientUser.username, | ||
)); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
final person = { | ||
'name': 'Mighty Fighter', | ||
'age': '19', | ||
}; | ||
Sentry.configureScope((scope) => scope.setContexts('person', person)); | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
Future<void> main() async { | ||
await Sentry.init((options) => options.environment = 'staging'); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
import 'package:flutter/widgets.dart'; | ||
import 'package:sentry_flutter/sentry_flutter.dart'; | ||
Future<void> main() async { | ||
await SentryFlutter.init( | ||
(options) => options.environment = 'staging', | ||
() { | ||
// Run your App | ||
runApp(MyApp()); | ||
}, | ||
); | ||
// or define SENTRY_ENVIRONMENT via Dart environment variable (--dart-define) | ||
} | ||
final sentry = SentryClient( | ||
environmentAttributes: const Event( | ||
environment: 'production' | ||
) | ||
); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
Sentry.configureScope((scope) => scope.setExtra( | ||
'character.name', | ||
'Mighty Fighter', | ||
)); | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
SentryEvent beforeSend(SentryEvent event, dynamic hint) { | ||
if (event.exception is DatabaseException) { | ||
event = event.copyWith(fingerprint: ['database-connection-error']); | ||
} | ||
return event; | ||
} | ||
Future<void> main() async { | ||
await Sentry.init((options) => options.beforeSend = beforeSend); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
```dart | ||
import 'package:sentry/sentry.dart'; | ||
SentryEvent beforeSend(SentryEvent event, dynamic hint) { | ||
if (event.exception is DatabaseException) { | ||
event = event.copyWith(fingerprint: ['database-connection-error']); | ||
} | ||
return event; | ||
} | ||
Future<void> main() async { | ||
await Sentry.init((options) => options.beforeSend = beforeSend); | ||
} | ||
``` |
Oops, something went wrong.
013c875
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs: