avoid sending analytics on ci systems (#3765)
* avoid sending analytics on ci systems * review comments
This commit is contained in:
parent
153e1bb918
commit
bd564a02af
@ -102,7 +102,7 @@ Future<Null> main(List<String> args) async {
|
|||||||
|
|
||||||
flutterUsage.sendException(error, chain);
|
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.
|
// If we're working on the tools themselves, just print the stack trace.
|
||||||
stderr.writeln('$error');
|
stderr.writeln('$error');
|
||||||
stderr.writeln(chain.terse.toString());
|
stderr.writeln(chain.terse.toString());
|
||||||
|
@ -8,6 +8,13 @@ import 'dart:io';
|
|||||||
import 'package:crypto/crypto.dart';
|
import 'package:crypto/crypto.dart';
|
||||||
import 'package:path/path.dart' as path;
|
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) {
|
String hex(List<int> bytes) {
|
||||||
StringBuffer result = new StringBuffer();
|
StringBuffer result = new StringBuffer();
|
||||||
for (int part in bytes)
|
for (int part in bytes)
|
||||||
|
@ -10,7 +10,7 @@ import '../base/process.dart';
|
|||||||
import '../dart/pub.dart';
|
import '../dart/pub.dart';
|
||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
import '../runner/flutter_command.dart';
|
import '../runner/flutter_command.dart';
|
||||||
import '../runner/version.dart';
|
import '../version.dart';
|
||||||
|
|
||||||
class UpgradeCommand extends FlutterCommand {
|
class UpgradeCommand extends FlutterCommand {
|
||||||
@override
|
@override
|
||||||
|
@ -12,7 +12,7 @@ import 'base/context.dart';
|
|||||||
import 'base/os.dart';
|
import 'base/os.dart';
|
||||||
import 'globals.dart';
|
import 'globals.dart';
|
||||||
import 'ios/ios_workflow.dart';
|
import 'ios/ios_workflow.dart';
|
||||||
import 'runner/version.dart';
|
import 'version.dart';
|
||||||
|
|
||||||
const Map<String, String> _osNames = const <String, String>{
|
const Map<String, String> _osNames = const <String, String>{
|
||||||
'macos': 'Mac OS',
|
'macos': 'Mac OS',
|
||||||
|
@ -18,7 +18,7 @@ import '../build_configuration.dart';
|
|||||||
import '../globals.dart';
|
import '../globals.dart';
|
||||||
import '../package_map.dart';
|
import '../package_map.dart';
|
||||||
import '../toolchain.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 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)
|
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 'package:usage/usage.dart';
|
||||||
|
|
||||||
import 'base/context.dart';
|
import 'base/context.dart';
|
||||||
|
import 'base/utils.dart';
|
||||||
import 'globals.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
|
// 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).
|
// correctly track usage by operating system (dart-lang/usage/issues/70).
|
||||||
@ -22,7 +23,19 @@ class Usage {
|
|||||||
Usage() {
|
Usage() {
|
||||||
String version = FlutterVersion.getVersionString(whitelistBranchName: true);
|
String version = FlutterVersion.getVersionString(whitelistBranchName: true);
|
||||||
_analytics = new AnalyticsIO(_kFlutterUA, 'flutter', version);
|
_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.
|
/// Returns [Usage] active in the current app context.
|
||||||
@ -82,10 +95,14 @@ class Usage {
|
|||||||
|
|
||||||
final String versionString = FlutterVersion.getVersionString(whitelistBranchName: true);
|
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('');
|
||||||
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 ║
|
║ 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: ║
|
║ order to help Google contribute improvements to Flutter over time. See Google's privacy policy: ║
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
import 'dart:io';
|
import 'dart:io';
|
||||||
|
|
||||||
import '../artifacts.dart';
|
import 'artifacts.dart';
|
||||||
import '../base/process.dart';
|
import 'base/process.dart';
|
||||||
|
|
||||||
final Set<String> kKnownBranchNames = new Set<String>.from(<String>[
|
final Set<String> kKnownBranchNames = new Set<String>.from(<String>[
|
||||||
'master',
|
'master',
|
||||||
@ -64,7 +64,7 @@ class FlutterVersion {
|
|||||||
return new FlutterVersion(flutterRoot != null ? flutterRoot : ArtifactStore.flutterRoot);
|
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 }) {
|
static String getVersionString({ bool whitelistBranchName: false }) {
|
||||||
final String cwd = ArtifactStore.flutterRoot;
|
final String cwd = ArtifactStore.flutterRoot;
|
||||||
|
|
||||||
@ -80,7 +80,7 @@ class FlutterVersion {
|
|||||||
branch = 'dev';
|
branch = 'dev';
|
||||||
}
|
}
|
||||||
|
|
||||||
return '$commit/$branch';
|
return '$branch/$commit';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,10 +1,8 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -ex
|
set -ex
|
||||||
|
|
||||||
# Download dependencies flutter
|
# disable analytics on the bots and download Flutter dependencies
|
||||||
./bin/flutter --version
|
|
||||||
|
|
||||||
# Disable analytics on the bots (to avoid skewing analytics data).
|
|
||||||
./bin/flutter config --no-analytics
|
./bin/flutter config --no-analytics
|
||||||
|
|
||||||
|
# run pub get in all the repo packages
|
||||||
./bin/flutter update-packages
|
./bin/flutter update-packages
|
||||||
|
Loading…
x
Reference in New Issue
Block a user