flutter
flutter copied to clipboard
Edit command to disable/enable analytics in new unified analytics package
Use case
Once we start using the new unified analytics package for all dart and flutter related tooling, we will need to implement a cli command to disable or enable telemetry collection
Currently blocked until analytics package has been added to flutter tools
Is there any reason we can't use the existing one? Renaming this would break all scripts that automate opting out: https://github.com/christopherfujino/flutter/blob/flutter_tools_api/packages/flutter_tools/lib/src/commands/config.dart#L16
Oh I wasn't aware of this command, this issue will aim at refactoring it with the new package's disable telemetry method as well then
For my own reference, the block of code that needs to be edited when the new analytics package gets onboarded to flutter-tools
https://github.com/flutter/flutter/blob/master/packages/flutter_tools/lib/src/commands/config.dart#L129-L142
if (argResults?.wasParsed('analytics') ?? false) {
final bool value = boolArgDeprecated('analytics');
// 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 ${value ? 'enabled' : 'disabled'}.');
}
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 flutter doctor -v
and a minimal reproduction of the issue.