Skip to content

Commit a2b6adc

Browse files
authored
Add filtering to screenshots (#9448)
1 parent f7f3f3d commit a2b6adc

File tree

1 file changed

+30
-0
lines changed
  • platform-includes/enriching-events/attach-screenshots

1 file changed

+30
-0
lines changed

platform-includes/enriching-events/attach-screenshots/flutter.mdx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,33 @@ Future<void> main() async {
1919
);
2020
}
2121
```
22+
23+
### Filtering Screenshots
24+
25+
You can filter your screenshots by using the `beforeScreenshot` callback.
26+
It is called before taking a screenshot and if the callback returns `false`, the screenshot will not be attached.
27+
28+
```dart
29+
import 'package:flutter/widgets.dart';
30+
import 'package:sentry_flutter/sentry_flutter.dart';
31+
32+
Future<void> main() async {
33+
await SentryFlutter.init(
34+
(options) {
35+
options.dsn = '___PUBLIC_DSN___';
36+
options.attachScreenshot = true;
37+
options.beforeScreenshot = (event, {hint}) {
38+
// Return false if you don't want to attach the screenshot based on some condition.
39+
return true;
40+
};
41+
},
42+
appRunner: () => runApp(
43+
// Wrap your app widget with the [SentryWidget] widget.
44+
SentryWidget(
45+
child: MyApp(),
46+
),
47+
),
48+
);
49+
}
50+
```
51+

0 commit comments

Comments
 (0)