Skip to content

fix(unity): update SentryEvent to have IsCaptured to allow dropping screenshots of filtered events#5162

Merged
JoshuaMoelans merged 4 commits intomainfrom
joshua/fix/unity_screenshot_handling
Apr 28, 2026
Merged

fix(unity): update SentryEvent to have IsCaptured to allow dropping screenshots of filtered events#5162
JoshuaMoelans merged 4 commits intomainfrom
joshua/fix/unity_screenshot_handling

Conversation

@JoshuaMoelans
Copy link
Copy Markdown
Member

As suggested in getsentry/sentry-unity#2642 , we add a flag so we can read from it during the CaptureScreenshotCoroutine. We gate it behind #if SENTRY_UNITY to not expose it for the other .NET SDK consumers.


As described in the 'Future Ideas' section of the unity PR, at some point we might want to provide sentry-unity with a wrapper ISentryClient which can overwrite methods, to avoid needing changes in .NET for unity specific stuff like we need to do in this PR.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 74.06%. Comparing base (cd3f966) to head (75f83b8).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5162   +/-   ##
=======================================
  Coverage   74.05%   74.06%           
=======================================
  Files         501      501           
  Lines       18111    18113    +2     
  Branches     3521     3521           
=======================================
+ Hits        13413    13415    +2     
  Misses       3838     3838           
  Partials      860      860           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/Sentry/SentryClient.cs Outdated
Comment thread src/Sentry/SentryClient.cs Outdated
Comment thread src/Sentry/Platforms/Unity/SentryEvent.Unity.cs
Comment thread src/Sentry/Platforms/Unity/SentryEvent.Unity.cs Outdated
@Flash0ver Flash0ver marked this pull request as ready for review April 23, 2026 15:35
@JoshuaMoelans JoshuaMoelans changed the title fix(unity): update SentryEvent to have WasCaptured to allow dropping screenshots of filtered events fix(unity): update SentryEvent to have IsCaptured to allow dropping screenshots of filtered events Apr 24, 2026
Comment on lines +416 to +418
#if SENTRY_UNITY
@event.IsCaptured = true; // See SentryEvent.Unity.cs for more details.
#endif
Copy link
Copy Markdown
Member

@Flash0ver Flash0ver Apr 27, 2026

Choose a reason for hiding this comment

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

@jamescrosswell is this "pattern" alright?

(adding a member via src/Sentry/Platforms/Unity/SentryEvent.Unity.cs partial type,
and using it here conditionally)

Copy link
Copy Markdown
Collaborator

@jamescrosswell jamescrosswell Apr 27, 2026

Choose a reason for hiding this comment

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

It's nice and simple. The only alternative I can think of is that Unity could register a UnityEventProcessor that did this... I'm not sure that's easier to read/maintain though unless Unity starts to do quite complex special processing of these events.

Copy link
Copy Markdown
Member

@Flash0ver Flash0ver Apr 28, 2026

Choose a reason for hiding this comment

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

I'm not quite positive that this would work reliably, as there might be

  • other Event-Processors dropping the Event
  • a user's Before-Send dropping the Event
  • Sampling of the Event
  • the Backpressure-Monitor influencing the Sampling decision
  • or the Background-Worker's queue being full

sentry-unity might provide it's own ISentryClient though, which is

  • wrapping the default sentry-unity SentryClient
  • wrapping a potential user client (SentrySdk.BindClient(ISentryClient))
  • attaching "fused" data to SentryEvent

So that it's a 100 % sentry-unity-owned solution.

See also getsentry/sentry-unity#2642: "Future Ideas"

Copy link
Copy Markdown
Collaborator

@jamescrosswell jamescrosswell left a comment

Choose a reason for hiding this comment

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

LGTM

@JoshuaMoelans JoshuaMoelans merged commit a2318ff into main Apr 28, 2026
46 checks passed
@JoshuaMoelans JoshuaMoelans deleted the joshua/fix/unity_screenshot_handling branch April 28, 2026 08:10
jamescrosswell pushed a commit that referenced this pull request Apr 30, 2026
…ng screenshots of filtered events (#5162)

* Update SentryEvent to have WasCaptured on Unity

* Format code

* apply suggestions from code review

---------

Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io>
evgenygunko pushed a commit to evgenygunko/CopyWordsDA that referenced this pull request May 6, 2026
This PR contains the following updates:

| Package | Type | Update | Change |
|---|---|---|---|
| [Sentry.Maui](https://sentry.io/) ([source](https://github.com/getsentry/sentry-dotnet)) | nuget | minor | `6.4.1` -> `6.5.0` |

---

### Release Notes

<details>
<summary>getsentry/sentry-dotnet (Sentry.Maui)</summary>

### [`v6.5.0`](https://github.com/getsentry/sentry-dotnet/blob/HEAD/CHANGELOG.md#650)

[Compare Source](getsentry/sentry-dotnet@6.4.1...6.5.0)

##### Features ✨

-   feat: Add support to send OTEL traces via OTLP by [@&#8203;jamescrosswell](https://github.com/jamescrosswell) in [#&#8203;4899](getsentry/sentry-dotnet#4899)

##### Fixes 🐛

-   fix(unity): update `SentryEvent` to have `IsCaptured` to allow dropping screenshots of filtered events by [@&#8203;JoshuaMoelans](https://github.com/JoshuaMoelans) in [#&#8203;5162](getsentry/sentry-dotnet#5162)
-   fix: Memory leak when filtered Activities get garbage collected before `PruneFilteredSpans` runs by [@&#8203;jamescrosswell](https://github.com/jamescrosswell) in [#&#8203;5186](getsentry/sentry-dotnet#5186)

##### Dependencies ⬆️

##### Deps

-   chore(deps): update Cocoa SDK to v9.12.0 by [@&#8203;github-actions](https://github.com/github-actions) in [#&#8203;5179](getsentry/sentry-dotnet#5179)
-   chore(deps): update CLI to v3.4.1 by [@&#8203;github-actions](https://github.com/github-actions) in [#&#8203;5171](getsentry/sentry-dotnet#5171)
-   chore(deps): update Native SDK to v0.13.8 by [@&#8203;github-actions](https://github.com/github-actions) in [#&#8203;5165](getsentry/sentry-dotnet#5165)
-   chore(deps): update Java SDK to v8.40.0 by [@&#8203;github-actions](https://github.com/github-actions) in [#&#8203;5161](getsentry/sentry-dotnet#5161)
-   chore(deps): update Cocoa SDK to v9.11.0 by [@&#8203;github-actions](https://github.com/github-actions) in [#&#8203;5160](getsentry/sentry-dotnet#5160)
-   chore(deps): update CLI to v3.4.0 by [@&#8203;github-actions](https://github.com/github-actions) in [#&#8203;5145](getsentry/sentry-dotnet#5145)
-   chore(deps): update Java SDK to v8.39.1 by [@&#8203;github-actions](https://github.com/github-actions) in [#&#8203;5144](getsentry/sentry-dotnet#5144)

##### Other

-   perf(logs): avoid string allocation when no parameters are passed by [@&#8203;Flash0ver](https://github.com/Flash0ver) in [#&#8203;4697](getsentry/sentry-dotnet#4697)
-   chore: fix missing skill by [@&#8203;jamescrosswell](https://github.com/jamescrosswell) in [#&#8203;5134](getsentry/sentry-dotnet#5134)

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined).

🚦 *...
gunndabad added a commit to DFE-Digital/teaching-record-system that referenced this pull request May 6, 2026
Updated [Sentry.AspNetCore](https://github.com/getsentry/sentry-dotnet)
from 6.4.1 to 6.5.0.

<details>
<summary>Release notes</summary>

_Sourced from [Sentry.AspNetCore's
releases](https://github.com/getsentry/sentry-dotnet/releases)._

## 6.5.0

### Features ✨

- feat: Add support to send OTEL traces via OTLP by @​jamescrosswell in
[#​4899](getsentry/sentry-dotnet#4899)

### Fixes 🐛

- fix(unity): update `SentryEvent` to have `IsCaptured` to allow
dropping screenshots of filtered events by @​JoshuaMoelans in
[#​5162](getsentry/sentry-dotnet#5162)
- fix: Memory leak when filtered Activities get garbage collected before
`PruneFilteredSpans` runs by @​jamescrosswell in
[#​5186](getsentry/sentry-dotnet#5186)

### Dependencies ⬆️

#### Deps

- chore(deps): update Cocoa SDK to v9.12.0 by @​github-actions in
[#​5179](getsentry/sentry-dotnet#5179)
- chore(deps): update CLI to v3.4.1 by @​github-actions in
[#​5171](getsentry/sentry-dotnet#5171)
- chore(deps): update Native SDK to v0.13.8 by @​github-actions in
[#​5165](getsentry/sentry-dotnet#5165)
- chore(deps): update Java SDK to v8.40.0 by @​github-actions in
[#​5161](getsentry/sentry-dotnet#5161)
- chore(deps): update Cocoa SDK to v9.11.0 by @​github-actions in
[#​5160](getsentry/sentry-dotnet#5160)
- chore(deps): update CLI to v3.4.0 by @​github-actions in
[#​5145](getsentry/sentry-dotnet#5145)
- chore(deps): update Java SDK to v8.39.1 by @​github-actions in
[#​5144](getsentry/sentry-dotnet#5144)

### Other

- perf(logs): avoid string allocation when no parameters are passed by
@​Flash0ver in
[#​4697](getsentry/sentry-dotnet#4697)
- chore: fix missing skill by @​jamescrosswell in
[#​5134](getsentry/sentry-dotnet#5134)

Commits viewable in [compare
view](getsentry/sentry-dotnet@6.4.1...6.5.0).
</details>

Updated
[Sentry.Extensions.Logging](https://github.com/getsentry/sentry-dotnet)
from 6.4.1 to 6.5.0.

<details>
<summary>Release notes</summary>

_Sourced from [Sentry.Extensions.Logging's
releases](https://github.com/getsentry/sentry-dotnet/releases)._

## 6.5.0

### Features ✨

- feat: Add support to send OTEL traces via OTLP by @​jamescrosswell in
[#​4899](getsentry/sentry-dotnet#4899)

### Fixes 🐛

- fix(unity): update `SentryEvent` to have `IsCaptured` to allow
dropping screenshots of filtered events by @​JoshuaMoelans in
[#​5162](getsentry/sentry-dotnet#5162)
- fix: Memory leak when filtered Activities get garbage collected before
`PruneFilteredSpans` runs by @​jamescrosswell in
[#​5186](getsentry/sentry-dotnet#5186)

### Dependencies ⬆️

#### Deps

- chore(deps): update Cocoa SDK to v9.12.0 by @​github-actions in
[#​5179](getsentry/sentry-dotnet#5179)
- chore(deps): update CLI to v3.4.1 by @​github-actions in
[#​5171](getsentry/sentry-dotnet#5171)
- chore(deps): update Native SDK to v0.13.8 by @​github-actions in
[#​5165](getsentry/sentry-dotnet#5165)
- chore(deps): update Java SDK to v8.40.0 by @​github-actions in
[#​5161](getsentry/sentry-dotnet#5161)
- chore(deps): update Cocoa SDK to v9.11.0 by @​github-actions in
[#​5160](getsentry/sentry-dotnet#5160)
- chore(deps): update CLI to v3.4.0 by @​github-actions in
[#​5145](getsentry/sentry-dotnet#5145)
- chore(deps): update Java SDK to v8.39.1 by @​github-actions in
[#​5144](getsentry/sentry-dotnet#5144)

### Other

- perf(logs): avoid string allocation when no parameters are passed by
@​Flash0ver in
[#​4697](getsentry/sentry-dotnet#4697)
- chore: fix missing skill by @​jamescrosswell in
[#​5134](getsentry/sentry-dotnet#5134)

Commits viewable in [compare
view](getsentry/sentry-dotnet@6.4.1...6.5.0).
</details>

Dependabot will resolve any conflicts with this PR as long as you don't
alter it yourself. You can also trigger a rebase manually by commenting
`@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits
that have been made to it
- `@dependabot show <dependency name> ignore conditions` will show all
of the ignore conditions of the specified dependency
- `@dependabot ignore <dependency name> major version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's major version (unless you unignore this specific
dependency's major version or upgrade to it yourself)
- `@dependabot ignore <dependency name> minor version` will close this
group update PR and stop Dependabot creating any more for the specific
dependency's minor version (unless you unignore this specific
dependency's minor version or upgrade to it yourself)
- `@dependabot ignore <dependency name>` will close this group update PR
and stop Dependabot creating any more for the specific dependency
(unless you unignore this specific dependency or upgrade to it yourself)
- `@dependabot unignore <dependency name>` will remove all of the ignore
conditions of the specified dependency
- `@dependabot unignore <dependency name> <ignore condition>` will
remove the ignore condition of the specified dependency and ignore
conditions


</details>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: James Gunn <james@gunn.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants