Skip to content

Commit 0341624

Browse files
authored
Fix the products_initialized GA stats (#8928)
1 parent c2e3494 commit 0341624

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

src/commands/init.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { Options } from "../options";
1515
import { isEnabled } from "../experiments";
1616
import { readTemplateSync } from "../templates";
1717
import { FirebaseError } from "../error";
18-
import { trackGA4 } from "../track";
1918

2019
const homeDir = os.homedir();
2120

@@ -150,8 +149,6 @@ export async function initAction(feature: string, options: Options): Promise<voi
150149
);
151150
}
152151

153-
const start = process.uptime();
154-
155152
const cwd = options.cwd || process.cwd();
156153

157154
const warnings = [];
@@ -257,9 +254,6 @@ export async function initAction(feature: string, options: Options): Promise<voi
257254
if (!fsutils.fileExistsSync(config.path(".gitignore"))) {
258255
config.writeProjectFile(".gitignore", GITIGNORE_TEMPLATE);
259256
}
260-
const duration = Math.floor((process.uptime() - start) * 1000);
261-
262-
await trackGA4("product_init", { products_initialized: setup.features?.join(",") }, duration);
263257

264258
logger.info();
265259
utils.logSuccess("Firebase initialization complete!");

src/init/index.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { RCData } from "../rc";
88
import { Config } from "../config";
99
import { FirebaseConfig } from "../firebaseConfig";
1010
import { Options } from "../options";
11+
import { trackGA4 } from "../track";
1112

1213
export interface Setup {
1314
config: FirebaseConfig;
@@ -93,6 +94,8 @@ const featureMap = new Map(featuresList.map((feature) => [feature.name, feature]
9394
export 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. */
127135
export 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
}

src/track.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ type cliEventNames =
1111
| "command_execution"
1212
| "product_deploy"
1313
| "product_init"
14+
| "product_init_mcp"
1415
| "error"
1516
| "login"
1617
| "api_enabled"

0 commit comments

Comments
 (0)