From 3476b966524ff313baf3e31d1818cde33d6fa37f Mon Sep 17 00:00:00 2001 From: Elias Yishak <42216813+eliasyishak@users.noreply.github.com> Date: Wed, 19 Apr 2023 10:00:20 -0400 Subject: [PATCH] Update helper message for `--suppress-analytics` (#124810) Fixes: https://github.com/flutter/flutter/issues/124808 --- packages/flutter_tools/lib/runner.dart | 16 ++++------- .../src/runner/flutter_command_runner.dart | 2 +- .../general.shard/runner/runner_test.dart | 28 ------------------- 3 files changed, 7 insertions(+), 39 deletions(-) diff --git a/packages/flutter_tools/lib/runner.dart b/packages/flutter_tools/lib/runner.dart index 7858632a0102..c95416f22a74 100644 --- a/packages/flutter_tools/lib/runner.dart +++ b/packages/flutter_tools/lib/runner.dart @@ -88,14 +88,6 @@ Future run( await globals.analytics.setTelemetry(value); } - // If the user has opted out of legacy analytics, we will continue - // to opt them out of unified analytics and inform them - if (!globals.flutterUsage.enabled && globals.analytics.telemetryEnabled) { - await globals.analytics.setTelemetry(false); - globals.logger.printStatus( - 'Please note that analytics reporting was already disabled, and will continue to be disabled.\n'); - } - await runner.run(args); // Triggering [runZoned]'s error callback does not necessarily mean that @@ -285,6 +277,11 @@ Future _exit(int code, {required ShutdownHooks shutdownHooks}) async { // Ensure that the consent message has been displayed for unified analytics if (globals.analytics.shouldShowMessage) { globals.logger.printStatus(globals.analytics.getConsentMessage); + if (!globals.flutterUsage.enabled) { + globals.printStatus( + 'Please note that analytics reporting was already disabled, ' + 'and will continue to be disabled.\n'); + } // Because the legacy analytics may have also sent a message, // the conditional below will print additional messaging informing @@ -296,8 +293,7 @@ Future _exit(int code, {required ShutdownHooks shutdownHooks}) async { 'the flutter tool is migrating to a new analytics system. ' 'Disabling analytics collection will disable both the legacy ' 'and new analytics collection systems. ' - 'You can disable analytics reporting by running either `flutter --disable-telemetry` ' - 'or `flutter config --no-analytics\n'); + 'You can disable analytics reporting by running `flutter --disable-telemetry`\n'); } // Invoking this will onboard the flutter tool onto diff --git a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart index a0f3454c8fa7..141220d18a67 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart @@ -77,7 +77,7 @@ class FlutterCommandRunner extends CommandRunner { help: 'Allow Flutter to check for updates when this command runs.'); argParser.addFlag('suppress-analytics', negatable: false, - help: 'Suppress analytics reporting when this command runs.'); + help: 'Suppress analytics reporting for the current CLI invocation.'); argParser.addFlag('disable-telemetry', negatable: false, help: 'Disable telemetry reporting when this command runs.'); diff --git a/packages/flutter_tools/test/general.shard/runner/runner_test.dart b/packages/flutter_tools/test/general.shard/runner/runner_test.dart index ff4bc7c37e10..9eff81619b23 100644 --- a/packages/flutter_tools/test/general.shard/runner/runner_test.dart +++ b/packages/flutter_tools/test/general.shard/runner/runner_test.dart @@ -346,34 +346,6 @@ void main() { ProcessManager: () => FakeProcessManager.any(), }, ); - - testUsingContext( - 'legacy analytics disabled will disable new analytics', - () async { - - io.setExitFunctionForTests((int exitCode) {}); - - await runner.run( - [], - () => [], - // This flutterVersion disables crash reporting. - flutterVersion: '[user-branch]/', - shutdownHooks: ShutdownHooks(), - ); - - expect(globals.flutterUsage.enabled, false); - expect(globals.analytics.telemetryEnabled, false); - expect(testLogger.statusText.contains( - 'Please note that analytics ' - 'reporting was already disabled'), true); - }, - overrides: { - Analytics: () => FakeAnalytics(), - FileSystem: () => MemoryFileSystem.test(), - ProcessManager: () => FakeProcessManager.any(), - Usage: () => legacyAnalytics, - }, - ); }); }