Skip to content

Commit a7615cf

Browse files
jamescrosswellgetsentry-botFlash0ver
authored
fix: CaptureFeedback now applies event processors (#4942)
Co-authored-by: Sentry Github Bot <bot+github-bot@sentry.io> Co-authored-by: Stefan Pölz <38893694+Flash0ver@users.noreply.github.com>
1 parent 50186be commit a7615cf

11 files changed

+82
-7
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
### Features
66

77
- GA release for Sentry Metrics ([#5023](https://github.com/getsentry/sentry-dotnet/pull/5023))
8-
8+
9+
### Fixes
10+
11+
- Common tags such as `Environment` and `Release` and custom event processors are all now correctly applied to CaptureFeedback events ([#4942](https://github.com/getsentry/sentry-dotnet/pull/4942))
12+
913
## 6.2.0
1014

1115
### Features

src/Sentry/CaptureFeedbackErrorReason.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,8 @@ public enum CaptureFeedbackResult
4040
/// Capture failed because the <see cref="SentryFeedback.Message"/> message is empty.
4141
/// </summary>
4242
EmptyMessage,
43+
/// <summary>
44+
/// The <see cref="SentryFeedback"/> was discarded by an event processor.
45+
/// </summary>
46+
DroppedByEventProcessor,
4347
}

src/Sentry/Internal/DataCategory.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ namespace Sentry.Internal;
66
public static DataCategory Attachment = new("attachment");
77
public static DataCategory Default = new("default");
88
public static DataCategory Error = new("error");
9+
public static DataCategory Feedback = new("feedback");
910
public static DataCategory Internal = new("internal");
1011
public static DataCategory Security = new("security");
1112
public static DataCategory Session = new("session");

src/Sentry/Internal/SentryEventHelper.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ namespace Sentry.Internal;
44

55
internal static class SentryEventHelper
66
{
7-
public static SentryEvent? ProcessEvent(SentryEvent? evt, IEnumerable<ISentryEventProcessor> processors, SentryHint? hint, SentryOptions options)
7+
public static SentryEvent? ProcessEvent(SentryEvent? evt, IEnumerable<ISentryEventProcessor> processors,
8+
SentryHint? hint, SentryOptions options, DataCategory dataCategory)
89
{
910
if (evt == null)
1011
{
@@ -19,7 +20,7 @@ internal static class SentryEventHelper
1920
processedEvent = processor.DoProcessEvent(processedEvent, effectiveHint);
2021
if (processedEvent == null)
2122
{
22-
options.ClientReportRecorder.RecordDiscardedEvent(DiscardReason.EventProcessor, DataCategory.Error);
23+
options.ClientReportRecorder.RecordDiscardedEvent(DiscardReason.EventProcessor, dataCategory);
2324
options.LogInfo("Event dropped by processor {0}", processor.GetType().Name);
2425
break;
2526
}

src/Sentry/Platforms/Cocoa/SentrySdk.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -295,7 +295,8 @@ private static bool SuppressNativeCrash(SentryOptions options, CocoaSdk.SentryEv
295295
}
296296

297297
var sentryEvent = evt.ToSentryEvent();
298-
if (SentryEventHelper.ProcessEvent(sentryEvent, manualProcessors, null, options) is not { } processedEvent)
298+
if (SentryEventHelper.ProcessEvent(sentryEvent, manualProcessors, null, options, DataCategory.Error)
299+
is not { } processedEvent)
299300
{
300301
return null;
301302
}

src/Sentry/SentryClient.cs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,12 +117,19 @@ public SentryId CaptureFeedback(SentryFeedback feedback, out CaptureFeedbackResu
117117
evt.Level = scope.Level;
118118
}
119119

120+
if (SentryEventHelper.ProcessEvent(evt, scope.GetAllEventProcessors(), hint, _options, DataCategory.Feedback)
121+
is not { } processedEvent)
122+
{
123+
result = CaptureFeedbackResult.DroppedByEventProcessor;
124+
return SentryId.Empty; // Dropped by an event processor
125+
}
126+
120127
var attachments = hint.Attachments.ToList();
121-
var envelope = Envelope.FromFeedback(evt, _options.DiagnosticLogger, attachments, scope.SessionUpdate);
128+
var envelope = Envelope.FromFeedback(processedEvent, _options.DiagnosticLogger, attachments, scope.SessionUpdate);
122129
if (CaptureEnvelope(envelope))
123130
{
124131
result = CaptureFeedbackResult.Success;
125-
return evt.EventId;
132+
return processedEvent.EventId;
126133
}
127134
result = CaptureFeedbackResult.UnknownError;
128135
return SentryId.Empty;
@@ -345,7 +352,8 @@ private SentryId DoSendEvent(SentryEvent @event, SentryHint? hint, Scope? scope)
345352
}
346353
}
347354

348-
if (SentryEventHelper.ProcessEvent(@event, scope.GetAllEventProcessors(), hint, _options) is not { } processedEvent)
355+
if (SentryEventHelper.ProcessEvent(@event, scope.GetAllEventProcessors(), hint, _options, DataCategory.Error)
356+
is not { } processedEvent)
349357
{
350358
return SentryId.Empty; // Dropped by an event processor
351359
}

test/Sentry.Tests/ApiApprovalTests.Run.DotNet10_0.verified.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ namespace Sentry
5151
UnknownError = 1,
5252
DisabledHub = 2,
5353
EmptyMessage = 3,
54+
DroppedByEventProcessor = 4,
5455
}
5556
public enum CheckInStatus
5657
{

test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ namespace Sentry
5151
UnknownError = 1,
5252
DisabledHub = 2,
5353
EmptyMessage = 3,
54+
DroppedByEventProcessor = 4,
5455
}
5556
public enum CheckInStatus
5657
{

test/Sentry.Tests/ApiApprovalTests.Run.DotNet9_0.verified.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ namespace Sentry
5151
UnknownError = 1,
5252
DisabledHub = 2,
5353
EmptyMessage = 3,
54+
DroppedByEventProcessor = 4,
5455
}
5556
public enum CheckInStatus
5657
{

test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ namespace Sentry
5151
UnknownError = 1,
5252
DisabledHub = 2,
5353
EmptyMessage = 3,
54+
DroppedByEventProcessor = 4,
5455
}
5556
public enum CheckInStatus
5657
{

0 commit comments

Comments
 (0)