@@ -15,7 +15,7 @@ import { getProject } from "./management/projects";
1515import { reconcileStudioFirebaseProject } from "./management/studio" ;
1616import { requireAuth } from "./requireAuth" ;
1717import { Options } from "./options" ;
18- import { logger , useConsoleLoggers } from "./logger" ;
18+ import { useConsoleLoggers } from "./logger" ;
1919import { isFirebaseStudio } from "./env" ;
2020
2121export interface CommandModule {
@@ -236,28 +236,28 @@ export class Command {
236236 } ) ;
237237 }
238238 const duration = Math . floor ( ( process . uptime ( ) - start ) * 1000 ) ;
239- try {
240- const trackSuccess = trackGA4 (
241- "command_execution" ,
242- {
243- command_name : this . name ,
244- result : "success" ,
245- interactive : getInheritedOption ( options , "nonInteractive" ) ? "false" : "true" ,
246- } ,
247- duration ,
248- ) ;
249- const tracks = [ trackSuccess ] ;
250- if ( isEmulator ) {
251- tracks . push (
239+ const trackSuccess = trackGA4 (
240+ "command_execution" ,
241+ {
242+ command_name : this . name ,
243+ result : "success" ,
244+ interactive : getInheritedOption ( options , "nonInteractive" ) ? "false" : "true" ,
245+ } ,
246+ duration ,
247+ ) ;
248+ if ( ! isEmulator ) {
249+ await withTimeout ( 5000 , trackSuccess ) ;
250+ } else {
251+ await withTimeout (
252+ 5000 ,
253+ Promise . all ( [
254+ trackSuccess ,
252255 trackEmulator ( "command_success" , {
253256 command_name : this . name ,
254257 duration,
255258 } ) ,
256- ) ;
257- }
258- await withTimeout ( 1000 , Promise . all ( tracks ) ) ;
259- } catch ( gaErr ) {
260- logger . debug ( "Analytics tracking failed during success path:" , gaErr ) ;
259+ ] ) ,
260+ ) ;
261261 }
262262 process . exit ( ) ;
263263 } )
@@ -278,30 +278,27 @@ export class Command {
278278 } ) ;
279279 }
280280 const duration = Math . floor ( ( process . uptime ( ) - start ) * 1000 ) ;
281- try {
282- const trackError = trackGA4 (
283- "command_execution" ,
284- {
285- command_name : this . name ,
286- result : "error" ,
287- interactive : getInheritedOption ( options , "nonInteractive" ) ? "false" : "true" ,
288- } ,
289- duration ,
290- ) ;
291- const tracks = [ trackError ] ;
292- if ( isEmulator ) {
293- tracks . push (
294- trackEmulator ( "command_error" , {
281+ await withTimeout (
282+ 5000 ,
283+ Promise . all ( [
284+ trackGA4 (
285+ "command_execution" ,
286+ {
295287 command_name : this . name ,
296- duration,
297- error_type : err ?. exit === 1 ? "user" : "unexpected" ,
298- } ) ,
299- ) ;
300- }
301- await withTimeout ( 1000 , Promise . all ( tracks ) ) ;
302- } catch ( gaErr ) {
303- logger . debug ( "Analytics tracking failed during error path:" , gaErr ) ;
304- }
288+ result : "error" ,
289+ interactive : getInheritedOption ( options , "nonInteractive" ) ? "false" : "true" ,
290+ } ,
291+ duration ,
292+ ) ,
293+ isEmulator
294+ ? trackEmulator ( "command_error" , {
295+ command_name : this . name ,
296+ duration,
297+ error_type : err . exit === 1 ? "user" : "unexpected" ,
298+ } )
299+ : Promise . resolve ( ) ,
300+ ] ) ,
301+ ) ;
305302
306303 client . errorOut ( err ) ;
307304 } ) ;
0 commit comments