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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

## Unreleased

### Significant change in behavior

- The User.IpAddress is now set to {{auto}} by default, even when sendDefaultPII is disabled ([#2981](https://github.com/getsentry/sentry-dotnet/pull/2981))
- The "Prevent Storing of IP Addresses" option in the "Security & Privacy" project settings on sentry.io can be used to control this instead

### Dependencies

- Bump Cocoa SDK from v8.17.1 to v8.17.2 ([#2972](https://github.com/getsentry/sentry-dotnet/pull/2972))
Expand Down
12 changes: 5 additions & 7 deletions src/Sentry/Internal/Enricher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ namespace Sentry.Internal;

internal class Enricher
{
internal const string DefaultIpAddress = "{{auto}}";

private readonly SentryOptions _options;

private readonly Lazy<Runtime> _runtimeLazy = new(() =>
Expand Down Expand Up @@ -74,15 +76,11 @@ 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.SendDefaultPii)
if (_options is { SendDefaultPii: true, IsEnvironmentUser: true } && !eventLike.HasUser())
{
if (_options.IsEnvironmentUser && !eventLike.HasUser())
{
eventLike.User.Username = Environment.UserName;
}

eventLike.User.IpAddress ??= "{{auto}}";
eventLike.User.Username = Environment.UserName;
}
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 @@ -23,7 +23,9 @@
IsSampled: true
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Environment: production,
Breadcrumbs: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
IsSampled: true
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Environment: production,
Breadcrumbs: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@
IsSampled: true
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Environment: production,
Breadcrumbs: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ WHERE @@ROWCOUNT = 1 AND [Id] = scope_identity();
Operation:
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Breadcrumbs: [
{
Message: Entity Framework Core initialized 'TestDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer:' with options: NoTracking ,
Expand Down Expand Up @@ -66,7 +68,9 @@ WHERE @@ROWCOUNT = 1 AND [Id] = scope_identity();,
IsSampled: true
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Spans: [
{
IsFinished: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ WHERE @@ROWCOUNT = 1 AND [Id] = scope_identity();
Operation:
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Breadcrumbs: [
{
Message: Entity Framework Core initialized 'TestDbContext' using provider 'Microsoft.EntityFrameworkCore.SqlServer:' with options: NoTracking ,
Expand Down Expand Up @@ -66,7 +68,9 @@ WHERE @@ROWCOUNT = 1 AND [Id] = scope_identity();,
IsSampled: true
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Spans: [
{
IsFinished: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@
IsSampled: true
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Spans: [
{
IsFinished: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
Operation:
}
},
User: {}
User: {
IpAddress: {{auto}}
}
}
},
{
Expand All @@ -42,7 +44,9 @@
IsSampled: true
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Spans: [
{
IsFinished: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
Operation:
}
},
User: {}
User: {
IpAddress: {{auto}}
}
}
},
{
Expand All @@ -42,7 +44,9 @@
IsSampled: true
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Spans: [
{
IsFinished: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
Operation:
}
},
User: {}
User: {
IpAddress: {{auto}}
}
}
},
{
Expand All @@ -42,7 +44,9 @@
IsSampled: true
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Spans: [
{
IsFinished: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
Operation:
}
},
User: {}
User: {
IpAddress: {{auto}}
}
}
},
{
Expand All @@ -42,7 +44,9 @@
IsSampled: true
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Spans: [
{
IsFinished: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
Operation:
}
},
User: {}
User: {
IpAddress: {{auto}}
}
}
},
{
Expand All @@ -42,7 +44,9 @@
IsSampled: true
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Spans: [
{
IsFinished: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@
Operation:
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Environment: production
}
},
Expand All @@ -43,7 +45,9 @@
IsSampled: true
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Environment: production,
Spans: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@
Operation:
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Environment: production
}
}
Expand Down Expand Up @@ -71,7 +73,9 @@
Operation:
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Environment: production
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
Operation:
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Environment: production
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
Operation:
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Environment: production
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@
Operation:
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Environment: production
}
}
Expand Down
4 changes: 3 additions & 1 deletion test/Sentry.Tests/EventProcessorTests.Simple.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@
Operation:
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Environment: production
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@
Operation:
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Environment: production
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@
Operation:
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Environment: production
}
}
Expand Down Expand Up @@ -173,7 +175,9 @@
IsSampled: true
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Environment: production,
IsFinished: true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@
Operation:
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Environment: production
}
}
Expand Down Expand Up @@ -173,7 +175,9 @@
IsSampled: true
}
},
User: {},
User: {
IpAddress: {{auto}}
},
Environment: production,
IsFinished: true
}
Expand Down
Loading