Commit bd564a02 authored by Devon Carew's avatar Devon Carew

avoid sending analytics on ci systems (#3765)

* avoid sending analytics on ci systems

* review comments
parent 153e1bb9
......@@ -102,7 +102,7 @@ Future<Null> main(List<String> args) async {
flutterUsage.sendException(error, chain);
if (Platform.environment.containsKey('FLUTTER_DEV')) {
if (Platform.environment.containsKey('FLUTTER_DEV') || isRunningOnBot) {
// If we're working on the tools themselves, just print the stack trace.
stderr.writeln('$error');
stderr.writeln(chain.terse.toString());
......
......@@ -8,6 +8,13 @@ import 'dart:io';
import 'package:crypto/crypto.dart';
import 'package:path/path.dart' as path;
bool get isRunningOnBot {
// https://docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
return
Platform.environment['TRAVIS'] == 'true' ||
Platform.environment['CONTINUOUS_INTEGRATION'] == 'true';
}
String hex(List<int> bytes) {
StringBuffer result = new StringBuffer();
for (int part in bytes)
......
......@@ -10,7 +10,7 @@ import '../base/process.dart';
import '../dart/pub.dart';
import '../globals.dart';
import '../runner/flutter_command.dart';
import '../runner/version.dart';
import '../version.dart';
class UpgradeCommand extends FlutterCommand {
@override
......
......@@ -12,7 +12,7 @@ import 'base/context.dart';
import 'base/os.dart';
import 'globals.dart';
import 'ios/ios_workflow.dart';
import 'runner/version.dart';
import 'version.dart';
const Map<String, String> _osNames = const <String, String>{
'macos': 'Mac OS',
......
......@@ -18,7 +18,7 @@ import '../build_configuration.dart';
import '../globals.dart';
import '../package_map.dart';
import '../toolchain.dart';
import 'version.dart';
import '../version.dart';
const String kFlutterRootEnvironmentVariableName = 'FLUTTER_ROOT'; // should point to //flutter/ (root of flutter/flutter repo)
const String kFlutterEngineEnvironmentVariableName = 'FLUTTER_ENGINE'; // should point to //engine/src/ (root of flutter/engine repo)
......
......@@ -8,8 +8,9 @@ import 'package:usage/src/usage_impl_io.dart';
import 'package:usage/usage.dart';
import 'base/context.dart';
import 'base/utils.dart';
import 'globals.dart';
import 'runner/version.dart';
import 'version.dart';
// TODO(devoncarew): We'll need to do some work on the user agent in order to
// correctly track usage by operating system (dart-lang/usage/issues/70).
......@@ -22,7 +23,19 @@ class Usage {
Usage() {
String version = FlutterVersion.getVersionString(whitelistBranchName: true);
_analytics = new AnalyticsIO(_kFlutterUA, 'flutter', version);
_analytics.analyticsOpt = AnalyticsOpt.optOut;
bool runningOnCI = false;
// Many CI systems don't do a full git checkout.
if (version.startsWith('unknown/'))
runningOnCI = true;
// Check for common CI systems.
if (isRunningOnBot)
runningOnCI = true;
// If we think we're running on a CI system, default to not sending analytics.
_analytics.analyticsOpt = runningOnCI ? AnalyticsOpt.optIn : AnalyticsOpt.optOut;
}
/// Returns [Usage] active in the current app context.
......@@ -82,10 +95,14 @@ class Usage {
final String versionString = FlutterVersion.getVersionString(whitelistBranchName: true);
String welcomeString = 'Welcome to Flutter! - Flutter version $versionString - https://flutter.io';
welcomeString = welcomeString.padLeft((welcomeString.length + 100) ~/ 2);
welcomeString = welcomeString.padRight(100);
printStatus('');
printStatus('''
╔════════════════════════════════════════════════════════════════════════════════════════════════════╗
Welcome to Flutter! - Flutter version $versionString - https://flutter.io
$welcomeString
║ ║
║ 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:
......
......@@ -4,8 +4,8 @@
import 'dart:io';
import '../artifacts.dart';
import '../base/process.dart';
import 'artifacts.dart';
import 'base/process.dart';
final Set<String> kKnownBranchNames = new Set<String>.from(<String>[
'master',
......@@ -64,7 +64,7 @@ class FlutterVersion {
return new FlutterVersion(flutterRoot != null ? flutterRoot : ArtifactStore.flutterRoot);
}
/// Return a short string for the version (`a76bc8e22b/alpha`).
/// Return a short string for the version (`alpha/a76bc8e22b`).
static String getVersionString({ bool whitelistBranchName: false }) {
final String cwd = ArtifactStore.flutterRoot;
......@@ -80,7 +80,7 @@ class FlutterVersion {
branch = 'dev';
}
return '$commit/$branch';
return '$branch/$commit';
}
}
......
#!/bin/bash
set -ex
# Download dependencies flutter
./bin/flutter --version
# Disable analytics on the bots (to avoid skewing analytics data).
# disable analytics on the bots and download Flutter dependencies
./bin/flutter config --no-analytics
# run pub get in all the repo packages
./bin/flutter update-packages
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