@@ -41,7 +41,8 @@ export function getMetricsDispatcher(options: MetricsConfigOptions) {
4141 /** We redact strings in arg values, unless they are named here */
4242 const allowList = {
4343 // applies to all commands
44- "*" : [ "format" , "log-level" , "logLevel" ] ,
44+ // use camelCase version
45+ "*" : [ "format" , "logLevel" ] ,
4546 // specific commands
4647 tail : [ "status" ] ,
4748 } ;
@@ -86,7 +87,7 @@ export function getMetricsDispatcher(options: MetricsConfigOptions) {
8687 return ;
8788 }
8889 printMetricsBanner ( ) ;
89- const argsUsed = normaliseArgs ( properties . args ?? { } ) ;
90+ const argsUsed = sanitiseUserInput ( properties . args ?? { } ) ;
9091 const argsCombination = argsUsed . sort ( ) . join ( ", " ) ;
9192 const commonEventProperties : CommonEventProperties = {
9293 amplitude_session_id,
@@ -201,9 +202,15 @@ export function getMetricsDispatcher(options: MetricsConfigOptions) {
201202
202203export type Properties = Record < string , unknown > ;
203204
205+ const normalise = ( arg : string ) => {
206+ const camelize = ( str : string ) =>
207+ str . replace ( / - ./ g, ( x ) => x [ 1 ] . toUpperCase ( ) ) ;
208+ return camelize ( arg . replace ( "experimental" , "x" ) ) ;
209+ } ;
210+
204211const exclude = new Set ( [ "$0" , "_" ] ) ;
205212/** just some pretty naive cleaning so we don't send "experimental-versions", "experimentalVersions", "x-versions" and "xVersions" etc. */
206- const normaliseArgs = ( argsWithValues : Record < string , unknown > ) => {
213+ const sanitiseUserInput = ( argsWithValues : Record < string , unknown > ) => {
207214 const result : string [ ] = [ ] ;
208215 const args = Object . keys ( argsWithValues ) ;
209216 for ( const arg of args ) {
@@ -216,10 +223,8 @@ const normaliseArgs = (argsWithValues: Record<string, unknown>) => {
216223 ) {
217224 continue ;
218225 }
219- const normalisedArg = arg
220- . replace ( "experimental" , "x" )
221- . replaceAll ( "-" , "" )
222- . toLowerCase ( ) ;
226+
227+ const normalisedArg = normalise ( arg ) ;
223228 if ( result . includes ( normalisedArg ) ) {
224229 continue ;
225230 }
@@ -248,7 +253,7 @@ export const redactArgValues = (
248253 if (
249254 typeof value === "number" ||
250255 typeof value === "boolean" ||
251- allowedKeys . includes ( key )
256+ allowedKeys . includes ( normalise ( key ) )
252257 ) {
253258 result [ key ] = value ;
254259 } else if ( typeof value === "string" ) {
0 commit comments