Commit b471a9cf authored by Seth Ladd's avatar Seth Ladd Committed by GitHub

send channel name as a custom dimension (#10814)

* send channel name as a custom dimension

* tweaks from review

* remove unused import
parent c14470e0
......@@ -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;
......
......@@ -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
......
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