Skip to content

Commit 69bd829

Browse files
authored
docs(flutter): Use sentry flutter init in samples (#11858)
1 parent 4792cc9 commit 69bd829

File tree

42 files changed

+351
-365
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+351
-365
lines changed

docs/platforms/dart/integrations/dio.mdx

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,10 @@ final response = await dio.get<String>('https://wrong-url.dev/');
5858
This is an opt-out feature. The following example shows how to disable it:
5959

6060

61-
```dart
62-
import 'package:sentry/sentry.dart';
63-
64-
Future<void> main() async {
65-
await Sentry.init(
66-
(options) {
67-
options.dsn = '___PUBLIC_DSN___';
68-
options.captureFailedRequests = false;
69-
},
70-
appRunner: initApp, // Init your App.
71-
);
72-
}
61+
```dart {2}
62+
await Sentry.init((options) {
63+
options.captureFailedRequests = false;
64+
});
7365
```
7466

7567
## Tracing for HTTP Requests

docs/platforms/flutter/session-replay/index.mdx

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,11 @@ dependencies:
3434
To set up the integration, add the following to your Sentry initialization:
3535
3636
```dart
37-
await SentryFlutter.init(
38-
(options) {
39-
...
40-
options.experimental.replay.sessionSampleRate = 1.0;
41-
options.experimental.replay.onErrorSampleRate = 1.0;
42-
},
43-
appRunner: () => runApp(MyApp()),
44-
);
37+
await SentryFlutter.init((options) {
38+
...
39+
options.experimental.replay.sessionSampleRate = 1.0;
40+
options.experimental.replay.onErrorSampleRate = 1.0;
41+
});
4542
```
4643

4744
## Verify
Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
1-
```dart
2-
import 'package:sentry/sentry.dart';
3-
4-
Future<void> main() async {
5-
await Sentry.init(
6-
(options) {
7-
options.dsn = '___PUBLIC_DSN___';
8-
options.allowUrls = ["^https://sentry.com.*\$", "my-custom-domain"];
9-
},
10-
appRunner: initApp, // Init your App.
11-
);
12-
}
1+
```dart {2}
2+
await Sentry.init((options) {
3+
options.allowUrls = ["^https://sentry.com.*\$", "my-custom-domain"];
4+
});
135
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
```dart {2}
2+
await SentryFlutter.init((options) {
3+
options.allowUrls = ["^https://sentry.com.*\$", "my-custom-domain"];
4+
});
5+
```
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
```dart
2-
import 'package:sentry/sentry.dart';
3-
4-
Breadcrumb? beforeBreadcrumb(Breadcrumb? breadcrumb, Hint hint) {
5-
return hint is MyHint ? null : crumb;
6-
}
7-
8-
Future<void> main() async {
9-
await Sentry.init((options) => options.beforeBreadcrumb = beforeBreadcrumb);
10-
}
1+
```dart {3}
2+
await Sentry.init((options) {
3+
options.beforeBreadcrumb = (breadcrumb, hint) {
4+
return hint is MyHint ? null : crumb;
5+
};
6+
});
117
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```dart {3}
2+
await SentryFlutter.init((options) {
3+
options.beforeBreadcrumb = (breadcrumb, hint) {
4+
return hint is MyHint ? null : crumb;
5+
};
6+
});
7+
```
Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
```dart
2-
import 'package:sentry/sentry.dart';
3-
4-
FutureOr<SentryEvent?> beforeSend(SentryEvent event, Hint hint) async {
5-
if (event.throwable is DatabaseException) {
6-
event = event.copyWith(fingerprint: ['database-connection-error']);
7-
}
8-
return event;
9-
}
10-
11-
Future<void> main() async {
12-
await Sentry.init((options) => options.beforeSend = beforeSend);
13-
}
1+
```dart {3-6}
2+
await Sentry.init((options) {
3+
options.beforeSend = (event, hint) {
4+
if (event.throwable is DatabaseException) {
5+
event = event.copyWith(fingerprint: ['database-connection-error']);
6+
}
7+
return event;
8+
};
9+
});
1410
```
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
```dart {3-6}
2+
await SentryFlutter.init((options) {
3+
options.beforeSend = (event, hint) {
4+
if (event.throwable is DatabaseException) {
5+
event = event.copyWith(fingerprint: ['database-connection-error']);
6+
}
7+
return event;
8+
};
9+
});
10+
```
Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
```dart
2-
import 'package:sentry/sentry.dart';
3-
4-
FutureOr<SentryEvent?> beforeSend(SentryEvent event, Hint hint) async {
5-
return hint is MyHint ? null : event;
6-
}
7-
8-
Future<void> main() async {
9-
await Sentry.init((options) => options.beforeSend = beforeSend);
10-
}
1+
```dart {3}
2+
await Sentry.init((options) {
3+
options.beforeSend = (event, hint) {
4+
return hint is MyHint ? null : event;
5+
};
6+
});
117
```
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
```dart {3}
2+
await SentryFlutter.init((options) {
3+
options.beforeSend = (event, hint) {
4+
return hint is MyHint ? null : event;
5+
};
6+
});
7+
```

0 commit comments

Comments
 (0)