@@ -8,6 +8,7 @@ import { RCData } from "../rc";
88import { Config } from "../config" ;
99import { FirebaseConfig } from "../firebaseConfig" ;
1010import { Options } from "../options" ;
11+ import { trackGA4 } from "../track" ;
1112
1213export interface Setup {
1314 config : FirebaseConfig ;
@@ -93,6 +94,8 @@ const featureMap = new Map(featuresList.map((feature) => [feature.name, feature]
9394export async function init ( setup : Setup , config : Config , options : any ) : Promise < any > {
9495 const nextFeature = setup . features ?. shift ( ) ;
9596 if ( nextFeature ) {
97+ const start = process . uptime ( ) ;
98+
9699 const f = featureMap . get ( nextFeature ) ;
97100 if ( ! f ) {
98101 const availableFeatures = Object . keys ( features )
@@ -120,13 +123,20 @@ export async function init(setup: Setup, config: Config, options: any): Promise<
120123 if ( f . postSetup ) {
121124 await f . postSetup ( setup , config , options ) ;
122125 }
126+
127+ const duration = Math . floor ( ( process . uptime ( ) - start ) * 1000 ) ;
128+ await trackGA4 ( "product_init" , { feature : nextFeature } , duration ) ;
129+
123130 return init ( setup , config , options ) ;
124131 }
125132}
126133
134+ /** Actuate the feature init flow from firebase_init MCP tool. */
127135export async function actuate ( setup : Setup , config : Config , options : any ) : Promise < any > {
128136 const nextFeature = setup . features ?. shift ( ) ;
129137 if ( nextFeature ) {
138+ const start = process . uptime ( ) ;
139+
130140 const f = lookupFeature ( nextFeature ) ;
131141 logger . info ( clc . bold ( `\n${ clc . white ( "===" ) } ${ capitalize ( nextFeature ) } Setup Actuation` ) ) ;
132142
@@ -139,6 +149,10 @@ export async function actuate(setup: Setup, config: Config, options: any): Promi
139149 await f . actuate ( setup , config , options ) ;
140150 }
141151 }
152+
153+ const duration = Math . floor ( ( process . uptime ( ) - start ) * 1000 ) ;
154+ await trackGA4 ( "product_init_mcp" , { feature : nextFeature } , duration ) ;
155+
142156 return actuate ( setup , config , options ) ;
143157 }
144158}
0 commit comments