diff --git a/packages/telemetry/src/sendTelemetry.ts b/packages/telemetry/src/sendTelemetry.ts index 97714f152cd6..fad08cca75a6 100644 --- a/packages/telemetry/src/sendTelemetry.ts +++ b/packages/telemetry/src/sendTelemetry.ts @@ -21,21 +21,31 @@ interface SensitiveArgPositions { positions: Array options?: never redactWith: Array + allowOnly: Array } g: { positions: Array options?: never redactWith: Array + allowOnly?: Array } generate: { positions: Array options?: never redactWith: Array + allowOnly?: Array } prisma: { positions?: never options: Array redactWith: Array + allowOnly?: Array + } + lint: { + positions?: Array + options?: never + redactWith: Array + allowOnly: Array } } @@ -45,6 +55,7 @@ const SENSITIVE_ARG_POSITIONS: SensitiveArgPositions = { exec: { positions: [1], redactWith: ['[script]'], + allowOnly: ['exec'], }, g: { positions: [2, 3], @@ -58,6 +69,10 @@ const SENSITIVE_ARG_POSITIONS: SensitiveArgPositions = { options: ['--name'], redactWith: ['[name]'], }, + lint: { + allowOnly: ['lint', '--fix'], + redactWith: ['[path]'], + }, } interface Args { @@ -149,6 +164,18 @@ export const sanitizeArgv = ( } }) } + + // allow only clause + if (sensitiveCommand.allowOnly) { + args.forEach((arg: string, index: number) => { + if ( + !sensitiveCommand.allowOnly?.includes(arg) && + !sensitiveCommand.redactWith.includes(arg) + ) { + args[index] = sensitiveCommand.redactWith[0] + } + }) + } } return args.join(' ')