Skip to content

Commit

Permalink
Removed obsolete User.Segment property
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescrosswell committed Aug 26, 2024
1 parent de216fa commit a8026c3
Show file tree
Hide file tree
Showing 12 changed files with 1 addition and 91 deletions.
3 changes: 0 additions & 3 deletions src/Sentry.NLog/SentryTarget.cs
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,6 @@ private void InnerWrite(LogEventInfo logEvent)
Username = User.Username?.Render(logEvent),
Email = User.Email?.Render(logEvent),
IpAddress = User.IpAddress?.Render(logEvent),
#pragma warning disable CS0618 // Type or member is obsolete
Segment = User.Segment?.Render(logEvent)
#pragma warning restore CS0618 // Type or member is obsolete
};

if (User.Other?.Count > 0)
Expand Down
10 changes: 0 additions & 10 deletions src/Sentry/DynamicSamplingContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ private DynamicSamplingContext(
double? sampleRate = null,
string? release = null,
string? environment = null,
string? userSegment = null,
string? transactionName = null)
{
// Validate and set required values
Expand Down Expand Up @@ -72,11 +71,6 @@ private DynamicSamplingContext(
items.Add("environment", environment);
}

if (!string.IsNullOrWhiteSpace(userSegment))
{
items.Add("user_segment", userSegment);
}

if (!string.IsNullOrWhiteSpace(transactionName))
{
items.Add("transaction", transactionName);
Expand Down Expand Up @@ -127,9 +121,6 @@ public static DynamicSamplingContext CreateFromTransaction(TransactionTracer tra
var traceId = transaction.TraceId;
var sampled = transaction.IsSampled;
var sampleRate = transaction.SampleRate!.Value;
#pragma warning disable CS0618 // Type or member is obsolete
var userSegment = transaction.User.Segment;
#pragma warning restore CS0618 // Type or member is obsolete
var transactionName = transaction.NameSource.IsHighQuality() ? transaction.Name : null;

// These two may not have been set yet on the transaction, but we can get them directly.
Expand All @@ -143,7 +134,6 @@ public static DynamicSamplingContext CreateFromTransaction(TransactionTracer tra
sampleRate,
release,
environment,
userSegment,
transactionName);
}

Expand Down
6 changes: 0 additions & 6 deletions src/Sentry/Platforms/Android/Extensions/UserExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ public static SentryUser ToUser(this JavaSdk.Protocol.User user) =>
Id = user.Id,
IpAddress = user.IpAddress,
Username = user.Username,
#pragma warning disable CS0618 // Type or member is obsolete
Segment = user.Segment,
#pragma warning restore CS0618 // Type or member is obsolete
Other = user.Data ?? EmptyDictionary
};

Expand All @@ -25,9 +22,6 @@ public static JavaSdk.Protocol.User ToJavaUser(this SentryUser user) =>
Id = user.Id,
IpAddress = user.IpAddress,
Username = user.Username,
#pragma warning disable CS0618 // Type or member is obsolete
Segment = user.Segment,
#pragma warning restore CS0618 // Type or member is obsolete
Data = user.Other.Count == 0 ? null : user.Other
};
}
6 changes: 0 additions & 6 deletions src/Sentry/Platforms/Cocoa/Extensions/UserExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@ public static SentryUser ToUser(this CocoaSdk.SentryUser user, IDiagnosticLogger
Id = user.UserId,
IpAddress = user.IpAddress,
Username = user.Username,
#pragma warning disable CS0618 // Type or member is obsolete
Segment = user.Segment,
#pragma warning restore CS0618 // Type or member is obsolete
Other = user.Data.ToStringDictionary(logger)
};

Expand All @@ -25,9 +22,6 @@ public static CocoaSdk.SentryUser ToCocoaUser(this SentryUser user)
UserId = user.Id,
IpAddress = user.IpAddress,
Username = user.Username,
#pragma warning disable CS0618 // Type or member is obsolete
Segment = user.Segment ?? "",
#pragma warning restore CS0618 // Type or member is obsolete
Data = user.Other.ToNullableNSDictionary()
};

Expand Down
30 changes: 0 additions & 30 deletions src/Sentry/SentryUser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ public sealed class SentryUser : ISentryJsonSerializable
private string? _username;
private string? _email;
private string? _ipAddress;
private string? _segment;
private IDictionary<string, string>? _other;

/// <summary>
Expand Down Expand Up @@ -82,23 +81,6 @@ public string? IpAddress
}
}

/// <summary>
/// The segment the user belongs to.
/// </summary>
[Obsolete("This property is deprecated and will be removed in a future version.")]
public string? Segment
{
get => _segment;
set
{
if (_segment != value)
{
_segment = value;
PropertyChanged?.Invoke(this);
}
}
}

/// <summary>
/// Additional information about the user.
/// </summary>
Expand Down Expand Up @@ -137,9 +119,6 @@ internal void CopyTo(SentryUser? user)
user.Username ??= Username;
user.Email ??= Email;
user.IpAddress ??= IpAddress;
#pragma warning disable CS0618 // Type or member is obsolete
user.Segment ??= Segment;
#pragma warning restore CS0618 // Type or member is obsolete

user._other ??= _other?.ToDictionary(
entry => entry.Key,
Expand All @@ -151,9 +130,6 @@ Id is not null ||
Username is not null ||
Email is not null ||
IpAddress is not null ||
#pragma warning disable CS0618 // Type or member is obsolete
Segment is not null ||
#pragma warning restore CS0618 // Type or member is obsolete
_other?.Count > 0;

/// <inheritdoc />
Expand All @@ -165,9 +141,6 @@ public void WriteTo(Utf8JsonWriter writer, IDiagnosticLogger? _)
writer.WriteStringIfNotWhiteSpace("username", Username);
writer.WriteStringIfNotWhiteSpace("email", Email);
writer.WriteStringIfNotWhiteSpace("ip_address", IpAddress);
#pragma warning disable CS0618 // Type or member is obsolete
writer.WriteStringIfNotWhiteSpace("segment", Segment);
#pragma warning restore CS0618 // Type or member is obsolete
writer.WriteStringDictionaryIfNotEmpty("other", _other!);

writer.WriteEndObject();
Expand All @@ -191,9 +164,6 @@ public static SentryUser FromJson(JsonElement json)
Username = username,
Email = email,
IpAddress = ip,
#pragma warning disable CS0618 // Type or member is obsolete
Segment = segment,
#pragma warning restore CS0618 // Type or member is obsolete
_other = other?.WhereNotNullValue().ToDict()
};
}
Expand Down
2 changes: 0 additions & 2 deletions test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -980,8 +980,6 @@ namespace Sentry
public string? Id { get; set; }
public string? IpAddress { get; set; }
public System.Collections.Generic.IDictionary<string, string> Other { get; set; }
[System.Obsolete("This property is deprecated and will be removed in a future version.")]
public string? Segment { get; set; }
public string? Username { get; set; }
public Sentry.SentryUser Clone() { }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { }
Expand Down
2 changes: 0 additions & 2 deletions test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -980,8 +980,6 @@ namespace Sentry
public string? Id { get; set; }
public string? IpAddress { get; set; }
public System.Collections.Generic.IDictionary<string, string> Other { get; set; }
[System.Obsolete("This property is deprecated and will be removed in a future version.")]
public string? Segment { get; set; }
public string? Username { get; set; }
public Sentry.SentryUser Clone() { }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { }
Expand Down
2 changes: 0 additions & 2 deletions test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -982,8 +982,6 @@ namespace Sentry
public string? Id { get; set; }
public string? IpAddress { get; set; }
public System.Collections.Generic.IDictionary<string, string> Other { get; set; }
[System.Obsolete("This property is deprecated and will be removed in a future version.")]
public string? Segment { get; set; }
public string? Username { get; set; }
public Sentry.SentryUser Clone() { }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { }
Expand Down
2 changes: 0 additions & 2 deletions test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt
Original file line number Diff line number Diff line change
Expand Up @@ -977,8 +977,6 @@ namespace Sentry
public string? Id { get; set; }
public string? IpAddress { get; set; }
public System.Collections.Generic.IDictionary<string, string> Other { get; set; }
[System.Obsolete("This property is deprecated and will be removed in a future version.")]
public string? Segment { get; set; }
public string? Username { get; set; }
public Sentry.SentryUser Clone() { }
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { }
Expand Down
6 changes: 1 addition & 5 deletions test/Sentry.Tests/DynamicSamplingContextTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -255,16 +255,13 @@ public void CreateFromTransaction(bool? isSampled)
SampleRate = 0.5,
User =
{
#pragma warning disable CS0618 // Type or member is obsolete
Segment = "Group A"
#pragma warning restore CS0618 // Type or member is obsolete
},
};

var dsc = transaction.CreateDynamicSamplingContext(options);

Assert.NotNull(dsc);
Assert.Equal(isSampled.HasValue ? 8 : 7, dsc.Items.Count);
Assert.Equal(isSampled.HasValue ? 7 : 6, dsc.Items.Count);
Assert.Equal(traceId.ToString(), Assert.Contains("trace_id", dsc.Items));
Assert.Equal("d4d82fc1c2c4032a83f3a29aa3a3aff", Assert.Contains("public_key", dsc.Items));
if (transaction.IsSampled is { } sampled)
Expand All @@ -278,7 +275,6 @@ public void CreateFromTransaction(bool? isSampled)
Assert.Equal("0.5", Assert.Contains("sample_rate", dsc.Items));
Assert.Equal("foo@2.4.5", Assert.Contains("release", dsc.Items));
Assert.Equal("staging", Assert.Contains("environment", dsc.Items));
Assert.Equal("Group A", Assert.Contains("user_segment", dsc.Items));
Assert.Equal("GET /person/{id}", Assert.Contains("transaction", dsc.Items));
}

Expand Down
10 changes: 0 additions & 10 deletions test/Sentry.Tests/Protocol/ScopeTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,6 @@ public void HasUser_UserWithIpAddress_ReturnsTrue()
Assert.True(sut.HasUser());
}

[Fact]
public void HasUser_UserWithSegment_ReturnsTrue()
{
var sut = _fixture.GetSut();
#pragma warning disable CS0618 // Type or member is obsolete
sut.User.Segment = "test";
#pragma warning restore CS0618 // Type or member is obsolete
Assert.True(sut.HasUser());
}

[Fact]
public void HasUser_UserWithOther_ReturnsTrue()
{
Expand Down
13 changes: 0 additions & 13 deletions test/Sentry.Tests/Protocol/UserTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ public void SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject()
Username = "user-name",
Email = "test@sentry.io",
IpAddress = "::1",
#pragma warning disable CS0618 // Type or member is obsolete
Segment = "A1",
#pragma warning restore CS0618 // Type or member is obsolete
Other = new Dictionary<string, string> { { "testCustomValueKey", "testCustomValue" } }
};

Expand All @@ -32,7 +29,6 @@ public void SerializeObject_AllPropertiesSetToNonDefault_SerializesValidObject()
"username": "user-name",
"email": "test@sentry.io",
"ip_address": "::1",
"segment": "A1",
"other": {
"testCustomValueKey": "testCustomValue"
}
Expand All @@ -50,9 +46,6 @@ public void Clone_CopyValues()
Email = "emal@sentry.io",
IpAddress = "::1",
Username = "user",
#pragma warning disable CS0618 // Type or member is obsolete
Segment = "segment",
#pragma warning restore CS0618 // Type or member is obsolete
Other = new Dictionary<string, string>
{
{"testCustomValueKey", "testCustomValue"}
Expand All @@ -65,9 +58,6 @@ public void Clone_CopyValues()
Assert.Equal(sut.Username, clone.Username);
Assert.Equal(sut.Email, clone.Email);
Assert.Equal(sut.IpAddress, clone.IpAddress);
#pragma warning disable CS0618 // Type or member is obsolete
Assert.Equal(sut.Segment, clone.Segment);
#pragma warning restore CS0618 // Type or member is obsolete
Assert.Equal(sut.Other, clone.Other);
}

Expand All @@ -86,9 +76,6 @@ public static IEnumerable<object[]> TestCases()
yield return new object[] { (new SentryUser { Username = "some username" }, """{"username":"some username"}""") };
yield return new object[] { (new SentryUser { Email = "some email" }, """{"email":"some email"}""") };
yield return new object[] { (new SentryUser { IpAddress = "some ipAddress" }, """{"ip_address":"some ipAddress"}""") };
#pragma warning disable CS0618 // Type or member is obsolete
yield return new object[] { (new SentryUser { Segment = "some segment" }, """{"segment":"some segment"}""") };
#pragma warning restore CS0618 // Type or member is obsolete

var other = new Dictionary<string, string> { { "testCustomValueKey", "testCustomValue" } };
yield return new object[] { (new SentryUser { Other = other }, """{"other":{"testCustomValueKey":"testCustomValue"}}""") };
Expand Down

0 comments on commit a8026c3

Please sign in to comment.