Ensure analytics are sent before disabling (#62094)
This commit is contained in:
parent
7877d46c8b
commit
523afbe58b
@ -113,9 +113,15 @@ class ConfigCommand extends FlutterCommand {
|
||||
|
||||
if (argResults.wasParsed('analytics')) {
|
||||
final bool value = boolArg('analytics');
|
||||
// We send the analytics event *before* toggling the flag intentionally
|
||||
// to be sure that opt-out events are sent correctly.
|
||||
// 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'}.');
|
||||
}
|
||||
|
@ -233,6 +233,9 @@ void main() {
|
||||
|
||||
expect(mockUsage.enabled, false);
|
||||
|
||||
// Verify that we flushed the analytics queue.
|
||||
verify(mockUsage.ensureAnalyticsSent());
|
||||
|
||||
// Verify that we only send the analytics disable event, and no other
|
||||
// info.
|
||||
verifyNever(mockUsage.sendCommand(
|
||||
|
Loading…
x
Reference in New Issue
Block a user