Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Significant change in behavior

- The User.IpAddress is now only set to `{{auto}}` when `SendDefaultPii` is enabled. This change gives you control over IP address collection directly on the client ([#3893](https://github.com/getsentry/sentry-dotnet/pull/3893))

### Features

- .NET on iOS: Add experimental EnableAppHangTrackingV2 configuration flag to the options binding SDK ([#3877](https://github.com/getsentry/sentry-dotnet/pull/3877))
Expand Down
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 @@ -26,8 +26,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
},
Environment: production,
Breadcrumbs: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
},
Environment: production,
Breadcrumbs: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
},
Spans: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
},
Spans: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
}
}
},
Expand All @@ -46,8 +45,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
},
Breadcrumbs: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
}
}
},
Expand All @@ -46,8 +45,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
},
Breadcrumbs: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
}
}
},
Expand All @@ -46,8 +45,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
},
Breadcrumbs: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
}
}
},
Expand All @@ -46,8 +45,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
},
Breadcrumbs: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
},
Environment: production
}
Expand All @@ -47,8 +46,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
},
Environment: production,
Breadcrumbs: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
}
},
User: {
Id: Guid_3,
IpAddress: {{auto}}
Id: Guid_3
},
Environment: production
}
Expand Down Expand Up @@ -75,8 +74,7 @@
}
},
User: {
Id: Guid_3,
IpAddress: {{auto}}
Id: Guid_3
},
Environment: production
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
}
},
User: {
Id: Guid_3,
IpAddress: {{auto}}
Id: Guid_3
},
Environment: production
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@
}
},
User: {
Id: Guid_3,
IpAddress: {{auto}}
Id: Guid_3
},
Environment: production
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,7 @@
}
},
User: {
Id: Guid_3,
IpAddress: {{auto}}
Id: Guid_3
},
Environment: production
}
Expand Down
3 changes: 1 addition & 2 deletions test/Sentry.Tests/EventProcessorTests.Simple.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
}
},
User: {
Id: Guid_3,
IpAddress: {{auto}}
Id: Guid_3
},
Environment: production
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@
}
},
User: {
Id: Guid_3,
IpAddress: {{auto}}
Id: Guid_3
},
Environment: production
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
},
Environment: production
}
Expand Down Expand Up @@ -177,8 +176,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
},
Environment: production,
IsFinished: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
},
Environment: production
}
Expand Down Expand Up @@ -177,8 +176,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
},
Environment: production,
IsFinished: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
},
Environment: production
}
Expand Down Expand Up @@ -177,8 +176,7 @@
}
},
User: {
Id: Guid_1,
IpAddress: {{auto}}
Id: Guid_1
},
Environment: production,
IsFinished: true
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_UserIpUserIpNotSet()
{
//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
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
}
},
User: {
Id: Guid_3,
IpAddress: {{auto}}
Id: Guid_3
},
Environment: production
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@
}
},
User: {
Id: Guid_3,
IpAddress: {{auto}}
Id: Guid_3
},
Environment: production
}
Expand Down Expand Up @@ -85,8 +84,7 @@
}
},
User: {
Id: Guid_3,
IpAddress: {{auto}}
Id: Guid_3
},
Environment: production,
IsFinished: true
Expand Down
Loading