Unverified Commit 10d8758b authored by Christopher Fujino's avatar Christopher Fujino Committed by GitHub

add analytics fields for attached device os version & run mode (#34074)

Adds two new custom analytics dimensions: run_target_os_version and run_target_mode_name that are sent with each invocation of flutter run and show up in Google Analytics as "screens".
parent 8af16c8f
......@@ -208,9 +208,15 @@ class RunCommand extends RunCommandBase {
@override
Future<Map<String, String>> get usageValues async {
final bool isEmulator = await devices[0].isLocalEmulator;
final String deviceType = devices.length == 1
? getNameForTargetPlatform(await devices[0].targetPlatform)
: 'multiple';
String deviceType, deviceOsVersion;
if (devices.length == 1) {
deviceType = getNameForTargetPlatform(await devices[0].targetPlatform);
deviceOsVersion = await devices[0].sdkNameAndVersion;
} else {
deviceType = 'multiple';
deviceOsVersion = 'multiple';
}
final String modeName = getBuildInfo().modeName;
final AndroidProject androidProject = FlutterProject.current().android;
final IosProject iosProject = FlutterProject.current().ios;
final List<String> hostLanguage = <String>[];
......@@ -225,6 +231,8 @@ class RunCommand extends RunCommandBase {
return <String, String>{
kCommandRunIsEmulator: '$isEmulator',
kCommandRunTargetName: deviceType,
kCommandRunTargetOsVersion: deviceOsVersion,
kCommandRunModeName: modeName,
kCommandRunProjectModule: '${FlutterProject.current().isModule}',
kCommandRunProjectHostLanguage: hostLanguage.join(','),
};
......
......@@ -16,6 +16,10 @@ import 'globals.dart';
import 'version.dart';
const String _kFlutterUA = 'UA-67589403-6';
const String kSessionHostOsDetails = 'cd1';
const String kSessionChannelName = 'cd2';
const String kEventReloadReasonParameterName = 'cd5';
const String kEventReloadFinalLibraryCount = 'cd6';
const String kEventReloadSyncedLibraryCount = 'cd7';
......@@ -31,6 +35,8 @@ const String kCommandRunTargetName = 'cd4';
const String kCommandRunProjectType = 'cd14';
const String kCommandRunProjectHostLanguage = 'cd15';
const String kCommandRunProjectModule = 'cd18';
const String kCommandRunTargetOsVersion = 'cd22';
const String kCommandRunModeName = 'cd23';
const String kCommandCreateAndroidLanguage = 'cd16';
const String kCommandCreateIosLanguage = 'cd17';
......@@ -51,9 +57,9 @@ class Usage {
documentDirectory: configDirOverride != null ? fs.directory(configDirOverride) : null);
// Report a more detailed OS version string than package:usage does by default.
_analytics.setSessionValue('cd1', os.name);
_analytics.setSessionValue(kSessionHostOsDetails, os.name);
// Send the branch name as the "channel".
_analytics.setSessionValue('cd2', flutterVersion.getBranchName(redactUnknownBranches: true));
_analytics.setSessionValue(kSessionChannelName, flutterVersion.getBranchName(redactUnknownBranches: true));
// Record the host as the application installer ID - the context that flutter_tools is running in.
if (platform.environment.containsKey('FLUTTER_HOST')) {
_analytics.setSessionValue('aiid', platform.environment['FLUTTER_HOST']);
......
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