Skip to content

feat(godot): Enriching events with scene tree data #13531

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

Merged
merged 7 commits into from
May 2, 2025
Merged
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
6 changes: 6 additions & 0 deletions docs/platforms/godot/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ If enabled, the SDK will try to take a screenshot and attach it to the event.

</ConfigKey>

<ConfigKey name="attach-scene-tree">

If enabled, the SDK will capture and attach scene tree information to events. The scene tree data is attached as a `view-hierarchy.json` file, and you can explore it in the "Scene Tree" section of each issue that includes this attachment. This provides valuable context about your game's scene tree at the time of the error. See <PlatformLink to="/enriching-events/view-hierarchy/">Scene Tree</PlatformLink> for more details.

</ConfigKey>

## Error Logger Options

<ConfigKey name="logger-enabled">
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
44 changes: 44 additions & 0 deletions docs/platforms/godot/enriching-events/view-hierarchy/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
---
title: "Scene Tree"
description: "Learn more about capturing scene tree data during errors and crashes. Sentry provides a visual representation of your game's scene tree at the time of failure, giving you additional insight into issues."
---

Sentry captures a JSON representation of engine's scene tree during errors and crashes, adding it to the event as an attachment. This feature is also known as View Hierarchy in Sentry.

<Alert title="Note">

This process can only be performed on the main thread, which means it may not be available during events that happen on threads other than the main thread. Additionally, if an error occurs before the scene tree is initialized, this information cannot be captured. Inherently, this feature should be considered a best-effort solution.

</Alert>

## Enabling Scene Tree Attachments

Scene tree capturing is an opt-in feature. To attach scene tree information to your events, navigate to **Project Settings > Sentry > Options** and enable the **Attach Scene Tree** option:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the scene contain sensitive data? I wonder why we don't make this enable by default everywhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bruno-garcia I was thinking the same. The risk of sensitive data is very low IMO. We mostly include node names, classes, script file local paths within project.


![Project Settings Screenshot](./img/project-settings.png)

Or, like so, if you're <PlatformLink to="/configuration/options/">configuring things programmatically</PlatformLink>:

```GDScript
extends SentryConfiguration

func _configure(options: SentryOptions):
options.attach_scene_tree = true
```

## Viewing Scene Tree Attachments

Scene tree information is attached as `view-hierarchy.json` file. You can find it 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.

<Include name="common-imgs/viewhierarchy-list-example" />

On the **Issue Details** page, you can interact with the scene tree attachment in a section called "Scene Tree". This section represents the state of your scene tree at the time of an error event. There are two displays: a tree view, and detailed view for a selected node. You can select nodes in the tree to view the properties collected by the SDK. The SDK will report on the following keys for each node in the view:

- `name`: The name of the node.
- `class`: Built-in class of the node.
- `script`: The file path of the script attached to the node. Only nodes with a script attached include this property.
- `scene`: The original scene's file path, if the node has been instantiated from a PackedScene file. Only scene root nodes include this property.

This feature provides a snapshot of your game's scene tree structure at the moment of error, making it easier to identify which nodes were active or gain a better understanding of the relationship between the nodes.

![Scene Tree Example](./img/scene-tree-example.png)