Skip to content

Commit

Permalink
make helper classes private to file
Browse files Browse the repository at this point in the history
  • Loading branch information
denrase committed Sep 10, 2024
1 parent a3211e6 commit 6ae5a65
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 18 deletions.
34 changes: 17 additions & 17 deletions flutter/lib/src/integrations/native_app_start_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class NativeAppStartHandler {
await transaction.finish(endTimestamp: appStartInfo.end);
}

AppStartInfo? _infoNativeAppStart(
_AppStartInfo? _infoNativeAppStart(
NativeAppStart nativeAppStart,
DateTime? appStartEnd,
) {
Expand Down Expand Up @@ -109,13 +109,13 @@ class NativeAppStartHandler {
}
}

List<TimeSpan> nativeSpanTimes = [];
List<_TimeSpan> nativeSpanTimes = [];
for (final entry in nativeAppStart.nativeSpanTimes.entries) {
try {
final startTimestampMs =
entry.value['startTimestampMsSinceEpoch'] as int;
final endTimestampMs = entry.value['stopTimestampMsSinceEpoch'] as int;
nativeSpanTimes.add(TimeSpan(
nativeSpanTimes.add(_TimeSpan(
start: DateTime.fromMillisecondsSinceEpoch(startTimestampMs),
end: DateTime.fromMillisecondsSinceEpoch(endTimestampMs),
description: entry.key as String,
Expand All @@ -131,8 +131,8 @@ class NativeAppStartHandler {
// Performance wise this won't affect us since the native span amount is very low.
nativeSpanTimes.sort((a, b) => a.start.compareTo(b.start));

return AppStartInfo(
nativeAppStart.isColdStart ? AppStartType.cold : AppStartType.warm,
return _AppStartInfo(
nativeAppStart.isColdStart ? _AppStartType.cold : _AppStartType.warm,
start: appStartDateTime,
end: appStartEnd,
pluginRegistration: pluginRegistrationDateTime,
Expand All @@ -142,7 +142,7 @@ class NativeAppStartHandler {
}

Future<void> _attachAppStartSpans(
AppStartInfo appStartInfo, SentryTracer transaction) async {
_AppStartInfo appStartInfo, SentryTracer transaction) async {
final transactionTraceId = transaction.context.traceId;
final appStartEnd = appStartInfo.end;
if (appStartEnd == null) {
Expand Down Expand Up @@ -200,11 +200,11 @@ class NativeAppStartHandler {
}

Future<void> _attachNativeSpans(
AppStartInfo appStartInfo,
_AppStartInfo appStartInfo,
SentryTracer transaction,
SentrySpan parent,
) async {
await Future.forEach<TimeSpan>(appStartInfo.nativeSpanTimes,
await Future.forEach<_TimeSpan>(appStartInfo.nativeSpanTimes,
(timeSpan) async {
try {
final span = await _createAndFinishSpan(
Expand Down Expand Up @@ -250,10 +250,10 @@ class NativeAppStartHandler {
}
}

enum AppStartType { cold, warm }
enum _AppStartType { cold, warm }

class AppStartInfo {
AppStartInfo(
class _AppStartInfo {
_AppStartInfo(
this.type, {
required this.start,
required this.pluginRegistration,
Expand All @@ -262,9 +262,9 @@ class AppStartInfo {
this.end,
});

final AppStartType type;
final _AppStartType type;
final DateTime start;
final List<TimeSpan> nativeSpanTimes;
final List<_TimeSpan> nativeSpanTimes;

// We allow the end to be null, since it might be set at a later time
// with setAppStartEnd when autoAppStart is disabled
Expand All @@ -280,22 +280,22 @@ class AppStartInfo {
if (duration == null) {
return null;
}
return type == AppStartType.cold
return type == _AppStartType.cold
? SentryMeasurement.coldAppStart(duration)
: SentryMeasurement.warmAppStart(duration);
}

String get appStartTypeOperation => 'app.start.${type.name}';

String get appStartTypeDescription =>
type == AppStartType.cold ? 'Cold Start' : 'Warm Start';
type == _AppStartType.cold ? 'Cold Start' : 'Warm Start';
final pluginRegistrationDescription = 'App start to plugin registration';
final sentrySetupDescription = 'Before Sentry Init Setup';
final firstFrameRenderDescription = 'First frame render';
}

class TimeSpan {
TimeSpan({required this.start, required this.end, required this.description});
class _TimeSpan {
_TimeSpan({required this.start, required this.end, required this.description});

final DateTime start;
final DateTime end;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ class NativeAppStartIntegration extends Integration<SentryFlutterOptions> {
final FrameCallbackHandler _frameCallbackHandler;
final NativeAppStartHandler _nativeAppStartHandler;
DateTime? _appStartEnd;

/// This timestamp marks the end of app startup. Either set by calling
// ignore: deprecated_member_use_from_same_package
/// [SentryFlutter.setAppStartEnd]. The [SentryFlutterOptions.autoAppStart]
/// option needs to be false.
@internal
Expand Down
1 change: 1 addition & 0 deletions flutter/lib/src/sentry_flutter_options.dart
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ class SentryFlutterOptions extends SentryOptions {
/// Automatically track app start measurement and send it with the
/// first transaction. Set to false when configuring option to disable or if
/// you want to set the end time of app startup manually using
// ignore: deprecated_member_use_from_same_package
/// [SentryFlutter.setAppStartEnd].
bool autoAppStart = true;

Expand Down

0 comments on commit 6ae5a65

Please sign in to comment.