Skip to content

Commit dc9a036

Browse files
authored
fix: Apply Enricher to User Feedback (#4883)
1 parent ba47ffa commit dc9a036

3 files changed

Lines changed: 24 additions & 7 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
### Fixes
1010

11+
- User Feedback now contains additional Context and Tags, like `Environment` and `Release` ([#4883](https://github.com/getsentry/sentry-dotnet/pull/4883))
1112
- Allow Sentry failures from the Sentry CLI when SENTRY_ALLOW_FAILURE is set ([#4852](https://github.com/getsentry/sentry-dotnet/pull/4852))
1213
- The SDK now logs a specific error message when envelopes are rejected due to size limits (HTTP 413) ([#4863](https://github.com/getsentry/sentry-dotnet/pull/4863))
1314
- Fixed thread-safety issue on Android when multiple events are captured concurrently ([#4814](https://github.com/getsentry/sentry-dotnet/pull/4814))
@@ -1271,7 +1272,6 @@ If you have compilation errors you can find the affected types or overloads miss
12711272
- The `WithScope` and `WithScopeAsync` methods have been removed. We have discovered that these methods didn't work correctly in certain desktop contexts, especially when using a global scope. ([#2717](https://github.com/getsentry/sentry-dotnet/pull/2717))
12721273

12731274
Replace your usage of `WithScope` with overloads of `Capture*` methods:
1274-
12751275
- `SentrySdk.CaptureEvent(SentryEvent @event, Action<Scope> scopeCallback)`
12761276
- `SentrySdk.CaptureMessage(string message, Action<Scope> scopeCallback)`
12771277
- `SentrySdk.CaptureException(Exception exception, Action<Scope> scopeCallback)`
@@ -1670,18 +1670,15 @@ There are some functional differences when publishing Native AOT:
16701670
### Features
16711671

16721672
- Azure Functions (Isolated Worker/Out-of-Process) support ([#2346](https://github.com/getsentry/sentry-dotnet/pull/2346))
1673-
16741673
- Initial `beta.1` release. Please give it a try and let us know how it goes!
16751674
- Documentation is TBD. For now, see `/samples/Sentry.Samples.Azure.Functions.Worker`.
16761675

16771676
- Add `Hint` support ([#2351](https://github.com/getsentry/sentry-dotnet/pull/2351))
1678-
16791677
- Currently, this allows you to manipulate attachments in the various "before" event delegates.
16801678
- Hints can also be used in event and transaction processors by implementing `ISentryEventProcessorWithHint` or `ISentryTransactionProcessorWithHint`, instead of `ISentryEventProcessor` or `ISentryTransactionProcessor`.
16811679
- Note: Obsoletes the `BeforeSend`, `BeforeSendTransaction`, and `BeforeBreadcrumb` properties on the `SentryOptions` class. They have been replaced with `SetBeforeSend`, `SetBeforeSendTransaction`, and `SetBeforeBreadcrumb` respectively. Each one provides overloads both with and without a `Hint` object.
16821680

16831681
- Allow setting the active span on the scope ([#2364](https://github.com/getsentry/sentry-dotnet/pull/2364))
1684-
16851682
- Note: Obsoletes the `Scope.GetSpan` method in favor of a `Scope.Span` property (which now has a setter as well).
16861683

16871684
- Remove authority from URLs sent to Sentry ([#2365](https://github.com/getsentry/sentry-dotnet/pull/2365))
@@ -1690,7 +1687,6 @@ There are some functional differences when publishing Native AOT:
16901687
### Fixes
16911688

16921689
- Fix `EnableTracing` option conflict with `TracesSampleRate` ([#2368](https://github.com/getsentry/sentry-dotnet/pull/2368))
1693-
16941690
- NOTE: This is a potentially breaking change, as the `TracesSampleRate` property has been made nullable.
16951691
Though extremely uncommon, if you are _retrieving_ the `TracesSampleRate` property for some reason, you will need to account for nulls.
16961692
However, there is no change to the behavior or _typical_ usage of either of these properties.
@@ -1766,12 +1762,10 @@ There are some functional differences when publishing Native AOT:
17661762
### Dependencies
17671763

17681764
- Bump Cocoa SDK from v8.3.0 to v8.4.0 ([#2237](https://github.com/getsentry/sentry-dotnet/pull/2237), [#2248](https://github.com/getsentry/sentry-dotnet/pull/2248), [#2251](https://github.com/getsentry/sentry-dotnet/pull/2251), [#2285](https://github.com/getsentry/sentry-dotnet/pull/2285))
1769-
17701765
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#840)
17711766
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.3.0...8.4.0)
17721767

17731768
- Bump CLI from v2.14.4 to v2.17.0 ([#2238](https://github.com/getsentry/sentry-dotnet/pull/2238), [#2244](https://github.com/getsentry/sentry-dotnet/pull/2244), [#2252](https://github.com/getsentry/sentry-dotnet/pull/2252), [#2264](https://github.com/getsentry/sentry-dotnet/pull/2264), [#2292](https://github.com/getsentry/sentry-dotnet/pull/2292))
1774-
17751769
- [changelog](https://github.com/getsentry/sentry-cli/blob/master/CHANGELOG.md#2170)
17761770
- [diff](https://github.com/getsentry/sentry-cli/compare/2.14.4...2.17.0)
17771771

src/Sentry/SentryClient.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ public SentryId CaptureFeedback(SentryFeedback feedback, out CaptureFeedbackResu
108108
// Evaluate and copy before invoking the callback
109109
scope.Evaluate();
110110
scope.Apply(evt);
111+
_enricher.Apply(evt);
111112

112113
if (scope.Level != null && scope.Level != SentryLevel.Info)
113114
{

test/Sentry.Tests/SentryClientTests.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -995,6 +995,28 @@ public void CaptureFeedback_WithHint_HasHintAttachment()
995995
envelope.Items.Count(item => item.TryGetType() == "attachment") == 1));
996996
}
997997

998+
[Fact]
999+
public void CaptureFeedback_FeedbackHasReleaseAndEnvironment()
1000+
{
1001+
// Arrange
1002+
_fixture.SentryOptions.Release = "my-test-release";
1003+
_fixture.SentryOptions.Environment = "my-test-environment";
1004+
Envelope envelope = null;
1005+
var sut = _fixture.GetSut();
1006+
sut.Worker.EnqueueEnvelope(Arg.Do<Envelope>(e => envelope = e));
1007+
var feedback = new SentryFeedback("Test feedback");
1008+
1009+
// Act
1010+
var result = sut.CaptureFeedback(feedback);
1011+
1012+
// Assert
1013+
result.Should().NotBe(SentryId.Empty);
1014+
var item = envelope.Items.First(x => x.TryGetType() == EnvelopeItem.TypeValueFeedback);
1015+
var @event = (SentryEvent)((JsonSerializable)item.Payload).Source;
1016+
Assert.Equal(_fixture.SentryOptions.Release, @event.Release);
1017+
Assert.Equal(_fixture.SentryOptions.Environment, @event.Environment);
1018+
}
1019+
9981020
[Fact]
9991021
public void CaptureTransaction_SampledOut_Dropped()
10001022
{

0 commit comments

Comments
 (0)