flutter icon indicating copy to clipboard operation
flutter copied to clipboard

Edit command to disable/enable analytics in new unified analytics package

Open eliasyishak opened this issue 1 year ago • 4 comments

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

eliasyishak avatar Feb 28 '23 18:02 eliasyishak

Currently blocked until analytics package has been added to flutter tools

eliasyishak avatar Feb 28 '23 18:02 eliasyishak

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

christopherfujino avatar Feb 28 '23 20:02 christopherfujino

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

eliasyishak avatar Feb 28 '23 21:02 eliasyishak

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'}.');
    }

eliasyishak avatar Mar 01 '23 16:03 eliasyishak

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.

github-actions[bot] avatar Apr 19 '23 19:04 github-actions[bot]