Skip to content

Commit 70d3d4a

Browse files
authored
Add telemetry to autoconfig (#11199)
* Add metrics for autoconfig * Update telemetry.md language * Create good-cups-boil.md
1 parent 88aa707 commit 70d3d4a

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

.changeset/good-cups-boil.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+
Add telemetry to autoconfig

packages/wrangler/src/autoconfig/run.ts

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { runCommand } from "../deployment-bundle/run-custom-build";
66
import { confirm } from "../dialogs";
77
import { getCIOverrideName } from "../environment-variables/misc-variables";
88
import { logger } from "../logger";
9+
import { sendMetricsEvent } from "../metrics";
910
import { getDevCompatibilityDate } from "../utils/compatibility-date";
1011
import { addWranglerToAssetsIgnore } from "./add-wrangler-assetsignore";
1112
import { addWranglerToGitIgnore } from "./c3-vendor/add-wrangler-gitignore";
@@ -14,9 +15,28 @@ import { displayAutoConfigDetails } from "./details";
1415
import type { AutoConfigDetails } from "./types";
1516
import type { RawConfig } from "@cloudflare/workers-utils";
1617

18+
type AutoconfigMetrics = Pick<
19+
AutoConfigDetails,
20+
"buildCommand" | "outputDir"
21+
> & {
22+
framework: string | undefined;
23+
};
24+
1725
export async function runAutoConfig(
1826
autoConfigDetails: AutoConfigDetails
1927
): Promise<void> {
28+
const detected: AutoconfigMetrics = {
29+
buildCommand: autoConfigDetails.buildCommand,
30+
outputDir: autoConfigDetails.outputDir,
31+
framework: autoConfigDetails.framework?.name,
32+
};
33+
sendMetricsEvent(
34+
"autoconfig detected",
35+
{
36+
detected,
37+
},
38+
{}
39+
);
2040
displayAutoConfigDetails(autoConfigDetails);
2141

2242
const deploy = await confirm("Do you want to deploy using these settings?");
@@ -76,5 +96,20 @@ export async function runAutoConfig(
7696
);
7797
}
7898

99+
const used: AutoconfigMetrics = {
100+
buildCommand: autoConfigDetails.buildCommand,
101+
outputDir: autoConfigDetails.outputDir,
102+
framework: autoConfigDetails.framework?.name,
103+
};
104+
105+
sendMetricsEvent(
106+
"autoconfig accepted",
107+
{
108+
detected,
109+
used,
110+
},
111+
{}
112+
);
113+
79114
return;
80115
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ export type EventNames =
8282
| "delete pipeline"
8383
| "update pipeline"
8484
| "show pipeline"
85-
| "provision resources";
85+
| "provision resources"
86+
| "autoconfig detected"
87+
| "autoconfig accepted";
8688

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

packages/wrangler/telemetry.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ Telemetry in Wrangler allows us to better identify bugs and gain visibility on u
1212

1313
- What command is being run (e.g. `wrangler deploy`, `wrangler dev`)
1414
- Anonymized arguments and flags given to Wrangler (e.g. `wrangler deploy ./src/index.ts --dry-run=true --outdir=dist` would be sent as `wrangler deploy REDACTED --dry-run=true --outdir=REDACTED`)
15-
- Anonymized information about your Worker (e.g. whether or not Workers Assets is being used, whether or not TypeScript is being used)
15+
- Anonymized information about your Worker. For instance, this can include (this list is non-exhaustive):
16+
- Whether or not Workers Assets is being used, along with the output directory
17+
- Whether or not TypeScript is being used
18+
- The framework being used
19+
- The build command being used
1620
- Information about your connection to Cloudflare's API (e.g. how long it takes Wrangler to deploy your Worker)
1721
- The version of the Wrangler client that is sending the event
1822
- The package manager that the Wrangler client is using. (e.g. npm, yarn)

0 commit comments

Comments
 (0)