Skip to content

Commit

Permalink
Revert "Update helper message for --suppress-analytics" (#125141)
Browse files Browse the repository at this point in the history
  • Loading branch information
godofredoc authored Apr 19, 2023
1 parent 3476b96 commit 03d7256
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
16 changes: 10 additions & 6 deletions packages/flutter_tools/lib/runner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ Future<int> 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
Expand Down Expand Up @@ -277,11 +285,6 @@ Future<int> _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
Expand All @@ -293,7 +296,8 @@ Future<int> _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 `flutter --disable-telemetry`\n');
'You can disable analytics reporting by running either `flutter --disable-telemetry` '
'or `flutter config --no-analytics\n');
}

// Invoking this will onboard the flutter tool onto
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class FlutterCommandRunner extends CommandRunner<void> {
help: 'Allow Flutter to check for updates when this command runs.');
argParser.addFlag('suppress-analytics',
negatable: false,
help: 'Suppress analytics reporting for the current CLI invocation.');
help: 'Suppress analytics reporting when this command runs.');
argParser.addFlag('disable-telemetry',
negatable: false,
help: 'Disable telemetry reporting when this command runs.');
Expand Down
28 changes: 28 additions & 0 deletions packages/flutter_tools/test/general.shard/runner/runner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,34 @@ void main() {
ProcessManager: () => FakeProcessManager.any(),
},
);

testUsingContext(
'legacy analytics disabled will disable new analytics',
() async {

io.setExitFunctionForTests((int exitCode) {});

await runner.run(
<String>[],
() => <FlutterCommand>[],
// 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: <Type, Generator>{
Analytics: () => FakeAnalytics(),
FileSystem: () => MemoryFileSystem.test(),
ProcessManager: () => FakeProcessManager.any(),
Usage: () => legacyAnalytics,
},
);
});
}

Expand Down

0 comments on commit 03d7256

Please sign in to comment.