Unverified Commit cd3aec36 authored by Zachary Anderson's avatar Zachary Anderson Committed by GitHub

[flutter_tool] Report analytics as disabled when suppressed (#71728)

parent a12c22b2
...@@ -84,9 +84,11 @@ class ConfigCommand extends FlutterCommand { ...@@ -84,9 +84,11 @@ class ConfigCommand extends FlutterCommand {
if (values.isEmpty) { if (values.isEmpty) {
values = ' No settings have been configured.'; values = ' No settings have been configured.';
} }
final bool analyticsEnabled = globals.flutterUsage.enabled &&
!globals.flutterUsage.suppressAnalytics;
return return
'\nSettings:\n$values\n\n' '\nSettings:\n$values\n\n'
'Analytics reporting is currently ${globals.flutterUsage.enabled ? 'enabled' : 'disabled'}.'; 'Analytics reporting is currently ${analyticsEnabled ? 'enabled' : 'disabled'}.';
} }
/// Return null to disable analytics recording of the `config` command. /// Return null to disable analytics recording of the `config` command.
......
...@@ -288,6 +288,24 @@ void main() { ...@@ -288,6 +288,24 @@ void main() {
}, overrides: <Type, Generator>{ }, overrides: <Type, Generator>{
Usage: () => mockUsage, Usage: () => mockUsage,
}); });
testUsingContext('analytics reported disabled when suppressed', () async {
final ConfigCommand configCommand = ConfigCommand();
final CommandRunner<void> commandRunner = createTestCommandRunner(configCommand);
mockUsage.suppressAnalytics = true;
await commandRunner.run(<String>[
'config',
]);
expect(
testLogger.statusText,
containsIgnoringWhitespace('Analytics reporting is currently disabled'),
);
}, overrides: <Type, Generator>{
Usage: () => mockUsage,
});
}); });
} }
...@@ -306,4 +324,7 @@ class MockFlutterVersion extends Mock implements FlutterVersion {} ...@@ -306,4 +324,7 @@ class MockFlutterVersion extends Mock implements FlutterVersion {}
class MockUsage extends Mock implements Usage { class MockUsage extends Mock implements Usage {
@override @override
bool enabled = true; bool enabled = true;
@override
bool suppressAnalytics = false;
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment