Skip to content

Commit

Permalink
deprecate: user segment (#2119)
Browse files Browse the repository at this point in the history
* Update

* update

* Add deprecation to setUserSegment
  • Loading branch information
buenaflor authored Jun 25, 2024
1 parent acbd5d3 commit e4d5aa8
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
- Capture total frames, frames delay, slow & frozen frames and attach to spans ([#2106](https://github.com/getsentry/sentry-dart/pull/2106))
- Support WebAssembly compilation (dart2wasm) ([#2113](https://github.com/getsentry/sentry-dart/pull/2113))

### Deprecated

- User segment is now deprecated and will be removed in version 9.0.0. Use a custom tag or context instead. ([#2119](https://github.com/getsentry/sentry-dart/pull/2119))

### Dependencies

- Bump Cocoa SDK from v8.29.0 to v8.29.1 ([#2109](https://github.com/getsentry/sentry-dart/pull/2109))
Expand Down
4 changes: 4 additions & 0 deletions dart/lib/src/protocol/sentry_user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ class SentryUser {
final String? ipAddress;

/// The user segment, for apps that divide users in user segments.
@Deprecated(
'Will be removed in v9. Use a custom tag or context instead to capture this information.')
final String? segment;

/// Any other user context information that may be helpful.
Expand Down Expand Up @@ -129,6 +131,7 @@ class SentryUser {
if (username != null) 'username': username,
if (email != null) 'email': email,
if (ipAddress != null) 'ip_address': ipAddress,
// ignore: deprecated_member_use_from_same_package
if (segment != null) 'segment': segment,
if (data?.isNotEmpty ?? false) 'data': data,
// ignore: deprecated_member_use_from_same_package
Expand All @@ -155,6 +158,7 @@ class SentryUser {
username: username ?? this.username,
email: email ?? this.email,
ipAddress: ipAddress ?? this.ipAddress,
// ignore: deprecated_member_use_from_same_package
segment: segment ?? this.segment,
data: data ?? this.data,
// ignore: deprecated_member_use_from_same_package
Expand Down
4 changes: 4 additions & 0 deletions dart/lib/src/sentry_baggage.dart
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ class SentryBaggage {
if (scope.user?.id != null) {
setUserId(scope.user!.id!);
}
// ignore: deprecated_member_use_from_same_package
if (scope.user?.segment != null) {
// ignore: deprecated_member_use_from_same_package
setUserSegment(scope.user!.segment!);
}
}
Expand Down Expand Up @@ -176,6 +178,8 @@ class SentryBaggage {
set('sentry-user_id', value);
}

@Deprecated(
'Will be removed in v9 since functionality has been removed from Sentry')
void setUserSegment(String value) {
set('sentry-user_segment', value);
}
Expand Down
5 changes: 5 additions & 0 deletions dart/lib/src/sentry_trace_context_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class SentryTraceContextHeader {
final String? release;
final String? environment;
final String? userId;
@Deprecated(
'Will be removed in v9 since functionality has been removed from Sentry')
final String? userSegment;
final String? transaction;
final String? sampleRate;
Expand Down Expand Up @@ -48,6 +50,7 @@ class SentryTraceContextHeader {
if (release != null) 'release': release,
if (environment != null) 'environment': environment,
if (userId != null) 'user_id': userId,
// ignore: deprecated_member_use_from_same_package
if (userSegment != null) 'user_segment': userSegment,
if (transaction != null) 'transaction': transaction,
if (sampleRate != null) 'sample_rate': sampleRate,
Expand All @@ -71,7 +74,9 @@ class SentryTraceContextHeader {
if (userId != null) {
baggage.setUserId(userId!);
}
// ignore: deprecated_member_use_from_same_package
if (userSegment != null) {
// ignore: deprecated_member_use_from_same_package
baggage.setUserSegment(userSegment!);
}
if (transaction != null) {
Expand Down
1 change: 1 addition & 0 deletions dart/lib/src/sentry_tracer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ class SentryTracer extends ISentrySpan {
release: _hub.options.release,
environment: _hub.options.environment,
userId: null, // because of PII not sending it for now
// ignore: deprecated_member_use_from_same_package
userSegment: user?.segment,
transaction:
_isHighQualityTransactionName(transactionNameSource) ? name : null,
Expand Down
1 change: 1 addition & 0 deletions dart/test/protocol/sentry_baggage_header_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ void main() {
baggage.setRelease('release');
baggage.setEnvironment('environment');
baggage.setUserId('userId');
// ignore: deprecated_member_use_from_same_package
baggage.setUserSegment('userSegment');
baggage.setTransaction('transaction');
baggage.setSampleRate('1.0');
Expand Down
1 change: 1 addition & 0 deletions dart/test/protocol/sentry_user_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ void main() {
expect('email1', copy.email);
expect('ipAddress1', copy.ipAddress);
expect({'key1': 'value1'}, copy.data);
// ignore: deprecated_member_use_from_same_package
expect('seg1', copy.segment);
});
});
Expand Down
1 change: 1 addition & 0 deletions dart/test/sentry_trace_context_header_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ void main() {
expect(context.release, 'release');
expect(context.environment, 'environment');
expect(context.userId, 'user_id');
// ignore: deprecated_member_use_from_same_package
expect(context.userSegment, 'user_segment');
expect(context.transaction, 'transaction');
expect(context.sampleRate, '1.0');
Expand Down
1 change: 1 addition & 0 deletions dart/test/sentry_tracer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,7 @@ void main() {
expect(context.publicKey, 'abc');
expect(context.release, 'release');
expect(context.environment, 'environment');
// ignore: deprecated_member_use_from_same_package
expect(context.userSegment, 'segment');
expect(context.transaction, 'name');
expect(context.sampleRate, '1');
Expand Down

0 comments on commit e4d5aa8

Please sign in to comment.