Skip to content

Commit 60310cd

Browse files
authored
chore: add metrics event for provisioning (#8077)
* add event for provisioning * changeset * fixup
1 parent 9cfe0d8 commit 60310cd

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

.changeset/wet-glasses-rush.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"wrangler": patch
3+
---
4+
5+
feat: add telemetry to experimental auto-provisioning

packages/wrangler/src/deployment-bundle/bindings.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { prompt, select } from "../dialogs";
77
import { UserError } from "../errors";
88
import { createKVNamespace, listKVNamespaces } from "../kv/helpers";
99
import { logger } from "../logger";
10+
import * as metrics from "../metrics";
1011
import { APIError } from "../parse";
1112
import { createR2Bucket, getR2Bucket, listR2Buckets } from "../r2/helpers";
1213
import { isLegacyEnv } from "../utils/isLegacyEnv";
@@ -421,7 +422,18 @@ export async function provisionBindings(
421422
);
422423
}
423424

425+
const resourceCount = pendingResources.reduce(
426+
(acc, resource) => {
427+
acc[resource.resourceType] ??= 0;
428+
acc[resource.resourceType]++;
429+
return acc;
430+
},
431+
{} as Record<string, number>
432+
);
424433
logger.log(`🎉 All resources provisioned, continuing with deployment...\n`);
434+
metrics.sendMetricsEvent("provision resources", resourceCount, {
435+
sendMetrics: config.send_metrics,
436+
});
425437
}
426438
}
427439

packages/wrangler/src/metrics/send-event.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ export type EventNames =
8181
| "list pipelines"
8282
| "delete pipeline"
8383
| "update pipeline"
84-
| "show pipeline";
84+
| "show pipeline"
85+
| "provision resources";
8586

8687
/**
8788
* Send a metrics event, with no extra properties, to Cloudflare, if usage tracking is enabled.

0 commit comments

Comments
 (0)