Skip to content

Commit

Permalink
Merge branch 'v9' into v9-before-send-transaction-hint
Browse files Browse the repository at this point in the history
  • Loading branch information
denrase committed Feb 12, 2025
2 parents 84dbcd3 + 98d6f2d commit 4053fe6
Show file tree
Hide file tree
Showing 19 changed files with 41 additions and 207 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
- Remove deprecated `beforeScreenshot` ([#2662](https://github.com/getsentry/sentry-dart/pull/2662))
- Add hint for transactions ([#2675](https://github.com/getsentry/sentry-dart/pull/2675))
- `BeforeSendTransactionCallback` now has a `Hint` parameter
- Remove deprecated loggers ([#2685](https://github.com/getsentry/sentry-dart/pull/2685))
- Remove user segment ([#2687](https://github.com/getsentry/sentry-dart/pull/2687))
- Remove `options.autoAppStart` and `setAppStartEnd` ([#2680](https://github.com/getsentry/sentry-dart/pull/2680))

### Dependencies

Expand All @@ -17,12 +20,22 @@

## Unreleased

### Deprecations

- Deprecate `autoAppStart` and `setAppStartEnd` ([#2681](https://github.com/getsentry/sentry-dart/pull/2681))

### Other

- Remove macOS display refresh rate support ([#2628](https://github.com/getsentry/sentry-dart/pull/2628))
- Can't reliably detect on multi-monitor systems and on older macOS versions.
- Not very meaningful, as other applications may be running in parallel and affecting it.

### Dependencies

- Bump Native SDK from v0.7.19 to v0.7.20 ([#2652](https://github.com/getsentry/sentry-dart/pull/2652))
- [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#0720)
- [diff](https://github.com/getsentry/sentry-native/compare/0.7.19...0.7.20)

## 8.13.0

### Breaking changes
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": "foo@example.com",
/// "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
41 changes: 9 additions & 32 deletions dart/lib/src/sentry_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,6 @@ class SentryOptions {
/// This does not change whether an event is captured.
MaxResponseBodySize maxResponseBodySize = MaxResponseBodySize.never;

// ignore: deprecated_member_use_from_same_package
SentryLogger _logger = noOpLogger;

/// Logger interface to log useful debugging information if debug is enabled
Expand Down Expand Up @@ -159,12 +158,10 @@ class SentryOptions {

set debug(bool newValue) {
_debug = newValue;
// ignore: deprecated_member_use_from_same_package
if (_debug == true && logger == noOpLogger) {
_logger = _debugLogger;
}
if (_debug == false && logger == _debugLogger) {
// ignore: deprecated_member_use_from_same_package
_logger = noOpLogger;
}
}
Expand Down Expand Up @@ -601,6 +598,15 @@ class SentryOptions {
}
}

@visibleForTesting
void noOpLogger(
SentryLevel level,
String message, {
String? logger,
Object? exception,
StackTrace? stackTrace,
}) {}

/// This function is called with an SDK specific event object and can return a modified event
/// object or nothing to skip reporting the event
typedef BeforeSendCallback = FutureOr<SentryEvent?> Function(
Expand Down Expand Up @@ -643,32 +649,3 @@ typedef SentryLogger = void Function(

typedef TracesSamplerCallback = double? Function(
SentrySamplingContext samplingContext);

/// A NoOp logger that does nothing
@Deprecated('Will be removed in v8. Disable [debug] instead')
void noOpLogger(
SentryLevel level,
String message, {
String? logger,
Object? exception,
StackTrace? stackTrace,
}) {}

/// A Logger that prints out the level and message
@Deprecated('Will be removed in v8. Enable [debug] instead')
void dartLogger(
SentryLevel level,
String message, {
String? logger,
Object? exception,
StackTrace? stackTrace,
}) {
log(
'[${level.name}] $message',
level: level.toDartLogLevel(),
name: logger ?? 'sentry',
time: getUtcDateTime(),
error: exception,
stackTrace: stackTrace,
);
}
2 changes: 1 addition & 1 deletion dart/lib/src/sentry_run_zoned_guarded.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ class SentryRunZonedGuarded {
// This happens for example if:
// - hub.addBreadcrumb() called print() itself
// - This happens for example if hub.isEnabled == false and
// options.logger == dartLogger
// options.logger == _debugLogger
//
// Anyway, in order to not cause a stack overflow due to recursion
// we drop any further print() call while adding a breadcrumb.
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 @@ -378,17 +378,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: 1 addition & 4 deletions dart/test/sentry_options_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,9 @@ void main() {

test('SentryLogger sets a diagnostic logger', () {
final options = defaultTestOptions();
// ignore: deprecated_member_use_from_same_package
expect(options.logger, noOpLogger);
// ignore: deprecated_member_use_from_same_package
options.logger = dartLogger;
options.debug = true;

// ignore: deprecated_member_use_from_same_package
expect(options.logger, isNot(noOpLogger));
});

Expand Down
5 changes: 1 addition & 4 deletions dart/test/sentry_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -486,18 +486,15 @@ void main() {
(options) {
options.dsn = fakeDsn;
options.debug = true;
// ignore: deprecated_member_use_from_same_package
expect(options.logger, isNot(noOpLogger));

options.debug = false;
// ignore: deprecated_member_use_from_same_package
expect(options.logger, noOpLogger);
},
options: sentryOptions,
);

// ignore: deprecated_member_use_from_same_package
expect(sentryOptions.logger, isNot(dartLogger));
expect(sentryOptions.logger, noOpLogger);
});

group('Sentry init optionsConfiguration', () {
Expand Down
Loading

0 comments on commit 4053fe6

Please sign in to comment.