@@ -146,22 +146,9 @@ export abstract class CommandModule<T extends {} = {}> implements CommandModuleI
146
146
147
147
let exitCode : number | void | undefined ;
148
148
try {
149
- // Run and time command.
150
149
if ( analytics ) {
151
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
152
- const internalMethods = ( yargs as any ) . getInternalMethods ( ) ;
153
- // $0 generate component [name] -> generate_component
154
- // $0 add <collection> -> add
155
- const fullCommand = ( internalMethods . getUsageInstance ( ) . getUsage ( ) [ 0 ] [ 0 ] as string )
156
- . split ( ' ' )
157
- . filter ( ( x ) => {
158
- const code = x . charCodeAt ( 0 ) ;
159
-
160
- return code >= 97 && code <= 122 ;
161
- } )
162
- . join ( '_' ) ;
163
-
164
- analytics . reportCommandRunEvent ( fullCommand ) ;
150
+ this . reportCommandRunAnalytics ( analytics ) ;
151
+ this . reportWorkspaceInfoAnalytics ( analytics ) ;
165
152
}
166
153
167
154
exitCode = await this . run ( camelCasedOptions as Options < T > & OtherOptions ) ;
@@ -307,6 +294,49 @@ export abstract class CommandModule<T extends {} = {}> implements CommandModuleI
307
294
308
295
return parameters ;
309
296
}
297
+
298
+ private reportCommandRunAnalytics ( analytics : AnalyticsCollector ) : void {
299
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
300
+ const internalMethods = ( yargs as any ) . getInternalMethods ( ) ;
301
+ // $0 generate component [name] -> generate_component
302
+ // $0 add <collection> -> add
303
+ const fullCommand = ( internalMethods . getUsageInstance ( ) . getUsage ( ) [ 0 ] [ 0 ] as string )
304
+ . split ( ' ' )
305
+ . filter ( ( x ) => {
306
+ const code = x . charCodeAt ( 0 ) ;
307
+
308
+ return code >= 97 && code <= 122 ;
309
+ } )
310
+ . join ( '_' ) ;
311
+
312
+ analytics . reportCommandRunEvent ( fullCommand ) ;
313
+ }
314
+
315
+ private reportWorkspaceInfoAnalytics ( analytics : AnalyticsCollector ) : void {
316
+ const { workspace } = this . context ;
317
+ if ( ! workspace ) {
318
+ return ;
319
+ }
320
+
321
+ let applicationProjectsCount = 0 ;
322
+ let librariesProjectsCount = 0 ;
323
+ for ( const project of workspace . projects . values ( ) ) {
324
+ switch ( project . extensions [ 'projectType' ] ) {
325
+ case 'application' :
326
+ applicationProjectsCount ++ ;
327
+ break ;
328
+ case 'library' :
329
+ librariesProjectsCount ++ ;
330
+ break ;
331
+ }
332
+ }
333
+
334
+ analytics . reportWorkspaceInfoEvent ( {
335
+ [ EventCustomMetric . AllProjectsCount ] : librariesProjectsCount + applicationProjectsCount ,
336
+ [ EventCustomMetric . ApplicationProjectsCount ] : applicationProjectsCount ,
337
+ [ EventCustomMetric . LibraryProjectsCount ] : librariesProjectsCount ,
338
+ } ) ;
339
+ }
310
340
}
311
341
312
342
/**
0 commit comments