feat(fetch): identify CLI with a Clerk-CLI User-Agent header#301
Conversation
🦋 Changeset detectedLatest commit: f71b7dd The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
📝 WalkthroughWalkthroughThis pull request implements a Clerk-CLI-specific User-Agent header for outbound HTTP requests. A new Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Sets `Clerk-CLI/<version> (Bun/<v>; <platform>-<arch>[; ci])` on every outbound request via the central loggedFetch helper, replacing Bun's default `Bun/<v>` UA so Clerk's edge can route or filter CLI traffic separately (e.g. to dedicated PLAPI Cloud Run services). Also routes the lone direct fetch() in api/catalog through loggedFetch so it picks up the UA and gets the standard debug logging.
bbb6439 to
f71b7dd
Compare
| import { DEV_CLI_VERSION, resolveCliVersion } from "./version.ts"; | ||
|
|
||
| export function buildUserAgent(): string { | ||
| const version = resolveCliVersion() ?? DEV_CLI_VERSION; |
There was a problem hiding this comment.
In the future it would be nice to encapsulate this as like getCliVersion() so callers don't need to worry about the fallback.
Summary
User-Agent: Clerk-CLI/<version> (Bun/<v>; <platform>-<arch>[; ci])on every outbound request via the centralloggedFetchhelper, replacing Bun's defaultBun/<v>so Clerk's edge can route or filter CLI traffic separately.fetch()inapi/catalogthroughloggedFetch, picking up both the UA and standard debug-logging behavior (also fixes a pre-existing violation of.claude/rules/debug-logging.md).User-Agentvia headers (verified infetch.test.ts).Test plan
bun run format— cleanbun run lint— 0 warnings, 0 errorsbun run typecheck— passesbun run build— passesuser-agent.test.ts+fetch.test.tscover UA shape, caller override, platform/arch, CI marker, printable-ASCII — all greentoken-exchange.test.tsto read headers viaHeaders.get()(the helper now passes aHeadersinstance through)Clerk-CLI/...instead ofBun/...