@@ -122,32 +122,32 @@ function consolidateAppEventCalls(appEventCalls) {
122122 // use argPosition as key as obj arg have no string argValue
123123 let argCountMap = { } ;
124124
125- // iterate through and take the most verbose arg for each position
126- // also add to a countMap { [argPosition]: count }.merge { ["objectArg${argPosition}.${nestedArg.key}"]: count }
127125 consolidatedAppEvent . args = appEventCalls . reduce ( ( result , appEvent ) => {
128126 appEvent . args . forEach ( ( arg ) => {
129127 const position = arg . argPosition ;
130128 const existingArg = result [ position ] ;
131-
132- if ( existingArg && existingArg . argValue . length < arg . argValue . length ) {
129+ const existingArgLength = existingArg ? existingArg . argValue . length : 0 ;
130+ if ( arg . argValue . length > existingArgLength ) {
133131 result [ position ] = { ...arg } ;
134132 //TODO: also see if we should be considering descriptions and nestedArgs
135133 }
136134
137135 // Add to count map that will be used to determine isAlwaysPresent later for the arg
138- argCountMap [ position ] += 1 ;
136+ argCountMap [ position ] ||= 0 ;
137+ argCountMap [ position ] ++ ;
139138
140139 if ( arg . argType === "object" ) {
141140 arg . argValue . forEach ( ( nestedArg ) => {
142141 const key = `objectArg${ position } .${ nestedArg . key } ` ;
143- argCountMap [ key ] += 1 ;
142+ // argCountMap[key] += 1;
143+ argCountMap [ key ] ||= 0 ;
144+ argCountMap [ key ] ++ ;
144145 } ) ;
145146 }
146147 } ) ;
147148 return result ;
148149 } , [ ] ) ;
149150
150- // only push if arg
151151 consolidatedAppEvent . args . forEach ( ( arg ) => {
152152 if ( arg . argType === "object" ) {
153153 arg . argValue . forEach ( ( nestedArg ) => {
0 commit comments