Skip to content

Commit 46ade49

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 3e5e257 commit 46ade49

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

docs/design/analytics.md

+1-1
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

+1-1
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

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

23-
const BYTES_PER_MEGABYTES = 1024 * 1024;
23+
const BYTES_PER_GIGABYTES = 1024 * 1024 * 1024;
2424

2525
let _defaultAngularCliPropertyCache: string;
2626
export const AnalyticsProperties = {
@@ -129,8 +129,8 @@ function _getCpuSpeed() {
129129
* @private
130130
*/
131131
function _getRamSize() {
132-
// Report in megabytes. Otherwise it's too much noise.
133-
return Math.floor(os.totalmem() / BYTES_PER_MEGABYTES);
132+
// Report in gigabytes (or closest). Otherwise it's too much noise.
133+
return Math.round(os.totalmem() / BYTES_PER_GIGABYTES);
134134
}
135135

136136
/**
@@ -287,7 +287,7 @@ export class UniversalAnalytics implements analytics.Analytics {
287287
// We set custom metrics for values we care about.
288288
this._dimensions[analytics.NgCliAnalyticsDimensions.CpuCount] = _getCpuCount();
289289
this._dimensions[analytics.NgCliAnalyticsDimensions.CpuSpeed] = _getCpuSpeed();
290-
this._dimensions[analytics.NgCliAnalyticsDimensions.RamInMegabytes] = _getRamSize();
290+
this._dimensions[analytics.NgCliAnalyticsDimensions.RamInGigabytes] = _getRamSize();
291291
this._dimensions[analytics.NgCliAnalyticsDimensions.NodeVersion] = _getNumericNodeVersion();
292292
}
293293

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

+2-3
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)