feat(@angular/cli): report RAM in gigabytes instead of megabytes

Otherwise its too much noise. Some people have weird MB count probably due to
containers and VMs.
This commit is contained in:
Hans Larsen 2019-06-26 13:14:10 -07:00 committed by vikerman
parent 3e5e2574c7
commit 46ade49a2f
4 changed files with 8 additions and 9 deletions

View File

@ -43,7 +43,7 @@ Note: There's a limit of 20 custom dimensions.
|:---:|:---|:---| |:---:|:---|:---|
| 1 | `CPU Count` | `number` | | 1 | `CPU Count` | `number` |
| 2 | `CPU Speed` | `number` | | 2 | `CPU Speed` | `number` |
| 3 | `RAM (In MB)` | `number` | | 3 | `RAM (In GB)` | `number` |
| 4 | `Node Version` | `number` | | 4 | `Node Version` | `number` |
| 5 | `Flag: --style` | `string` | | 5 | `Flag: --style` | `string` |
| 6 | `--collection` | `string` | | 6 | `--collection` | `string` |

View File

@ -614,7 +614,7 @@ export declare class MultiAnalytics implements Analytics {
export declare enum NgCliAnalyticsDimensions { export declare enum NgCliAnalyticsDimensions {
CpuCount = 1, CpuCount = 1,
CpuSpeed = 2, CpuSpeed = 2,
RamInMegabytes = 3, RamInGigabytes = 3,
NodeVersion = 4, NodeVersion = 4,
NgAddCollection = 6, NgAddCollection = 6,
NgBuildBuildEventLog = 7, NgBuildBuildEventLog = 7,

View File

@ -20,7 +20,7 @@ import { isTTY } from '../utilities/tty';
const analyticsDebug = debug('ng:analytics'); // Generate analytics, including settings and users. const analyticsDebug = debug('ng:analytics'); // Generate analytics, including settings and users.
const analyticsLogDebug = debug('ng:analytics:log'); // Actual logs of events. const analyticsLogDebug = debug('ng:analytics:log'); // Actual logs of events.
const BYTES_PER_MEGABYTES = 1024 * 1024; const BYTES_PER_GIGABYTES = 1024 * 1024 * 1024;
let _defaultAngularCliPropertyCache: string; let _defaultAngularCliPropertyCache: string;
export const AnalyticsProperties = { export const AnalyticsProperties = {
@ -129,8 +129,8 @@ function _getCpuSpeed() {
* @private * @private
*/ */
function _getRamSize() { function _getRamSize() {
// Report in megabytes. Otherwise it's too much noise. // Report in gigabytes (or closest). Otherwise it's too much noise.
return Math.floor(os.totalmem() / BYTES_PER_MEGABYTES); return Math.round(os.totalmem() / BYTES_PER_GIGABYTES);
} }
/** /**
@ -287,7 +287,7 @@ export class UniversalAnalytics implements analytics.Analytics {
// We set custom metrics for values we care about. // We set custom metrics for values we care about.
this._dimensions[analytics.NgCliAnalyticsDimensions.CpuCount] = _getCpuCount(); this._dimensions[analytics.NgCliAnalyticsDimensions.CpuCount] = _getCpuCount();
this._dimensions[analytics.NgCliAnalyticsDimensions.CpuSpeed] = _getCpuSpeed(); this._dimensions[analytics.NgCliAnalyticsDimensions.CpuSpeed] = _getCpuSpeed();
this._dimensions[analytics.NgCliAnalyticsDimensions.RamInMegabytes] = _getRamSize(); this._dimensions[analytics.NgCliAnalyticsDimensions.RamInGigabytes] = _getRamSize();
this._dimensions[analytics.NgCliAnalyticsDimensions.NodeVersion] = _getNumericNodeVersion(); this._dimensions[analytics.NgCliAnalyticsDimensions.NodeVersion] = _getNumericNodeVersion();
} }

View File

@ -11,7 +11,6 @@ export * from './logging';
export * from './multi'; export * from './multi';
export * from './noop'; export * from './noop';
/** /**
* MAKE SURE TO KEEP THIS IN SYNC WITH THE TABLE AND CONTENT IN `/docs/design/analytics.md`. * MAKE SURE TO KEEP THIS IN SYNC WITH THE TABLE AND CONTENT IN `/docs/design/analytics.md`.
* WE LIST THOSE DIMENSIONS (AND MORE). * WE LIST THOSE DIMENSIONS (AND MORE).
@ -23,7 +22,7 @@ export * from './noop';
export enum NgCliAnalyticsDimensions { export enum NgCliAnalyticsDimensions {
CpuCount = 1, CpuCount = 1,
CpuSpeed = 2, CpuSpeed = 2,
RamInMegabytes = 3, RamInGigabytes = 3,
NodeVersion = 4, NodeVersion = 4,
NgAddCollection = 6, NgAddCollection = 6,
NgBuildBuildEventLog = 7, NgBuildBuildEventLog = 7,
@ -53,7 +52,7 @@ export enum NgCliAnalyticsMetrics {
export const NgCliAnalyticsDimensionsFlagInfo: { [name: string]: [string, string] } = { export const NgCliAnalyticsDimensionsFlagInfo: { [name: string]: [string, string] } = {
CpuCount: ['CPU Count', 'number'], CpuCount: ['CPU Count', 'number'],
CpuSpeed: ['CPU Speed', 'number'], CpuSpeed: ['CPU Speed', 'number'],
RamInMegabytes: ['RAM (In MB)', 'number'], RamInGigabytes: ['RAM (In GB)', 'number'],
NodeVersion: ['Node Version', 'number'], NodeVersion: ['Node Version', 'number'],
NgAddCollection: ['--collection', 'string'], NgAddCollection: ['--collection', 'string'],
NgBuildBuildEventLog: ['--buildEventLog', 'boolean'], NgBuildBuildEventLog: ['--buildEventLog', 'boolean'],