Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(flutter): Document beforeCapture function customization #12190

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 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,32 @@ 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.12.0` or higher.

</Note>

Because capturing view hierarchy can be a resource-intensive operation on Flutter, it's limited to one view hierarchy every 2 seconds using a debouncing mechanism. This behavior can be overruled if you supply a `BeforeCaptureCallback` for view hierarchies in the `SentryFlutterOptions`.

The `BeforeCaptureCallback` also 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:

```java
await SentryFlutter.init((options) {
options.attachViewHierarchy = true;
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,32 @@ await SentryFlutter.init(
);
```

### Customize Screenshot Capturing

<Note>

Requires SDK version `8.11.0` or higher.

</Note>

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

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:

```java
await SentryFlutter.init((options) {
options.attachScreenshot = true;
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 +52,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
Loading