Commit 71383096 authored by Devon Carew's avatar Devon Carew

make the usage text more visible (#3693)

* make the usage text more visible

* update the look of the usage text
parent bf0f38c6
......@@ -6,7 +6,6 @@ import 'dart:async';
import 'dart:io';
import 'package:args/command_runner.dart';
import 'package:path/path.dart' as path;
import 'package:stack_trace/stack_trace.dart';
import 'src/base/context.dart';
......@@ -84,18 +83,8 @@ Future<Null> main(List<String> args) async {
context[DeviceManager] = new DeviceManager();
Doctor.initGlobal();
if (flutterUsage.isFirstRun) {
printStatus(
'The Flutter tool anonymously reports feature usage statistics and basic crash reports to Google to\n'
'help Google contribute improvements to Flutter over time. Use "flutter config" to control this\n'
'behavior. See Google\'s privacy policy: https://www.google.com/intl/en/policies/privacy/\n'
);
}
dynamic result = await runner.run(args);
if (result is int)
_exit(result);
_exit(result is int ? result : 0);
}, onError: (dynamic error, Chain chain) {
if (error is UsageException) {
stderr.writeln(error.message);
......@@ -126,7 +115,7 @@ Future<Null> main(List<String> args) async {
File file = _createCrashReport(args, error, chain);
stderr.writeln(
'Crash report written to ${path.relative(file.path)}; '
'Crash report written to ${file.path};\n'
'please let us know at https://github.com/flutter/flutter/issues.');
}
......@@ -173,6 +162,9 @@ String _doctorText() {
}
Future<Null> _exit(int code) async {
if (flutterUsage.isFirstRun)
flutterUsage.printUsage();
// Send any last analytics calls that are in progress without overly delaying
// the tool's exit (we wait a maximum of 250ms).
if (flutterUsage.enabled) {
......
......@@ -163,6 +163,9 @@ abstract class FlutterCommand extends Command {
// Populate the cache.
await cache.updateAll();
if (flutterUsage.isFirstRun)
flutterUsage.printUsage();
_setupToolchain();
_setupApplicationPackages();
......
......@@ -8,6 +8,7 @@ import 'package:usage/src/usage_impl_io.dart';
import 'package:usage/usage.dart';
import 'base/context.dart';
import 'globals.dart';
import 'runner/version.dart';
// TODO(devoncarew): We'll need to do some work on the user agent in order to
......@@ -29,6 +30,8 @@ class Usage {
Analytics _analytics;
bool _printedUsage = false;
bool get isFirstRun => _analytics.firstRun;
bool get enabled => _analytics.enabled;
......@@ -71,6 +74,27 @@ class Usage {
// out-of-process from flutter_tools?
return _analytics.waitForLastPing(timeout: new Duration(milliseconds: 250));
}
void printUsage() {
if (_printedUsage)
return;
_printedUsage = true;
final String versionString = FlutterVersion.getVersionString(whitelistBranchName: true);
printStatus('');
printStatus('''
╔════════════════════════════════════════════════════════════════════════════════════════════════════╗
║ Welcome to Flutter! - Flutter version $versionString - https://flutter.io ║
║ ║
║ The Flutter tool anonymously reports feature usage statistics and basic crash reports to Google in ║
║ order to help Google contribute improvements to Flutter over time. See Google's privacy policy:
https://www.google.com/intl/en/policies/privacy/ ║
Use "flutter config --no-analytics" to disable analytics reporting
╚════════════════════════════════════════════════════════════════════════════════════════════════════╝
''', emphasis: true);
}
}
class UsageTimer {
......
......@@ -143,6 +143,9 @@ class MockUsage implements Usage {
@override
Future<Null> ensureAnalyticsSent() => new Future<Null>.value();
@override
void printUsage() { }
}
class _MockUsageTimer implements UsageTimer {
......
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