Skip to content

Commit 7f31615

Browse files
committed
document debounce ob beforeCaptureScreenshot
1 parent 99016ee commit 7f31615

File tree

1 file changed

+27
-1
lines changed
  • platform-includes/enriching-events/attach-screenshots

1 file changed

+27
-1
lines changed

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

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,32 @@ await SentryFlutter.init(
1313
);
1414
```
1515

16+
### Customize Screenshot Capturing
17+
18+
<Note>
19+
20+
Requires SDK version `8.11.0` or higher.
21+
22+
</Note>
23+
24+
Because capturing screenshots can be a resource-intensive operation on Flutter, it's limited to one screenshot every 2 seconds using a debouncing mechanism. This behavior can be overruled if you supply a `BeforeCaptureCallback` for screenshots in the `SentryFlutterOptions`.
25+
26+
The `BeforeCaptureCallback` also allows you to customize the behavior based on event data, so you can decide when to capture a screenshot and when not to. For example, you can decide to only capture screenshots of fatal events:
27+
28+
```java
29+
await SentryFlutter.init((options) {
30+
options.attachScreenshot = true;
31+
options.beforeCaptureScreenshot = (event, hint, debounce) async {
32+
// If debounce is active, skip capturing
33+
if (debounce) {
34+
return false;
35+
}
36+
// Capture if it's a fatal event
37+
return event.level == SentryLevel.fatal;
38+
};
39+
});
40+
```
41+
1642
## Redact Screenshots via `masking`
1743

1844
The masking feature is by default disabled for Screenshots. To enable masking, use the `options.experimental.privacy` parameter.
@@ -26,7 +52,7 @@ The masking feature is by default disabled for Screenshots. To enable masking, u
2652

2753
## Filtering Screenshots
2854

29-
You can filter your screenshots by using the `beforeScreenshot` callback, which is called before attaching a screenshot to an event. By default, the callback returns `true` which means that all screenshots are attached.
55+
You can filter your screenshots by using the `beforeCaptureScreenshot` callback, which is called before attaching a screenshot to an event. By default, the callback returns `true` which means that all screenshots are attached.
3056

3157
If the callback returns `false`, the screenshot will not be attached.
3258

0 commit comments

Comments
 (0)