From ab17dfc32472bcfeff2fb8141cb915e58d37e95d Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 21 Sep 2022 11:05:33 +0200 Subject: [PATCH 01/10] Feat set custom measurement --- dart/lib/sentry.dart | 1 - dart/lib/src/noop_sentry_span.dart | 3 ++ dart/lib/src/protocol/sentry_span.dart | 9 ++++ dart/lib/src/protocol/sentry_transaction.dart | 16 +++--- dart/lib/src/sentry_measurement.dart | 32 ++++++++--- dart/lib/src/sentry_measurement_unit.dart | 53 +++++++++++++++++++ dart/lib/src/sentry_span_interface.dart | 7 +++ dart/lib/src/sentry_tracer.dart | 15 +++--- dart/lib/src/tracing.dart | 2 + .../native_app_start_event_processor.dart | 3 +- .../navigation/sentry_navigator_observer.dart | 7 ++- 11 files changed, 123 insertions(+), 25 deletions(-) create mode 100644 dart/lib/src/sentry_measurement_unit.dart diff --git a/dart/lib/sentry.dart b/dart/lib/sentry.dart index bb7db1cc95..917e032522 100644 --- a/dart/lib/sentry.dart +++ b/dart/lib/sentry.dart @@ -29,4 +29,3 @@ export 'src/sentry_attachment/sentry_attachment.dart'; export 'src/sentry_user_feedback.dart'; // tracing export 'src/tracing.dart'; -export 'src/sentry_measurement.dart'; diff --git a/dart/lib/src/noop_sentry_span.dart b/dart/lib/src/noop_sentry_span.dart index 89c7dc8bf9..297b579d9b 100644 --- a/dart/lib/src/noop_sentry_span.dart +++ b/dart/lib/src/noop_sentry_span.dart @@ -77,4 +77,7 @@ class NoOpSentrySpan extends ISentrySpan { @override SentryTraceHeader toSentryTrace() => _header; + + @override + void setMeasurement(String name, num value, {SentryMeasurementUnit? unit}) {} } diff --git a/dart/lib/src/protocol/sentry_span.dart b/dart/lib/src/protocol/sentry_span.dart index ca743e7c00..bf38dcf41d 100644 --- a/dart/lib/src/protocol/sentry_span.dart +++ b/dart/lib/src/protocol/sentry_span.dart @@ -182,4 +182,13 @@ class SentrySpan extends ISentrySpan { _context.spanId, sampled: sampled, ); + + @override + void setMeasurement( + String name, + num value, { + SentryMeasurementUnit? unit, + }) { + _tracer.setMeasurement(name, value, unit: unit); + } } diff --git a/dart/lib/src/protocol/sentry_transaction.dart b/dart/lib/src/protocol/sentry_transaction.dart index 21576657c8..56ea6ca9cf 100644 --- a/dart/lib/src/protocol/sentry_transaction.dart +++ b/dart/lib/src/protocol/sentry_transaction.dart @@ -11,7 +11,7 @@ class SentryTransaction extends SentryEvent { static const String _type = 'transaction'; late final List spans; final SentryTracer _tracer; - late final List measurements; + late final Map measurements; SentryTransaction( this._tracer, { @@ -32,7 +32,7 @@ class SentryTransaction extends SentryEvent { SdkVersion? sdk, SentryRequest? request, String? type, - List? measurements, + Map? measurements, }) : super( eventId: eventId, timestamp: timestamp ?? _tracer.endTimestamp, @@ -56,7 +56,7 @@ class SentryTransaction extends SentryEvent { final spanContext = _tracer.context; spans = _tracer.children; - this.measurements = measurements ?? []; + this.measurements = measurements ?? {}; this.contexts.trace = spanContext.toTraceContext( sampled: _tracer.sampled, @@ -76,8 +76,8 @@ class SentryTransaction extends SentryEvent { if (measurements.isNotEmpty) { final map = {}; - for (final measurement in measurements) { - map[measurement.name] = measurement.toJson(); + for (final item in measurements.entries) { + map[item.key] = item.value.toJson(); } json['measurements'] = map; } @@ -117,7 +117,7 @@ class SentryTransaction extends SentryEvent { List? exceptions, List? threads, String? type, - List? measurements, + Map? measurements, }) => SentryTransaction( _tracer, @@ -139,9 +139,7 @@ class SentryTransaction extends SentryEvent { sdk: sdk ?? this.sdk, request: request ?? this.request, type: type ?? this.type, - measurements: (measurements != null - ? List.from(measurements) - : null) ?? + measurements: (measurements != null ? Map.from(measurements) : null) ?? this.measurements, ); } diff --git a/dart/lib/src/sentry_measurement.dart b/dart/lib/src/sentry_measurement.dart index 43a2ac18bd..d7c568ee29 100644 --- a/dart/lib/src/sentry_measurement.dart +++ b/dart/lib/src/sentry_measurement.dart @@ -1,34 +1,52 @@ +import 'sentry_measurement_unit.dart'; + class SentryMeasurement { - SentryMeasurement(this.name, this.value); + SentryMeasurement( + this.name, + this.value, { + this.unit, + }); /// Amount of frames drawn during a transaction - SentryMeasurement.totalFrames(this.value) : name = 'frames_total'; + SentryMeasurement.totalFrames(this.value) + : name = 'frames_total', + unit = SentryMeasurementUnit.none; /// Amount of slow frames drawn during a transaction. /// A slow frame is any frame longer than 1s / refreshrate. /// So for example any frame slower than 16ms for a refresh rate of 60hz. - SentryMeasurement.slowFrames(this.value) : name = 'frames_slow'; + SentryMeasurement.slowFrames(this.value) + : name = 'frames_slow', + unit = SentryMeasurementUnit.none; /// Amount of frozen frames drawn during a transaction. /// Typically defined as frames slower than 500ms. - SentryMeasurement.frozenFrames(this.value) : name = 'frames_frozen'; + SentryMeasurement.frozenFrames(this.value) + : name = 'frames_frozen', + unit = SentryMeasurementUnit.none; + /// Duration of the Cold App start in milliseconds SentryMeasurement.coldAppStart(Duration duration) : assert(!duration.isNegative), name = 'app_start_cold', - value = duration.inMilliseconds; + value = duration.inMilliseconds, + unit = SentryMeasurementUnit.milliSecond; + /// Duration of the Warm App start in milliseconds SentryMeasurement.warmAppStart(Duration duration) : assert(!duration.isNegative), name = 'app_start_warm', - value = duration.inMilliseconds; + value = duration.inMilliseconds, + unit = SentryMeasurementUnit.milliSecond; final String name; final num value; + final SentryMeasurementUnit? unit; Map toJson() { - return { + return { 'value': value, + if (unit != null) 'unit': unit?.toStringValue(), }; } } diff --git a/dart/lib/src/sentry_measurement_unit.dart b/dart/lib/src/sentry_measurement_unit.dart new file mode 100644 index 0000000000..e53432b827 --- /dev/null +++ b/dart/lib/src/sentry_measurement_unit.dart @@ -0,0 +1,53 @@ +enum SentryMeasurementUnit { + /// Nanosecond (`"nanosecond"`), 10^-9 seconds. + nanoSecond, + + /// Microsecond (`"microsecond"`), 10^-6 seconds. + microSecond, + + /// Millisecond (`"millisecond"`), 10^-3 seconds. + milliSecond, + + /// Full second (`"second"`). + second, + + /// Minute (`"minute"`), 60 seconds. + minute, + + /// Hour (`"hour"`), 3600 seconds. + hour, + + /// Day (`"day"`), 86,400 seconds. + day, + + /// Week (`"week"`), 604,800 seconds. + week, + + /// Untyped value without a unit. + none, +} + +extension SentryMeasurementUnitExtension on SentryMeasurementUnit { + String toStringValue() { + switch (this) { + case SentryMeasurementUnit.nanoSecond: + return 'nanosecond'; + case SentryMeasurementUnit.microSecond: + return 'microsecond'; + case SentryMeasurementUnit.milliSecond: + return 'millisecond'; + case SentryMeasurementUnit.second: + return 'second'; + case SentryMeasurementUnit.minute: + return 'minute'; + case SentryMeasurementUnit.hour: + return 'hour'; + case SentryMeasurementUnit.day: + return 'day'; + case SentryMeasurementUnit.week: + return 'week'; + case SentryMeasurementUnit.none: + return 'none'; + } + } +} diff --git a/dart/lib/src/sentry_span_interface.dart b/dart/lib/src/sentry_span_interface.dart index a49d687078..2b7d7f8558 100644 --- a/dart/lib/src/sentry_span_interface.dart +++ b/dart/lib/src/sentry_span_interface.dart @@ -56,4 +56,11 @@ abstract class ISentrySpan { /// Returns the trace information that could be sent as a sentry-trace header. SentryTraceHeader toSentryTrace(); + + /// Set observed measurement for this transaction. + void setMeasurement( + String name, + num value, { + SentryMeasurementUnit? unit, + }); } diff --git a/dart/lib/src/sentry_tracer.dart b/dart/lib/src/sentry_tracer.dart index e334bcac6c..5dd835bb05 100644 --- a/dart/lib/src/sentry_tracer.dart +++ b/dart/lib/src/sentry_tracer.dart @@ -15,7 +15,7 @@ class SentryTracer extends ISentrySpan { late final SentrySpan _rootSpan; final List _children = []; final Map _extra = {}; - final List _measurements = []; + final Map _measurements = {}; Timer? _autoFinishAfterTimer; Function(SentryTracer)? _onFinish; @@ -249,12 +249,9 @@ class SentryTracer extends ISentrySpan { @override SentryTraceHeader toSentryTrace() => _rootSpan.toSentryTrace(); - void addMeasurements(List measurements) { - _measurements.addAll(measurements); - } - @visibleForTesting - List get measurements => _measurements; + Map get measurements => + Map.unmodifiable(_measurements); bool _haveAllChildrenFinished() { for (final child in children) { @@ -269,4 +266,10 @@ class SentryTracer extends ISentrySpan { SentrySpan span, DateTime endTimestampCandidate) => !span.startTimestamp .isAfter((span.endTimestamp ?? endTimestampCandidate)); + + @override + void setMeasurement(String name, num value, {SentryMeasurementUnit? unit}) { + final measurement = SentryMeasurement(name, value, unit: unit); + _measurements[name] = measurement; + } } diff --git a/dart/lib/src/tracing.dart b/dart/lib/src/tracing.dart index 362463076d..40607a436a 100644 --- a/dart/lib/src/tracing.dart +++ b/dart/lib/src/tracing.dart @@ -4,3 +4,5 @@ export 'sentry_span_context.dart'; export 'sentry_span_interface.dart'; export 'noop_sentry_span.dart'; export 'invalid_sentry_trace_header_exception.dart'; +export 'sentry_measurement.dart'; +export 'sentry_measurement_unit.dart'; diff --git a/flutter/lib/src/event_processor/native_app_start_event_processor.dart b/flutter/lib/src/event_processor/native_app_start_event_processor.dart index 4affebb40e..5308f21c59 100644 --- a/flutter/lib/src/event_processor/native_app_start_event_processor.dart +++ b/flutter/lib/src/event_processor/native_app_start_event_processor.dart @@ -40,7 +40,8 @@ class NativeAppStartEventProcessor extends EventProcessor { if (measurement.value >= _maxAppStartMillis) { return event; } - event.measurements.add(measurement); + // event.measurements.add(measurement); + event.measurements[measurement.name] = measurement; } return event; } diff --git a/flutter/lib/src/navigation/sentry_navigator_observer.dart b/flutter/lib/src/navigation/sentry_navigator_observer.dart index 39a01e4459..436f757f1c 100644 --- a/flutter/lib/src/navigation/sentry_navigator_observer.dart +++ b/flutter/lib/src/navigation/sentry_navigator_observer.dart @@ -182,7 +182,12 @@ class SentryNavigatorObserver extends RouteObserver> { final nativeFrames = await _native .endNativeFramesCollection(transaction.context.traceId); if (nativeFrames != null) { - transaction.addMeasurements(nativeFrames.toMeasurements()); + // transaction.addMeasurements(nativeFrames.toMeasurements()); + final measurements = nativeFrames.toMeasurements(); + for (final item in measurements) { + transaction.setMeasurement(item.name, item.value, + unit: item.unit); + } } } }, From 9fb63ab1cc7856fde1a4215b27e6cf6c6cca6202 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 21 Sep 2022 11:18:00 +0200 Subject: [PATCH 02/10] ref --- .../native_app_start_event_processor.dart | 1 - .../navigation/sentry_navigator_observer.dart | 26 ++++++++++++------- 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/flutter/lib/src/event_processor/native_app_start_event_processor.dart b/flutter/lib/src/event_processor/native_app_start_event_processor.dart index 5308f21c59..298e8f3808 100644 --- a/flutter/lib/src/event_processor/native_app_start_event_processor.dart +++ b/flutter/lib/src/event_processor/native_app_start_event_processor.dart @@ -40,7 +40,6 @@ class NativeAppStartEventProcessor extends EventProcessor { if (measurement.value >= _maxAppStartMillis) { return event; } - // event.measurements.add(measurement); event.measurements[measurement.name] = measurement; } return event; diff --git a/flutter/lib/src/navigation/sentry_navigator_observer.dart b/flutter/lib/src/navigation/sentry_navigator_observer.dart index 436f757f1c..a170691867 100644 --- a/flutter/lib/src/navigation/sentry_navigator_observer.dart +++ b/flutter/lib/src/navigation/sentry_navigator_observer.dart @@ -182,11 +182,14 @@ class SentryNavigatorObserver extends RouteObserver> { final nativeFrames = await _native .endNativeFramesCollection(transaction.context.traceId); if (nativeFrames != null) { - // transaction.addMeasurements(nativeFrames.toMeasurements()); final measurements = nativeFrames.toMeasurements(); - for (final item in measurements) { - transaction.setMeasurement(item.name, item.value, - unit: item.unit); + for (final item in measurements.entries) { + final measurement = item.value; + transaction.setMeasurement( + item.key, + measurement.value, + unit: measurement.unit, + ); } } } @@ -279,11 +282,14 @@ class RouteObserverBreadcrumb extends Breadcrumb { } extension NativeFramesMeasurement on NativeFrames { - List toMeasurements() { - return [ - SentryMeasurement.totalFrames(totalFrames), - SentryMeasurement.slowFrames(slowFrames), - SentryMeasurement.frozenFrames(frozenFrames), - ]; + Map toMeasurements() { + final total = SentryMeasurement.totalFrames(totalFrames); + final slow = SentryMeasurement.slowFrames(slowFrames); + final frozen = SentryMeasurement.frozenFrames(frozenFrames); + return { + total.name: total, + slow.name: slow, + frozen.name: frozen, + }; } } From 2ab2e0a8d1a3a47a0bfffdad540e1d9ca3a78a2d Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 21 Sep 2022 14:14:27 +0200 Subject: [PATCH 03/10] fix tests --- .../integrations/native_app_start_integration_test.dart | 8 ++++---- flutter/test/sentry_navigator_observer_test.dart | 5 +++-- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/flutter/test/integrations/native_app_start_integration_test.dart b/flutter/test/integrations/native_app_start_integration_test.dart index 56222d999f..d1555c45b8 100644 --- a/flutter/test/integrations/native_app_start_integration_test.dart +++ b/flutter/test/integrations/native_app_start_integration_test.dart @@ -36,8 +36,8 @@ void main() { final enriched = await processor.apply(transaction) as SentryTransaction; final expected = SentryMeasurement('app_start_cold', 10); - expect(enriched.measurements[0].name, expected.name); - expect(enriched.measurements[0].value, expected.value); + expect(enriched.measurements['app_start_cold'], expected); + // expect(enriched.measurements[0].value, expected.value); }); test('native app start measurement not added to following transactions', @@ -69,7 +69,7 @@ void main() { final tracer = fixture.createTracer(); final transaction = SentryTransaction(tracer).copyWith(); - transaction.measurements.add(measurement); + transaction.measurements[measurement.name] = measurement; final processor = fixture.options.eventProcessors.first; @@ -77,7 +77,7 @@ void main() { var secondEnriched = await processor.apply(enriched) as SentryTransaction; expect(secondEnriched.measurements.length, 2); - expect(secondEnriched.measurements.contains(measurement), true); + expect(secondEnriched.measurements.containsKey(measurement.name), true); }); test('native app start measurement not added if more than 60s', () async { diff --git a/flutter/test/sentry_navigator_observer_test.dart b/flutter/test/sentry_navigator_observer_test.dart index b5be8fff9d..c8334c142e 100644 --- a/flutter/test/sentry_navigator_observer_test.dart +++ b/flutter/test/sentry_navigator_observer_test.dart @@ -98,7 +98,7 @@ void main() { expect(mockNativeChannel.numberOfEndNativeFramesCalls, 1); - final measurements = actualTransaction?.measurements ?? []; + final measurements = actualTransaction?.measurements ?? {}; expect(measurements.length, 3); @@ -106,7 +106,8 @@ void main() { final expectedSlow = SentryMeasurement.slowFrames(2); final expectedFrozen = SentryMeasurement.frozenFrames(1); - for (final measurement in measurements) { + for (final item in measurements.entries) { + final measurement = item.value; if (measurement.name == expectedTotal.name) { expect(measurement.value, expectedTotal.value); } else if (measurement.name == expectedSlow.name) { From 0770a10b7e52b2836fcd546ec9ef4ab1b0444e72 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 21 Sep 2022 14:27:08 +0200 Subject: [PATCH 04/10] fix mocks --- CHANGELOG.md | 1 + .../native_app_start_integration_test.dart | 1 - flutter/test/mocks.mocks.dart | 1119 ++++++++++++----- 3 files changed, 804 insertions(+), 317 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a8da7653a..bf926a29bf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ - [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7251) - [diff](https://github.com/getsentry/sentry-cocoa/compare/7.23.0...7.25.1) - Allow routeNameExtractor to set transaction names ([#1005](https://github.com/getsentry/sentry-dart/pull/1005)) +- Allow users to set custom measurements ([#1011](https://github.com/getsentry/sentry-dart/pull/1011)) ## 6.9.1 diff --git a/flutter/test/integrations/native_app_start_integration_test.dart b/flutter/test/integrations/native_app_start_integration_test.dart index d1555c45b8..56858904dd 100644 --- a/flutter/test/integrations/native_app_start_integration_test.dart +++ b/flutter/test/integrations/native_app_start_integration_test.dart @@ -37,7 +37,6 @@ void main() { final expected = SentryMeasurement('app_start_cold', 10); expect(enriched.measurements['app_start_cold'], expected); - // expect(enriched.measurements[0].value, expected.value); }); test('native app start measurement not added to following transactions', diff --git a/flutter/test/mocks.mocks.dart b/flutter/test/mocks.mocks.dart index 4936689a35..72678fd5a9 100644 --- a/flutter/test/mocks.mocks.dart +++ b/flutter/test/mocks.mocks.dart @@ -1,7 +1,8 @@ -// Mocks generated by Mockito 5.2.0 from annotations +// Mocks generated by Mockito 5.3.1 from annotations // in sentry_flutter/example/windows/flutter/ephemeral/.plugin_symlinks/sentry_flutter/example/linux/flutter/ephemeral/.plugin_symlinks/sentry_flutter/example/ios/.symlinks/plugins/sentry_flutter/test/mocks.dart. // Do not manually edit this file. +// ignore_for_file: no_leading_underscores_for_library_prefixes import 'dart:async' as _i6; import 'package:flutter/src/services/binary_messenger.dart' as _i5; @@ -26,27 +27,100 @@ import 'mocks.dart' as _i12; // ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis // ignore_for_file: camel_case_types -// ignore_for_file: invalid_use_of_internal_member +// ignore_for_file: subtype_of_sealed_class -class _FakeSentrySpanContext_0 extends _i1.Fake - implements _i2.SentrySpanContext {} +class _FakeSentrySpanContext_0 extends _i1.SmartFake + implements _i2.SentrySpanContext { + _FakeSentrySpanContext_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeDateTime_1 extends _i1.Fake implements DateTime {} +class _FakeDateTime_1 extends _i1.SmartFake implements DateTime { + _FakeDateTime_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeISentrySpan_2 extends _i1.Fake implements _i2.ISentrySpan {} +class _FakeISentrySpan_2 extends _i1.SmartFake implements _i2.ISentrySpan { + _FakeISentrySpan_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeSentryTraceHeader_3 extends _i1.Fake - implements _i3.SentryTraceHeader {} +class _FakeSentryTraceHeader_3 extends _i1.SmartFake + implements _i3.SentryTraceHeader { + _FakeSentryTraceHeader_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeMethodCodec_4 extends _i1.Fake implements _i4.MethodCodec {} +class _FakeMethodCodec_4 extends _i1.SmartFake implements _i4.MethodCodec { + _FakeMethodCodec_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeBinaryMessenger_5 extends _i1.Fake implements _i5.BinaryMessenger {} +class _FakeBinaryMessenger_5 extends _i1.SmartFake + implements _i5.BinaryMessenger { + _FakeBinaryMessenger_5( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeSentryOptions_6 extends _i1.Fake implements _i2.SentryOptions {} +class _FakeSentryOptions_6 extends _i1.SmartFake implements _i2.SentryOptions { + _FakeSentryOptions_6( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeSentryId_7 extends _i1.Fake implements _i3.SentryId {} +class _FakeSentryId_7 extends _i1.SmartFake implements _i3.SentryId { + _FakeSentryId_7( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeHub_8 extends _i1.Fake implements _i2.Hub {} +class _FakeHub_8 extends _i1.SmartFake implements _i2.Hub { + _FakeHub_8( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} /// A class which mocks [Transport]. /// @@ -58,9 +132,13 @@ class MockTransport extends _i1.Mock implements _i2.Transport { @override _i6.Future<_i3.SentryId?> send(_i7.SentryEnvelope? envelope) => - (super.noSuchMethod(Invocation.method(#send, [envelope]), - returnValue: Future<_i3.SentryId?>.value()) - as _i6.Future<_i3.SentryId?>); + (super.noSuchMethod( + Invocation.method( + #send, + [envelope], + ), + returnValue: _i6.Future<_i3.SentryId?>.value(), + ) as _i6.Future<_i3.SentryId?>); } /// A class which mocks [SentryTracer]. @@ -72,93 +150,230 @@ class MockSentryTracer extends _i1.Mock implements _i8.SentryTracer { } @override - String get name => - (super.noSuchMethod(Invocation.getter(#name), returnValue: '') as String); - @override - set name(String? _name) => super.noSuchMethod(Invocation.setter(#name, _name), - returnValueForMissingStub: null); - @override - _i2.SentrySpanContext get context => - (super.noSuchMethod(Invocation.getter(#context), - returnValue: _FakeSentrySpanContext_0()) as _i2.SentrySpanContext); - @override - DateTime get startTimestamp => - (super.noSuchMethod(Invocation.getter(#startTimestamp), - returnValue: _FakeDateTime_1()) as DateTime); - @override - Map get data => (super.noSuchMethod(Invocation.getter(#data), - returnValue: {}) as Map); - @override - bool get finished => - (super.noSuchMethod(Invocation.getter(#finished), returnValue: false) - as bool); - @override - List<_i3.SentrySpan> get children => - (super.noSuchMethod(Invocation.getter(#children), - returnValue: <_i3.SentrySpan>[]) as List<_i3.SentrySpan>); - @override - set throwable(dynamic throwable) => - super.noSuchMethod(Invocation.setter(#throwable, throwable), - returnValueForMissingStub: null); - @override - set status(_i3.SpanStatus? status) => - super.noSuchMethod(Invocation.setter(#status, status), - returnValueForMissingStub: null); - @override - Map get tags => (super.noSuchMethod(Invocation.getter(#tags), - returnValue: {}) as Map); - @override - List<_i2.SentryMeasurement> get measurements => (super.noSuchMethod( - Invocation.getter(#measurements), - returnValue: <_i2.SentryMeasurement>[]) as List<_i2.SentryMeasurement>); - @override - _i6.Future finish({_i3.SpanStatus? status, DateTime? endTimestamp}) => + String get name => (super.noSuchMethod( + Invocation.getter(#name), + returnValue: '', + ) as String); + @override + set name(String? _name) => super.noSuchMethod( + Invocation.setter( + #name, + _name, + ), + returnValueForMissingStub: null, + ); + @override + _i2.SentrySpanContext get context => (super.noSuchMethod( + Invocation.getter(#context), + returnValue: _FakeSentrySpanContext_0( + this, + Invocation.getter(#context), + ), + ) as _i2.SentrySpanContext); + @override + DateTime get startTimestamp => (super.noSuchMethod( + Invocation.getter(#startTimestamp), + returnValue: _FakeDateTime_1( + this, + Invocation.getter(#startTimestamp), + ), + ) as DateTime); + @override + Map get data => (super.noSuchMethod( + Invocation.getter(#data), + returnValue: {}, + ) as Map); + @override + bool get finished => (super.noSuchMethod( + Invocation.getter(#finished), + returnValue: false, + ) as bool); + @override + List<_i3.SentrySpan> get children => (super.noSuchMethod( + Invocation.getter(#children), + returnValue: <_i3.SentrySpan>[], + ) as List<_i3.SentrySpan>); + @override + set throwable(dynamic throwable) => super.noSuchMethod( + Invocation.setter( + #throwable, + throwable, + ), + returnValueForMissingStub: null, + ); + @override + set status(_i3.SpanStatus? status) => super.noSuchMethod( + Invocation.setter( + #status, + status, + ), + returnValueForMissingStub: null, + ); + @override + Map get tags => (super.noSuchMethod( + Invocation.getter(#tags), + returnValue: {}, + ) as Map); + @override + Map get measurements => (super.noSuchMethod( + Invocation.getter(#measurements), + returnValue: {}, + ) as Map); + @override + _i6.Future finish({ + _i3.SpanStatus? status, + DateTime? endTimestamp, + }) => (super.noSuchMethod( - Invocation.method( - #finish, [], {#status: status, #endTimestamp: endTimestamp}), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); - @override - void removeData(String? key) => - super.noSuchMethod(Invocation.method(#removeData, [key]), - returnValueForMissingStub: null); - @override - void removeTag(String? key) => - super.noSuchMethod(Invocation.method(#removeTag, [key]), - returnValueForMissingStub: null); - @override - void setData(String? key, dynamic value) => - super.noSuchMethod(Invocation.method(#setData, [key, value]), - returnValueForMissingStub: null); - @override - void setTag(String? key, String? value) => - super.noSuchMethod(Invocation.method(#setTag, [key, value]), - returnValueForMissingStub: null); - @override - _i2.ISentrySpan startChild(String? operation, - {String? description, DateTime? startTimestamp}) => + Invocation.method( + #finish, + [], + { + #status: status, + #endTimestamp: endTimestamp, + }, + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + void removeData(String? key) => super.noSuchMethod( + Invocation.method( + #removeData, + [key], + ), + returnValueForMissingStub: null, + ); + @override + void removeTag(String? key) => super.noSuchMethod( + Invocation.method( + #removeTag, + [key], + ), + returnValueForMissingStub: null, + ); + @override + void setData( + String? key, + dynamic value, + ) => + super.noSuchMethod( + Invocation.method( + #setData, + [ + key, + value, + ], + ), + returnValueForMissingStub: null, + ); + @override + void setTag( + String? key, + String? value, + ) => + super.noSuchMethod( + Invocation.method( + #setTag, + [ + key, + value, + ], + ), + returnValueForMissingStub: null, + ); + @override + _i2.ISentrySpan startChild( + String? operation, { + String? description, + DateTime? startTimestamp, + }) => (super.noSuchMethod( - Invocation.method(#startChild, [operation], - {#description: description, #startTimestamp: startTimestamp}), - returnValue: _FakeISentrySpan_2()) as _i2.ISentrySpan); + Invocation.method( + #startChild, + [operation], + { + #description: description, + #startTimestamp: startTimestamp, + }, + ), + returnValue: _FakeISentrySpan_2( + this, + Invocation.method( + #startChild, + [operation], + { + #description: description, + #startTimestamp: startTimestamp, + }, + ), + ), + ) as _i2.ISentrySpan); @override _i2.ISentrySpan startChildWithParentSpanId( - _i3.SpanId? parentSpanId, String? operation, - {String? description, DateTime? startTimestamp}) => + _i3.SpanId? parentSpanId, + String? operation, { + String? description, + DateTime? startTimestamp, + }) => (super.noSuchMethod( + Invocation.method( + #startChildWithParentSpanId, + [ + parentSpanId, + operation, + ], + { + #description: description, + #startTimestamp: startTimestamp, + }, + ), + returnValue: _FakeISentrySpan_2( + this, Invocation.method( - #startChildWithParentSpanId, - [parentSpanId, operation], - {#description: description, #startTimestamp: startTimestamp}), - returnValue: _FakeISentrySpan_2()) as _i2.ISentrySpan); - @override - _i3.SentryTraceHeader toSentryTrace() => - (super.noSuchMethod(Invocation.method(#toSentryTrace, []), - returnValue: _FakeSentryTraceHeader_3()) as _i3.SentryTraceHeader); - @override - void addMeasurements(List<_i2.SentryMeasurement>? measurements) => - super.noSuchMethod(Invocation.method(#addMeasurements, [measurements]), - returnValueForMissingStub: null); + #startChildWithParentSpanId, + [ + parentSpanId, + operation, + ], + { + #description: description, + #startTimestamp: startTimestamp, + }, + ), + ), + ) as _i2.ISentrySpan); + @override + _i3.SentryTraceHeader toSentryTrace() => (super.noSuchMethod( + Invocation.method( + #toSentryTrace, + [], + ), + returnValue: _FakeSentryTraceHeader_3( + this, + Invocation.method( + #toSentryTrace, + [], + ), + ), + ) as _i3.SentryTraceHeader); + @override + void setMeasurement( + String? name, + num? value, { + _i2.SentryMeasurementUnit? unit, + }) => + super.noSuchMethod( + Invocation.method( + #setMeasurement, + [ + name, + value, + ], + {#unit: unit}, + ), + returnValueForMissingStub: null, + ); } /// A class which mocks [MethodChannel]. @@ -170,36 +385,81 @@ class MockMethodChannel extends _i1.Mock implements _i9.MethodChannel { } @override - String get name => - (super.noSuchMethod(Invocation.getter(#name), returnValue: '') as String); - @override - _i4.MethodCodec get codec => (super.noSuchMethod(Invocation.getter(#codec), - returnValue: _FakeMethodCodec_4()) as _i4.MethodCodec); - @override - _i5.BinaryMessenger get binaryMessenger => - (super.noSuchMethod(Invocation.getter(#binaryMessenger), - returnValue: _FakeBinaryMessenger_5()) as _i5.BinaryMessenger); - @override - _i6.Future invokeMethod(String? method, [dynamic arguments]) => - (super.noSuchMethod(Invocation.method(#invokeMethod, [method, arguments]), - returnValue: Future.value()) as _i6.Future); - @override - _i6.Future?> invokeListMethod(String? method, - [dynamic arguments]) => + String get name => (super.noSuchMethod( + Invocation.getter(#name), + returnValue: '', + ) as String); + @override + _i4.MethodCodec get codec => (super.noSuchMethod( + Invocation.getter(#codec), + returnValue: _FakeMethodCodec_4( + this, + Invocation.getter(#codec), + ), + ) as _i4.MethodCodec); + @override + _i5.BinaryMessenger get binaryMessenger => (super.noSuchMethod( + Invocation.getter(#binaryMessenger), + returnValue: _FakeBinaryMessenger_5( + this, + Invocation.getter(#binaryMessenger), + ), + ) as _i5.BinaryMessenger); + @override + _i6.Future invokeMethod( + String? method, [ + dynamic arguments, + ]) => (super.noSuchMethod( - Invocation.method(#invokeListMethod, [method, arguments]), - returnValue: Future?>.value()) as _i6.Future?>); - @override - _i6.Future?> invokeMapMethod(String? method, - [dynamic arguments]) => + Invocation.method( + #invokeMethod, + [ + method, + arguments, + ], + ), + returnValue: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future?> invokeListMethod( + String? method, [ + dynamic arguments, + ]) => (super.noSuchMethod( - Invocation.method(#invokeMapMethod, [method, arguments]), - returnValue: Future?>.value()) as _i6.Future?>); + Invocation.method( + #invokeListMethod, + [ + method, + arguments, + ], + ), + returnValue: _i6.Future?>.value(), + ) as _i6.Future?>); + @override + _i6.Future?> invokeMapMethod( + String? method, [ + dynamic arguments, + ]) => + (super.noSuchMethod( + Invocation.method( + #invokeMapMethod, + [ + method, + arguments, + ], + ), + returnValue: _i6.Future?>.value(), + ) as _i6.Future?>); @override void setMethodCallHandler( _i6.Future Function(_i4.MethodCall)? handler) => - super.noSuchMethod(Invocation.method(#setMethodCallHandler, [handler]), - returnValueForMissingStub: null); + super.noSuchMethod( + Invocation.method( + #setMethodCallHandler, + [handler], + ), + returnValueForMissingStub: null, + ); } /// A class which mocks [SentryNative]. @@ -211,82 +471,165 @@ class MockSentryNative extends _i1.Mock implements _i10.SentryNative { } @override - set appStartEnd(DateTime? _appStartEnd) => - super.noSuchMethod(Invocation.setter(#appStartEnd, _appStartEnd), - returnValueForMissingStub: null); + set appStartEnd(DateTime? _appStartEnd) => super.noSuchMethod( + Invocation.setter( + #appStartEnd, + _appStartEnd, + ), + returnValueForMissingStub: null, + ); @override - bool get didFetchAppStart => - (super.noSuchMethod(Invocation.getter(#didFetchAppStart), - returnValue: false) as bool); + bool get didFetchAppStart => (super.noSuchMethod( + Invocation.getter(#didFetchAppStart), + returnValue: false, + ) as bool); @override void setNativeChannel(_i11.SentryNativeChannel? nativeChannel) => - super.noSuchMethod(Invocation.method(#setNativeChannel, [nativeChannel]), - returnValueForMissingStub: null); - @override - _i6.Future<_i11.NativeAppStart?> fetchNativeAppStart() => - (super.noSuchMethod(Invocation.method(#fetchNativeAppStart, []), - returnValue: Future<_i11.NativeAppStart?>.value()) - as _i6.Future<_i11.NativeAppStart?>); - @override - _i6.Future beginNativeFramesCollection() => - (super.noSuchMethod(Invocation.method(#beginNativeFramesCollection, []), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); + super.noSuchMethod( + Invocation.method( + #setNativeChannel, + [nativeChannel], + ), + returnValueForMissingStub: null, + ); + @override + _i6.Future<_i11.NativeAppStart?> fetchNativeAppStart() => (super.noSuchMethod( + Invocation.method( + #fetchNativeAppStart, + [], + ), + returnValue: _i6.Future<_i11.NativeAppStart?>.value(), + ) as _i6.Future<_i11.NativeAppStart?>); + @override + _i6.Future beginNativeFramesCollection() => (super.noSuchMethod( + Invocation.method( + #beginNativeFramesCollection, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override _i6.Future<_i11.NativeFrames?> endNativeFramesCollection( _i3.SentryId? traceId) => (super.noSuchMethod( - Invocation.method(#endNativeFramesCollection, [traceId]), - returnValue: Future<_i11.NativeFrames?>.value()) - as _i6.Future<_i11.NativeFrames?>); - @override - _i6.Future setContexts(String? key, dynamic value) => - (super.noSuchMethod(Invocation.method(#setContexts, [key, value]), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); - @override - _i6.Future removeContexts(String? key) => - (super.noSuchMethod(Invocation.method(#removeContexts, [key]), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); - @override - _i6.Future setUser(_i3.SentryUser? sentryUser) => - (super.noSuchMethod(Invocation.method(#setUser, [sentryUser]), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); + Invocation.method( + #endNativeFramesCollection, + [traceId], + ), + returnValue: _i6.Future<_i11.NativeFrames?>.value(), + ) as _i6.Future<_i11.NativeFrames?>); + @override + _i6.Future setContexts( + String? key, + dynamic value, + ) => + (super.noSuchMethod( + Invocation.method( + #setContexts, + [ + key, + value, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future removeContexts(String? key) => (super.noSuchMethod( + Invocation.method( + #removeContexts, + [key], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future setUser(_i3.SentryUser? sentryUser) => (super.noSuchMethod( + Invocation.method( + #setUser, + [sentryUser], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override _i6.Future addBreadcrumb(_i3.Breadcrumb? breadcrumb) => - (super.noSuchMethod(Invocation.method(#addBreadcrumb, [breadcrumb]), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); - @override - _i6.Future clearBreadcrumbs() => - (super.noSuchMethod(Invocation.method(#clearBreadcrumbs, []), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); - @override - _i6.Future setExtra(String? key, dynamic value) => - (super.noSuchMethod(Invocation.method(#setExtra, [key, value]), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); - @override - _i6.Future removeExtra(String? key) => - (super.noSuchMethod(Invocation.method(#removeExtra, [key]), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); - @override - _i6.Future setTag(String? key, String? value) => - (super.noSuchMethod(Invocation.method(#setTag, [key, value]), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); - @override - _i6.Future removeTag(String? key) => - (super.noSuchMethod(Invocation.method(#removeTag, [key]), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); - @override - void reset() => super.noSuchMethod(Invocation.method(#reset, []), - returnValueForMissingStub: null); + (super.noSuchMethod( + Invocation.method( + #addBreadcrumb, + [breadcrumb], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future clearBreadcrumbs() => (super.noSuchMethod( + Invocation.method( + #clearBreadcrumbs, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future setExtra( + String? key, + dynamic value, + ) => + (super.noSuchMethod( + Invocation.method( + #setExtra, + [ + key, + value, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future removeExtra(String? key) => (super.noSuchMethod( + Invocation.method( + #removeExtra, + [key], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future setTag( + String? key, + String? value, + ) => + (super.noSuchMethod( + Invocation.method( + #setTag, + [ + key, + value, + ], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future removeTag(String? key) => (super.noSuchMethod( + Invocation.method( + #removeTag, + [key], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + void reset() => super.noSuchMethod( + Invocation.method( + #reset, + [], + ), + returnValueForMissingStub: null, + ); } /// A class which mocks [Hub]. @@ -298,156 +641,300 @@ class MockHub extends _i1.Mock implements _i2.Hub { } @override - _i2.SentryOptions get options => - (super.noSuchMethod(Invocation.getter(#options), - returnValue: _FakeSentryOptions_6()) as _i2.SentryOptions); - @override - bool get isEnabled => - (super.noSuchMethod(Invocation.getter(#isEnabled), returnValue: false) - as bool); - @override - _i3.SentryId get lastEventId => - (super.noSuchMethod(Invocation.getter(#lastEventId), - returnValue: _FakeSentryId_7()) as _i3.SentryId); - @override - _i6.Future<_i3.SentryId> captureEvent(_i3.SentryEvent? event, - {dynamic stackTrace, dynamic hint, _i2.ScopeCallback? withScope}) => + _i2.SentryOptions get options => (super.noSuchMethod( + Invocation.getter(#options), + returnValue: _FakeSentryOptions_6( + this, + Invocation.getter(#options), + ), + ) as _i2.SentryOptions); + @override + bool get isEnabled => (super.noSuchMethod( + Invocation.getter(#isEnabled), + returnValue: false, + ) as bool); + @override + _i3.SentryId get lastEventId => (super.noSuchMethod( + Invocation.getter(#lastEventId), + returnValue: _FakeSentryId_7( + this, + Invocation.getter(#lastEventId), + ), + ) as _i3.SentryId); + @override + _i6.Future<_i3.SentryId> captureEvent( + _i3.SentryEvent? event, { + dynamic stackTrace, + dynamic hint, + _i2.ScopeCallback? withScope, + }) => (super.noSuchMethod( - Invocation.method(#captureEvent, [ - event - ], { - #stackTrace: stackTrace, - #hint: hint, - #withScope: withScope - }), - returnValue: Future<_i3.SentryId>.value(_FakeSentryId_7())) - as _i6.Future<_i3.SentryId>); - @override - _i6.Future<_i3.SentryId> captureException(dynamic throwable, - {dynamic stackTrace, dynamic hint, _i2.ScopeCallback? withScope}) => + Invocation.method( + #captureEvent, + [event], + { + #stackTrace: stackTrace, + #hint: hint, + #withScope: withScope, + }, + ), + returnValue: _i6.Future<_i3.SentryId>.value(_FakeSentryId_7( + this, + Invocation.method( + #captureEvent, + [event], + { + #stackTrace: stackTrace, + #hint: hint, + #withScope: withScope, + }, + ), + )), + ) as _i6.Future<_i3.SentryId>); + @override + _i6.Future<_i3.SentryId> captureException( + dynamic throwable, { + dynamic stackTrace, + dynamic hint, + _i2.ScopeCallback? withScope, + }) => (super.noSuchMethod( - Invocation.method(#captureException, [ - throwable - ], { - #stackTrace: stackTrace, - #hint: hint, - #withScope: withScope - }), - returnValue: Future<_i3.SentryId>.value(_FakeSentryId_7())) - as _i6.Future<_i3.SentryId>); - @override - _i6.Future<_i3.SentryId> captureMessage(String? message, - {_i3.SentryLevel? level, - String? template, - List? params, - dynamic hint, - _i2.ScopeCallback? withScope}) => + Invocation.method( + #captureException, + [throwable], + { + #stackTrace: stackTrace, + #hint: hint, + #withScope: withScope, + }, + ), + returnValue: _i6.Future<_i3.SentryId>.value(_FakeSentryId_7( + this, + Invocation.method( + #captureException, + [throwable], + { + #stackTrace: stackTrace, + #hint: hint, + #withScope: withScope, + }, + ), + )), + ) as _i6.Future<_i3.SentryId>); + @override + _i6.Future<_i3.SentryId> captureMessage( + String? message, { + _i3.SentryLevel? level, + String? template, + List? params, + dynamic hint, + _i2.ScopeCallback? withScope, + }) => (super.noSuchMethod( - Invocation.method(#captureMessage, [ - message - ], { - #level: level, - #template: template, - #params: params, - #hint: hint, - #withScope: withScope - }), - returnValue: Future<_i3.SentryId>.value(_FakeSentryId_7())) - as _i6.Future<_i3.SentryId>); + Invocation.method( + #captureMessage, + [message], + { + #level: level, + #template: template, + #params: params, + #hint: hint, + #withScope: withScope, + }, + ), + returnValue: _i6.Future<_i3.SentryId>.value(_FakeSentryId_7( + this, + Invocation.method( + #captureMessage, + [message], + { + #level: level, + #template: template, + #params: params, + #hint: hint, + #withScope: withScope, + }, + ), + )), + ) as _i6.Future<_i3.SentryId>); @override _i6.Future captureUserFeedback(_i2.SentryUserFeedback? userFeedback) => (super.noSuchMethod( - Invocation.method(#captureUserFeedback, [userFeedback]), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); - @override - _i6.Future addBreadcrumb(_i3.Breadcrumb? crumb, {dynamic hint}) => + Invocation.method( + #captureUserFeedback, + [userFeedback], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + _i6.Future addBreadcrumb( + _i3.Breadcrumb? crumb, { + dynamic hint, + }) => (super.noSuchMethod( - Invocation.method(#addBreadcrumb, [crumb], {#hint: hint}), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); - @override - void bindClient(_i2.SentryClient? client) => - super.noSuchMethod(Invocation.method(#bindClient, [client]), - returnValueForMissingStub: null); - @override - _i2.Hub clone() => (super.noSuchMethod(Invocation.method(#clone, []), - returnValue: _FakeHub_8()) as _i2.Hub); - @override - _i6.Future close() => (super.noSuchMethod(Invocation.method(#close, []), - returnValue: Future.value(), - returnValueForMissingStub: Future.value()) as _i6.Future); + Invocation.method( + #addBreadcrumb, + [crumb], + {#hint: hint}, + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); + @override + void bindClient(_i2.SentryClient? client) => super.noSuchMethod( + Invocation.method( + #bindClient, + [client], + ), + returnValueForMissingStub: null, + ); + @override + _i2.Hub clone() => (super.noSuchMethod( + Invocation.method( + #clone, + [], + ), + returnValue: _FakeHub_8( + this, + Invocation.method( + #clone, + [], + ), + ), + ) as _i2.Hub); + @override + _i6.Future close() => (super.noSuchMethod( + Invocation.method( + #close, + [], + ), + returnValue: _i6.Future.value(), + returnValueForMissingStub: _i6.Future.value(), + ) as _i6.Future); @override _i6.FutureOr configureScope(_i2.ScopeCallback? callback) => - (super.noSuchMethod(Invocation.method(#configureScope, [callback])) - as _i6.FutureOr); - @override - _i2.ISentrySpan startTransaction(String? name, String? operation, - {String? description, - DateTime? startTimestamp, - bool? bindToScope, - bool? waitForChildren, - Duration? autoFinishAfter, - bool? trimEnd, - _i2.OnTransactionFinish? onFinish, - Map? customSamplingContext}) => + (super.noSuchMethod(Invocation.method( + #configureScope, + [callback], + )) as _i6.FutureOr); + @override + _i2.ISentrySpan startTransaction( + String? name, + String? operation, { + String? description, + DateTime? startTimestamp, + bool? bindToScope, + bool? waitForChildren, + Duration? autoFinishAfter, + bool? trimEnd, + _i2.OnTransactionFinish? onFinish, + Map? customSamplingContext, + }) => (super.noSuchMethod( - Invocation.method(#startTransaction, [ - name, - operation - ], { - #description: description, - #startTimestamp: startTimestamp, - #bindToScope: bindToScope, - #waitForChildren: waitForChildren, - #autoFinishAfter: autoFinishAfter, - #trimEnd: trimEnd, - #onFinish: onFinish, - #customSamplingContext: customSamplingContext - }), - returnValue: _i12.startTransactionShim(name, operation, - description: description, - startTimestamp: startTimestamp, - bindToScope: bindToScope, - waitForChildren: waitForChildren, - autoFinishAfter: autoFinishAfter, - trimEnd: trimEnd, - onFinish: onFinish, - customSamplingContext: customSamplingContext)) - as _i2.ISentrySpan); + Invocation.method( + #startTransaction, + [ + name, + operation, + ], + { + #description: description, + #startTimestamp: startTimestamp, + #bindToScope: bindToScope, + #waitForChildren: waitForChildren, + #autoFinishAfter: autoFinishAfter, + #trimEnd: trimEnd, + #onFinish: onFinish, + #customSamplingContext: customSamplingContext, + }, + ), + returnValue: _i12.startTransactionShim( + name, + operation, + description: description, + startTimestamp: startTimestamp, + bindToScope: bindToScope, + waitForChildren: waitForChildren, + autoFinishAfter: autoFinishAfter, + trimEnd: trimEnd, + onFinish: onFinish, + customSamplingContext: customSamplingContext, + ), + ) as _i2.ISentrySpan); @override _i2.ISentrySpan startTransactionWithContext( - _i2.SentryTransactionContext? transactionContext, - {Map? customSamplingContext, - DateTime? startTimestamp, - bool? bindToScope, - bool? waitForChildren, - Duration? autoFinishAfter, - bool? trimEnd, - _i2.OnTransactionFinish? onFinish}) => + _i2.SentryTransactionContext? transactionContext, { + Map? customSamplingContext, + DateTime? startTimestamp, + bool? bindToScope, + bool? waitForChildren, + Duration? autoFinishAfter, + bool? trimEnd, + _i2.OnTransactionFinish? onFinish, + }) => (super.noSuchMethod( - Invocation.method(#startTransactionWithContext, [ - transactionContext - ], { + Invocation.method( + #startTransactionWithContext, + [transactionContext], + { #customSamplingContext: customSamplingContext, #startTimestamp: startTimestamp, #bindToScope: bindToScope, #waitForChildren: waitForChildren, #autoFinishAfter: autoFinishAfter, #trimEnd: trimEnd, - #onFinish: onFinish - }), - returnValue: _FakeISentrySpan_2()) as _i2.ISentrySpan); + #onFinish: onFinish, + }, + ), + returnValue: _FakeISentrySpan_2( + this, + Invocation.method( + #startTransactionWithContext, + [transactionContext], + { + #customSamplingContext: customSamplingContext, + #startTimestamp: startTimestamp, + #bindToScope: bindToScope, + #waitForChildren: waitForChildren, + #autoFinishAfter: autoFinishAfter, + #trimEnd: trimEnd, + #onFinish: onFinish, + }, + ), + ), + ) as _i2.ISentrySpan); @override _i6.Future<_i3.SentryId> captureTransaction( _i3.SentryTransaction? transaction) => - (super.noSuchMethod(Invocation.method(#captureTransaction, [transaction]), - returnValue: Future<_i3.SentryId>.value(_FakeSentryId_7())) - as _i6.Future<_i3.SentryId>); + (super.noSuchMethod( + Invocation.method( + #captureTransaction, + [transaction], + ), + returnValue: _i6.Future<_i3.SentryId>.value(_FakeSentryId_7( + this, + Invocation.method( + #captureTransaction, + [transaction], + ), + )), + ) as _i6.Future<_i3.SentryId>); @override void setSpanContext( - dynamic throwable, _i2.ISentrySpan? span, String? transaction) => + dynamic throwable, + _i2.ISentrySpan? span, + String? transaction, + ) => super.noSuchMethod( - Invocation.method(#setSpanContext, [throwable, span, transaction]), - returnValueForMissingStub: null); + Invocation.method( + #setSpanContext, + [ + throwable, + span, + transaction, + ], + ), + returnValueForMissingStub: null, + ); } From 5d34cae77484f91ecdeceee8a552f79cc79445fc Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 21 Sep 2022 14:31:04 +0200 Subject: [PATCH 05/10] fix test --- .../test/integrations/native_app_start_integration_test.dart | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/flutter/test/integrations/native_app_start_integration_test.dart b/flutter/test/integrations/native_app_start_integration_test.dart index 56858904dd..555cddd2a5 100644 --- a/flutter/test/integrations/native_app_start_integration_test.dart +++ b/flutter/test/integrations/native_app_start_integration_test.dart @@ -35,8 +35,9 @@ void main() { final processor = fixture.options.eventProcessors.first; final enriched = await processor.apply(transaction) as SentryTransaction; - final expected = SentryMeasurement('app_start_cold', 10); - expect(enriched.measurements['app_start_cold'], expected); + final measurement = enriched.measurements['app_start_cold']!; + expect(measurement.value, 10); + expect(measurement.unit, SentryMeasurementUnit.milliSecond); }); test('native app start measurement not added to following transactions', From f79c283f9773fdac06eff3551692ab268315556d Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 21 Sep 2022 14:38:24 +0200 Subject: [PATCH 06/10] add tests --- dart/test/sentry_measurement_test.dart | 42 ++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 dart/test/sentry_measurement_test.dart diff --git a/dart/test/sentry_measurement_test.dart b/dart/test/sentry_measurement_test.dart new file mode 100644 index 0000000000..144a8f9b7f --- /dev/null +++ b/dart/test/sentry_measurement_test.dart @@ -0,0 +1,42 @@ +import 'package:collection/collection.dart'; +import 'package:sentry/sentry.dart'; +import 'package:test/test.dart'; + +void main() { + group('$SentryMeasurement', () { + test('total frames has none unit', () { + expect( + SentryMeasurement.totalFrames(10).unit, SentryMeasurementUnit.none); + }); + + test('slow frames has none unit', () { + expect(SentryMeasurement.slowFrames(10).unit, SentryMeasurementUnit.none); + }); + + test('frozen frames has none unit', () { + expect( + SentryMeasurement.frozenFrames(10).unit, SentryMeasurementUnit.none); + }); + + test('warm start has milliseconds unit', () { + expect(SentryMeasurement.warmAppStart(Duration(seconds: 1)).unit, + SentryMeasurementUnit.milliSecond); + }); + + test('cold start has milliseconds unit', () { + expect(SentryMeasurement.coldAppStart(Duration(seconds: 1)).unit, + SentryMeasurementUnit.milliSecond); + }); + + test('toJson sets unit if given', () { + final measurement = SentryMeasurement('name', 10, + unit: SentryMeasurementUnit.milliSecond); + final map = { + 'value': 10, + 'unit': 'millisecond', + }; + + expect(MapEquality().equals(measurement.toJson(), map), true); + }); + }); +} From 6d8a8df79cd8b1b1f08a896c77e969671c5b4dec Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Wed, 21 Sep 2022 14:42:30 +0200 Subject: [PATCH 07/10] fix internal usafge --- flutter/test/mocks.mocks.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/flutter/test/mocks.mocks.dart b/flutter/test/mocks.mocks.dart index 72678fd5a9..26cca64a20 100644 --- a/flutter/test/mocks.mocks.dart +++ b/flutter/test/mocks.mocks.dart @@ -28,6 +28,7 @@ import 'mocks.dart' as _i12; // ignore_for_file: unnecessary_parenthesis // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class +// ignore_for_file: invalid_use_of_internal_member class _FakeSentrySpanContext_0 extends _i1.SmartFake implements _i2.SentrySpanContext { From fc1bc4ede4d5fcb6906a6ac7046fccf5985d77d0 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 22 Sep 2022 13:09:03 +0200 Subject: [PATCH 08/10] fix --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c6f67ea0d..04a7fa66ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +### Features + +- Allow users to set custom measurements ([#1011](https://github.com/getsentry/sentry-dart/pull/1011)) + ## 6.10.0 ### Fixes From 1ccd9748a52b2f2833ec69c0eaa68a6ce0463d90 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto Date: Thu, 22 Sep 2022 15:39:29 +0200 Subject: [PATCH 09/10] fix changelog --- CHANGELOG.md | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2695129db3..e91232b41d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,6 @@ ## Unreleased -### Features - -- Allow users to set custom measurements ([#1011](https://github.com/getsentry/sentry-dart/pull/1011)) ### Fixes - Scope cloning method was not setting the user ([#1013](https://github.com/getsentry/sentry-dart/pull/1013)) @@ -12,6 +9,7 @@ ### Features - Dynamic sampling ([#1004](https://github.com/getsentry/sentry-dart/pull/1004)) +- Allow users to set custom measurements ([#1011](https://github.com/getsentry/sentry-dart/pull/1011)) ## 6.10.0 @@ -29,8 +27,6 @@ - Bump Cocoa SDK from v7.23.0 to v7.25.1 ([#993](https://github.com/getsentry/sentry-dart/pull/993), [#996](https://github.com/getsentry/sentry-dart/pull/996), [#1000](https://github.com/getsentry/sentry-dart/pull/1000), [#1007](https://github.com/getsentry/sentry-dart/pull/1007)) - [changelog](https://github.com/getsentry/sentry-cocoa/blob/master/CHANGELOG.md#7251) - [diff](https://github.com/getsentry/sentry-cocoa/compare/7.23.0...7.25.1) -- Allow routeNameExtractor to set transaction names ([#1005](https://github.com/getsentry/sentry-dart/pull/1005)) -- Allow users to set custom measurements ([#1011](https://github.com/getsentry/sentry-dart/pull/1011)) - Dynamic sampling ([#1004](https://github.com/getsentry/sentry-dart/pull/1004)) ## 6.9.1 From a8a3c071b0b30b2c53cb16b47e9767777016b6b0 Mon Sep 17 00:00:00 2001 From: Manoel Aranda Neto <5731772+marandaneto@users.noreply.github.com> Date: Fri, 23 Sep 2022 09:28:59 +0200 Subject: [PATCH 10/10] Update CHANGELOG.md Co-authored-by: Philipp Hofmann --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e91232b41d..027c4be048 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ ### Features - Dynamic sampling ([#1004](https://github.com/getsentry/sentry-dart/pull/1004)) -- Allow users to set custom measurements ([#1011](https://github.com/getsentry/sentry-dart/pull/1011)) +- Set custom measurements on transactions ([#1011](https://github.com/getsentry/sentry-dart/pull/1011)) ## 6.10.0