Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions src/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import { isEnabled } from "../experiments";
import { readTemplateSync } from "../templates";
import { FirebaseError } from "../error";
import { trackGA4 } from "../track";

const homeDir = os.homedir();

Expand Down Expand Up @@ -150,8 +149,6 @@
);
}

const start = process.uptime();

const cwd = options.cwd || process.cwd();

const warnings = [];
Expand Down Expand Up @@ -189,7 +186,7 @@

const setup: Setup = {
config: config.src,
rcfile: config.readProjectFile(".firebaserc", {

Check warning on line 189 in src/commands/init.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
json: true,
fallback: {},
}),
Expand Down Expand Up @@ -257,9 +254,6 @@
if (!fsutils.fileExistsSync(config.path(".gitignore"))) {
config.writeProjectFile(".gitignore", GITIGNORE_TEMPLATE);
}
const duration = Math.floor((process.uptime() - start) * 1000);

await trackGA4("product_init", { products_initialized: setup.features?.join(",") }, duration);

logger.info();
utils.logSuccess("Firebase initialization complete!");
Expand Down
14 changes: 14 additions & 0 deletions src/init/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import { Config } from "../config";
import { FirebaseConfig } from "../firebaseConfig";
import { Options } from "../options";
import { trackGA4 } from "../track";

export interface Setup {
config: FirebaseConfig;
Expand All @@ -17,12 +18,12 @@
featureInfo?: SetupInfo;

/** Basic Project information */
project?: Record<string, any>;

Check warning on line 21 in src/init/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
projectId?: string;
projectLocation?: string;
isBillingEnabled?: boolean;

hosting?: Record<string, any>;

Check warning on line 26 in src/init/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
}

export interface SetupInfo {
Expand Down Expand Up @@ -90,9 +91,11 @@

const featureMap = new Map(featuresList.map((feature) => [feature.name, feature]));

export async function init(setup: Setup, config: Config, options: any): Promise<any> {

Check warning on line 94 in src/init/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type

Check warning on line 94 in src/init/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type

Check warning on line 94 in src/init/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
const nextFeature = setup.features?.shift();
if (nextFeature) {
const start = process.uptime();

const f = featureMap.get(nextFeature);
if (!f) {
const availableFeatures = Object.keys(features)
Expand All @@ -108,25 +111,32 @@
);

if (f.doSetup) {
await f.doSetup(setup, config, options);

Check warning on line 114 in src/init/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `Options`
} else {
if (f.askQuestions) {
await f.askQuestions(setup, config, options);

Check warning on line 117 in src/init/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `Options`
}
if (f.actuate) {
await f.actuate(setup, config, options);

Check warning on line 120 in src/init/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `Options`
}
}
if (f.postSetup) {
await f.postSetup(setup, config, options);

Check warning on line 124 in src/init/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe argument of type `any` assigned to a parameter of type `Options`
}

const duration = Math.floor((process.uptime() - start) * 1000);
await trackGA4("product_init", { feature: nextFeature }, duration);

return init(setup, config, options);
}
}

/** Actuate the feature init flow from firebase_init MCP tool. */
export async function actuate(setup: Setup, config: Config, options: any): Promise<any> {
const nextFeature = setup.features?.shift();
if (nextFeature) {
const start = process.uptime();

const f = lookupFeature(nextFeature);
logger.info(clc.bold(`\n${clc.white("===")} ${capitalize(nextFeature)} Setup Actuation`));

Expand All @@ -139,6 +149,10 @@
await f.actuate(setup, config, options);
}
}

const duration = Math.floor((process.uptime() - start) * 1000);
await trackGA4("product_init_mcp", { feature: nextFeature }, duration);

return actuate(setup, config, options);
}
}
Expand Down
1 change: 1 addition & 0 deletions src/track.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ type cliEventNames =
| "command_execution"
| "product_deploy"
| "product_init"
| "product_init_mcp"
| "error"
| "login"
| "api_enabled"
Expand Down
Loading