Skip to content

Commit

Permalink
docs(flutter): Document beforeCapture function customization (#12190)
Browse files Browse the repository at this point in the history
  • Loading branch information
denrase authored Jan 15, 2025
1 parent 4fde9bf commit 2004f78
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
25 changes: 25 additions & 0 deletions docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,31 @@ View hierarchy debugging is an opt-in feature. You can enable it as shown below:

<PlatformContent includePath="enriching-events/attach-viewhierarchy" />

### Customize View Hierarchy Capturing

<Note>

Requires SDK version `8.13.0` or higher.

</Note>

Capturing view hierarchies on Flutter is limited to once every 2 seconds by default to minimize performance impact. While this debounce interval is fixed, you can override individual capture decisions by implementing the `beforeCaptureViewHierarchy` option in your `SentryFlutterOptions`.

The `beforeCaptureViewHierarchy` option allows you to customize behavior based on event data so you can decide when to capture view hierarchy and when not to. For example, you can decide to only capture view hierarchy for fatal events:

```flutter {2-9}
await SentryFlutter.init((options) {
options.beforeCaptureViewHierarchy = (event, hint, debounce) async {
// If debounce is active, skip capturing
if (debounce) {
return false;
}
// Capture if it's a fatal event
return event.level == SentryLevel.fatal;
};
});
```

## Viewing View Hierarchy Attachments

View hierarchies appear in the "Attachments" tab, where you can view all attachments, as well as associated events. Click the event ID to open the [Issue Details](/product/issues/issue-details) page of that specific event.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,31 @@ await SentryFlutter.init(
);
```

### Customize Screenshot Capturing

<Note>

Requires SDK version `8.11.0` or higher.

</Note>

Capturing screenshots on Flutter is limited to once every 2 seconds by default to minimize performance impact. While this debounce interval is fixed, you can override individual capture decisions by implementing the `beforeCaptureScreenshot` option in your `SentryFlutterOptions`.

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:

```flutter {2-9}
await SentryFlutter.init((options) {
options.beforeCaptureScreenshot = (event, hint, debounce) async {
// If debounce is active, skip capturing
if (debounce) {
return false;
}
// Capture if it's a fatal event
return event.level == SentryLevel.fatal;
};
});
```

## Redact Screenshots via `masking`

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

## Filtering Screenshots

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.
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.

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

Expand Down

0 comments on commit 2004f78

Please sign in to comment.