Skip to content

Commit f617617

Browse files
committed
document for viewHierarchy
1 parent 7f31615 commit f617617

File tree

1 file changed

+26
-0
lines changed
  • docs/platforms/flutter/enriching-events/viewhierarchy

1 file changed

+26
-0
lines changed

docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,32 @@ View hierarchy debugging is an opt-in feature. You can enable it as shown below:
2121

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

24+
### Customize View Hierarchy Capturing
25+
26+
<Note>
27+
28+
Requires SDK version `8.12.0` or higher.
29+
30+
</Note>
31+
32+
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`.
33+
34+
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:
35+
36+
```java
37+
await SentryFlutter.init((options) {
38+
options.attachViewHierarchy = true;
39+
options.beforeCaptureViewHierarchy = (event, hint, debounce) async {
40+
// If debounce is active, skip capturing
41+
if (debounce) {
42+
return false;
43+
}
44+
// Capture if it's a fatal event
45+
return event.level == SentryLevel.fatal;
46+
};
47+
});
48+
```
49+
2450
## Viewing View Hierarchy Attachments
2551

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

0 commit comments

Comments
 (0)