Skip to content

fix: Setting the ViewHierarchy attachmentType #2036

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 3 commits into from
Feb 25, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Fixes

- Resolved an issue where the SDK would not properly annotate the ViewHierarchy's `AttachmentType`. This would cause it to not render properly on the issues-page on Sentry ([#2036](https://github.com/getsentry/sentry-unity/pull/2036))
- The SDK now ensures that the correct version of the Android SDK gets used during the build. This prevents dependency conflicts and no longer requires "clean" builds to resolve ([#2031](https://github.com/getsentry/sentry-unity/pull/2031))

### Dependencies
Expand Down
2 changes: 1 addition & 1 deletion src/Sentry.Unity/ViewHierarchyEventProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public ViewHierarchyEventProcessor(SentryUnityOptions sentryOptions)

if (_options.BeforeCaptureViewHierarchyInternal?.Invoke() is not false)
{
hint.AddAttachment(CaptureViewHierarchy(), "view-hierarchy.json", contentType: "application/json");
hint.AddAttachment(CaptureViewHierarchy(), "view-hierarchy.json", AttachmentType.ViewHierarchy, "application/json");
}
else
{
Expand Down
2 changes: 2 additions & 0 deletions test/Sentry.Unity.Tests/ViewHierarchyEventProcessorTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.IO;
using System.Linq;
using System.Threading;
using NUnit.Framework;
using UnityEngine;
Expand Down Expand Up @@ -39,6 +40,7 @@ public void Process_IsMainThread_AddsViewHierarchyToHint()
sut.Process(sentryEvent, hint);

Assert.AreEqual(1, hint.Attachments.Count);
Assert.AreEqual(AttachmentType.ViewHierarchy, hint.Attachments.First().Type);
}

[Test]
Expand Down