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