-
Notifications
You must be signed in to change notification settings - Fork 27.7k
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
Add analytics package + setTelemetry method attached #124015
Add analytics package + setTelemetry method attached #124015
Conversation
// Disable analytics if user passes in the `--disable-telemetry` option | ||
// `flutter --disable-telemetry` | ||
// | ||
// Same functionality as `flutter config --no-analytics` for disabling | ||
// except with the `value` hard coded as false | ||
if (args.contains('--disable-telemetry')) { | ||
const bool value = false; | ||
// The tool sends the analytics event *before* toggling the flag | ||
// intentionally to be sure that opt-out events are sent correctly. | ||
AnalyticsConfigEvent(enabled: value).send(); | ||
if (!value) { | ||
// Normally, the tool waits for the analytics to all send before the | ||
// tool exits, but only when analytics are enabled. When reporting that | ||
// analytics have been disable, the wait must be done here instead. | ||
await globals.flutterUsage.ensureAnalyticsSent(); | ||
} | ||
globals.flutterUsage.enabled = value; | ||
globals.printStatus('Analytics reporting disabled.'); | ||
|
||
// TODO(eliasyishak): Set the telemetry for the unified_analytics | ||
// package as well, the above will be removed once we have | ||
// fully transitioned to using the new package | ||
await globals.analytics.setTelemetry(value); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code snippet has been taken from the command flutter config --[no-]analytics
. In the config command case, the flag can have a value of true
or false
so that the user can enable collection if they wanted.
With this flag --disable-telemetry
, we are using the same logic except the value is being hard coded to false
. PDD is only requiring us to have the disable option for now
packages/flutter_tools/test/general.shard/unified_analytics_test.dart
Outdated
Show resolved
Hide resolved
packages/flutter_tools/test/general.shard/runner/runner_test.dart
Outdated
Show resolved
Hide resolved
'runner disable telemetry with flag', | ||
() async { | ||
io.setExitFunctionForTests((int exitCode) {}); | ||
fileSystem = MemoryFileSystem.test(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this be set before the test runs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but the setup in this file was only for the other tests which expected errors. There was no global setup being run under main
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, the rest of this test never references fileSystem
, so you can just instantiate it in the anonymous closure on line 338 (which will be 337 after you delete this line)
bool get shouldShowMessage { | ||
final bool result = _fakeShowMessage; | ||
if (result) { | ||
_fakeShowMessage = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we be setting this to false when clientShowedMessage
is called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah good call, fixing now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm
Merge master
Submitting with Google Testing pending LGTM. There's an internal bug where the GitHub status is being incorrectly overridden by a cron job. |
The first of many PRs for transitioning to `package:unified_analytics`. This PR is only focused on disabling and enabling telemetry via the `flutter config --[no-]analytics` flag Fixes: flutter#121617 ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. <!-- Links --> [Contributor Guide]: https://github.com/flutter/flutter/wiki/Tree-hygiene#overview [Tree Hygiene]: https://github.com/flutter/flutter/wiki/Tree-hygiene [test-exempt]: https://github.com/flutter/flutter/wiki/Tree-hygiene#tests [Flutter Style Guide]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo [Features we expect every widget to implement]: https://github.com/flutter/flutter/wiki/Style-guide-for-Flutter-repo#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/wiki/Tree-hygiene#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/wiki/Chat --------- Co-authored-by: Christopher Fujino <fujino@google.com> Co-authored-by: Christopher Fujino <christopherfujino@gmail.com>
The first of many PRs for transitioning to
package:unified_analytics
. This PR is only focused on disabling and enabling telemetry via theflutter config --[no-]analytics
flagFixes: #121617
Pre-launch Checklist
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.