Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 13 additions & 0 deletions src/init/features/dataconnect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@

// askQuestions prompts the user about the Data Connect service they want to init. Any prompting
// logic should live here, and _no_ actuation logic should live here.
export async function askQuestions(setup: Setup): Promise<void> {

Check warning on line 100 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
const info: RequiredInfo = {
analyticsFlow: "cli",
appDescription: "",
Expand Down Expand Up @@ -150,10 +150,10 @@

// actuate writes product specific files and makes product specifc API calls.
// It does not handle writing firebase.json and .firebaserc
export async function actuate(setup: Setup, config: Config, options: any): Promise<void> {

Check warning on line 153 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type

Check warning on line 153 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Missing JSDoc comment
// Most users will want to persist data between emulator runs, so set this to a reasonable default.
const dir: string = config.get("dataconnect.source", "dataconnect");

Check warning on line 155 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
const dataDir = config.get("emulators.dataconnect.dataDir", `${dir}/.dataconnect/pgliteData`);

Check warning on line 156 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
config.set("emulators.dataconnect.dataDir", dataDir);

const info = setup.featureInfo?.dataconnect;
Expand All @@ -170,6 +170,15 @@
await actuateWithInfo(setup, config, info, options);
await sdk.actuate(setup, config);
} finally {
const sdkInfo = setup.featureInfo?.dataconnectSdk;
const platformCounts = (sdkInfo?.apps ?? []).reduce(
(acc, a) => {
const platform = a.platform.toLowerCase();
acc[platform] = (acc[platform] || 0) + 1;
return acc;
},
{} as Record<string, number>,
);
void trackGA4("dataconnect_init", {
flow: info.analyticsFlow,
project_status: setup.projectId
Expand All @@ -179,6 +188,10 @@
: "blaze"
: "spark"
: "missing",
num_web_apps: platformCounts["web"] || 0,
num_android_apps: platformCounts["android"] || 0,
num_ios_apps: platformCounts["ios"] || 0,
num_flutter_apps: platformCounts["flutter"] || 0,
});
}

Expand All @@ -186,7 +199,7 @@
setup.instructions.push(
`You can visualize the Data Connect Schema in Firebase Console:

https://console.firebase.google.com/project/${setup.projectId!}/dataconnect/locations/${info.locationId}/services/${info.serviceId}/schema`,

Check warning on line 202 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Forbidden non-null assertion
);
}
if (!setup.isBillingEnabled) {
Expand All @@ -201,7 +214,7 @@
setup: Setup,
config: Config,
info: RequiredInfo,
options: any,

Check warning on line 217 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
): Promise<void> {
const projectId = setup.projectId;
if (!projectId) {
Expand Down Expand Up @@ -308,7 +321,7 @@
{ schemaGql: schemaFiles, connectors: connectors, seedDataGql: seedDataGql },
options,
);
} catch (err: any) {

Check warning on line 324 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
logLabeledError("dataconnect", `Operation Generation failed...`);
// GiF generate operation API has stability concerns.
// Fallback to save only the generated schema.
Expand Down Expand Up @@ -382,9 +395,9 @@
config: Config,
info: RequiredInfo,
serviceGql: ServiceGQL,
options: any,

Check warning on line 398 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unexpected any. Specify a different type
): Promise<void> {
const dir: string = config.get("dataconnect.source") || "dataconnect";

Check warning on line 400 in src/init/features/dataconnect/index.ts

View workflow job for this annotation

GitHub Actions / lint (20)

Unsafe assignment of an `any` value
const subbedDataconnectYaml = subDataconnectYamlValues({
...info,
connectorDirs: serviceGql.connectors.map((c) => c.path),
Expand Down
24 changes: 18 additions & 6 deletions src/init/features/dataconnect/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,17 +163,29 @@ export async function actuate(setup: Setup, config: Config) {
try {
await actuateWithInfo(setup, config, sdkInfo);
} finally {
let flow = "no_app";
if (sdkInfo.apps.length) {
const platforms = sdkInfo.apps.map((a) => a.platform.toLowerCase()).sort();
flow = `${platforms.join("_")}_app`;
}
if (fdcInfo) {
let flow = "no_app";
if (sdkInfo.apps.length) {
const platforms = sdkInfo.apps.map((a) => a.platform.toLowerCase()).sort();
flow = `${platforms.join("_")}_app`;
}
fdcInfo.analyticsFlow += `_${flow}`;
} else {
const platformCounts = sdkInfo.apps.reduce(
(acc, a) => {
const platform = a.platform.toLowerCase();
acc[platform] = (acc[platform] || 0) + 1;
return acc;
},
{} as Record<string, number>,
);
void trackGA4("dataconnect_init", {
project_status: setup.projectId ? (setup.isBillingEnabled ? "blaze" : "spark") : "missing",
flow: `cli_sdk_${flow}`,
flow: "cli_sdk",
num_web_apps: platformCounts["web"] || 0,
num_android_apps: platformCounts["android"] || 0,
num_ios_apps: platformCounts["ios"] || 0,
num_flutter_apps: platformCounts["flutter"] || 0,
});
}
}
Expand Down
Loading