Skip to content

Commit

Permalink
Merge branch 'main' into feat/replay-custom-redact
Browse files Browse the repository at this point in the history
  • Loading branch information
vaind authored Oct 10, 2024
2 parents 35495b2 + 547db82 commit 534bbb4
Show file tree
Hide file tree
Showing 11 changed files with 211 additions and 92 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
- Improve app start integration ([#2266](https://github.com/getsentry/sentry-dart/pull/2266))
- Fixes ([#2103](https://github.com/getsentry/sentry-dart/issues/2103))
- Fixes ([#2233](https://github.com/getsentry/sentry-dart/issues/2233))
- Only store slow and frozen frames for frame delay calculation ([#2337](https://github.com/getsentry/sentry-dart/pull/2337))

### Fixes

Expand All @@ -40,6 +41,8 @@
- Rounding error used on frames.total and reject frame measurements if frames.total is less than frames.slow or frames.frozen ([#2308](https://github.com/getsentry/sentry-dart/pull/2308))
- iOS replay integration when only `onErrorSampleRate` is specified ([#2306](https://github.com/getsentry/sentry-dart/pull/2306))
- Fix TTID timing issue ([#2326](https://github.com/getsentry/sentry-dart/pull/2326))
- Accessing invalid json fields from `fetchNativeAppStart` should return null ([#2340](https://github.com/getsentry/sentry-dart/pull/2340))
- Error when calling `SentryFlutter.reportFullyDisplayed()` twice ([#2339](https://github.com/getsentry/sentry-dart/pull/2339))

### Deprecate

Expand All @@ -51,6 +54,9 @@
- Bump Cocoa SDK from v8.36.0 to v8.37.0 ([#2334](https://github.com/getsentry/sentry-dart/pull/2334))
- [changelog](https://github.com/getsentry/sentry-cocoa/blob/main/CHANGELOG.md#8370)
- [diff](https://github.com/getsentry/sentry-cocoa/compare/8.36.0...8.37.0)
- Bump Android SDK from v7.14.0 to v7.15.0 ([#2342](https://github.com/getsentry/sentry-dart/pull/2342))
- [changelog](https://github.com/getsentry/sentry-java/blob/main/CHANGELOG.md#7150)
- [diff](https://github.com/getsentry/sentry-java/compare/7.14.0...7.15.0)

## 8.9.0

Expand Down
2 changes: 1 addition & 1 deletion flutter/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ android {
}

dependencies {
api 'io.sentry:sentry-android:7.14.0'
api 'io.sentry:sentry-android:7.15.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"

// Required -- JUnit 4 framework
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ class SentryFlutter(
data: Map<String, Any>,
) {
options.sessionSampleRate = data["sessionSampleRate"] as? Double
options.errorSampleRate = data["onErrorSampleRate"] as? Double
options.onErrorSampleRate = data["onErrorSampleRate"] as? Double
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class SentryFlutterTest {
assertEquals("0000", fixture.options.proxy?.pass)

assertEquals(0.5, fixture.options.experimental.sessionReplay.sessionSampleRate)
assertEquals(0.6, fixture.options.experimental.sessionReplay.errorSampleRate)
assertEquals(0.6, fixture.options.experimental.sessionReplay.onErrorSampleRate)

// Note: these are currently read-only in SentryReplayOptions so we're only asserting the default values here to
// know when there's a change in the native SDK, as it may require a manual change in the Flutter implementation.
Expand Down
28 changes: 23 additions & 5 deletions flutter/lib/src/native/native_app_start.dart
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import 'package:meta/meta.dart';
import 'package:sentry/sentry.dart';

@internal
class NativeAppStart {
Expand All @@ -13,12 +14,29 @@ class NativeAppStart {
bool isColdStart;
Map<dynamic, dynamic> nativeSpanTimes;

factory NativeAppStart.fromJson(Map<String, dynamic> json) {
static NativeAppStart? fromJson(Map<String, dynamic> json) {
final appStartTime = json['appStartTime'];
final pluginRegistrationTime = json['pluginRegistrationTime'];
final isColdStart = json['isColdStart'];
final nativeSpanTimes = json['nativeSpanTimes'];

if (appStartTime is! double ||
pluginRegistrationTime is! int ||
isColdStart is! bool ||
nativeSpanTimes is! Map) {
// ignore: invalid_use_of_internal_member
Sentry.currentHub.options.logger(
SentryLevel.warning,
'Failed to parse json when capturing App Start metrics. App Start wont be reported.',
);
return null;
}

return NativeAppStart(
appStartTime: json['appStartTime'] as double,
pluginRegistrationTime: json['pluginRegistrationTime'] as int,
isColdStart: json['isColdStart'] as bool,
nativeSpanTimes: json['nativeSpanTimes'] as Map<dynamic, dynamic>,
appStartTime: appStartTime,
pluginRegistrationTime: pluginRegistrationTime,
isColdStart: isColdStart,
nativeSpanTimes: nativeSpanTimes,
);
}
}
24 changes: 17 additions & 7 deletions flutter/lib/src/navigation/time_to_full_display_tracker.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class TimeToFullDisplayTracker {
ISentrySpan? _ttfdSpan;
ISentrySpan? _transaction;
Duration _autoFinishAfter = const Duration(seconds: 30);
final options = Sentry.currentHub.options;

// End timestamp provider is only needed when the TTFD timeout is triggered
EndTimestampProvider _endTimestampProvider = ttidEndTimestampProvider();
Expand Down Expand Up @@ -72,17 +73,26 @@ class TimeToFullDisplayTracker {
}

Future<void> reportFullyDisplayed() async {
final endTimestamp = getUtcDateTime();
final startTimestamp = _startTimestamp;
final ttfdSpan = _ttfdSpan;
if (_ttfdSpan == null || _startTimestamp == null) {
options.logger(
SentryLevel.warning,
'TTFD tracker not started',
);
return;
}

if (ttfdSpan?.finished == true || startTimestamp == null) {
_completedTTFDTracking.complete();
if (_completedTTFDTracking.isCompleted || _ttfdSpan?.finished == true) {
options.logger(
SentryLevel.warning,
'TTFD tracker already completed',
);
return;
}

_setTTFDMeasurement(startTimestamp, endTimestamp);
await ttfdSpan?.finish(status: SpanStatus.ok(), endTimestamp: endTimestamp);
final endTimestamp = getUtcDateTime();
_setTTFDMeasurement(_startTimestamp!, endTimestamp);
await _ttfdSpan?.finish(
status: SpanStatus.ok(), endTimestamp: endTimestamp);

_completedTTFDTracking.complete();
}
Expand Down
13 changes: 12 additions & 1 deletion flutter/lib/src/sentry_flutter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,18 @@ mixin SentryFlutter {
/// Reports the time it took for the screen to be fully displayed.
/// This requires the [SentryFlutterOptions.enableTimeToFullDisplayTracing] option to be set to `true`.
static Future<void> reportFullyDisplayed() async {
return SentryNavigatorObserver.timeToDisplayTracker?.reportFullyDisplayed();
try {
return SentryNavigatorObserver.timeToDisplayTracker
?.reportFullyDisplayed();
} catch (e, stackTrace) {
// ignore: invalid_use_of_internal_member
Sentry.currentHub.options.logger(
SentryLevel.error,
'Error while reporting TTFD',
exception: e,
stackTrace: stackTrace,
);
}
}

/// Pauses the app hang tracking.
Expand Down
Loading

0 comments on commit 534bbb4

Please sign in to comment.