sentry-unity
sentry-unity copied to clipboard
Screenshots and View Hierarchy lost with `ClearAttachment`
When calling scope.ClearAttachments()
it also removes the automated screenshot and view hierarchy integrations.
depends on https://github.com/getsentry/sentry-dotnet/issues/1469
We could somehow expose a workaround for now - call the following after ClearAttachments():
SentrySdk.ConfigureScope(s =>
s.AddAttachment(new ScreenshotAttachment(
new ScreenshotAttachmentContent(options, SentryMonoBehaviour.Instance))));
but those are currently internal
Is there any workaround available for this, beyond recompiling new Sentry SDKs to un-mark those those internal classes?
For some wider context: We're clearing and adding attachments because we want to have a [GUID].ext
filename, rather than a common filename, which represents our game state. I don't know how to do that without clearing first.
Also, I'd really love the ability to add attachments in the beforeSend
callback, which feels like a more natural place to pull game state into an outgoing event. That's mentioned in #663
a
[GUID].ext
filename
Are you trying to rename the screenshot or are you referring to your own files you're attaching?
Our own files--we have GUIDs assigned to the block of data that represents the current game state in a turn-based game. Partly this is to make it easier to pick out the right file for issues that end up with multiple events. The combined attachment view for grouped events on the Sentry backend can be a little rough.
I ended up copying the structure of the screenshot attachment class, with a generic filename and the contents being pulled at the time of the event. Would it be possible to add a setter to Attachment.FileName
(here), or otherwise allow a mechanism to change the filename from within the IAttachmentContent.GetStream()
method? That would also work for this specific case.
Also, I'd really love the ability to add attachments in the
beforeSend
callback, which feels like a more natural place to pull game state into an outgoing event. That's mentioned in #663
We agree with the idea to have it be accessible in the beforeSend
and it looks like the way forward will be hints. I think this also would properly resolve the issue and I'll try to move that feature forward.
AFAIK the screenshot name is expected by the frontend to be in one of those formats.
The .NET SDK now supports Hints
so we no longer need to add attachments directly to the scope. And those integrations no longer get lost on ClearScope
.