Skip to content

Commit 0eea9ca

Browse files
Merge branch 'main' into alexsohn/fix/fail-build-when-profiling-with-blazor-wasm
2 parents 28377c7 + e1f9b5f commit 0eea9ca

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
### Fixes
66

77
- Fail when building Blazor WASM with Profiling. We don't support profiling in Blazor WebAssembly projects. ([#4512](https://github.com/getsentry/sentry-dotnet/pull/4512))
8+
- Do not overwrite user IP if it is set manually in ASP.NET sdk ([#4513](https://github.com/getsentry/sentry-dotnet/pull/4513))
89

910
## 5.15.0
1011

src/Sentry.AspNet/Internal/SystemWebRequestEventProcessor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public SystemWebRequestEventProcessor(IRequestPayloadExtractor payloadExtractor,
7373
@event.User.Username = null;
7474
}
7575

76-
@event.User.IpAddress = context.Request.UserHostAddress;
76+
@event.User.IpAddress ??= context.Request.UserHostAddress;
7777
if (context.User.Identity is { } identity)
7878
{
7979
@event.User.Username = identity.Name;

test/Sentry.AspNet.Tests/Internal/SystemWebRequestEventProcessorTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,21 @@ public void Process_NoBodyExtracted_NoRequestData()
7070
Assert.Same(expected, actual);
7171
Assert.Null(expected.Request.Data);
7272
}
73+
74+
[Fact]
75+
public void Process_PresetUserIP_NotOverwritten()
76+
{
77+
const string userIp = "192.0.0.1";
78+
var evt = new SentryEvent();
79+
evt.User.IpAddress = userIp;
80+
81+
Context = HttpContextBuilder.Build();
82+
// Ensure user is not null
83+
Context.User = new GenericPrincipal(new GenericIdentity("TestUser"), null);
84+
_fixture.SentryOptions.SendDefaultPii = true;
85+
var sut = _fixture.GetSut();
86+
87+
var processedEvt = sut.Process(evt);
88+
Assert.Equal(userIp, processedEvt?.User.IpAddress);
89+
}
7390
}

test/Sentry.Tests/Internals/SentryStopwatchTests.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,13 @@ public void CurrentDateTimeOffset_IsValid()
2424
current.Should().BeCloseTo(DateTimeOffset.UtcNow, TestPrecision);
2525
}
2626

27-
[Fact]
27+
[SkippableFact]
2828
public void Elapsed_IsValid()
2929
{
30+
#if IOS
31+
Skip.If(TestEnvironment.IsGitHubActions, "Flaky on iOS in CI.");
32+
#endif
33+
3034
var sleepTime = TimeSpan.FromMilliseconds(100);
3135

3236
var sw = SentryStopwatch.StartNew();

0 commit comments

Comments
 (0)