Skip to content

Commit 03d7256

Browse files
authored
Revert "Update helper message for --suppress-analytics" (#125141)
Reverts flutter/flutter#124810
1 parent 3476b96 commit 03d7256

3 files changed

Lines changed: 39 additions & 7 deletions

File tree

packages/flutter_tools/lib/runner.dart

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ Future<int> run(
8888
await globals.analytics.setTelemetry(value);
8989
}
9090

91+
// If the user has opted out of legacy analytics, we will continue
92+
// to opt them out of unified analytics and inform them
93+
if (!globals.flutterUsage.enabled && globals.analytics.telemetryEnabled) {
94+
await globals.analytics.setTelemetry(false);
95+
globals.logger.printStatus(
96+
'Please note that analytics reporting was already disabled, and will continue to be disabled.\n');
97+
}
98+
9199
await runner.run(args);
92100

93101
// Triggering [runZoned]'s error callback does not necessarily mean that
@@ -277,11 +285,6 @@ Future<int> _exit(int code, {required ShutdownHooks shutdownHooks}) async {
277285
// Ensure that the consent message has been displayed for unified analytics
278286
if (globals.analytics.shouldShowMessage) {
279287
globals.logger.printStatus(globals.analytics.getConsentMessage);
280-
if (!globals.flutterUsage.enabled) {
281-
globals.printStatus(
282-
'Please note that analytics reporting was already disabled, '
283-
'and will continue to be disabled.\n');
284-
}
285288

286289
// Because the legacy analytics may have also sent a message,
287290
// the conditional below will print additional messaging informing
@@ -293,7 +296,8 @@ Future<int> _exit(int code, {required ShutdownHooks shutdownHooks}) async {
293296
'the flutter tool is migrating to a new analytics system. '
294297
'Disabling analytics collection will disable both the legacy '
295298
'and new analytics collection systems. '
296-
'You can disable analytics reporting by running `flutter --disable-telemetry`\n');
299+
'You can disable analytics reporting by running either `flutter --disable-telemetry` '
300+
'or `flutter config --no-analytics\n');
297301
}
298302

299303
// Invoking this will onboard the flutter tool onto

packages/flutter_tools/lib/src/runner/flutter_command_runner.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ class FlutterCommandRunner extends CommandRunner<void> {
7777
help: 'Allow Flutter to check for updates when this command runs.');
7878
argParser.addFlag('suppress-analytics',
7979
negatable: false,
80-
help: 'Suppress analytics reporting for the current CLI invocation.');
80+
help: 'Suppress analytics reporting when this command runs.');
8181
argParser.addFlag('disable-telemetry',
8282
negatable: false,
8383
help: 'Disable telemetry reporting when this command runs.');

packages/flutter_tools/test/general.shard/runner/runner_test.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,34 @@ void main() {
346346
ProcessManager: () => FakeProcessManager.any(),
347347
},
348348
);
349+
350+
testUsingContext(
351+
'legacy analytics disabled will disable new analytics',
352+
() async {
353+
354+
io.setExitFunctionForTests((int exitCode) {});
355+
356+
await runner.run(
357+
<String>[],
358+
() => <FlutterCommand>[],
359+
// This flutterVersion disables crash reporting.
360+
flutterVersion: '[user-branch]/',
361+
shutdownHooks: ShutdownHooks(),
362+
);
363+
364+
expect(globals.flutterUsage.enabled, false);
365+
expect(globals.analytics.telemetryEnabled, false);
366+
expect(testLogger.statusText.contains(
367+
'Please note that analytics '
368+
'reporting was already disabled'), true);
369+
},
370+
overrides: <Type, Generator>{
371+
Analytics: () => FakeAnalytics(),
372+
FileSystem: () => MemoryFileSystem.test(),
373+
ProcessManager: () => FakeProcessManager.any(),
374+
Usage: () => legacyAnalytics,
375+
},
376+
);
349377
});
350378
}
351379

0 commit comments

Comments
 (0)