Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
check of pii first
  • Loading branch information
bitsandfoxes committed Jan 15, 2025
commit f600d9a99dc62b991ff54887c0c41f2f145d5b69
10 changes: 7 additions & 3 deletions src/Sentry/Internal/Enricher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,16 @@ public void Apply(IEventLike eventLike)

// User
// Report local user if opt-in PII, no user was already set to event and feature not opted-out:
if (_options is { SendDefaultPii: true, IsEnvironmentUser: true } && !eventLike.HasUser())
if (_options.SendDefaultPii)
{
eventLike.User.Username = Environment.UserName;
if (_options.IsEnvironmentUser && !eventLike.HasUser())
{
eventLike.User.Username = Environment.UserName;
}

eventLike.User.IpAddress ??= DefaultIpAddress;
}
eventLike.User.Id ??= _options.InstallationId;
eventLike.User.IpAddress ??= DefaultIpAddress;

//Apply App startup and Boot time
eventLike.Contexts.App.StartTime ??= ProcessInfo.Instance?.StartupTime;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ public void Process_SendDefaultPiiTrueAndUserIpSet_UserIpIgnoreServerInferredIp(
}

[Fact]
public void Process_SendDefaultPiiFalse_UserIpAuto()
public void Process_SendDefaultPiiFalse_UserIpNull()
{
//Arrange
var evt = new SentryEvent();
Expand All @@ -143,7 +143,7 @@ public void Process_SendDefaultPiiFalse_UserIpAuto()
_ = sut.Process(evt);

//Assert
evt.User.IpAddress.Should().Be(Enricher.DefaultIpAddress);
evt.User.IpAddress.Should().Be(null);
}

[Fact]
Expand Down
Loading