refactor: use dimensions for some values instead of metrics

This is after a discussion with someone internal. Metrics are good
for sums but not for comparisons and search/filtering.
This commit is contained in:
Hans Larsen 2019-03-26 13:48:45 -07:00 committed by Alex Eagle
parent 00fb4cea4f
commit 55471770db
8 changed files with 23 additions and 25 deletions

View File

@ -42,15 +42,13 @@
"type": "boolean", "type": "boolean",
"default": false, "default": false,
"aliases": [ "d" ], "aliases": [ "d" ],
"description": "When true, runs through and reports activity without writing out results.", "description": "When true, runs through and reports activity without writing out results."
"x-user-analytics": 1
}, },
"force": { "force": {
"type": "boolean", "type": "boolean",
"default": false, "default": false,
"aliases": [ "f" ], "aliases": [ "f" ],
"description": "When true, forces overwriting of existing files.", "description": "When true, forces overwriting of existing files."
"x-user-analytics": 2
} }
} }
}, },
@ -59,8 +57,7 @@
"interactive": { "interactive": {
"type": "boolean", "type": "boolean",
"default": "true", "default": "true",
"description": "When false, disables interactive input prompts.", "description": "When false, disables interactive input prompts."
"x-user-analytics": 3
}, },
"defaults": { "defaults": {
"type": "boolean", "type": "boolean",

View File

@ -242,6 +242,7 @@ export class UniversalAnalytics implements analytics.Analytics {
private _ua: ua.Visitor; private _ua: ua.Visitor;
private _dirty = false; private _dirty = false;
private _metrics: (string | number)[] = []; private _metrics: (string | number)[] = [];
private _dimensions: (string | number)[] = [];
/** /**
* @param trackingId The Google Analytics ID. * @param trackingId The Google Analytics ID.
@ -267,10 +268,10 @@ export class UniversalAnalytics implements analytics.Analytics {
this._ua.set('aid', _getNodeVersion()); this._ua.set('aid', _getNodeVersion());
// We set custom metrics for values we care about. // We set custom metrics for values we care about.
this._metrics[analytics.NgCliAnalyticsMetrics.CpuCount] = _getCpuCount(); this._dimensions[analytics.NgCliAnalyticsDimensions.CpuCount] = _getCpuCount();
this._metrics[analytics.NgCliAnalyticsMetrics.CpuSpeed] = _getCpuSpeed(); this._dimensions[analytics.NgCliAnalyticsDimensions.CpuSpeed] = _getCpuSpeed();
this._metrics[analytics.NgCliAnalyticsMetrics.RamInMegabytes] = _getRamSize(); this._dimensions[analytics.NgCliAnalyticsDimensions.RamInMegabytes] = _getRamSize();
this._metrics[analytics.NgCliAnalyticsMetrics.NodeVersion] = _getNumericNodeVersion(); this._dimensions[analytics.NgCliAnalyticsDimensions.NodeVersion] = _getNumericNodeVersion();
} }
/** /**
@ -279,8 +280,9 @@ export class UniversalAnalytics implements analytics.Analytics {
*/ */
private _customVariables(options: analytics.CustomDimensionsAndMetricsOptions) { private _customVariables(options: analytics.CustomDimensionsAndMetricsOptions) {
const additionals: { [key: string]: boolean | number | string } = {}; const additionals: { [key: string]: boolean | number | string } = {};
this._metrics.forEach((v, i) => additionals['cm' + i] = v); this._dimensions.forEach((v, i) => additionals['cd' + i] = v);
(options.dimensions || []).forEach((v, i) => additionals['cd' + i] = v); (options.dimensions || []).forEach((v, i) => additionals['cd' + i] = v);
this._metrics.forEach((v, i) => additionals['cm' + i] = v);
(options.metrics || []).forEach((v, i) => additionals['cm' + i] = v); (options.metrics || []).forEach((v, i) => additionals['cm' + i] = v);
return additionals; return additionals;

View File

@ -17,16 +17,20 @@ export * from './noop';
* WE LIST THOSE DIMENSIONS (AND MORE). * WE LIST THOSE DIMENSIONS (AND MORE).
*/ */
export enum NgCliAnalyticsDimensions { export enum NgCliAnalyticsDimensions {
CpuCount = 1,
CpuSpeed = 2,
RamInMegabytes = 3,
NodeVersion = 4,
NgAddCollection = 6, NgAddCollection = 6,
NgBuildBuildEventLog = 7, NgBuildBuildEventLog = 7,
BuildErrors = 20, BuildErrors = 20,
} }
export enum NgCliAnalyticsMetrics { export enum NgCliAnalyticsMetrics {
CpuCount = 1, UNUSED_1 = 1,
CpuSpeed = 2, UNUSED_2 = 2,
RamInMegabytes = 3, UNUSED_3 = 3,
NodeVersion = 4, UNUSED_4 = 4,
BuildTime = 5, BuildTime = 5,
NgOnInitCount = 6, NgOnInitCount = 6,
InitialChunkSize = 7, InitialChunkSize = 7,

View File

@ -92,8 +92,7 @@
"skipInstall": { "skipInstall": {
"description": "Skip installing dependency packages.", "description": "Skip installing dependency packages.",
"type": "boolean", "type": "boolean",
"default": false, "default": false
"x-user-analytics": 4
}, },
"lintFix": { "lintFix": {
"type": "boolean", "type": "boolean",

View File

@ -37,8 +37,7 @@
"skipInstall": { "skipInstall": {
"description": "When true, does not install dependency packages.", "description": "When true, does not install dependency packages.",
"type": "boolean", "type": "boolean",
"default": false, "default": false
"x-user-analytics": 4
}, },
"skipTsConfig": { "skipTsConfig": {
"type": "boolean", "type": "boolean",

View File

@ -26,8 +26,7 @@
"skipInstall": { "skipInstall": {
"description": "When true, does not install dependency packages.", "description": "When true, does not install dependency packages.",
"type": "boolean", "type": "boolean",
"default": false, "default": false
"x-user-analytics": 4
}, },
"linkCli": { "linkCli": {
"description": "When true, links the CLI to the global version (internal development only).", "description": "When true, links the CLI to the global version (internal development only).",

View File

@ -57,8 +57,7 @@
"skipInstall": { "skipInstall": {
"description": "When true, does not install packages for dependencies.", "description": "When true, does not install packages for dependencies.",
"type": "boolean", "type": "boolean",
"default": false, "default": false
"x-user-analytics": 4
} }
}, },
"required": [ "required": [

View File

@ -21,8 +21,7 @@
"skipInstall": { "skipInstall": {
"description": "When true, does not install packages for dependencies.", "description": "When true, does not install packages for dependencies.",
"type": "boolean", "type": "boolean",
"default": false, "default": false
"x-user-analytics": 4
}, },
"linkCli": { "linkCli": {
"description": "When true, links the CLI to the global version (internal development only).", "description": "When true, links the CLI to the global version (internal development only).",