diff --git a/CHANGELOG.md b/CHANGELOG.md index 0bc2f45ab2..9c47d19658 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,10 @@ - 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)) diff --git a/dart/lib/src/protocol/sentry_user.dart b/dart/lib/src/protocol/sentry_user.dart index 3b2f2cab1c..c173432fcd 100644 --- a/dart/lib/src/protocol/sentry_user.dart +++ b/dart/lib/src/protocol/sentry_user.dart @@ -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. @@ -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 @@ -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 diff --git a/dart/lib/src/sentry_baggage.dart b/dart/lib/src/sentry_baggage.dart index 25aab900f4..ebed8765b1 100644 --- a/dart/lib/src/sentry_baggage.dart +++ b/dart/lib/src/sentry_baggage.dart @@ -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!); } } @@ -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); } diff --git a/dart/lib/src/sentry_trace_context_header.dart b/dart/lib/src/sentry_trace_context_header.dart index bcb1d0b1bb..d1ee5368af 100644 --- a/dart/lib/src/sentry_trace_context_header.dart +++ b/dart/lib/src/sentry_trace_context_header.dart @@ -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; @@ -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, @@ -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) { diff --git a/dart/lib/src/sentry_tracer.dart b/dart/lib/src/sentry_tracer.dart index 2326db0716..d9d57df8c1 100644 --- a/dart/lib/src/sentry_tracer.dart +++ b/dart/lib/src/sentry_tracer.dart @@ -361,6 +361,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, diff --git a/dart/test/protocol/sentry_baggage_header_test.dart b/dart/test/protocol/sentry_baggage_header_test.dart index 38428be41a..3e8555aba9 100644 --- a/dart/test/protocol/sentry_baggage_header_test.dart +++ b/dart/test/protocol/sentry_baggage_header_test.dart @@ -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'); diff --git a/dart/test/protocol/sentry_user_test.dart b/dart/test/protocol/sentry_user_test.dart index 2a958624e2..d3c8e078ba 100644 --- a/dart/test/protocol/sentry_user_test.dart +++ b/dart/test/protocol/sentry_user_test.dart @@ -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); }); }); diff --git a/dart/test/sentry_trace_context_header_test.dart b/dart/test/sentry_trace_context_header_test.dart index 6ba6d93bc2..c4f856f344 100644 --- a/dart/test/sentry_trace_context_header_test.dart +++ b/dart/test/sentry_trace_context_header_test.dart @@ -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'); diff --git a/dart/test/sentry_tracer_test.dart b/dart/test/sentry_tracer_test.dart index 7ba5e80fac..a1251c224b 100644 --- a/dart/test/sentry_tracer_test.dart +++ b/dart/test/sentry_tracer_test.dart @@ -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');