Skip to content

Commit

Permalink
Merge branch 'main' into v9
Browse files Browse the repository at this point in the history
  • Loading branch information
denrase committed Feb 5, 2025
2 parents 888d2b8 + eafd4ab commit 0343b5a
Show file tree
Hide file tree
Showing 39 changed files with 250 additions and 305 deletions.
51 changes: 49 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,62 @@
- [diff](https://github.com/getsentry/sentry-java/compare/7.20.1...8.1.0)

## Unreleased
## 8.13.0

### Breaking changes

- Remove Metrics API ([#2571](https://github.com/getsentry/sentry-dart/pull/2571))
- The Metrics product never reached maturity from beta and has officially ended in October 7th, 2024
- Read [this post](https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Metrics-Beta-Ended-on-October-7th) for more information

### Features

- Add `beforeCapture` for View Hierarchy ([#2523](https://github.com/getsentry/sentry-dart/pull/2523))
- View hierarchy calls are now debounced for 2 seconds.
- JS SDK integration ([#2572](https://github.com/getsentry/sentry-dart/pull/2572))
- Enable the integration by setting `options.enableSentryJs = true`
- Features:
- Sending envelopes through Sentry JS transport layer
- Capturing native JS errors
- Add SentryReplayQuality setting (`options.experimental.replay.quality`) ([#2582](https://github.com/getsentry/sentry-dart/pull/2582))
- SPM Support ([#2280](https://github.com/getsentry/sentry-dart/pull/2280))

### Enhancements

- Replay: improve iOS native interop performance ([#2530](https://github.com/getsentry/sentry-dart/pull/2530), [#2573](https://github.com/getsentry/sentry-dart/pull/2573))
- Replay: improve orientation change tracking accuracy on Android ([#2540](https://github.com/getsentry/sentry-dart/pull/2540))
- Print a warning if the rate limit was reached ([#2595](https://github.com/getsentry/sentry-dart/pull/2595))
- Add replay masking config to tags and report SDKs versions ([#2592](https://github.com/getsentry/sentry-dart/pull/2592))
- Enable `options.debug` when in debug mode ([#2597](https://github.com/getsentry/sentry-dart/pull/2597))
- Propagate sample seed in baggage header ([#2629](https://github.com/getsentry/sentry-dart/pull/2629))
- Read more about the specs [here](https://develop.sentry.dev/sdk/telemetry/traces/#propagated-random-value)
- Finish and start new transaction when tapping same element again ([#2623](https://github.com/getsentry/sentry-dart/pull/2623))

### Fixes

- Replay: fix masking for frames captured during UI changes ([#2553](https://github.com/getsentry/sentry-dart/pull/2553), [#2657](https://github.com/getsentry/sentry-dart/pull/2657))
- Replay: fix widget masks overlap when navigating between screens ([#2486](https://github.com/getsentry/sentry-dart/pull/2486), [#2576](https://github.com/getsentry/sentry-dart/pull/2576))
- WASM compat for Drift ([#2580](https://github.com/getsentry/sentry-dart/pull/2580))
- Fix image flickering when using `SentryAssetBundle` ([#2577](https://github.com/getsentry/sentry-dart/pull/2577))
- Fix print recursion detection ([#2624](https://github.com/getsentry/sentry-dart/pull/2624))

### Misc

- Transfer ownership of `sentry_link` to Sentry. You can view the changelog for the previous versions [here](https://github.com/getsentry/sentry-dart/blob/main/link/CHANGELOG_OLD.md) ([#2338](https://github.com/getsentry/sentry-dart/pull/2338))
- No functional changes have been made. This version is identical to the previous one.
- Change license from Apache to MIT

### Dependencies

- Bump Cocoa SDK from v8.44.0-beta.1 to v8.44.0 ([#2649](https://github.com/getsentry/sentry-dart/pull/2649))
- Bump Native SDK from v0.7.17 to v0.7.19 ([#2578](https://github.com/getsentry/sentry-dart/pull/2578), [#2588](https://github.com/getsentry/sentry-dart/pull/2588))
- [changelog](https://github.com/getsentry/sentry-native/blob/master/CHANGELOG.md#0719)
- [diff](https://github.com/getsentry/sentry-native/compare/0.7.17...0.7.19)
- Bump Android SDK from v7.19.0 to v7.20.1 ([#2536](https://github.com/getsentry/sentry-dart/pull/2536), [#2549](https://github.com/getsentry/sentry-dart/pull/2549), [#2593](https://github.com/getsentry/sentry-dart/pull/2593))
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#7201)
- [diff](https://github.com/getsentry/sentry-java/compare/7.20.0...7.20.1)
- Bump Cocoa SDK from v8.42.0 to v8.44.0 ([#2542](https://github.com/getsentry/sentry-dart/pull/2542), [#2548](https://github.com/getsentry/sentry-dart/pull/2548), [#2598](https://github.com/getsentry/sentry-dart/pull/2598), [#2649](https://github.com/getsentry/sentry-dart/pull/2649))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8440)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.44.0-beta.1...8.44.0)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.42.0...8.44.0)

## 8.13.0-beta.3

Expand Down
18 changes: 16 additions & 2 deletions dart/lib/src/sentry_baggage.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import 'package:meta/meta.dart';
import 'scope.dart';
import 'protocol.dart';

import 'scope.dart';
import 'sentry_options.dart';

class SentryBaggage {
static const String _sampleRateKeyName = 'sentry-sample_rate';
static const String _sampleRandKeyName = 'sentry-sample_rand';

static const int _maxChars = 8192;
static const int _maxListMember = 64;

Expand Down Expand Up @@ -194,6 +195,10 @@ class SentryBaggage {
set(_sampleRateKeyName, value);
}

void setSampleRand(String value) {
set(_sampleRandKeyName, value);
}

void setSampled(String value) {
set('sentry-sampled', value);
}
Expand All @@ -207,6 +212,15 @@ class SentryBaggage {
return double.tryParse(sampleRate);
}

double? getSampleRand() {
final sampleRand = get(_sampleRandKeyName);
if (sampleRand == null) {
return null;
}

return double.tryParse(sampleRand);
}

void setReplayId(String value) => set('sentry-replay_id', value);

SentryId? getReplayId() {
Expand Down
8 changes: 7 additions & 1 deletion dart/lib/src/sentry_trace_context_header.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import 'package:meta/meta.dart';

import 'protocol/sentry_id.dart';
import 'protocol/access_aware_map.dart';
import 'protocol/sentry_id.dart';
import 'sentry_baggage.dart';
import 'sentry_options.dart';

Expand All @@ -15,6 +15,7 @@ class SentryTraceContextHeader {
this.userSegment,
this.transaction,
this.sampleRate,
this.sampleRand,
this.sampled,
this.unknown,
this.replayId,
Expand All @@ -30,6 +31,7 @@ class SentryTraceContextHeader {
final String? userSegment;
final String? transaction;
final String? sampleRate;
final String? sampleRand;
final String? sampled;

@internal
Expand Down Expand Up @@ -102,6 +104,9 @@ class SentryTraceContextHeader {
if (sampleRate != null) {
baggage.setSampleRate(sampleRate!);
}
if (sampleRand != null) {
baggage.setSampleRand(sampleRand!);
}
if (sampled != null) {
baggage.setSampled(sampled!);
}
Expand All @@ -113,6 +118,7 @@ class SentryTraceContextHeader {

factory SentryTraceContextHeader.fromBaggage(SentryBaggage baggage) {
return SentryTraceContextHeader(
// TODO: implement and use proper get methods here
SentryId.fromId(baggage.get('sentry-trace_id').toString()),
baggage.get('sentry-public_key').toString(),
release: baggage.get('sentry-release'),
Expand Down
8 changes: 8 additions & 0 deletions dart/lib/src/sentry_tracer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -385,6 +385,7 @@ class SentryTracer extends ISentrySpan {
transaction:
_isHighQualityTransactionName(transactionNameSource) ? name : null,
sampleRate: _sampleRateToString(_rootSpan.samplingDecision?.sampleRate),
sampleRand: _sampleRandToString(_rootSpan.samplingDecision?.sampleRand),
sampled: _rootSpan.samplingDecision?.sampled.toString(),
);

Expand All @@ -398,6 +399,13 @@ class SentryTracer extends ISentrySpan {
return sampleRate != null ? SampleRateFormat().format(sampleRate) : null;
}

String? _sampleRandToString(double? sampleRand) {
if (!isValidSampleRand(sampleRand)) {
return null;
}
return sampleRand != null ? SampleRateFormat().format(sampleRand) : null;
}

bool _isHighQualityTransactionName(SentryTransactionNameSource source) {
return source != SentryTransactionNameSource.url;
}
Expand Down
28 changes: 16 additions & 12 deletions dart/lib/src/sentry_traces_sampler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,9 @@ class SentryTracesSampler {
final tracesSampler = _options.tracesSampler;
if (tracesSampler != null) {
try {
final result = tracesSampler(samplingContext);
if (result != null) {
return SentryTracesSamplingDecision(
_sample(result),
sampleRate: result,
);
final sampleRate = tracesSampler(samplingContext);
if (sampleRate != null) {
return _makeSampleDecision(sampleRate);
}
} catch (exception, stackTrace) {
_options.logger(
Expand Down Expand Up @@ -64,10 +61,7 @@ class SentryTracesSampler {
double? optionsOrDefaultRate = optionsRate ?? defaultRate;

if (optionsOrDefaultRate != null) {
return SentryTracesSamplingDecision(
_sample(optionsOrDefaultRate),
sampleRate: optionsOrDefaultRate,
);
return _makeSampleDecision(optionsOrDefaultRate);
}

return SentryTracesSamplingDecision(false);
Expand All @@ -78,8 +72,18 @@ class SentryTracesSampler {
if (optionsRate == null || !tracesSamplingDecision.sampled) {
return false;
}
return _sample(optionsRate);
return _isSampled(optionsRate);
}

bool _sample(double result) => !(result < _random.nextDouble());
SentryTracesSamplingDecision _makeSampleDecision(double sampleRate) {
final sampleRand = _random.nextDouble();
final sampled = _isSampled(sampleRate, sampleRand: sampleRand);
return SentryTracesSamplingDecision(sampled,
sampleRate: sampleRate, sampleRand: sampleRand);
}

bool _isSampled(double sampleRate, {double? sampleRand}) {
final rand = sampleRand ?? _random.nextDouble();
return rand <= sampleRate;
}
}
2 changes: 2 additions & 0 deletions dart/lib/src/sentry_traces_sampling_decision.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ class SentryTracesSamplingDecision {
SentryTracesSamplingDecision(
this.sampled, {
this.sampleRate,
this.sampleRand,
});

final bool sampled;
final double? sampleRate;
final double? sampleRand;
}
8 changes: 5 additions & 3 deletions dart/lib/src/sentry_transaction_context.dart
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
import 'package:meta/meta.dart';
import 'sentry_trace_origins.dart';

import 'protocol.dart';
import 'sentry_baggage.dart';
import 'sentry_trace_origins.dart';
import 'tracing.dart';

@immutable
class SentryTransactionContext extends SentrySpanContext {
final String name;
final SentryTracesSamplingDecision? parentSamplingDecision;
final SentryTransactionNameSource? transactionNameSource;
final SentryTracesSamplingDecision? samplingDecision;
final SentryTracesSamplingDecision? parentSamplingDecision;

SentryTransactionContext(
this.name,
String operation, {
super.description,
this.parentSamplingDecision,
super.traceId,
super.spanId,
super.parentSpanId,
this.transactionNameSource,
this.samplingDecision,
this.parentSamplingDecision,
super.origin,
}) : super(
operation: operation,
Expand All @@ -35,6 +35,7 @@ class SentryTransactionContext extends SentrySpanContext {
SentryBaggage? baggage,
}) {
final sampleRate = baggage?.getSampleRate();
final sampleRand = baggage?.getSampleRand();
return SentryTransactionContext(
name,
operation,
Expand All @@ -44,6 +45,7 @@ class SentryTransactionContext extends SentrySpanContext {
? SentryTracesSamplingDecision(
traceHeader.sampled!,
sampleRate: sampleRate,
sampleRand: sampleRand,
)
: null,
transactionNameSource:
Expand Down
7 changes: 7 additions & 0 deletions dart/lib/src/utils/tracing_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,10 @@ bool isValidSampleRate(double? sampleRate) {
}
return !sampleRate.isNaN && sampleRate >= 0.0 && sampleRate <= 1.0;
}

bool isValidSampleRand(double? sampleRand) {
if (sampleRand == null) {
return false;
}
return !sampleRand.isNaN && sampleRand >= 0.0 && sampleRand < 1.0;
}
2 changes: 1 addition & 1 deletion dart/lib/src/version.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
library;

/// The SDK version reported to Sentry.io in the submitted events.
const String sdkVersion = '8.13.0-beta.3';
const String sdkVersion = '8.13.0';

String sdkName(bool isWeb) => isWeb ? _browserSdkName : _ioSdkName;

Expand Down
2 changes: 1 addition & 1 deletion dart/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: sentry
version: 8.13.0-beta.3
version: 8.13.0
description: >
A crash reporting library for Dart that sends crash reports to Sentry.io.
This library supports Dart VM and Web. For Flutter consider sentry_flutter instead.
Expand Down
2 changes: 2 additions & 0 deletions dart/test/protocol/sentry_baggage_header_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ void main() {
baggage.setUserSegment('userSegment');
baggage.setTransaction('transaction');
baggage.setSampleRate('1.0');
baggage.setSampleRand('0.4');
baggage.setSampled('false');
final replayId = SentryId.newId().toString();
baggage.setReplayId(replayId);
Expand All @@ -37,6 +38,7 @@ void main() {
'sentry-user_segment=userSegment,'
'sentry-transaction=transaction,'
'sentry-sample_rate=1.0,'
'sentry-sample_rand=0.4,'
'sentry-sampled=false,'
'sentry-replay_id=$replayId');
});
Expand Down
2 changes: 2 additions & 0 deletions dart/test/sentry_tracer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ void main() {
SentryTracesSamplingDecision(
true,
sampleRate: 1.0,
sampleRand: 0.8,
);
final _context = SentryTransactionContext(
'name',
Expand All @@ -512,6 +513,7 @@ void main() {
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);
expect(newBaggage.get('sentry-sampled'), 'true');
});

Expand Down
2 changes: 1 addition & 1 deletion dio/lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// The SDK version reported to Sentry.io in the submitted events.
const String sdkVersion = '8.13.0-beta.3';
const String sdkVersion = '8.13.0';

/// The package name reported to Sentry.io in the submitted events.
const String packageName = 'pub:sentry_dio';
4 changes: 2 additions & 2 deletions dio/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: sentry_dio
description: An integration which adds support for performance tracing for the Dio package.
version: 8.13.0-beta.3
version: 8.13.0
homepage: https://docs.sentry.io/platforms/dart/
repository: https://github.com/getsentry/sentry-dart
issue_tracker: https://github.com/getsentry/sentry-dart/issues
Expand All @@ -19,7 +19,7 @@ platforms:

dependencies:
dio: ^5.0.0
sentry: 8.13.0-beta.3
sentry: 8.13.0

dev_dependencies:
meta: ^1.3.0
Expand Down
2 changes: 1 addition & 1 deletion drift/lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// The SDK version reported to Sentry.io in the submitted events.
const String sdkVersion = '8.13.0-beta.3';
const String sdkVersion = '8.13.0';

/// The package name reported to Sentry.io in the submitted events.
const String packageName = 'pub:sentry_drift';
4 changes: 2 additions & 2 deletions drift/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: sentry_drift
description: An integration which adds support for performance tracing for the drift package.
version: 8.13.0-beta.3
version: 8.13.0
homepage: https://docs.sentry.io/platforms/flutter/
repository: https://github.com/getsentry/sentry-dart
issue_tracker: https://github.com/getsentry/sentry-dart/issues
Expand All @@ -17,7 +17,7 @@ platforms:
web:

dependencies:
sentry: 8.13.0-beta.3
sentry: 8.13.0
meta: ^1.3.0
drift: ^2.13.0

Expand Down
2 changes: 1 addition & 1 deletion file/lib/src/version.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// The SDK version reported to Sentry.io in the submitted events.
const String sdkVersion = '8.13.0-beta.3';
const String sdkVersion = '8.13.0';

/// The package name reported to Sentry.io in the submitted events.
const String packageName = 'pub:sentry_file';
Loading

0 comments on commit 0343b5a

Please sign in to comment.