Add telemetry for detecting whether AI coding agents have Cloudflare skills installed#13868
Conversation
🦋 Changeset detectedLatest commit: f62f04d The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
✅ All changesets look good |
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
There was a problem hiding this comment.
I'm Bonk, and I've done a quick review of your PR.
This PR adds telemetry to detect whether the current AI coding agent has Cloudflare skills installed, reporting "automatic", "manual", false, or null to telemetry events.
Issues (ranked by severity)
-
Bug: Cache filename mismatch between tests and production code — The constant
SKILLS_REPO_CACHE_FILENAMEis"cloudflare-skills-repo-cache.json"(line 223 ofagents-skills-install.ts), but both cache tests write to"skills-repo-cache.json". This means the production code never finds the cache file during tests. I confirmed both "uses cached GitHub API response within TTL" and "falls back to stale cache when GitHub API returns an error" fail locally. -
Bug: Missing
metadata.acceptedcheck may misclassify"manual"installs as"automatic"—computeTelemetryCurrentAgentSkillsInstalled(line 409) returns"automatic"whenisInNeedingInstall && !isInCopyFailed, but doesn't verifymetadata.accepted === true. TheinstallCloudflareSkillsGloballyfunction writesagentsNeedingInstallto the metadata file even when the user declines the prompt (accepted: false). If the user declines Wrangler's prompt but later installs skills manually, the telemetry would incorrectly report"automatic"instead of"manual".
| const configDir = getGlobalWranglerConfigPath(); | ||
| mkdirSync(configDir, { recursive: true }); | ||
| writeFileSync( | ||
| path.join(configDir, "skills-repo-cache.json"), |
There was a problem hiding this comment.
Bug: The production constant is "cloudflare-skills-repo-cache.json" but this uses "skills-repo-cache.json". The cache is never found, so fetchSkillNamesFromGitHub hits the (missing) MSW mock and the test fails. Same issue on line 866.
| path.join(configDir, "skills-repo-cache.json"), | |
| path.join(configDir, "cloudflare-skills-repo-cache.json"), |
| const configDir = getGlobalWranglerConfigPath(); | ||
| mkdirSync(configDir, { recursive: true }); | ||
| writeFileSync( | ||
| path.join(configDir, "skills-repo-cache.json"), |
There was a problem hiding this comment.
Same filename mismatch as above:
| path.join(configDir, "skills-repo-cache.json"), | |
| path.join(configDir, "cloudflare-skills-repo-cache.json"), |
| (agent) => agent.globalSkillsPath === matchingAgent.globalSkillsPath | ||
| ); | ||
|
|
||
| if (isInNeedingInstall === true && !isInCopyFailed) { |
There was a problem hiding this comment.
This should also check metadata.accepted === true. When the user declines the install prompt, installCloudflareSkillsGlobally still writes the metadata with accepted: false and a populated agentsNeedingInstall array. If the user later manually installs skills, this condition passes and telemetry reports "automatic" instead of "manual".
| if (isInNeedingInstall === true && !isInCopyFailed) { | |
| if (metadata.accepted && isInNeedingInstall === true && !isInCopyFailed) { |
|
Review submitted successfully on PR #13868 with three actionable findings:
|
34c9efd to
f62f04d
Compare
Fixes https://jira.cfdata.org/browse/DEVX-2608
Wrangler now includes a
currentAgentSkillsInstalledproperty in telemetry events that reports whether the current AI coding agent has Cloudflare skills present on disk. The value distinguishes between skills installed automatically by Wrangler ("automatic"), skills installed manually by the user ("manual"), no skills present (false), or no supported agent detected (null). Skill names are fetched from the GitHub Contents API with a 24-hour disk cache to avoid rate limits.Note
This merges on top of the changes in #13846, so 13846 needs to be merged first
telemetry.md(34c9efd)A picture of a cute animal (not mandatory, but encouraged)