Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback to current datetime when failing on parse session json file #235

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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