-
Notifications
You must be signed in to change notification settings - Fork 28.6k
Ensure all events sent via package:unified_analytics are received #136926
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
Comments
FYI @eliasyishak & @andrewkolos |
Actually, what would be easier than wrapping, is to just have |
Related to what I said in this comment, whatever we decide on for sending events, I don't think we can reliably check BigQuery exports to confirm our approach is working. I am exploring now how it would look if we kept the futures for each send internal to package:unified_analytics now |
Captured the issue in the |
Looping back on this issue, we made progress on this by implementing an internal futures list within the There was also additional functionality added to the existing PR below is where these updates were made: |
Closing since I believe we addressed this in dart-lang/tools#184, feel free to reopen if needed |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
From the discussion in #136647 (comment), since the public API to send analytics from package:unified_analytics returns a
Future<http.Response>
(https://github.com/dart-lang/tools/blob/92c5c15e3eb713b39779f4545bfa207ccdfeb1af/pkgs/unified_analytics/lib/src/analytics.dart#L562), callers need to decide to either:unawaited()
functionWith option 1, however, this would mean that future tool work may not happen until AFTER the HTTP request has finished. And with option 2, if the dart isolate finishes its other work, it appears to exit, cancelling the HTTP request to the analytics server.
With the existing GA3 implementation, before exiting the tool we call
globals.flutterUsage.ensureAnalyticsSent();
https://github.com/flutter/flutter/blob/main/packages/flutter_tools/lib/src/base/process.dart#L617 which ends up calling thewaitForLastPing()
method in package:usage: https://github.com/dart-lang/usage/blob/master/lib/src/usage_impl.dart#L224. package:usage maintains its own list of futures (https://github.com/dart-lang/usage/blob/master/lib/src/usage_impl.dart#L77) thatwaitForLastPing()
will ensure are completed (although we provide that method with a 250ms timeout to avoid extended delays of the tool exiting).I believe the simplest solution for the flutter tool would be to create a global class that wraps all calls to package:unified_analytics' .send() method, and collects the futures. Then we can await all these futures at the same place we do for GA3 events (https://github.com/flutter/flutter/blob/main/packages/flutter_tools/lib/src/base/process.dart#L617), with a 250ms timeout.
The text was updated successfully, but these errors were encountered: