Skip to content

Commit dc7cac1

Browse files
authored
feat: add analytics for runtime config usage (#8870)
* feat: add analytics for runtime config usage Adds analytics to track whether a functions deployment includes a non-empty runtime config. This will help determine the impact of potentially removing runtime config from the deployment flow in the future. The flag is added to the analytics event. * chore: update changelog with PR number
1 parent f9dccab commit dc7cac1

File tree

5 files changed

+9
-1
lines changed

5 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
- Added analytics to track runtime config usage in functions deployments (#8870).
12
- Fixed issue where `__name__` fields with DESCENDING order were incorrectly filtered from index listings, causing duplicate index issues (#7629) and deployment conflicts (#8859). The fix now preserves `__name__` fields with explicit DESCENDING order while filtering out implicit ASCENDING `__name__` fields.

src/deploy/functions/args.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@ export interface Context {
5858

5959
// Tracks context for extension deploy
6060
extensions?: ExtContext;
61+
62+
// True if functions deploy is using runtime config
63+
hasRuntimeConfig?: boolean;
6164
}
6265

6366
export interface CodebaseDeployEvent {

src/deploy/functions/prepare.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ export async function prepare(
8989
let runtimeConfig: Record<string, unknown> = { firebase: firebaseConfig };
9090
if (checkAPIsEnabled[1]) {
9191
// If runtime config API is enabled, load the runtime config.
92-
runtimeConfig = { ...runtimeConfig, ...(await getFunctionsConfig(projectId)) };
92+
const config = await getFunctionsConfig(projectId);
93+
runtimeConfig = { ...runtimeConfig, ...config };
94+
context.hasRuntimeConfig = Object.keys(config).length > 0;
9395
}
9496

9597
context.codebaseDeployEvents = {};

src/deploy/functions/release/reporter.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,7 @@ describe("reporter", () => {
222222
fn_deploy_num_successes: 1,
223223
fn_deploy_num_canceled: 1,
224224
fn_deploy_num_failures: 1,
225+
has_runtime_config: "false",
225226
});
226227

227228
// The 0ms for an aborted function isn't counted.

src/deploy/functions/release/reporter.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export async function logAndTrackDeployStats(
118118
fn_deploy_num_successes: totalSuccesses,
119119
fn_deploy_num_canceled: totalAborts,
120120
fn_deploy_num_failures: totalErrors,
121+
has_runtime_config: String(!!context?.hasRuntimeConfig),
121122
};
122123
reports.push(trackGA4("function_deploy_group", fnDeployGroupEvent));
123124

0 commit comments

Comments
 (0)