Skip to content

Commit

Permalink
Refactoring to remove late variables and cyclic dependencies (#247)
Browse files Browse the repository at this point in the history
* Cleaned up `config_handler.dart`

* Cleaned up `log_handler.dart`

* Cleaned up `session.dart`

* Clean up `survey_handler.dart`

* Confighandler no longer late variable

* Remove `Initializer` dependency from `ConfigHandler`

* Remove `late` variable for `_clientId`

* Consolidate `Session` into `UserProperty`

* Sort members + swap error messages for tests

* `dart format .`

* Fix tests + note a TODO for `package:file`

* `..run()`

* Remove `UserProperty.initialize` method

* Remove `ErrorHandler` + no late for userprop and loghandler

* Fix test

* Make userprop variable private

* Move configHandler to constructor initializer

* Remove unnecessary parameters for log handler

* Add'l documentation

* Remove unused params for survey handler

* Changelog update + dartdocs

* Bump version to `6.0.0`

* Remove `Initializer` abstraction, sub for functions

* Fix test for session file modified timestamp

* Remove `sessionIdOverride` for session initializer

* Clean up CHANGELOG

* Fix failing test

* Format fix
  • Loading branch information
eliasyishak authored Mar 25, 2024
1 parent f611290 commit 5e26782
Show file tree
Hide file tree
Showing 17 changed files with 475 additions and 500 deletions.
9 changes: 8 additions & 1 deletion pkgs/unified_analytics/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## 6.0.0-wip

- Consolidate `Session` functionality into `UserProperty` to prevent race condition crash where session logic crashed before initializing `UserProperty`
- Get rid of `late` variables throughout implementation class, `AnalyticsImpl`
- Any error events (`Event.analyticsException`) encountered within package will be sent when invoking `Analytics.close`; replacing `ErrorHandler` functionality
- Exposing new method for `FakeAnalytics.sendPendingErrorEvents` to send error events on command

## 5.8.8

- [Bug fix](https://github.com/dart-lang/tools/issues/252) rewrite the other call site for the session file
Expand All @@ -8,7 +15,7 @@

## 5.8.6

- Refactored session handler class to use the last modified timestamp as the last ping value
- Refactored session handler class to use the last modified timestamp as the last ping value to prevent writing to file with each send
- Bumping intl package to 0.19.0 to fix version solving issue with flutter_tools

## 5.8.5
Expand Down
8 changes: 6 additions & 2 deletions pkgs/unified_analytics/example/serving_surveys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import 'package:clock/clock.dart';
import 'package:file/file.dart';
import 'package:file/memory.dart';
import 'package:path/path.dart' as p;

import 'package:unified_analytics/src/constants.dart';
import 'package:unified_analytics/src/enums.dart';
Expand Down Expand Up @@ -57,8 +58,11 @@ void main() async {
fs: fs,
platform: DevicePlatform.macos,
surveyHandler: FakeSurveyHandler.fromList(
homeDirectory: home,
fs: fs,
dismissedSurveyFile: fs.file(p.join(
home.path,
kDartToolDirectoryName,
kDismissedSurveyFileName,
)),
initializedSurveys: [
Survey(
uniqueId: 'uniqueId',
Expand Down
Loading

0 comments on commit 5e26782

Please sign in to comment.