send channel name as a custom dimension (#10814)

* send channel name as a custom dimension

* tweaks from review

* remove unused import
This commit is contained in:
Seth Ladd 2017-06-20 08:20:57 -07:00 committed by GitHub
parent c14470e0c7
commit b471a9cffc
2 changed files with 13 additions and 2 deletions

View File

@ -26,8 +26,9 @@ class Usage {
_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).
// default. Also, send the branch name as the "channel".
_analytics.setSessionValue('dimension1', os.name);
_analytics.setSessionValue('dimension2', FlutterVersion.getBranchName(whitelistBranchName: true));
bool runningOnCI = false;

View File

@ -149,6 +149,16 @@ class FlutterVersion {
String commit = _shortGitRevision(_runSync(<String>['git', 'rev-parse', 'HEAD']));
commit = commit.isEmpty ? 'unknown' : commit;
final String branch = getBranchName(whitelistBranchName: whitelistBranchName);
return '$branch/$commit';
}
/// Return the branch name.
///
/// If whitelistBranchName is true and the branch is unknown,
/// the branch name will be returned as 'dev'.
static String getBranchName({ bool whitelistBranchName: false }) {
String branch = _runSync(<String>['git', 'rev-parse', '--abbrev-ref', 'HEAD']);
branch = branch == 'HEAD' ? 'master' : branch;
@ -158,7 +168,7 @@ class FlutterVersion {
branch = 'dev';
}
return '$branch/$commit';
return branch;
}
/// The amount of time we wait before pinging the server to check for the