---
title: "View Hierarchy"
description: "Learn more about debugging the view hierarchy when an error occurs. Sentry pairs the view hierarchy representation with the original event, giving you additional insight into issues."
url: https://docs.sentry.io/platforms/apple/guides/visionos/enriching-events/viewhierarchy/
---

# View Hierarchy | Sentry for visionOS

Sentry makes it possible to render a JSON representation of the view hierarchy of an error and includes it as an [attachment](https://docs.sentry.io/platforms/apple/guides/visionos/enriching-events/attachments.md).

This feature only applies to SDKs with a user interface, such as the ones for mobile and desktop applications. In some environments like native iOS, rendering the view hierarchy requires the UI thread and in the event of a crash, that might not be available. Another example where the view hierarchy might not be available is when the event happens before the screen starts to load. So inherently, this feature is a best effort solution.

App hang events will not have view hierarchy because the main thread is blocked and Sentry can't interact with UI elements in a background view.

Deobfuscation for view hierarchies is fully supported for native SDKs, and React Native, but is currently not supported for Flutter. View hierarchies are not supported for SwiftUI.

## [Enabling View Hierarchy Attachments](https://docs.sentry.io/platforms/apple/guides/visionos/enriching-events/viewhierarchy.md#enabling-view-hierarchy-attachments)

View hierarchy debugging is an opt-in feature. You can enable it as shown below:

```swift
import Sentry

SentrySDK.start { options in
  options.attachViewHierarchy = true
}
```

### [Customize View Hierarchy Capturing](https://docs.sentry.io/platforms/apple/guides/visionos/enriching-events/viewhierarchy.md#customize-view-hierarchy-capturing)

Requires Cocoa SDK version `8.33.0` or higher.

The `beforeCaptureViewHierarchy` also allows you to customize the behavior based on event data, so you can decide when to capture a view hierarchy and when not to. The callback doesn't work for crash events.

```swift
import Sentry

SentrySDK.start { options in
    options.dsn = "___PUBLIC_DSN___"
    options.beforeCaptureViewHierarchy = { event in
        // Return false to not capture a view hierarchy for the event.
        return false
    }
}
```

## [Privacy In View Hierarchy Attachments](https://docs.sentry.io/platforms/apple/guides/visionos/enriching-events/viewhierarchy.md#privacy-in-view-hierarchy-attachments)

Sentry doesn't collect any user information (such as UILabel and UITextView text) with the view hierarchy attachment, which only contains structure and properties.

If you're using the view's `accessibilityIdentifier` property with personal information, make sure to disable `accessibilityIdentifier` reporting like in the example below:

```swift
import Sentry
SentrySDK.start { options in
  options.attachViewHierarchy = true
  options.reportAccessibilityIdentifier = false
}
```

## [Viewing View Hierarchy Attachments](https://docs.sentry.io/platforms/apple/guides/visionos/enriching-events/viewhierarchy.md#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](https://docs.sentry.io/product/issues/issue-details.md) page of that specific event.

On the **Issue Details** page, you can interact with the view hierarchy attachment in a section called "View Hierarchy". This section represents the state of your application at the time of an error event. There are three displays: a tree view, wireframe, and detailed view for a selected node. You can select nodes in either the tree or the wireframe to view the properties collected by the SDK. The SDK will report on the following keys for each node in the view: `alpha`, `visible`, `x`, `y`, `width`, `height`, `type`, and `identifier` if applicable, but there may be additional values specific to the SDK. This feature can be used as an exploratory tool to debug layout issues, visualize unnecessarily rendered content, or gain a better understanding of the relationship between views.
