mirror of
https://github.com/angular/angular-cli.git
synced 2025-05-22 23:15:56 +08:00
refactor: only collect Node version if it's a standard version string
Any other kinds of Node version are collected as "other" to avoid pulling in an unbounded user input.
This commit is contained in:
parent
c3adf11a5a
commit
b5dcb29cba
@ -10,6 +10,7 @@ import { randomUUID } from 'crypto';
|
||||
import * as https from 'https';
|
||||
import * as os from 'os';
|
||||
import * as querystring from 'querystring';
|
||||
import * as semver from 'semver';
|
||||
import type { CommandContext } from '../command-builder/command-module';
|
||||
import { ngDebug } from '../utilities/environment-options';
|
||||
import { assertIsError } from '../utilities/error';
|
||||
@ -52,8 +53,7 @@ export class AnalyticsCollector {
|
||||
|
||||
this.requestParameterStringified = querystring.stringify(requestParameters);
|
||||
|
||||
// Remove the `v` at the beginning.
|
||||
const nodeVersion = process.version.substring(1);
|
||||
const parsedVersion = semver.parse(process.version);
|
||||
const packageManagerVersion = context.packageManager.version;
|
||||
|
||||
this.userParameters = {
|
||||
@ -62,8 +62,10 @@ export class AnalyticsCollector {
|
||||
[UserCustomDimension.OsArchitecture]: os.arch(),
|
||||
// While User ID is being collected by GA, this is not visible in reports/for filtering.
|
||||
[UserCustomDimension.UserId]: userId,
|
||||
[UserCustomDimension.NodeVersion]: nodeVersion,
|
||||
[UserCustomDimension.NodeMajorVersion]: +nodeVersion.split('.', 1)[0],
|
||||
[UserCustomDimension.NodeVersion]: parsedVersion
|
||||
? `${parsedVersion.major}.${parsedVersion.minor}.${parsedVersion.patch}`
|
||||
: 'other',
|
||||
[UserCustomDimension.NodeMajorVersion]: parsedVersion?.major,
|
||||
[UserCustomDimension.PackageManager]: context.packageManager.name,
|
||||
[UserCustomDimension.PackageManagerVersion]: packageManagerVersion,
|
||||
[UserCustomDimension.PackageManagerMajorVersion]: packageManagerVersion
|
||||
|
Loading…
x
Reference in New Issue
Block a user