Skip to content

Commit

Permalink
fix(@angular-devkit/core): add Angular CLI major version as analytics…
Browse files Browse the repository at this point in the history
… dimension

With this change we replace the custom dimension 8 `AOT Enabled`, with `Angular CLI Major Version`. The motivation behind replacing this dimension is that the there is already an `aot` dimension with id 13 which serves for the same purpose.

More information to why we need a new dimension for the Angular CLI major version can be found #22130

Closes #22130
  • Loading branch information
alan-agius4 committed Mar 24, 2022
1 parent f65248b commit 455aeea
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 15 deletions.
2 changes: 1 addition & 1 deletion docs/design/analytics.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ Note: There's a limit of 20 custom dimensions.
| 5 | `Flag: --style` | `string` |
| 6 | `--collection` | `string` |
| 7 | `Flag: --strict` | `boolean` |
| 8 | `AOT Enabled` | `boolean` |
| 8 | `Angular CLI Major Version` | `string` |
| 9 | `Flag: --inline-style` | `boolean` |
| 10 | `Flag: --inline-template` | `boolean` |
| 11 | `Flag: --view-encapsulation` | `string` |
Expand Down
2 changes: 1 addition & 1 deletion goldens/public-api/angular_devkit/core/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,7 @@ class MultiAnalytics implements Analytics {
// @public
enum NgCliAnalyticsDimensions {
// (undocumented)
AotEnabled = 8,
AngularCLIMajorVersion = 8,
// (undocumented)
BuildErrors = 20,
// (undocumented)
Expand Down
3 changes: 3 additions & 0 deletions packages/angular/cli/src/analytics/analytics-collector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ export class AnalyticsCollector implements analytics.Analytics {
os.totalmem() / (1024 * 1024 * 1024),
);
this.parameters['cd' + analytics.NgCliAnalyticsDimensions.NodeVersion] = nodeVersion;

this.parameters['cd' + analytics.NgCliAnalyticsDimensions.AngularCLIMajorVersion] =
VERSION.major;
}

event(ec: string, ea: string, options: analytics.EventOptions = {}): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ export function getAnalyticsConfig(

// The category is the builder name if it's an angular builder.
return {
plugins: [
new NgBuildAnalyticsPlugin(
wco.projectRoot,
context.analytics,
category,
wco.buildOptions.aot ?? false,
),
],
plugins: [new NgBuildAnalyticsPlugin(wco.projectRoot, context.analytics, category)],
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export class NgBuildAnalyticsPlugin {
protected _projectRoot: string,
protected _analytics: analytics.Analytics,
protected _category: string,
private aotEnabled: boolean,
) {}

protected _reset() {
Expand Down Expand Up @@ -115,8 +114,6 @@ export class NgBuildAnalyticsPlugin {
dimensions[analytics.NgCliAnalyticsDimensions.BuildErrors] = `,${this._stats.errors.join()},`;
}

dimensions[analytics.NgCliAnalyticsDimensions.AotEnabled] = this.aotEnabled;

return dimensions;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/angular_devkit/core/src/analytics/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export enum NgCliAnalyticsDimensions {
RamInGigabytes = 3,
NodeVersion = 4,
NgAddCollection = 6,
AotEnabled = 8,
AngularCLIMajorVersion = 8,
BuildErrors = 20,
}

Expand Down Expand Up @@ -57,7 +57,7 @@ export const NgCliAnalyticsDimensionsFlagInfo: { [name: string]: [string, string
RamInGigabytes: ['RAM (In GB)', 'number'],
NodeVersion: ['Node Version', 'number'],
NgAddCollection: ['--collection', 'string'],
AotEnabled: ['AOT Enabled', 'boolean'],
AngularCLIMajorVersion: ['Angular CLI Major Version', 'string'],
BuildErrors: ['Build Errors (comma separated)', 'string'],
};

Expand Down

0 comments on commit 455aeea

Please sign in to comment.