@@ -4,7 +4,7 @@ import { configFormat } from "../config";
44import isInteractive from "../is-interactive" ;
55import { logger } from "../logger" ;
66import { sniffUserAgent } from "../package-manager" ;
7- import { CI } from "./../is-ci" ;
7+ import { CI , isPagesCI , isWorkersCI } from "./../is-ci" ;
88import {
99 getNodeVersion ,
1010 getOS ,
@@ -73,9 +73,13 @@ export function getMetricsDispatcher(options: MetricsConfigOptions) {
7373 properties : Omit <
7474 Extract < Events , { name : EventName } > [ "properties" ] ,
7575 keyof CommonEventProperties
76- >
76+ > ,
77+ argv ?: string [ ]
7778 ) {
7879 try {
80+ if ( properties . command ?. startsWith ( "wrangler login" ) ) {
81+ properties . command = "wrangler login" ;
82+ }
7983 if (
8084 properties . command === "wrangler telemetry disable" ||
8185 properties . command === "wrangler metrics disable"
@@ -91,7 +95,7 @@ export function getMetricsDispatcher(options: MetricsConfigOptions) {
9195 printMetricsBanner ( ) ;
9296 }
9397
94- const argsUsed = sanitiseUserInput ( properties . args ?? { } ) ;
98+ const argsUsed = sanitiseUserInput ( properties . args ?? { } , argv ) ;
9599 const argsCombination = argsUsed . sort ( ) . join ( ", " ) ;
96100 const commonEventProperties : CommonEventProperties = {
97101 amplitude_session_id,
@@ -104,6 +108,8 @@ export function getMetricsDispatcher(options: MetricsConfigOptions) {
104108 isFirstUsage : readMetricsConfig ( ) . permission === undefined ,
105109 configFileType : configFormat ( options . configPath ) ,
106110 isCI : CI . isCI ( ) ,
111+ isPagesCI : isPagesCI ( ) ,
112+ isWorkersCI : isWorkersCI ( ) ,
107113 isInteractive : isInteractive ( ) ,
108114 argsUsed,
109115 argsCombination,
@@ -213,11 +219,20 @@ const normalise = (arg: string) => {
213219} ;
214220
215221const exclude = new Set ( [ "$0" , "_" ] ) ;
216- /** just some pretty naive cleaning so we don't send "experimental-versions", "experimentalVersions", "x-versions" and "xVersions" etc. */
217- const sanitiseUserInput = ( argsWithValues : Record < string , unknown > ) => {
222+ /**
223+ * just some pretty naive cleaning so we don't send duplicates of "experimental-versions", "experimentalVersions", "x-versions" and "xVersions" etc.
224+ * optionally, if an argv is provided remove all args that were not specified in argv (which means that default values will be filtered out)
225+ */
226+ const sanitiseUserInput = (
227+ argsWithValues : Record < string , unknown > ,
228+ argv ?: string [ ]
229+ ) => {
218230 const result : string [ ] = [ ] ;
219231 const args = Object . keys ( argsWithValues ) ;
220232 for ( const arg of args ) {
233+ if ( Array . isArray ( argv ) && ! argv . some ( ( a ) => a . includes ( arg ) ) ) {
234+ continue ;
235+ }
221236 if ( exclude . has ( arg ) ) {
222237 continue ;
223238 }
0 commit comments