Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v9] Remove user segment #2687

Merged
merged 4 commits into from
Feb 11, 2025
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- Increase minimum SDK version requirements to Dart v3.5.0 and Flutter v3.24.0 ([#2643](https://github.com/getsentry/sentry-dart/pull/2643))
- Remove screenshot option `attachScreenshotOnlyWhenResumed` ([#2664](https://github.com/getsentry/sentry-dart/pull/2664))
- Remove deprecated `beforeScreenshot` ([#2662](https://github.com/getsentry/sentry-dart/pull/2662))
- Remove user segment ([#2687](https://github.com/getsentry/sentry-dart/pull/2687))

### Dependencies

Expand Down
24 changes: 4 additions & 20 deletions dart/lib/src/protocol/sentry_user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import 'access_aware_map.dart';
/// "username": "my_user",
/// "email": "[email protected]",
/// "ip_address": "127.0.0.1",
/// "segment": "segment"
/// }
/// ```
@immutable
Expand All @@ -39,20 +38,16 @@ class SentryUser {
this.username,
this.email,
this.ipAddress,
this.segment,
this.geo,
this.name,
Map<String, dynamic>? data,
@Deprecated('Will be removed in v8. Use [data] instead')
Map<String, dynamic>? extras,
this.unknown,
}) : assert(
id != null ||
username != null ||
email != null ||
ipAddress != null ||
segment != null,
),
}) : assert(id != null ||
username != null ||
email != null ||
ipAddress != null),
data = data == null ? null : Map.from(data),
// ignore: deprecated_member_use_from_same_package
extras = extras == null ? null : Map.from(extras);
Expand All @@ -69,11 +64,6 @@ class SentryUser {
/// The IP of the user.
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.
///
/// These keys are stored as extra information but not specifically processed
Expand Down Expand Up @@ -121,7 +111,6 @@ class SentryUser {
username: json['username'],
email: json['email'],
ipAddress: json['ip_address'],
segment: json['segment'],
data: data,
geo: geo,
name: json['name'],
Expand All @@ -140,8 +129,6 @@ 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
if (extras?.isNotEmpty ?? false) 'extras': extras,
Expand All @@ -155,7 +142,6 @@ class SentryUser {
String? username,
String? email,
String? ipAddress,
String? segment,
@Deprecated('Will be removed in v8. Use [data] instead')
Map<String, dynamic>? extras,
String? name,
Expand All @@ -167,8 +153,6 @@ 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
extras: extras ?? this.extras,
Expand Down
12 changes: 1 addition & 11 deletions dart/lib/src/sentry_baggage.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:meta/meta.dart';

import 'protocol.dart';
import 'scope.dart';
import 'sentry_options.dart';
Expand Down Expand Up @@ -106,11 +107,6 @@ 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!);
}
if (scope.replayId != null && scope.replayId != SentryId.empty()) {
setReplayId(scope.replayId.toString());
}
Expand Down Expand Up @@ -181,12 +177,6 @@ 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);
}

void setTransaction(String value) {
set('sentry-transaction', value);
}
Expand Down
12 changes: 0 additions & 12 deletions dart/lib/src/sentry_trace_context_header.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ class SentryTraceContextHeader {
this.release,
this.environment,
this.userId,
this.userSegment,
this.transaction,
this.sampleRate,
this.sampleRand,
Expand All @@ -26,9 +25,6 @@ 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;
final String? sampleRand;
Expand All @@ -49,7 +45,6 @@ class SentryTraceContextHeader {
release: json['release'],
environment: json['environment'],
userId: json['user_id'],
userSegment: json['user_segment'],
transaction: json['transaction'],
sampleRate: json['sample_rate'],
sampled: json['sampled'],
Expand All @@ -68,8 +63,6 @@ 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,
if (sampled != null) 'sampled': sampled,
Expand All @@ -93,11 +86,6 @@ 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) {
baggage.setTransaction(transaction!);
}
Expand Down
5 changes: 0 additions & 5 deletions dart/lib/src/sentry_tracer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -371,17 +371,12 @@ class SentryTracer extends ISentrySpan {
return _sentryTraceContextHeader;
}

SentryUser? user;
_hub.configureScope((scope) => user = scope.user);

_sentryTraceContextHeader = SentryTraceContextHeader(
_rootSpan.context.traceId,
_hub.options.parsedDsn.publicKey,
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,
sampleRate: _sampleRateToString(_rootSpan.samplingDecision?.sampleRate),
Expand Down
3 changes: 0 additions & 3 deletions dart/test/protocol/sentry_baggage_header_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ 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');
baggage.setSampleRand('0.4');
Expand All @@ -35,7 +33,6 @@ void main() {
'sentry-release=release,'
'sentry-environment=environment,'
'sentry-user_id=userId,'
'sentry-user_segment=userSegment,'
'sentry-transaction=transaction,'
'sentry-sample_rate=1.0,'
'sentry-sample_rand=0.4,'
Expand Down
7 changes: 0 additions & 7 deletions dart/test/protocol/sentry_user_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ void main() {
email: 'email',
ipAddress: 'ipAddress',
data: {'key': 'value'},
segment: 'seg',
unknown: testUnknown,
);

Expand All @@ -21,7 +20,6 @@ void main() {
'email': 'email',
'ip_address': 'ipAddress',
'data': {'key': 'value'},
'segment': 'seg',
};
sentryUserJson.addAll(testUnknown);

Expand Down Expand Up @@ -56,7 +54,6 @@ void main() {
expect(json.containsKey('email'), false);
expect(json.containsKey('ip_address'), false);
expect(json.containsKey('extras'), false);
expect(json.containsKey('segment'), false);

data = SentryUser(ipAddress: 'ip');

Expand All @@ -67,7 +64,6 @@ void main() {
expect(json.containsKey('email'), false);
expect(json.containsKey('ip_address'), true);
expect(json.containsKey('extras'), false);
expect(json.containsKey('segment'), false);
});
});

Expand All @@ -89,16 +85,13 @@ void main() {
email: 'email1',
ipAddress: 'ipAddress1',
data: {'key1': 'value1'},
segment: 'seg1',
);

expect('id1', copy.id);
expect('username1', copy.username);
expect('email1', copy.email);
expect('ipAddress1', copy.ipAddress);
expect({'key1': 'value1'}, copy.data);
// ignore: deprecated_member_use_from_same_package
expect('seg1', copy.segment);
});
});
}
5 changes: 0 additions & 5 deletions dart/test/sentry_trace_context_header_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ void main() {
release: 'release',
environment: 'environment',
userId: 'user_id',
userSegment: 'user_segment',
transaction: 'transaction',
sampleRate: '1.0',
sampled: 'false',
Expand All @@ -28,7 +27,6 @@ void main() {
'release': 'release',
'environment': 'environment',
'user_id': 'user_id',
'user_segment': 'user_segment',
'transaction': 'transaction',
'sample_rate': '1.0',
'sampled': 'false',
Expand All @@ -42,8 +40,6 @@ 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');
expect(context.sampled, 'false');
Expand All @@ -66,7 +62,6 @@ void main() {
'sentry-release=release,'
'sentry-environment=environment,'
'sentry-user_id=user_id,'
'sentry-user_segment=user_segment,'
'sentry-transaction=transaction,'
'sentry-sample_rate=1.0,'
'sentry-sampled=false,'
Expand Down
4 changes: 0 additions & 4 deletions dart/test/sentry_tracer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,6 @@ void main() {
expect(newBaggage.get('sentry-public_key'), 'public');
expect(newBaggage.get('sentry-release'), 'release');
expect(newBaggage.get('sentry-environment'), 'environment');
expect(newBaggage.get('sentry-user_segment'), 'segment');
expect(newBaggage.get('sentry-transaction'), 'name');
expect(newBaggage.get('sentry-sample_rate'), '1');
expect(newBaggage.getSampleRand(), 0.8);
Expand Down Expand Up @@ -585,8 +584,6 @@ void main() {
expect(context.publicKey, 'public');
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');
expect(context.sampled, 'true');
Expand All @@ -603,7 +600,6 @@ class Fixture {

final user = SentryUser(
id: 'id',
segment: 'segment',
);

final hub = MockHub();
Expand Down
5 changes: 2 additions & 3 deletions dart/test/utils/tracing_utils_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void main() {
test('overwrites duplicate key values', () {
final headers = <String, String>{};
final oldValue =
'other-vendor-value=foo,sentry-trace_id=${SentryId.newId()},sentry-public_key=oldPublicKey,sentry-release=oldRelease,sentry-environment=oldEnvironment,sentry-user_id=oldUserId,sentry-user_segment=oldUserSegment,sentry-transaction=oldTransaction,sentry-sample_rate=0.5';
'other-vendor-value=foo,sentry-trace_id=${SentryId.newId()},sentry-public_key=oldPublicKey,sentry-release=oldRelease,sentry-environment=oldEnvironment,sentry-user_id=oldUserId,sentry-transaction=oldTransaction,sentry-sample_rate=0.5';

headers['baggage'] = oldValue;

Expand All @@ -125,7 +125,7 @@ void main() {
addBaggageHeaderFromSpan(sut, headers);

expect(headers[baggage!.name],
'other-vendor-value=foo,sentry-trace_id=${sut.context.traceId},sentry-public_key=public,sentry-release=release,sentry-environment=environment,sentry-user_segment=segment,sentry-transaction=name,sentry-sample_rate=1,sentry-sampled=true');
'other-vendor-value=foo,sentry-trace_id=${sut.context.traceId},sentry-public_key=public,sentry-release=release,sentry-environment=environment,sentry-transaction=name,sentry-sample_rate=1,sentry-sampled=true');
});
});

Expand Down Expand Up @@ -177,7 +177,6 @@ class Fixture {

final _user = SentryUser(
id: 'id',
segment: 'segment',
);

SentryTracer getSut() {
Expand Down
Loading