Skip to content

Commit 225fd1e

Browse files
Removed obsolete User.Segment property (#3563)
1 parent 94df25f commit 225fd1e

13 files changed

+4
-92
lines changed

CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
# Changelog
22

33
### API Changes
4-
- You should no longer pass `AndroidContext` as an argument to `SentrySdk.Init` ([#3562](https://github.com/getsentry/sentry-dotnet/pull/3562))
54

5+
- You should no longer pass `AndroidContext` as an argument to `SentrySdk.Init` ([#3562](https://github.com/getsentry/sentry-dotnet/pull/3562))
6+
- The `SentryUser.Segment` property has been deprecated. Consider sending this as a tag or additional data instead ([#3563](https://github.com/getsentry/sentry-dotnet/pull/3563))
7+
68
## 4.10.2
79

810
### Various fixes & improvements

src/Sentry.NLog/SentryTarget.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,6 @@ private void InnerWrite(LogEventInfo logEvent)
453453
Username = User.Username?.Render(logEvent),
454454
Email = User.Email?.Render(logEvent),
455455
IpAddress = User.IpAddress?.Render(logEvent),
456-
#pragma warning disable CS0618 // Type or member is obsolete
457-
Segment = User.Segment?.Render(logEvent)
458-
#pragma warning restore CS0618 // Type or member is obsolete
459456
};
460457

461458
if (User.Other?.Count > 0)

src/Sentry/DynamicSamplingContext.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ private DynamicSamplingContext(
2626
double? sampleRate = null,
2727
string? release = null,
2828
string? environment = null,
29-
string? userSegment = null,
3029
string? transactionName = null)
3130
{
3231
// Validate and set required values
@@ -72,11 +71,6 @@ private DynamicSamplingContext(
7271
items.Add("environment", environment);
7372
}
7473

75-
if (!string.IsNullOrWhiteSpace(userSegment))
76-
{
77-
items.Add("user_segment", userSegment);
78-
}
79-
8074
if (!string.IsNullOrWhiteSpace(transactionName))
8175
{
8276
items.Add("transaction", transactionName);
@@ -127,9 +121,6 @@ public static DynamicSamplingContext CreateFromTransaction(TransactionTracer tra
127121
var traceId = transaction.TraceId;
128122
var sampled = transaction.IsSampled;
129123
var sampleRate = transaction.SampleRate!.Value;
130-
#pragma warning disable CS0618 // Type or member is obsolete
131-
var userSegment = transaction.User.Segment;
132-
#pragma warning restore CS0618 // Type or member is obsolete
133124
var transactionName = transaction.NameSource.IsHighQuality() ? transaction.Name : null;
134125

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

src/Sentry/Platforms/Android/Extensions/UserExtensions.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ public static SentryUser ToUser(this JavaSdk.Protocol.User user) =>
1212
Id = user.Id,
1313
IpAddress = user.IpAddress,
1414
Username = user.Username,
15-
#pragma warning disable CS0618 // Type or member is obsolete
16-
Segment = user.Segment,
17-
#pragma warning restore CS0618 // Type or member is obsolete
1815
Other = user.Data ?? EmptyDictionary
1916
};
2017

@@ -25,9 +22,6 @@ public static JavaSdk.Protocol.User ToJavaUser(this SentryUser user) =>
2522
Id = user.Id,
2623
IpAddress = user.IpAddress,
2724
Username = user.Username,
28-
#pragma warning disable CS0618 // Type or member is obsolete
29-
Segment = user.Segment,
30-
#pragma warning restore CS0618 // Type or member is obsolete
3125
Data = user.Other.Count == 0 ? null : user.Other
3226
};
3327
}

src/Sentry/Platforms/Cocoa/Extensions/UserExtensions.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,6 @@ public static SentryUser ToUser(this CocoaSdk.SentryUser user, IDiagnosticLogger
1111
Id = user.UserId,
1212
IpAddress = user.IpAddress,
1313
Username = user.Username,
14-
#pragma warning disable CS0618 // Type or member is obsolete
15-
Segment = user.Segment,
16-
#pragma warning restore CS0618 // Type or member is obsolete
1714
Other = user.Data.ToStringDictionary(logger)
1815
};
1916

@@ -25,9 +22,6 @@ public static CocoaSdk.SentryUser ToCocoaUser(this SentryUser user)
2522
UserId = user.Id,
2623
IpAddress = user.IpAddress,
2724
Username = user.Username,
28-
#pragma warning disable CS0618 // Type or member is obsolete
29-
Segment = user.Segment ?? "",
30-
#pragma warning restore CS0618 // Type or member is obsolete
3125
Data = user.Other.ToNullableNSDictionary()
3226
};
3327

src/Sentry/SentryUser.cs

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ public sealed class SentryUser : ISentryJsonSerializable
1515
private string? _username;
1616
private string? _email;
1717
private string? _ipAddress;
18-
private string? _segment;
1918
private IDictionary<string, string>? _other;
2019

2120
/// <summary>
@@ -82,23 +81,6 @@ public string? IpAddress
8281
}
8382
}
8483

85-
/// <summary>
86-
/// The segment the user belongs to.
87-
/// </summary>
88-
[Obsolete("This property is deprecated and will be removed in a future version.")]
89-
public string? Segment
90-
{
91-
get => _segment;
92-
set
93-
{
94-
if (_segment != value)
95-
{
96-
_segment = value;
97-
PropertyChanged?.Invoke(this);
98-
}
99-
}
100-
}
101-
10284
/// <summary>
10385
/// Additional information about the user.
10486
/// </summary>
@@ -137,9 +119,6 @@ internal void CopyTo(SentryUser? user)
137119
user.Username ??= Username;
138120
user.Email ??= Email;
139121
user.IpAddress ??= IpAddress;
140-
#pragma warning disable CS0618 // Type or member is obsolete
141-
user.Segment ??= Segment;
142-
#pragma warning restore CS0618 // Type or member is obsolete
143122

144123
user._other ??= _other?.ToDictionary(
145124
entry => entry.Key,
@@ -151,9 +130,6 @@ Id is not null ||
151130
Username is not null ||
152131
Email is not null ||
153132
IpAddress is not null ||
154-
#pragma warning disable CS0618 // Type or member is obsolete
155-
Segment is not null ||
156-
#pragma warning restore CS0618 // Type or member is obsolete
157133
_other?.Count > 0;
158134

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

173146
writer.WriteEndObject();
@@ -191,9 +164,6 @@ public static SentryUser FromJson(JsonElement json)
191164
Username = username,
192165
Email = email,
193166
IpAddress = ip,
194-
#pragma warning disable CS0618 // Type or member is obsolete
195-
Segment = segment,
196-
#pragma warning restore CS0618 // Type or member is obsolete
197167
_other = other?.WhereNotNullValue().ToDict()
198168
};
199169
}

test/Sentry.Tests/ApiApprovalTests.Run.DotNet6_0.verified.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,8 +980,6 @@ namespace Sentry
980980
public string? Id { get; set; }
981981
public string? IpAddress { get; set; }
982982
public System.Collections.Generic.IDictionary<string, string> Other { get; set; }
983-
[System.Obsolete("This property is deprecated and will be removed in a future version.")]
984-
public string? Segment { get; set; }
985983
public string? Username { get; set; }
986984
public Sentry.SentryUser Clone() { }
987985
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { }

test/Sentry.Tests/ApiApprovalTests.Run.DotNet7_0.verified.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -980,8 +980,6 @@ namespace Sentry
980980
public string? Id { get; set; }
981981
public string? IpAddress { get; set; }
982982
public System.Collections.Generic.IDictionary<string, string> Other { get; set; }
983-
[System.Obsolete("This property is deprecated and will be removed in a future version.")]
984-
public string? Segment { get; set; }
985983
public string? Username { get; set; }
986984
public Sentry.SentryUser Clone() { }
987985
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { }

test/Sentry.Tests/ApiApprovalTests.Run.DotNet8_0.verified.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -982,8 +982,6 @@ namespace Sentry
982982
public string? Id { get; set; }
983983
public string? IpAddress { get; set; }
984984
public System.Collections.Generic.IDictionary<string, string> Other { get; set; }
985-
[System.Obsolete("This property is deprecated and will be removed in a future version.")]
986-
public string? Segment { get; set; }
987985
public string? Username { get; set; }
988986
public Sentry.SentryUser Clone() { }
989987
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { }

test/Sentry.Tests/ApiApprovalTests.Run.Net4_8.verified.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -977,8 +977,6 @@ namespace Sentry
977977
public string? Id { get; set; }
978978
public string? IpAddress { get; set; }
979979
public System.Collections.Generic.IDictionary<string, string> Other { get; set; }
980-
[System.Obsolete("This property is deprecated and will be removed in a future version.")]
981-
public string? Segment { get; set; }
982980
public string? Username { get; set; }
983981
public Sentry.SentryUser Clone() { }
984982
public void WriteTo(System.Text.Json.Utf8JsonWriter writer, Sentry.Extensibility.IDiagnosticLogger? _) { }

0 commit comments

Comments
 (0)