From f617617d0f7d8097a288501c2df8793e43aa064c Mon Sep 17 00:00:00 2001 From: Denis Andrasec Date: Thu, 19 Dec 2024 15:26:32 +0100 Subject: [PATCH] document for viewHierarchy --- .../enriching-events/viewhierarchy/index.mdx | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx b/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx index a16296f3d0f1a..bd7997e070c93 100644 --- a/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx +++ b/docs/platforms/flutter/enriching-events/viewhierarchy/index.mdx @@ -21,6 +21,32 @@ View hierarchy debugging is an opt-in feature. You can enable it as shown below: +### Customize View Hierarchy Capturing + + + +Requires SDK version `8.12.0` or higher. + + + +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.