-
-
Notifications
You must be signed in to change notification settings - Fork 56
Open
Labels
Description
What problem could Sentry solve that it doesn't?
Current Issue
The Unity SDK currently provides two BeforeCapture callbacks that have limited functionality:
- Screenshots:
internal Func<bool>? BeforeCaptureScreenshotInternal => _beforeCaptureScreenshot; - ViewHierarchy:
internal Func<bool>? BeforeCaptureViewHierarchyInternal => _beforeCaptureViewHierarchy;
Both callbacks share the same limitations:
- No arguments are passed to the callback function
- Only return a bool (capture or don't capture)
- Cannot access the current event context that triggered the capture
- Cannot modify the captured data
This design makes these callbacks minimally useful since users cannot make informed decisions about whether to capture data or modify it based on the actual content or event context.
Proposed Solutions
Screenshots: Change to BeforeSendScreenshot
Since screenshots are now being sent as standalone attachments (see #2240), the callback should be changed to BeforeSendScreenshot with the following improvements:
- Input: Pass the captured screenshot as Texture2D or byte[]
- Output: Allow returning modified byte[] or null to discard
- Benefits:
- Users can blur sensitive areas or redact PII
- Content-based filtering (skip blank/corrupted screenshots)
- Image processing (resize, compress, watermark)
ViewHierarchy: Change to BeforeAttachViewHierarchy
For view hierarchy capture, the callback should occur after capture but before attachment to allow data modification:
- Current flow: Capture → BeforeSend (modification is cumbersome)
hint.AddAttachment(CaptureViewHierarchy(), "view-hierarchy.json", AttachmentType.ViewHierarchy, "application/json"); - Proposed flow: Capture → BeforeAttachViewHierarchy → Add to hint
- Input: Pass the captured view hierarchy data as byte[]
- Output: Allow returning modified byte[] or null to discard
- Benefits:
- Easier data modification compared to processing in BeforeSend
- Can filter sensitive UI elements
- Can reduce hierarchy size based on content
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
No status