fix(unity): update SentryEvent to have IsCaptured to allow dropping screenshots of filtered events#5162
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
….com/getsentry/sentry-dotnet into joshua/fix/unity_screenshot_handling
SentryEvent to have WasCaptured to allow dropping screenshots of filtered eventsSentryEvent to have IsCaptured to allow dropping screenshots of filtered events
| #if SENTRY_UNITY | ||
| @event.IsCaptured = true; // See SentryEvent.Unity.cs for more details. | ||
| #endif |
There was a problem hiding this comment.
@jamescrosswell is this "pattern" alright?
(adding a member via src/Sentry/Platforms/Unity/SentryEvent.Unity.cs partial type,
and using it here conditionally)
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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-unitySentryClient - 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"
…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>
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 [@​jamescrosswell](https://github.com/jamescrosswell) in [#​4899](getsentry/sentry-dotnet#4899) ##### Fixes 🐛 - fix(unity): update `SentryEvent` to have `IsCaptured` to allow dropping screenshots of filtered events by [@​JoshuaMoelans](https://github.com/JoshuaMoelans) in [#​5162](getsentry/sentry-dotnet#5162) - fix: Memory leak when filtered Activities get garbage collected before `PruneFilteredSpans` runs by [@​jamescrosswell](https://github.com/jamescrosswell) in [#​5186](getsentry/sentry-dotnet#5186) ##### Dependencies ⬆️ ##### Deps - chore(deps): update Cocoa SDK to v9.12.0 by [@​github-actions](https://github.com/github-actions) in [#​5179](getsentry/sentry-dotnet#5179) - chore(deps): update CLI to v3.4.1 by [@​github-actions](https://github.com/github-actions) in [#​5171](getsentry/sentry-dotnet#5171) - chore(deps): update Native SDK to v0.13.8 by [@​github-actions](https://github.com/github-actions) in [#​5165](getsentry/sentry-dotnet#5165) - chore(deps): update Java SDK to v8.40.0 by [@​github-actions](https://github.com/github-actions) in [#​5161](getsentry/sentry-dotnet#5161) - chore(deps): update Cocoa SDK to v9.11.0 by [@​github-actions](https://github.com/github-actions) in [#​5160](getsentry/sentry-dotnet#5160) - chore(deps): update CLI to v3.4.0 by [@​github-actions](https://github.com/github-actions) in [#​5145](getsentry/sentry-dotnet#5145) - chore(deps): update Java SDK to v8.39.1 by [@​github-actions](https://github.com/github-actions) in [#​5144](getsentry/sentry-dotnet#5144) ##### Other - perf(logs): avoid string allocation when no parameters are passed by [@​Flash0ver](https://github.com/Flash0ver) in [#​4697](getsentry/sentry-dotnet#4697) - chore: fix missing skill by [@​jamescrosswell](https://github.com/jamescrosswell) in [#​5134](getsentry/sentry-dotnet#5134) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 *...
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>
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_UNITYto 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
ISentryClientwhich can overwrite methods, to avoid needing changes in .NET for unity specific stuff like we need to do in this PR.