Skip to content

Commit

Permalink
Fallback to current datetime when failing on parse session json file (#…
Browse files Browse the repository at this point in the history
…235)

* Fallback to current datetime when failing on parse

* Include issue in changelog
  • Loading branch information
eliasyishak authored Feb 21, 2024
1 parent 9f4e6a4 commit c7fbf26
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 4 additions & 0 deletions pkgs/unified_analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 5.8.3

- [Fix bug](https://github.com/flutter/flutter/issues/143792) when parsing session json file

## 5.8.2

- Added new event `Event.analyticsException` to track internal errors for this package
Expand Down
2 changes: 1 addition & 1 deletion pkgs/unified_analytics/lib/src/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ const int kLogFileLength = 2500;
const String kLogFileName = 'dart-flutter-telemetry.log';

/// The current version of the package, should be in line with pubspec version.
const String kPackageVersion = '5.8.2';
const String kPackageVersion = '5.8.3';

/// The minimum length for a session.
const int kSessionDurationMinutes = 30;
Expand Down
10 changes: 8 additions & 2 deletions pkgs/unified_analytics/lib/src/session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,10 @@ class Session {
description: 'message: ${err.message}\nsource: ${err.source}',
));

parseContents();
// Fallback to setting the session id as the current time
final now = clock.now();
_sessionId = now.millisecondsSinceEpoch;
_lastPing = now.millisecondsSinceEpoch;
} on FileSystemException catch (err) {
Initializer.createSessionFile(sessionFile: sessionFile);

Expand All @@ -115,7 +118,10 @@ class Session {
description: err.osError?.toString(),
));

parseContents();
// Fallback to setting the session id as the current time
final now = clock.now();
_sessionId = now.millisecondsSinceEpoch;
_lastPing = now.millisecondsSinceEpoch;
}
}
}
2 changes: 1 addition & 1 deletion pkgs/unified_analytics/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ description: >-
to Google Analytics.
# When updating this, keep the version consistent with the changelog and the
# value in lib/src/constants.dart.
version: 5.8.2
version: 5.8.3
repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics

environment:
Expand Down

0 comments on commit c7fbf26

Please sign in to comment.