Skip to content

Commit 2651b2e

Browse files
hanslvikerman
authored andcommitted
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.
1 parent 1fb75f6 commit 2651b2e

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

docs/design/analytics.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Note: There's a limit of 20 custom dimensions.
4343
|:---:|:---|:---|
4444
| 1 | `CPU Count` | `number` |
4545
| 2 | `CPU Speed` | `number` |
46-
| 3 | `RAM (In MB)` | `number` |
46+
| 3 | `RAM (In GB)` | `number` |
4747
| 4 | `Node Version` | `number` |
4848
| 5 | `Flag: --style` | `string` |
4949
| 6 | `--collection` | `string` |

etc/api/angular_devkit/core/src/_golden-api.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ export declare class MultiAnalytics implements Analytics {
614614
export declare enum NgCliAnalyticsDimensions {
615615
CpuCount = 1,
616616
CpuSpeed = 2,
617-
RamInMegabytes = 3,
617+
RamInGigabytes = 3,
618618
NodeVersion = 4,
619619
NgAddCollection = 6,
620620
NgBuildBuildEventLog = 7,

packages/angular/cli/models/analytics.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { isTTY } from '../utilities/tty';
1919
const analyticsDebug = debug('ng:analytics'); // Generate analytics, including settings and users.
2020
const analyticsLogDebug = debug('ng:analytics:log'); // Actual logs of events.
2121

22-
const BYTES_PER_MEGABYTES = 1024 * 1024;
22+
const BYTES_PER_GIGABYTES = 1024 * 1024 * 1024;
2323

2424
/**
2525
* This is the ultimate safelist for checking if a package name is safe to report to analytics.
@@ -102,8 +102,8 @@ function _getCpuSpeed() {
102102
* @private
103103
*/
104104
function _getRamSize() {
105-
// Report in megabytes. Otherwise it's too much noise.
106-
return Math.floor(os.totalmem() / BYTES_PER_MEGABYTES);
105+
// Report in gigabytes (or closest). Otherwise it's too much noise.
106+
return Math.round(os.totalmem() / BYTES_PER_GIGABYTES);
107107
}
108108

109109
/**
@@ -262,7 +262,7 @@ export class UniversalAnalytics implements analytics.Analytics {
262262
// We set custom metrics for values we care about.
263263
this._dimensions[analytics.NgCliAnalyticsDimensions.CpuCount] = _getCpuCount();
264264
this._dimensions[analytics.NgCliAnalyticsDimensions.CpuSpeed] = _getCpuSpeed();
265-
this._dimensions[analytics.NgCliAnalyticsDimensions.RamInMegabytes] = _getRamSize();
265+
this._dimensions[analytics.NgCliAnalyticsDimensions.RamInGigabytes] = _getRamSize();
266266
this._dimensions[analytics.NgCliAnalyticsDimensions.NodeVersion] = _getNumericNodeVersion();
267267
}
268268

packages/angular_devkit/core/src/analytics/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export * from './logging';
1111
export * from './multi';
1212
export * from './noop';
1313

14-
1514
/**
1615
* MAKE SURE TO KEEP THIS IN SYNC WITH THE TABLE AND CONTENT IN `/docs/design/analytics.md`.
1716
* WE LIST THOSE DIMENSIONS (AND MORE).
@@ -23,7 +22,7 @@ export * from './noop';
2322
export enum NgCliAnalyticsDimensions {
2423
CpuCount = 1,
2524
CpuSpeed = 2,
26-
RamInMegabytes = 3,
25+
RamInGigabytes = 3,
2726
NodeVersion = 4,
2827
NgAddCollection = 6,
2928
NgBuildBuildEventLog = 7,
@@ -53,7 +52,7 @@ export enum NgCliAnalyticsMetrics {
5352
export const NgCliAnalyticsDimensionsFlagInfo: { [name: string]: [string, string] } = {
5453
CpuCount: ['CPU Count', 'number'],
5554
CpuSpeed: ['CPU Speed', 'number'],
56-
RamInMegabytes: ['RAM (In MB)', 'number'],
55+
RamInGigabytes: ['RAM (In GB)', 'number'],
5756
NodeVersion: ['Node Version', 'number'],
5857
NgAddCollection: ['--collection', 'string'],
5958
NgBuildBuildEventLog: ['--buildEventLog', 'boolean'],

0 commit comments

Comments
 (0)