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

Late initialization error for Analytics.userProperty #238

Closed
eliasyishak opened this issue Feb 27, 2024 · 2 comments
Closed

Late initialization error for Analytics.userProperty #238

eliasyishak opened this issue Feb 27, 2024 · 2 comments

Comments

@eliasyishak
Copy link
Contributor

Recently, when we added the error handling class to log errors we encounter within the package, we failed to consider the case when an error occurs on start up. Specifically, if the ~/.dart-tool/dart-flutter-telemetry-session.json was malformed and was not valid json, we would encounter an error on start up.

And once we encounter this json parsing error, we properly handle it with our try/catch blocks in lib/src/session.dart file. While handling this error, we attempt to send an event that indicates what happened during this error. This error occurs because we have logic that has been placed in the Session class's constructor body.

We should instead move the logic that exists within the Session class's constructor body into a separate method called Session.initialize and only call that once we have ensured that all the necessary fields for Analytics have been initialized already

@khanhnwin
Copy link

Invocation: 'dart tooling-daemon --machine'
Exception: 'LateInitializationError: Field 'userProperty' has not been initialized.'
Stack Trace:
#0      AnalyticsImpl.userProperty (package:unified_analytics/src/analytics.dart)
#1      AnalyticsImpl.send (package:unified_analytics/src/analytics.dart:613:21)
#2      ErrorHandler.log (package:unified_analytics/src/error_handler.dart:29:18)
#3      Session._refreshSessionData (package:unified_analytics/src/session.dart:102:21)
#4      new Session (package:unified_analytics/src/session.dart:37:27)
#5      new AnalyticsImpl (package:unified_analytics/src/analytics.dart:429:23)
#6      new Analytics (package:unified_analytics/src/analytics.dart:87:12)
#7      createUnifiedAnalytics (package:dartdev/src/unified_analytics.dart:23:10)
#8      DartdevRunner.runCommand (package:dartdev/dartdev.dart:165:27)
#9      CommandRunner.run.<anonymous closure> (package:args/command_runner.dart:122:25)
#10     new Future.sync (dart:async/future.dart:306:31)
#11     CommandRunner.run (package:args/command_runner.dart:122:14)
#12     runDartdev (package:dartdev/dartdev.dart:46:29)
#13     main (file:///Volumes/Work/s/w/ir/x/w/sdk/pkg/dartdev/bin/dartdev.dart:11:9)
#14     _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:293:33)
#15     _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:184:12)
[12:28:59 PM] [DartToolingDaemon] [Info] Process /Users/ldap/Library/flutter/bin/cache/dart-sdk/bin/dart terminated! 255, null
[12:28:59 PM] [DartToolingDaemon] [Info] DTD connection closed

@eliasyishak
Copy link
Contributor Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants