From 7a6ef2ea4477b6cff0f27fad078f511d787d854b Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Wed, 2 Apr 2025 20:18:40 +1300 Subject: [PATCH 1/8] Added CaptureFeedback overload with configureScope parameter #4035 --- src/Sentry/Extensibility/DisabledHub.cs | 7 ++++++ src/Sentry/Extensibility/HubAdapter.cs | 8 +++++++ src/Sentry/IHub.cs | 8 +++++++ src/Sentry/Internal/Hub.cs | 23 +++++++++++++++++++ src/Sentry/SentrySdk.cs | 7 ++++++ ...piApprovalTests.Run.DotNet8_0.verified.txt | 4 ++++ ...piApprovalTests.Run.DotNet9_0.verified.txt | 4 ++++ .../ApiApprovalTests.Run.Net4_8.verified.txt | 4 ++++ 8 files changed, 65 insertions(+) diff --git a/src/Sentry/Extensibility/DisabledHub.cs b/src/Sentry/Extensibility/DisabledHub.cs index 6c18af6e45..0cb5636937 100644 --- a/src/Sentry/Extensibility/DisabledHub.cs +++ b/src/Sentry/Extensibility/DisabledHub.cs @@ -147,6 +147,13 @@ public bool CaptureEnvelope(Envelope envelope) /// public SentryId CaptureEvent(SentryEvent evt, Scope? scope = null, SentryHint? hint = null) => SentryId.Empty; + /// + /// No-Op. + /// + public void CaptureFeedback(SentryFeedback feedback, SentryHint hint, Action configureScope) + { + } + /// /// No-Op. /// diff --git a/src/Sentry/Extensibility/HubAdapter.cs b/src/Sentry/Extensibility/HubAdapter.cs index 61d715d341..1859c534db 100644 --- a/src/Sentry/Extensibility/HubAdapter.cs +++ b/src/Sentry/Extensibility/HubAdapter.cs @@ -222,6 +222,14 @@ public SentryId CaptureEvent(SentryEvent evt, Scope? scope) public SentryId CaptureEvent(SentryEvent evt, Scope? scope, SentryHint? hint = null) => SentrySdk.CaptureEvent(evt, scope, hint); + /// + /// Forwards the call to . + /// + [DebuggerStepThrough] + [EditorBrowsable(EditorBrowsableState.Never)] + public void CaptureFeedback(SentryFeedback feedback, SentryHint hint, Action configureScope) + => SentrySdk.CaptureFeedback(feedback, hint, configureScope); + /// /// Forwards the call to . /// diff --git a/src/Sentry/IHub.cs b/src/Sentry/IHub.cs index f7a609805b..79ee1ec64a 100644 --- a/src/Sentry/IHub.cs +++ b/src/Sentry/IHub.cs @@ -116,4 +116,12 @@ public TransactionContext ContinueTrace( /// The callback to configure the scope. /// public SentryId CaptureEvent(SentryEvent evt, SentryHint? hint, Action configureScope); + + /// + /// Captures feedback from the user. + /// + /// The feedback to send to Sentry. + /// Hint providing high level context for the source of the event, including attachments + /// Callback method to configure the scope. + public void CaptureFeedback(SentryFeedback feedback, SentryHint hint, Action configureScope); } diff --git a/src/Sentry/Internal/Hub.cs b/src/Sentry/Internal/Hub.cs index cd00686250..1fbbbd4a90 100644 --- a/src/Sentry/Internal/Hub.cs +++ b/src/Sentry/Internal/Hub.cs @@ -506,6 +506,29 @@ private SentryId CaptureEvent(SentryEvent evt, SentryHint? hint, Scope scope) } } + public void CaptureFeedback(SentryFeedback feedback, SentryHint hint, Action configureScope) + { + if (!IsEnabled) + { + return; + } + + try + { + var clonedScope = CurrentScope.Clone(); + configureScope(clonedScope); + + // Although we clone a temporary scope for the configureScope action, for the second scope + // argument (the breadcrumbScope) we pass in the current scope... this is because we want + // a breadcrumb to be left on the current scope for exception events + CaptureFeedback(feedback, clonedScope, hint); + } + catch (Exception e) + { + _options.LogError(e, "Failure to capture feedback"); + } + } + public void CaptureFeedback(SentryFeedback feedback, Scope? scope = null, SentryHint? hint = null) { if (!IsEnabled) diff --git a/src/Sentry/SentrySdk.cs b/src/Sentry/SentrySdk.cs index 401a0fa6f0..310dcb16cb 100644 --- a/src/Sentry/SentrySdk.cs +++ b/src/Sentry/SentrySdk.cs @@ -481,6 +481,13 @@ public static SentryId CaptureMessage(string message, SentryLevel level = Sentry public static SentryId CaptureMessage(string message, Action configureScope, SentryLevel level = SentryLevel.Info) => CurrentHub.CaptureMessage(message, configureScope, level); + /// + /// Captures feedback from the user. + /// + [DebuggerStepThrough] + public static void CaptureFeedback(SentryFeedback feedback, SentryHint hint, Action configureScope) + => CurrentHub.CaptureFeedback(feedback, hint, configureScope); + /// /// Captures feedback from the user. /// diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index 67795954b7..0f647ff217 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -212,6 +212,7 @@ namespace Sentry void BindException(System.Exception exception, Sentry.ISpan span); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope); + void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope); Sentry.TransactionContext ContinueTrace(Sentry.SentryTraceHeader? traceHeader, Sentry.BaggageHeader? baggageHeader, string? name = null, string? operation = null); Sentry.TransactionContext ContinueTrace(string? traceHeader, string? baggageHeader, string? name = null, string? operation = null); void EndSession(Sentry.SessionEndStatus status = 0); @@ -823,6 +824,7 @@ namespace Sentry public static Sentry.SentryId CaptureException(System.Exception exception) { } public static Sentry.SentryId CaptureException(System.Exception exception, System.Action configureScope) { } public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } + public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } public static void CaptureFeedback(string message, string? contactEmail = null, string? name = null, string? replayId = null, string? url = null, Sentry.SentryId? associatedEventId = default, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public static Sentry.SentryId CaptureMessage(string message, Sentry.SentryLevel level = 1) { } public static Sentry.SentryId CaptureMessage(string message, System.Action configureScope, Sentry.SentryLevel level = 1) { } @@ -1333,6 +1335,7 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } @@ -1379,6 +1382,7 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public Sentry.SentryId CaptureException(System.Exception exception) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt index 67795954b7..0f647ff217 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt @@ -212,6 +212,7 @@ namespace Sentry void BindException(System.Exception exception, Sentry.ISpan span); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope); + void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope); Sentry.TransactionContext ContinueTrace(Sentry.SentryTraceHeader? traceHeader, Sentry.BaggageHeader? baggageHeader, string? name = null, string? operation = null); Sentry.TransactionContext ContinueTrace(string? traceHeader, string? baggageHeader, string? name = null, string? operation = null); void EndSession(Sentry.SessionEndStatus status = 0); @@ -823,6 +824,7 @@ namespace Sentry public static Sentry.SentryId CaptureException(System.Exception exception) { } public static Sentry.SentryId CaptureException(System.Exception exception, System.Action configureScope) { } public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } + public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } public static void CaptureFeedback(string message, string? contactEmail = null, string? name = null, string? replayId = null, string? url = null, Sentry.SentryId? associatedEventId = default, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public static Sentry.SentryId CaptureMessage(string message, Sentry.SentryLevel level = 1) { } public static Sentry.SentryId CaptureMessage(string message, System.Action configureScope, Sentry.SentryLevel level = 1) { } @@ -1333,6 +1335,7 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } @@ -1379,6 +1382,7 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public Sentry.SentryId CaptureException(System.Exception exception) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt index 0c06282d34..92f6070fa5 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt @@ -200,6 +200,7 @@ namespace Sentry void BindException(System.Exception exception, Sentry.ISpan span); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope); + void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope); Sentry.TransactionContext ContinueTrace(Sentry.SentryTraceHeader? traceHeader, Sentry.BaggageHeader? baggageHeader, string? name = null, string? operation = null); Sentry.TransactionContext ContinueTrace(string? traceHeader, string? baggageHeader, string? name = null, string? operation = null); void EndSession(Sentry.SessionEndStatus status = 0); @@ -804,6 +805,7 @@ namespace Sentry public static Sentry.SentryId CaptureException(System.Exception exception) { } public static Sentry.SentryId CaptureException(System.Exception exception, System.Action configureScope) { } public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } + public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } public static void CaptureFeedback(string message, string? contactEmail = null, string? name = null, string? replayId = null, string? url = null, Sentry.SentryId? associatedEventId = default, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public static Sentry.SentryId CaptureMessage(string message, Sentry.SentryLevel level = 1) { } public static Sentry.SentryId CaptureMessage(string message, System.Action configureScope, Sentry.SentryLevel level = 1) { } @@ -1314,6 +1316,7 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } @@ -1360,6 +1363,7 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public Sentry.SentryId CaptureException(System.Exception exception) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } From 2dbcc190bcaae581a8d0e7de3adcc72be429dd85 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Thu, 3 Apr 2025 09:54:35 +1300 Subject: [PATCH 2/8] Update CHANGELOG.md --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e3dd61e5aa..1ce8348391 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Features + +- Added CaptureFeedback overload with configureScope parameter #4035 ([#4073](https://github.com/getsentry/sentry-dotnet/pull/4073)) + ## 5.5.0 ### Features From cc5312acbb0022bfe0641958d0403726b6414bf3 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Tue, 8 Apr 2025 10:16:12 +1200 Subject: [PATCH 3/8] Update CHANGELOG.md --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1ce8348391..be4fe36ee5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Features -- Added CaptureFeedback overload with configureScope parameter #4035 ([#4073](https://github.com/getsentry/sentry-dotnet/pull/4073)) +- Added CaptureFeedback overload with configureScope parameter ([#4073](https://github.com/getsentry/sentry-dotnet/pull/4073)) ## 5.5.0 From 738883b035f60a083b19e04d4b680c5c0e8bc325 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Tue, 8 Apr 2025 12:34:04 +1200 Subject: [PATCH 4/8] Review feedback --- CHANGELOG.md | 2 +- src/Sentry/Extensibility/DisabledHub.cs | 9 ++++++++- src/Sentry/Extensibility/HubAdapter.cs | 10 +++++++++- src/Sentry/IHub.cs | 11 +++++++++-- src/Sentry/Internal/Hub.cs | 19 +++++++++++++------ src/Sentry/SentrySdk.cs | 9 ++++++++- ...piApprovalTests.Run.DotNet8_0.verified.txt | 12 ++++++++---- ...piApprovalTests.Run.DotNet9_0.verified.txt | 12 ++++++++---- .../ApiApprovalTests.Run.Net4_8.verified.txt | 12 ++++++++---- 9 files changed, 72 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e7142d50e6..6ba35f03e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,7 +4,7 @@ ### Features -- Added CaptureFeedback overload with configureScope parameter ([#4073](https://github.com/getsentry/sentry-dotnet/pull/4073)) +- Added `CaptureFeedback` overload with `configureScope` parameter ([#4073](https://github.com/getsentry/sentry-dotnet/pull/4073)) ### Fixes diff --git a/src/Sentry/Extensibility/DisabledHub.cs b/src/Sentry/Extensibility/DisabledHub.cs index 0cb5636937..327857b4c1 100644 --- a/src/Sentry/Extensibility/DisabledHub.cs +++ b/src/Sentry/Extensibility/DisabledHub.cs @@ -150,7 +150,14 @@ public bool CaptureEnvelope(Envelope envelope) /// /// No-Op. /// - public void CaptureFeedback(SentryFeedback feedback, SentryHint hint, Action configureScope) + public void CaptureFeedback(SentryFeedback feedback, Action configureScope) + { + } + + /// + /// No-Op. + /// + public void CaptureFeedback(SentryFeedback feedback, SentryHint? hint, Action configureScope) { } diff --git a/src/Sentry/Extensibility/HubAdapter.cs b/src/Sentry/Extensibility/HubAdapter.cs index 1859c534db..b7c35aac79 100644 --- a/src/Sentry/Extensibility/HubAdapter.cs +++ b/src/Sentry/Extensibility/HubAdapter.cs @@ -227,7 +227,15 @@ public SentryId CaptureEvent(SentryEvent evt, Scope? scope, SentryHint? hint = n /// [DebuggerStepThrough] [EditorBrowsable(EditorBrowsableState.Never)] - public void CaptureFeedback(SentryFeedback feedback, SentryHint hint, Action configureScope) + public void CaptureFeedback(SentryFeedback feedback, Action configureScope) + => SentrySdk.CaptureFeedback(feedback, configureScope); + + /// + /// Forwards the call to . + /// + [DebuggerStepThrough] + [EditorBrowsable(EditorBrowsableState.Never)] + public void CaptureFeedback(SentryFeedback feedback, SentryHint? hint, Action configureScope) => SentrySdk.CaptureFeedback(feedback, hint, configureScope); /// diff --git a/src/Sentry/IHub.cs b/src/Sentry/IHub.cs index 79ee1ec64a..e915da6eab 100644 --- a/src/Sentry/IHub.cs +++ b/src/Sentry/IHub.cs @@ -121,7 +121,14 @@ public TransactionContext ContinueTrace( /// Captures feedback from the user. /// /// The feedback to send to Sentry. - /// Hint providing high level context for the source of the event, including attachments /// Callback method to configure the scope. - public void CaptureFeedback(SentryFeedback feedback, SentryHint hint, Action configureScope); + public void CaptureFeedback(SentryFeedback feedback, Action configureScope); + + /// + /// Captures feedback from the user. + /// + /// The feedback to send to Sentry. + /// An optional hint providing high level context for the source of the event, including attachments + /// Callback method to configure the scope. + public void CaptureFeedback(SentryFeedback feedback, SentryHint? hint, Action configureScope); } diff --git a/src/Sentry/Internal/Hub.cs b/src/Sentry/Internal/Hub.cs index 8be9437ef6..8601283ce9 100644 --- a/src/Sentry/Internal/Hub.cs +++ b/src/Sentry/Internal/Hub.cs @@ -506,7 +506,10 @@ private SentryId CaptureEvent(SentryEvent evt, SentryHint? hint, Scope scope) } } - public void CaptureFeedback(SentryFeedback feedback, SentryHint hint, Action configureScope) + public void CaptureFeedback(SentryFeedback feedback, Action configureScope) => + CaptureFeedback(feedback, null, configureScope); + + public void CaptureFeedback(SentryFeedback feedback, SentryHint? hint, Action configureScope) { if (!IsEnabled) { @@ -518,9 +521,6 @@ public void CaptureFeedback(SentryFeedback feedback, SentryHint hint, Action configureSco /// Captures feedback from the user. /// [DebuggerStepThrough] - public static void CaptureFeedback(SentryFeedback feedback, SentryHint hint, Action configureScope) + public static void CaptureFeedback(SentryFeedback feedback, Action configureScope) + => CurrentHub.CaptureFeedback(feedback, configureScope); + + /// + /// Captures feedback from the user. + /// + [DebuggerStepThrough] + public static void CaptureFeedback(SentryFeedback feedback, SentryHint? hint, Action configureScope) => CurrentHub.CaptureFeedback(feedback, hint, configureScope); /// diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index 7930d94f55..e512cfdd15 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -212,7 +212,8 @@ namespace Sentry void BindException(System.Exception exception, Sentry.ISpan span); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope); - void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope); + void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope); + void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope); Sentry.TransactionContext ContinueTrace(Sentry.SentryTraceHeader? traceHeader, Sentry.BaggageHeader? baggageHeader, string? name = null, string? operation = null); Sentry.TransactionContext ContinueTrace(string? traceHeader, string? baggageHeader, string? name = null, string? operation = null); void EndSession(Sentry.SessionEndStatus status = 0); @@ -824,8 +825,9 @@ namespace Sentry public static Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public static Sentry.SentryId CaptureException(System.Exception exception) { } public static Sentry.SentryId CaptureException(System.Exception exception, System.Action configureScope) { } + public static void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } + public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } public static void CaptureFeedback(string message, string? contactEmail = null, string? name = null, string? replayId = null, string? url = null, Sentry.SentryId? associatedEventId = default, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public static Sentry.SentryId CaptureMessage(string message, Sentry.SentryLevel level = 1) { } public static Sentry.SentryId CaptureMessage(string message, System.Action configureScope, Sentry.SentryLevel level = 1) { } @@ -1335,8 +1337,9 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } @@ -1382,8 +1385,9 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.Scope? scope, Sentry.SentryHint? hint = null) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public Sentry.SentryId CaptureException(System.Exception exception) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt index 7930d94f55..e512cfdd15 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt @@ -212,7 +212,8 @@ namespace Sentry void BindException(System.Exception exception, Sentry.ISpan span); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope); - void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope); + void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope); + void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope); Sentry.TransactionContext ContinueTrace(Sentry.SentryTraceHeader? traceHeader, Sentry.BaggageHeader? baggageHeader, string? name = null, string? operation = null); Sentry.TransactionContext ContinueTrace(string? traceHeader, string? baggageHeader, string? name = null, string? operation = null); void EndSession(Sentry.SessionEndStatus status = 0); @@ -824,8 +825,9 @@ namespace Sentry public static Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public static Sentry.SentryId CaptureException(System.Exception exception) { } public static Sentry.SentryId CaptureException(System.Exception exception, System.Action configureScope) { } + public static void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } + public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } public static void CaptureFeedback(string message, string? contactEmail = null, string? name = null, string? replayId = null, string? url = null, Sentry.SentryId? associatedEventId = default, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public static Sentry.SentryId CaptureMessage(string message, Sentry.SentryLevel level = 1) { } public static Sentry.SentryId CaptureMessage(string message, System.Action configureScope, Sentry.SentryLevel level = 1) { } @@ -1335,8 +1337,9 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } @@ -1382,8 +1385,9 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.Scope? scope, Sentry.SentryHint? hint = null) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public Sentry.SentryId CaptureException(System.Exception exception) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt index b3a7b7d707..53e7696195 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt @@ -200,7 +200,8 @@ namespace Sentry void BindException(System.Exception exception, Sentry.ISpan span); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope); - void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope); + void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope); + void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope); Sentry.TransactionContext ContinueTrace(Sentry.SentryTraceHeader? traceHeader, Sentry.BaggageHeader? baggageHeader, string? name = null, string? operation = null); Sentry.TransactionContext ContinueTrace(string? traceHeader, string? baggageHeader, string? name = null, string? operation = null); void EndSession(Sentry.SessionEndStatus status = 0); @@ -805,8 +806,9 @@ namespace Sentry public static Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public static Sentry.SentryId CaptureException(System.Exception exception) { } public static Sentry.SentryId CaptureException(System.Exception exception, System.Action configureScope) { } + public static void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } + public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } public static void CaptureFeedback(string message, string? contactEmail = null, string? name = null, string? replayId = null, string? url = null, Sentry.SentryId? associatedEventId = default, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public static Sentry.SentryId CaptureMessage(string message, Sentry.SentryLevel level = 1) { } public static Sentry.SentryId CaptureMessage(string message, System.Action configureScope, Sentry.SentryLevel level = 1) { } @@ -1316,8 +1318,9 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } @@ -1363,8 +1366,9 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.Scope? scope, Sentry.SentryHint? hint = null) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public Sentry.SentryId CaptureException(System.Exception exception) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint hint, System.Action configureScope) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } From 5a9ba539d632e8e04ec583e286af0a9774142840 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Wed, 30 Apr 2025 12:12:22 +1200 Subject: [PATCH 5/8] Consolidate two overloads into one --- src/Sentry/Extensibility/DisabledHub.cs | 9 +-------- src/Sentry/Extensibility/HubAdapter.cs | 12 ++---------- src/Sentry/IHub.cs | 9 +-------- src/Sentry/Internal/Hub.cs | 5 +---- src/Sentry/SentrySdk.cs | 11 ++--------- .../ApiApprovalTests.Run.DotNet8_0.verified.txt | 12 ++++-------- .../ApiApprovalTests.Run.DotNet9_0.verified.txt | 12 ++++-------- .../ApiApprovalTests.Run.Net4_8.verified.txt | 12 ++++-------- 8 files changed, 19 insertions(+), 63 deletions(-) diff --git a/src/Sentry/Extensibility/DisabledHub.cs b/src/Sentry/Extensibility/DisabledHub.cs index 327857b4c1..a5d7541dde 100644 --- a/src/Sentry/Extensibility/DisabledHub.cs +++ b/src/Sentry/Extensibility/DisabledHub.cs @@ -150,14 +150,7 @@ public bool CaptureEnvelope(Envelope envelope) /// /// No-Op. /// - public void CaptureFeedback(SentryFeedback feedback, Action configureScope) - { - } - - /// - /// No-Op. - /// - public void CaptureFeedback(SentryFeedback feedback, SentryHint? hint, Action configureScope) + public void CaptureFeedback(SentryFeedback feedback, Action configureScope, SentryHint? hint = null) { } diff --git a/src/Sentry/Extensibility/HubAdapter.cs b/src/Sentry/Extensibility/HubAdapter.cs index b7c35aac79..b21eb369ee 100644 --- a/src/Sentry/Extensibility/HubAdapter.cs +++ b/src/Sentry/Extensibility/HubAdapter.cs @@ -227,16 +227,8 @@ public SentryId CaptureEvent(SentryEvent evt, Scope? scope, SentryHint? hint = n /// [DebuggerStepThrough] [EditorBrowsable(EditorBrowsableState.Never)] - public void CaptureFeedback(SentryFeedback feedback, Action configureScope) - => SentrySdk.CaptureFeedback(feedback, configureScope); - - /// - /// Forwards the call to . - /// - [DebuggerStepThrough] - [EditorBrowsable(EditorBrowsableState.Never)] - public void CaptureFeedback(SentryFeedback feedback, SentryHint? hint, Action configureScope) - => SentrySdk.CaptureFeedback(feedback, hint, configureScope); + public void CaptureFeedback(SentryFeedback feedback, Action configureScope, SentryHint? hint = null) + => SentrySdk.CaptureFeedback(feedback, configureScope, hint); /// /// Forwards the call to . diff --git a/src/Sentry/IHub.cs b/src/Sentry/IHub.cs index e915da6eab..abf722c89d 100644 --- a/src/Sentry/IHub.cs +++ b/src/Sentry/IHub.cs @@ -122,13 +122,6 @@ public TransactionContext ContinueTrace( /// /// The feedback to send to Sentry. /// Callback method to configure the scope. - public void CaptureFeedback(SentryFeedback feedback, Action configureScope); - - /// - /// Captures feedback from the user. - /// - /// The feedback to send to Sentry. /// An optional hint providing high level context for the source of the event, including attachments - /// Callback method to configure the scope. - public void CaptureFeedback(SentryFeedback feedback, SentryHint? hint, Action configureScope); + public void CaptureFeedback(SentryFeedback feedback, Action configureScope, SentryHint? hint = null); } diff --git a/src/Sentry/Internal/Hub.cs b/src/Sentry/Internal/Hub.cs index 8601283ce9..cc9cbd3ef3 100644 --- a/src/Sentry/Internal/Hub.cs +++ b/src/Sentry/Internal/Hub.cs @@ -506,10 +506,7 @@ private SentryId CaptureEvent(SentryEvent evt, SentryHint? hint, Scope scope) } } - public void CaptureFeedback(SentryFeedback feedback, Action configureScope) => - CaptureFeedback(feedback, null, configureScope); - - public void CaptureFeedback(SentryFeedback feedback, SentryHint? hint, Action configureScope) + public void CaptureFeedback(SentryFeedback feedback, Action configureScope, SentryHint? hint = null) { if (!IsEnabled) { diff --git a/src/Sentry/SentrySdk.cs b/src/Sentry/SentrySdk.cs index fa2bc6b71a..81b658c440 100644 --- a/src/Sentry/SentrySdk.cs +++ b/src/Sentry/SentrySdk.cs @@ -492,15 +492,8 @@ public static SentryId CaptureMessage(string message, Action configureSco /// Captures feedback from the user. /// [DebuggerStepThrough] - public static void CaptureFeedback(SentryFeedback feedback, Action configureScope) - => CurrentHub.CaptureFeedback(feedback, configureScope); - - /// - /// Captures feedback from the user. - /// - [DebuggerStepThrough] - public static void CaptureFeedback(SentryFeedback feedback, SentryHint? hint, Action configureScope) - => CurrentHub.CaptureFeedback(feedback, hint, configureScope); + public static void CaptureFeedback(SentryFeedback feedback, Action configureScope, SentryHint? hint = null) + => CurrentHub.CaptureFeedback(feedback, configureScope, hint); /// /// Captures feedback from the user. diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt index e512cfdd15..925a97874c 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt @@ -212,8 +212,7 @@ namespace Sentry void BindException(System.Exception exception, Sentry.ISpan span); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope); - void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope); - void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope); + void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope, Sentry.SentryHint? hint = null); Sentry.TransactionContext ContinueTrace(Sentry.SentryTraceHeader? traceHeader, Sentry.BaggageHeader? baggageHeader, string? name = null, string? operation = null); Sentry.TransactionContext ContinueTrace(string? traceHeader, string? baggageHeader, string? name = null, string? operation = null); void EndSession(Sentry.SessionEndStatus status = 0); @@ -825,9 +824,8 @@ namespace Sentry public static Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public static Sentry.SentryId CaptureException(System.Exception exception) { } public static Sentry.SentryId CaptureException(System.Exception exception, System.Action configureScope) { } - public static void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } + public static void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope, Sentry.SentryHint? hint = null) { } public static void CaptureFeedback(string message, string? contactEmail = null, string? name = null, string? replayId = null, string? url = null, Sentry.SentryId? associatedEventId = default, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public static Sentry.SentryId CaptureMessage(string message, Sentry.SentryLevel level = 1) { } public static Sentry.SentryId CaptureMessage(string message, System.Action configureScope, Sentry.SentryLevel level = 1) { } @@ -1337,9 +1335,8 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope, Sentry.SentryHint? hint = null) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } @@ -1385,9 +1382,8 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.Scope? scope, Sentry.SentryHint? hint = null) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public Sentry.SentryId CaptureException(System.Exception exception) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope, Sentry.SentryHint? hint = null) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt index e512cfdd15..925a97874c 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt @@ -212,8 +212,7 @@ namespace Sentry void BindException(System.Exception exception, Sentry.ISpan span); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope); - void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope); - void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope); + void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope, Sentry.SentryHint? hint = null); Sentry.TransactionContext ContinueTrace(Sentry.SentryTraceHeader? traceHeader, Sentry.BaggageHeader? baggageHeader, string? name = null, string? operation = null); Sentry.TransactionContext ContinueTrace(string? traceHeader, string? baggageHeader, string? name = null, string? operation = null); void EndSession(Sentry.SessionEndStatus status = 0); @@ -825,9 +824,8 @@ namespace Sentry public static Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public static Sentry.SentryId CaptureException(System.Exception exception) { } public static Sentry.SentryId CaptureException(System.Exception exception, System.Action configureScope) { } - public static void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } + public static void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope, Sentry.SentryHint? hint = null) { } public static void CaptureFeedback(string message, string? contactEmail = null, string? name = null, string? replayId = null, string? url = null, Sentry.SentryId? associatedEventId = default, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public static Sentry.SentryId CaptureMessage(string message, Sentry.SentryLevel level = 1) { } public static Sentry.SentryId CaptureMessage(string message, System.Action configureScope, Sentry.SentryLevel level = 1) { } @@ -1337,9 +1335,8 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope, Sentry.SentryHint? hint = null) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } @@ -1385,9 +1382,8 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.Scope? scope, Sentry.SentryHint? hint = null) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public Sentry.SentryId CaptureException(System.Exception exception) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope, Sentry.SentryHint? hint = null) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } diff --git a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt index 53e7696195..583b80f350 100644 --- a/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt +++ b/test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt @@ -200,8 +200,7 @@ namespace Sentry void BindException(System.Exception exception, Sentry.ISpan span); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope); Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope); - void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope); - void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope); + void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope, Sentry.SentryHint? hint = null); Sentry.TransactionContext ContinueTrace(Sentry.SentryTraceHeader? traceHeader, Sentry.BaggageHeader? baggageHeader, string? name = null, string? operation = null); Sentry.TransactionContext ContinueTrace(string? traceHeader, string? baggageHeader, string? name = null, string? operation = null); void EndSession(Sentry.SessionEndStatus status = 0); @@ -806,9 +805,8 @@ namespace Sentry public static Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public static Sentry.SentryId CaptureException(System.Exception exception) { } public static Sentry.SentryId CaptureException(System.Exception exception, System.Action configureScope) { } - public static void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public static void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } + public static void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope, Sentry.SentryHint? hint = null) { } public static void CaptureFeedback(string message, string? contactEmail = null, string? name = null, string? replayId = null, string? url = null, Sentry.SentryId? associatedEventId = default, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public static Sentry.SentryId CaptureMessage(string message, Sentry.SentryLevel level = 1) { } public static Sentry.SentryId CaptureMessage(string message, System.Action configureScope, Sentry.SentryLevel level = 1) { } @@ -1318,9 +1316,8 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, System.Action configureScope) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope, Sentry.SentryHint? hint = null) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } @@ -1366,9 +1363,8 @@ namespace Sentry.Extensibility public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.Scope? scope, Sentry.SentryHint? hint = null) { } public Sentry.SentryId CaptureEvent(Sentry.SentryEvent evt, Sentry.SentryHint? hint, System.Action configureScope) { } public Sentry.SentryId CaptureException(System.Exception exception) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope) { } public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.Scope? scope = null, Sentry.SentryHint? hint = null) { } - public void CaptureFeedback(Sentry.SentryFeedback feedback, Sentry.SentryHint? hint, System.Action configureScope) { } + public void CaptureFeedback(Sentry.SentryFeedback feedback, System.Action configureScope, Sentry.SentryHint? hint = null) { } public void CaptureSession(Sentry.SessionUpdate sessionUpdate) { } public void CaptureTransaction(Sentry.SentryTransaction transaction) { } public void CaptureTransaction(Sentry.SentryTransaction transaction, Sentry.Scope? scope, Sentry.SentryHint? hint) { } From e231ce8e7e15ff9e031f6033500bbe01f03853f0 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Wed, 30 Apr 2025 12:31:27 +1200 Subject: [PATCH 6/8] Added unit tests --- .../Extensibility/HubAdapterTests.cs | 17 +++++++++++++++ test/Sentry.Tests/HubTests.cs | 21 +++++++++++++++++++ test/Sentry.Tests/SentrySdkTests.cs | 17 +++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/test/Sentry.Tests/Extensibility/HubAdapterTests.cs b/test/Sentry.Tests/Extensibility/HubAdapterTests.cs index cee0344ed2..83de560c53 100644 --- a/test/Sentry.Tests/Extensibility/HubAdapterTests.cs +++ b/test/Sentry.Tests/Extensibility/HubAdapterTests.cs @@ -28,6 +28,23 @@ public void CaptureEvent_WithScope_MockInvoked() Hub.Received(1).CaptureEvent(expectedEvent, expectedScope); } + [Fact] + public void CaptureFeedback_MockInvoked() + { + var expected = new SentryFeedback("foo"); + HubAdapter.Instance.CaptureFeedback(expected); + Hub.Received(1).CaptureFeedback(expected); + } + + [Fact] + public void CaptureFeedback_WithScope_MockInvoked() + { + var expectedEvent = new SentryFeedback("foo"); + var expectedScope = new Scope(); + HubAdapter.Instance.CaptureFeedback(expectedEvent, expectedScope); + Hub.Received(1).CaptureFeedback(expectedEvent, expectedScope); + } + [Fact] public void CaptureException_MockInvoked() { diff --git a/test/Sentry.Tests/HubTests.cs b/test/Sentry.Tests/HubTests.cs index f0c141617e..88d330f950 100644 --- a/test/Sentry.Tests/HubTests.cs +++ b/test/Sentry.Tests/HubTests.cs @@ -1596,6 +1596,27 @@ public void CaptureFeedback_HubEnabled(bool enabled) _fixture.Client.Received(enabled ? 1 : 0).CaptureFeedback(Arg.Any(), Arg.Any(), Arg.Any()); } + [Theory] + [InlineData(true)] + [InlineData(false)] + public void CaptureFeedback_ConfigureScope_ScopeApplied(bool enabled) + { + // Arrange + var hub = _fixture.GetSut(); + if (!enabled) + { + hub.Dispose(); + } + + var feedback = new SentryFeedback("Test feedback"); + + // Act + hub.CaptureFeedback(feedback, s => s.SetTag("foo", "bar")); + + // Assert + _fixture.Client.Received(enabled ? 1 : 0).CaptureFeedback(Arg.Any(), Arg.Is(s => s.Tags["foo"] == "bar"), Arg.Any()); + } + [Theory] [InlineData(true)] [InlineData(false)] diff --git a/test/Sentry.Tests/SentrySdkTests.cs b/test/Sentry.Tests/SentrySdkTests.cs index f88876e914..ed99d7a746 100644 --- a/test/Sentry.Tests/SentrySdkTests.cs +++ b/test/Sentry.Tests/SentrySdkTests.cs @@ -554,6 +554,23 @@ public void CaptureEvent_WithConfiguredScope_ScopeCallbackGetsInvoked() Assert.True(scopeCallbackWasInvoked); } + [Fact] + public void CaptureFeedback_WithConfiguredScope_ScopeCallbackGetsInvoked() + { + using var _ = SentrySdk.Init(o => + { + o.Dsn = ValidDsn; + o.AutoSessionTracking = false; + o.BackgroundWorker = Substitute.For(); + o.InitNativeSdks = false; + }); + + var scopeCallbackWasInvoked = false; + SentrySdk.CaptureFeedback(new SentryFeedback("Foo"), _ => scopeCallbackWasInvoked = true); + + Assert.True(scopeCallbackWasInvoked); + } + [Fact] public void CaptureException_WithConfiguredScope_ScopeCallbackGetsInvoked() { From 081d6faef6e63660503c4ca232c95dfc9a15d815 Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Wed, 30 Apr 2025 12:32:36 +1200 Subject: [PATCH 7/8] Update CHANGELOG.md --- CHANGELOG.md | 1 - 1 file changed, 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 60a67b7b9a..eb8c957329 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,6 @@ ### Features - Added `CaptureFeedback` overload with `configureScope` parameter ([#4073](https://github.com/getsentry/sentry-dotnet/pull/4073)) - - Custom SessionReplay masks in MAUI Android apps ([#4121](https://github.com/getsentry/sentry-dotnet/pull/4121)) ### Fixes From b588262879d789a62b52db40c1d9be83537f9f0d Mon Sep 17 00:00:00 2001 From: James Crosswell Date: Thu, 1 May 2025 09:24:19 +1200 Subject: [PATCH 8/8] Update HomeController.cs --- .../Sentry.Samples.AspNetCore.Mvc/Controllers/HomeController.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/samples/Sentry.Samples.AspNetCore.Mvc/Controllers/HomeController.cs b/samples/Sentry.Samples.AspNetCore.Mvc/Controllers/HomeController.cs index ef3a27275b..e39d037fbe 100644 --- a/samples/Sentry.Samples.AspNetCore.Mvc/Controllers/HomeController.cs +++ b/samples/Sentry.Samples.AspNetCore.Mvc/Controllers/HomeController.cs @@ -202,7 +202,7 @@ public async Task SubmitFeedback(FeedbackModel feedback) hint.AddAttachment(memoryStream.ToArray(), feedback.Screenshot.FileName, AttachmentType.Default, "image/png"); } - SentrySdk.CaptureFeedback(sentryFeedback, null, hint); + SentrySdk.CaptureFeedback(sentryFeedback, hint: hint); ViewBag.Message = "Feedback submitted successfully!"; return View("Index"); }