Commit 3f4cb1fe authored by Michael Goderbauer's avatar Michael Goderbauer Committed by GitHub

Report detailed OS version string to analytics (#8934)

parent 1bae8a03
...@@ -47,6 +47,19 @@ abstract class OperatingSystemUtils { ...@@ -47,6 +47,19 @@ abstract class OperatingSystemUtils {
void unzip(File file, Directory targetDirectory); void unzip(File file, Directory targetDirectory);
/// Returns a pretty name string for the current operating system.
///
/// If available, the detailed version of the OS is included.
String get name {
const Map<String, String> osNames = const <String, String>{
'macos': 'Mac OS',
'linux': 'Linux',
'windows': 'Windows'
};
final String osName = platform.operatingSystem;
return osNames.containsKey(osName) ? osNames[osName] : osName;
}
List<File> _which(String execName, {bool all: false}); List<File> _which(String execName, {bool all: false});
} }
...@@ -86,6 +99,28 @@ class _PosixUtils extends OperatingSystemUtils { ...@@ -86,6 +99,28 @@ class _PosixUtils extends OperatingSystemUtils {
runSync(<String>['mkfifo', path]); runSync(<String>['mkfifo', path]);
return fs.file(path); return fs.file(path);
} }
String _name;
@override
String get name {
if (_name == null) {
if (platform.isMacOS) {
final List<ProcessResult> results = <ProcessResult>[
processManager.runSync(<String>["sw_vers", "-productName"]),
processManager.runSync(<String>["sw_vers", "-productVersion"]),
processManager.runSync(<String>["sw_vers", "-buildVersion"]),
];
if (results.every((ProcessResult result) => result.exitCode == 0)) {
_name = "${results[0].stdout.trim()} ${results[1].stdout
.trim()} ${results[2].stdout.trim()}";
}
}
if (_name == null)
_name = super.name;
}
return _name;
}
} }
class _WindowsUtils extends OperatingSystemUtils { class _WindowsUtils extends OperatingSystemUtils {
...@@ -144,6 +179,21 @@ class _WindowsUtils extends OperatingSystemUtils { ...@@ -144,6 +179,21 @@ class _WindowsUtils extends OperatingSystemUtils {
File makePipe(String path) { File makePipe(String path) {
throw new UnsupportedError('makePipe is not implemented on Windows.'); throw new UnsupportedError('makePipe is not implemented on Windows.');
} }
String _name;
@override
String get name {
if (_name == null) {
final ProcessResult result = processManager.runSync(
<String>['ver'], runInShell: true);
if (result.exitCode == 0)
_name = result.stdout.trim();
else
_name = super.name;
}
return _name;
}
} }
/// Find and return the project root directory relative to the specified /// Find and return the project root directory relative to the specified
......
...@@ -13,7 +13,7 @@ import 'artifacts.dart'; ...@@ -13,7 +13,7 @@ import 'artifacts.dart';
import 'base/common.dart'; import 'base/common.dart';
import 'base/context.dart'; import 'base/context.dart';
import 'base/file_system.dart'; import 'base/file_system.dart';
import 'base/io.dart'; import 'base/os.dart';
import 'base/platform.dart'; import 'base/platform.dart';
import 'base/process_manager.dart'; import 'base/process_manager.dart';
import 'cache.dart'; import 'cache.dart';
...@@ -25,30 +25,6 @@ import 'version.dart'; ...@@ -25,30 +25,6 @@ import 'version.dart';
Doctor get doctor => context[Doctor]; Doctor get doctor => context[Doctor];
const Map<String, String> _osNames = const <String, String>{
'macos': 'Mac OS',
'linux': 'Linux',
'windows': 'Windows'
};
String osName() {
if (platform.isWindows) {
final ProcessResult result = processManager.runSync(<String>['ver'], runInShell: true);
if (result.exitCode == 0)
return result.stdout.trim();
} else if (platform.isMacOS) {
final List<ProcessResult> results = <ProcessResult>[
processManager.runSync(<String>["sw_vers", "-productName"]),
processManager.runSync(<String>["sw_vers", "-productVersion"]),
processManager.runSync(<String>["sw_vers", "-buildVersion"]),
];
if (results.every((ProcessResult result) => result.exitCode == 0))
return "${results[0].stdout.trim()} ${results[1].stdout.trim()} ${results[2].stdout.trim()}";
}
final String os = platform.operatingSystem;
return _osNames.containsKey(os) ? _osNames[os] : os;
}
class Doctor { class Doctor {
Doctor() { Doctor() {
_androidWorkflow = new AndroidWorkflow(); _androidWorkflow = new AndroidWorkflow();
...@@ -242,7 +218,7 @@ class _FlutterValidator extends DoctorValidator { ...@@ -242,7 +218,7 @@ class _FlutterValidator extends DoctorValidator {
messages.add(new ValidationMessage('Tools Dart version ${version.dartSdkVersion}')); messages.add(new ValidationMessage('Tools Dart version ${version.dartSdkVersion}'));
return new ValidationResult(valid, messages, return new ValidationResult(valid, messages,
statusInfo: 'on ${osName()}, channel ${version.channel}'); statusInfo: 'on ${os.name}, channel ${version.channel}');
} }
} }
......
...@@ -7,6 +7,7 @@ import 'dart:async'; ...@@ -7,6 +7,7 @@ import 'dart:async';
import 'package:usage/usage_io.dart'; import 'package:usage/usage_io.dart';
import 'base/context.dart'; import 'base/context.dart';
import 'base/os.dart';
import 'base/utils.dart'; import 'base/utils.dart';
import 'globals.dart'; import 'globals.dart';
import 'version.dart'; import 'version.dart';
...@@ -23,6 +24,10 @@ class Usage { ...@@ -23,6 +24,10 @@ class Usage {
final String version = versionOverride ?? FlutterVersion.getVersionString(whitelistBranchName: true); final String version = versionOverride ?? FlutterVersion.getVersionString(whitelistBranchName: true);
_analytics = new AnalyticsIO(_kFlutterUA, settingsName, version); _analytics = new AnalyticsIO(_kFlutterUA, settingsName, version);
// Report a more detailed OS version string than package:usage does by
// default as custom dimension 1 (configured in our analytics account).
_analytics.setSessionValue('dimension1', os.name);
bool runningOnCI = false; bool runningOnCI = false;
// Many CI systems don't do a full git checkout. // Many CI systems don't do a full git checkout.
......
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