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'; ...@@ -6,7 +6,6 @@ import 'dart:async';
import 'dart:io'; import 'dart:io';
import 'package:args/command_runner.dart'; import 'package:args/command_runner.dart';
import 'package:path/path.dart' as path;
import 'package:stack_trace/stack_trace.dart'; import 'package:stack_trace/stack_trace.dart';
import 'src/base/context.dart'; import 'src/base/context.dart';
...@@ -84,18 +83,8 @@ Future<Null> main(List<String> args) async { ...@@ -84,18 +83,8 @@ Future<Null> main(List<String> args) async {
context[DeviceManager] = new DeviceManager(); context[DeviceManager] = new DeviceManager();
Doctor.initGlobal(); 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); dynamic result = await runner.run(args);
_exit(result is int ? result : 0);
if (result is int)
_exit(result);
}, onError: (dynamic error, Chain chain) { }, onError: (dynamic error, Chain chain) {
if (error is UsageException) { if (error is UsageException) {
stderr.writeln(error.message); stderr.writeln(error.message);
...@@ -126,7 +115,7 @@ Future<Null> main(List<String> args) async { ...@@ -126,7 +115,7 @@ Future<Null> main(List<String> args) async {
File file = _createCrashReport(args, error, chain); File file = _createCrashReport(args, error, chain);
stderr.writeln( 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.'); 'please let us know at https://github.com/flutter/flutter/issues.');
} }
...@@ -173,6 +162,9 @@ String _doctorText() { ...@@ -173,6 +162,9 @@ String _doctorText() {
} }
Future<Null> _exit(int code) async { Future<Null> _exit(int code) async {
if (flutterUsage.isFirstRun)
flutterUsage.printUsage();
// Send any last analytics calls that are in progress without overly delaying // Send any last analytics calls that are in progress without overly delaying
// the tool's exit (we wait a maximum of 250ms). // the tool's exit (we wait a maximum of 250ms).
if (flutterUsage.enabled) { if (flutterUsage.enabled) {
......
...@@ -163,6 +163,9 @@ abstract class FlutterCommand extends Command { ...@@ -163,6 +163,9 @@ abstract class FlutterCommand extends Command {
// Populate the cache. // Populate the cache.
await cache.updateAll(); await cache.updateAll();
if (flutterUsage.isFirstRun)
flutterUsage.printUsage();
_setupToolchain(); _setupToolchain();
_setupApplicationPackages(); _setupApplicationPackages();
......
...@@ -8,6 +8,7 @@ import 'package:usage/src/usage_impl_io.dart'; ...@@ -8,6 +8,7 @@ import 'package:usage/src/usage_impl_io.dart';
import 'package:usage/usage.dart'; import 'package:usage/usage.dart';
import 'base/context.dart'; import 'base/context.dart';
import 'globals.dart';
import 'runner/version.dart'; import 'runner/version.dart';
// TODO(devoncarew): We'll need to do some work on the user agent in order to // TODO(devoncarew): We'll need to do some work on the user agent in order to
...@@ -29,6 +30,8 @@ class Usage { ...@@ -29,6 +30,8 @@ class Usage {
Analytics _analytics; Analytics _analytics;
bool _printedUsage = false;
bool get isFirstRun => _analytics.firstRun; bool get isFirstRun => _analytics.firstRun;
bool get enabled => _analytics.enabled; bool get enabled => _analytics.enabled;
...@@ -71,6 +74,27 @@ class Usage { ...@@ -71,6 +74,27 @@ class Usage {
// out-of-process from flutter_tools? // out-of-process from flutter_tools?
return _analytics.waitForLastPing(timeout: new Duration(milliseconds: 250)); 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 { class UsageTimer {
......
...@@ -143,6 +143,9 @@ class MockUsage implements Usage { ...@@ -143,6 +143,9 @@ class MockUsage implements Usage {
@override @override
Future<Null> ensureAnalyticsSent() => new Future<Null>.value(); Future<Null> ensureAnalyticsSent() => new Future<Null>.value();
@override
void printUsage() { }
} }
class _MockUsageTimer implements UsageTimer { 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