From 62a759d6256b7a181a7c5b2d5db99995b8acfa38 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Fri, 13 Mar 2026 17:35:43 -0700 Subject: [PATCH 1/2] updated capturefeedback api --- src/Sentry.Unity/SentrySdk.Dotnet.cs | 22 +++++++++++++++++++--- src/Sentry.Unity/SentrySdk.cs | 4 ++-- src/Sentry.Unity/SentryUnitySdk.cs | 6 +++--- test/Sentry.Unity.Tests/Stubs/TestHub.cs | 4 ++-- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/Sentry.Unity/SentrySdk.Dotnet.cs b/src/Sentry.Unity/SentrySdk.Dotnet.cs index 1d82975d9..2539aa3b2 100644 --- a/src/Sentry.Unity/SentrySdk.Dotnet.cs +++ b/src/Sentry.Unity/SentrySdk.Dotnet.cs @@ -315,21 +315,37 @@ public static SentryId CaptureMessage(string message, Action configureSco /// Captures feedback from the user. /// [DebuggerStepThrough] - public static void CaptureFeedback(SentryFeedback feedback, Action configureScope, SentryHint? hint = null) + public static SentryId CaptureFeedback(SentryFeedback feedback, Action configureScope, SentryHint? hint = null) => Sentry.SentrySdk.CaptureFeedback(feedback, configureScope, hint); /// /// Captures feedback from the user. /// [DebuggerStepThrough] - public static void CaptureFeedback(SentryFeedback feedback, Scope? scope = null, SentryHint? hint = null) + public static SentryId CaptureFeedback(SentryFeedback feedback, out CaptureFeedbackResult result, + Action configureScope, SentryHint? hint = null) + => Sentry.SentrySdk.CaptureFeedback(feedback, out result, configureScope, hint); + + /// + /// Captures feedback from the user. + /// + [DebuggerStepThrough] + public static SentryId CaptureFeedback(SentryFeedback feedback, Scope? scope = null, SentryHint? hint = null) => Sentry.SentrySdk.CaptureFeedback(feedback, scope, hint); /// /// Captures feedback from the user. /// [DebuggerStepThrough] - public static void CaptureFeedback(string message, string? contactEmail = null, string? name = null, + public static SentryId CaptureFeedback(SentryFeedback feedback, out CaptureFeedbackResult result, + Scope? scope = null, SentryHint? hint = null) + => Sentry.SentrySdk.CaptureFeedback(feedback, out result, scope, hint); + + /// + /// Captures feedback from the user. + /// + [DebuggerStepThrough] + public static SentryId CaptureFeedback(string message, string? contactEmail = null, string? name = null, string? replayId = null, string? url = null, SentryId? associatedEventId = null, Scope? scope = null, SentryHint? hint = null) => Sentry.SentrySdk.CaptureFeedback(new SentryFeedback(message, contactEmail, name, replayId, url, associatedEventId), diff --git a/src/Sentry.Unity/SentrySdk.cs b/src/Sentry.Unity/SentrySdk.cs index 55cb951bb..38f3b066d 100644 --- a/src/Sentry.Unity/SentrySdk.cs +++ b/src/Sentry.Unity/SentrySdk.cs @@ -106,6 +106,6 @@ public static CrashedLastRun GetLastRunState() /// /// Captures a User Feedback /// - public static void CaptureFeedback(string message, string? email, string? name, bool addScreenshot) => - UnitySdk?.CaptureFeedback(message, email, name, addScreenshot); + public static SentryId CaptureFeedback(string message, string? email, string? name, bool addScreenshot) => + UnitySdk?.CaptureFeedback(message, email, name, addScreenshot) ?? SentryId.Empty; } diff --git a/src/Sentry.Unity/SentryUnitySdk.cs b/src/Sentry.Unity/SentryUnitySdk.cs index 5e957cdec..a00899bac 100644 --- a/src/Sentry.Unity/SentryUnitySdk.cs +++ b/src/Sentry.Unity/SentryUnitySdk.cs @@ -113,12 +113,12 @@ public SentrySdk.CrashedLastRun CrashedLastRun() : SentrySdk.CrashedLastRun.DidNotCrash; } - public void CaptureFeedback(string message, string? email, string? name, bool addScreenshot) + public SentryId CaptureFeedback(string message, string? email, string? name, bool addScreenshot) { if (string.IsNullOrWhiteSpace(message)) { _options.LogError("To submit a feedback, you must provide a message."); - return; + return SentryId.Empty; } SentryHint? hint = null; @@ -150,7 +150,7 @@ public void CaptureFeedback(string message, string? email, string? name, bool ad } } - Sentry.SentrySdk.CurrentHub.CaptureFeedback(message, email, name, hint: hint); + return Sentry.SentrySdk.CurrentHub.CaptureFeedback(message, email, name, hint: hint); } internal static void SetUpWindowsPlayerCaching(SentryUnitySdk unitySdk, SentryUnityOptions options) diff --git a/test/Sentry.Unity.Tests/Stubs/TestHub.cs b/test/Sentry.Unity.Tests/Stubs/TestHub.cs index accbe8d3c..9c8af21dc 100644 --- a/test/Sentry.Unity.Tests/Stubs/TestHub.cs +++ b/test/Sentry.Unity.Tests/Stubs/TestHub.cs @@ -36,7 +36,7 @@ public SentryId CaptureFeedback(SentryFeedback feedback, out CaptureFeedbackResu throw new NotImplementedException(); } - public void CaptureFeedback(SentryFeedback feedback, Scope? scope = null, SentryHint? hint = null) + public SentryId CaptureFeedback(SentryFeedback feedback, Scope? scope = null, SentryHint? hint = null) { throw new NotImplementedException(); } @@ -202,7 +202,7 @@ public SentryId CaptureFeedback(SentryFeedback feedback, out CaptureFeedbackResu throw new NotImplementedException(); } - public void CaptureFeedback(SentryFeedback feedback, Action configureScope, SentryHint? hint = null) + public SentryId CaptureFeedback(SentryFeedback feedback, Action configureScope, SentryHint? hint = null) { throw new NotImplementedException(); } From 4522f92f4829fc9f5dc7c4e6ab0bf66cb96a3508 Mon Sep 17 00:00:00 2001 From: bitsandfoxes Date: Fri, 13 Mar 2026 20:42:31 -0700 Subject: [PATCH 2/2] Updated CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8fff0f2a4..cd9265f90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ ### Fixes +- `CaptureFeedback` now returns a `SentryId` and exposes a `CaptureFeedbackResult` out parameter to indicate whether feedback was captured successfully ([#2589](https://github.com/getsentry/sentry-unity/pull/2579)) - The SDK now also uses `.sentry-native` as a subdirectory for native support on desktop platforms. It now also falls back to `Application.persistentDataPath` instead of the current working directory. Note: `crashedLastRun` may report `false` for the first time after upgrading. ([#2547](https://github.com/getsentry/sentry-unity/pull/2547)) - The currently experimental Metrics are now opt-in by default ([#2546](https://github.com/getsentry/sentry-unity/pull/2546)) - When targeting Android, the SDK now syncs `AppStartTime` and `AppBuildType` to the native layer ([#2557](https://github.com/getsentry/sentry-unity/pull/2557))