Skip to content

Commit c7fbf26

Browse files
authored
Fallback to current datetime when failing on parse session json file (#235)
* Fallback to current datetime when failing on parse * Include issue in changelog
1 parent 9f4e6a4 commit c7fbf26

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

pkgs/unified_analytics/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 5.8.3
2+
3+
- [Fix bug](https://github.com/flutter/flutter/issues/143792) when parsing session json file
4+
15
## 5.8.2
26

37
- Added new event `Event.analyticsException` to track internal errors for this package

pkgs/unified_analytics/lib/src/constants.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ const int kLogFileLength = 2500;
8282
const String kLogFileName = 'dart-flutter-telemetry.log';
8383

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

8787
/// The minimum length for a session.
8888
const int kSessionDurationMinutes = 30;

pkgs/unified_analytics/lib/src/session.dart

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@ class Session {
105105
description: 'message: ${err.message}\nsource: ${err.source}',
106106
));
107107

108-
parseContents();
108+
// Fallback to setting the session id as the current time
109+
final now = clock.now();
110+
_sessionId = now.millisecondsSinceEpoch;
111+
_lastPing = now.millisecondsSinceEpoch;
109112
} on FileSystemException catch (err) {
110113
Initializer.createSessionFile(sessionFile: sessionFile);
111114

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

118-
parseContents();
121+
// Fallback to setting the session id as the current time
122+
final now = clock.now();
123+
_sessionId = now.millisecondsSinceEpoch;
124+
_lastPing = now.millisecondsSinceEpoch;
119125
}
120126
}
121127
}

pkgs/unified_analytics/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ description: >-
44
to Google Analytics.
55
# When updating this, keep the version consistent with the changelog and the
66
# value in lib/src/constants.dart.
7-
version: 5.8.2
7+
version: 5.8.3
88
repository: https://github.com/dart-lang/tools/tree/main/pkgs/unified_analytics
99

1010
environment:

0 commit comments

Comments
 (0)