diff --git a/CHANGELOG.md b/CHANGELOG.md index 6354eb4f46..9426f0ec6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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)) diff --git a/src/Sentry/Internal/Enricher.cs b/src/Sentry/Internal/Enricher.cs index df28a50e32..54829dca86 100644 --- a/src/Sentry/Internal/Enricher.cs +++ b/src/Sentry/Internal/Enricher.cs @@ -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; diff --git a/test/Sentry.AspNetCore.Tests/WebIntegrationTests.Versioning.DotNet8_0.verified.txt b/test/Sentry.AspNetCore.Tests/WebIntegrationTests.Versioning.DotNet8_0.verified.txt index a75596e368..f60140240c 100644 --- a/test/Sentry.AspNetCore.Tests/WebIntegrationTests.Versioning.DotNet8_0.verified.txt +++ b/test/Sentry.AspNetCore.Tests/WebIntegrationTests.Versioning.DotNet8_0.verified.txt @@ -26,8 +26,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 }, Environment: production, Breadcrumbs: [ diff --git a/test/Sentry.AspNetCore.Tests/WebIntegrationTests.Versioning.DotNet9_0.verified.txt b/test/Sentry.AspNetCore.Tests/WebIntegrationTests.Versioning.DotNet9_0.verified.txt index a75596e368..f60140240c 100644 --- a/test/Sentry.AspNetCore.Tests/WebIntegrationTests.Versioning.DotNet9_0.verified.txt +++ b/test/Sentry.AspNetCore.Tests/WebIntegrationTests.Versioning.DotNet9_0.verified.txt @@ -26,8 +26,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 }, Environment: production, Breadcrumbs: [ diff --git a/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.LoggingAsync.DotNet8_0.verified.txt b/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.LoggingAsync.DotNet8_0.verified.txt index 2eebc2dae0..298823718c 100644 --- a/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.LoggingAsync.DotNet8_0.verified.txt +++ b/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.LoggingAsync.DotNet8_0.verified.txt @@ -18,8 +18,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 }, Spans: [ { diff --git a/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.LoggingAsync.DotNet9_0.verified.txt b/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.LoggingAsync.DotNet9_0.verified.txt index 2eebc2dae0..298823718c 100644 --- a/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.LoggingAsync.DotNet9_0.verified.txt +++ b/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.LoggingAsync.DotNet9_0.verified.txt @@ -18,8 +18,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 }, Spans: [ { diff --git a/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.RecordsEfAsync.DotNet8_0.verified.txt b/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.RecordsEfAsync.DotNet8_0.verified.txt index 5c1985dbc1..aa6dedca8c 100644 --- a/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.RecordsEfAsync.DotNet8_0.verified.txt +++ b/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.RecordsEfAsync.DotNet8_0.verified.txt @@ -22,8 +22,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 } } }, @@ -46,8 +45,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 }, Breadcrumbs: [ { diff --git a/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.RecordsEfAsync.DotNet9_0.verified.txt b/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.RecordsEfAsync.DotNet9_0.verified.txt index 5c1985dbc1..aa6dedca8c 100644 --- a/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.RecordsEfAsync.DotNet9_0.verified.txt +++ b/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.RecordsEfAsync.DotNet9_0.verified.txt @@ -22,8 +22,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 } } }, @@ -46,8 +45,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 }, Breadcrumbs: [ { diff --git a/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.RecordsEfAsync.Net4_8.verified.txt b/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.RecordsEfAsync.Net4_8.verified.txt index ce2f1f8ffa..96826b04ae 100644 --- a/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.RecordsEfAsync.Net4_8.verified.txt +++ b/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.RecordsEfAsync.Net4_8.verified.txt @@ -22,8 +22,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 } } }, @@ -46,8 +45,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 }, Breadcrumbs: [ { diff --git a/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.RecordsSqlAsync.verified.txt b/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.RecordsSqlAsync.verified.txt index 37f2475d22..7d7654f67d 100644 --- a/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.RecordsSqlAsync.verified.txt +++ b/test/Sentry.DiagnosticSource.IntegrationTests/SqlListenerTests.RecordsSqlAsync.verified.txt @@ -22,8 +22,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 } } }, @@ -46,8 +45,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 }, Breadcrumbs: [ { diff --git a/test/Sentry.EntityFramework.Tests/IntegrationTests.Simple.verified.txt b/test/Sentry.EntityFramework.Tests/IntegrationTests.Simple.verified.txt index bc260895fb..e24261c17c 100644 --- a/test/Sentry.EntityFramework.Tests/IntegrationTests.Simple.verified.txt +++ b/test/Sentry.EntityFramework.Tests/IntegrationTests.Simple.verified.txt @@ -22,8 +22,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 }, Environment: production } @@ -47,8 +46,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 }, Environment: production, Breadcrumbs: [ diff --git a/test/Sentry.Log4Net.Tests/IntegrationTests.LoggingInsideTheContextOfLogging.verified.txt b/test/Sentry.Log4Net.Tests/IntegrationTests.LoggingInsideTheContextOfLogging.verified.txt index 92bf1b5798..35fe2365e2 100644 --- a/test/Sentry.Log4Net.Tests/IntegrationTests.LoggingInsideTheContextOfLogging.verified.txt +++ b/test/Sentry.Log4Net.Tests/IntegrationTests.LoggingInsideTheContextOfLogging.verified.txt @@ -33,8 +33,7 @@ } }, User: { - Id: Guid_3, - IpAddress: {{auto}} + Id: Guid_3 }, Environment: production } @@ -75,8 +74,7 @@ } }, User: { - Id: Guid_3, - IpAddress: {{auto}} + Id: Guid_3 }, Environment: production } diff --git a/test/Sentry.Log4Net.Tests/IntegrationTests.Simple.verified.txt b/test/Sentry.Log4Net.Tests/IntegrationTests.Simple.verified.txt index 65415cde47..4ec1830811 100644 --- a/test/Sentry.Log4Net.Tests/IntegrationTests.Simple.verified.txt +++ b/test/Sentry.Log4Net.Tests/IntegrationTests.Simple.verified.txt @@ -32,8 +32,7 @@ } }, User: { - Id: Guid_3, - IpAddress: {{auto}} + Id: Guid_3 }, Environment: production } diff --git a/test/Sentry.NLog.Tests/IntegrationTests.LoggingInsideTheContextOfLogging.verified.txt b/test/Sentry.NLog.Tests/IntegrationTests.LoggingInsideTheContextOfLogging.verified.txt index d333fa1efb..016d53f540 100644 --- a/test/Sentry.NLog.Tests/IntegrationTests.LoggingInsideTheContextOfLogging.verified.txt +++ b/test/Sentry.NLog.Tests/IntegrationTests.LoggingInsideTheContextOfLogging.verified.txt @@ -40,8 +40,7 @@ } }, User: { - Id: Guid_3, - IpAddress: {{auto}} + Id: Guid_3 }, Environment: production } diff --git a/test/Sentry.Serilog.Tests/IntegrationTests.LoggingInsideTheContextOfLogging.verified.txt b/test/Sentry.Serilog.Tests/IntegrationTests.LoggingInsideTheContextOfLogging.verified.txt index c5df4578af..d917dd9d91 100644 --- a/test/Sentry.Serilog.Tests/IntegrationTests.LoggingInsideTheContextOfLogging.verified.txt +++ b/test/Sentry.Serilog.Tests/IntegrationTests.LoggingInsideTheContextOfLogging.verified.txt @@ -39,8 +39,7 @@ } }, User: { - Id: Guid_3, - IpAddress: {{auto}} + Id: Guid_3 }, Environment: production } diff --git a/test/Sentry.Tests/EventProcessorTests.Simple.verified.txt b/test/Sentry.Tests/EventProcessorTests.Simple.verified.txt index f4d20928c3..b63e99dd53 100644 --- a/test/Sentry.Tests/EventProcessorTests.Simple.verified.txt +++ b/test/Sentry.Tests/EventProcessorTests.Simple.verified.txt @@ -32,8 +32,7 @@ } }, User: { - Id: Guid_3, - IpAddress: {{auto}} + Id: Guid_3 }, Environment: production } diff --git a/test/Sentry.Tests/EventProcessorTests.WithTransaction.verified.txt b/test/Sentry.Tests/EventProcessorTests.WithTransaction.verified.txt index 798424284e..af9d84138f 100644 --- a/test/Sentry.Tests/EventProcessorTests.WithTransaction.verified.txt +++ b/test/Sentry.Tests/EventProcessorTests.WithTransaction.verified.txt @@ -36,8 +36,7 @@ } }, User: { - Id: Guid_3, - IpAddress: {{auto}} + Id: Guid_3 }, Environment: production } diff --git a/test/Sentry.Tests/HubTests.CaptureEvent_ActiveTransaction_UnhandledExceptionTransactionEndedAsCrashed.DotNet8_0.verified.txt b/test/Sentry.Tests/HubTests.CaptureEvent_ActiveTransaction_UnhandledExceptionTransactionEndedAsCrashed.DotNet8_0.verified.txt index e2f6a68211..34439cfbcc 100644 --- a/test/Sentry.Tests/HubTests.CaptureEvent_ActiveTransaction_UnhandledExceptionTransactionEndedAsCrashed.DotNet8_0.verified.txt +++ b/test/Sentry.Tests/HubTests.CaptureEvent_ActiveTransaction_UnhandledExceptionTransactionEndedAsCrashed.DotNet8_0.verified.txt @@ -112,8 +112,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 }, Environment: production } @@ -177,8 +176,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 }, Environment: production, IsFinished: true diff --git a/test/Sentry.Tests/HubTests.CaptureEvent_ActiveTransaction_UnhandledExceptionTransactionEndedAsCrashed.DotNet9_0.verified.txt b/test/Sentry.Tests/HubTests.CaptureEvent_ActiveTransaction_UnhandledExceptionTransactionEndedAsCrashed.DotNet9_0.verified.txt index e2f6a68211..34439cfbcc 100644 --- a/test/Sentry.Tests/HubTests.CaptureEvent_ActiveTransaction_UnhandledExceptionTransactionEndedAsCrashed.DotNet9_0.verified.txt +++ b/test/Sentry.Tests/HubTests.CaptureEvent_ActiveTransaction_UnhandledExceptionTransactionEndedAsCrashed.DotNet9_0.verified.txt @@ -112,8 +112,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 }, Environment: production } @@ -177,8 +176,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 }, Environment: production, IsFinished: true diff --git a/test/Sentry.Tests/HubTests.CaptureEvent_ActiveTransaction_UnhandledExceptionTransactionEndedAsCrashed.Net4_8.verified.txt b/test/Sentry.Tests/HubTests.CaptureEvent_ActiveTransaction_UnhandledExceptionTransactionEndedAsCrashed.Net4_8.verified.txt index 800647416d..b453712534 100644 --- a/test/Sentry.Tests/HubTests.CaptureEvent_ActiveTransaction_UnhandledExceptionTransactionEndedAsCrashed.Net4_8.verified.txt +++ b/test/Sentry.Tests/HubTests.CaptureEvent_ActiveTransaction_UnhandledExceptionTransactionEndedAsCrashed.Net4_8.verified.txt @@ -112,8 +112,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 }, Environment: production } @@ -177,8 +176,7 @@ } }, User: { - Id: Guid_1, - IpAddress: {{auto}} + Id: Guid_1 }, Environment: production, IsFinished: true diff --git a/test/Sentry.Tests/Internals/MainSentryEventProcessorTests.cs b/test/Sentry.Tests/Internals/MainSentryEventProcessorTests.cs index 26956f6ad3..a34d28625f 100644 --- a/test/Sentry.Tests/Internals/MainSentryEventProcessorTests.cs +++ b/test/Sentry.Tests/Internals/MainSentryEventProcessorTests.cs @@ -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(); @@ -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] diff --git a/test/Sentry.Tests/TransactionProcessorTests.Discard.verified.txt b/test/Sentry.Tests/TransactionProcessorTests.Discard.verified.txt index 75f069a373..6ffc1f77f4 100644 --- a/test/Sentry.Tests/TransactionProcessorTests.Discard.verified.txt +++ b/test/Sentry.Tests/TransactionProcessorTests.Discard.verified.txt @@ -35,8 +35,7 @@ } }, User: { - Id: Guid_3, - IpAddress: {{auto}} + Id: Guid_3 }, Environment: production } diff --git a/test/Sentry.Tests/TransactionProcessorTests.Simple.verified.txt b/test/Sentry.Tests/TransactionProcessorTests.Simple.verified.txt index e97eedb4cd..b8a5f7a62b 100644 --- a/test/Sentry.Tests/TransactionProcessorTests.Simple.verified.txt +++ b/test/Sentry.Tests/TransactionProcessorTests.Simple.verified.txt @@ -35,8 +35,7 @@ } }, User: { - Id: Guid_3, - IpAddress: {{auto}} + Id: Guid_3 }, Environment: production } @@ -85,8 +84,7 @@ } }, User: { - Id: Guid_3, - IpAddress: {{auto}} + Id: Guid_3 }, Environment: production, IsFinished: true