[DX-1114] Tag Web CLI traffic with a distinct Ably-Agent#366
Conversation
Adds a getAgentName() helper that resolves to "ably-web-cli" when ABLY_WEB_CLI_MODE=true and "ably-cli" otherwise, and routes all SDK agents options and Ably-Agent headers (status check, Control API) through it so Ably can attribute hosted Web CLI traffic separately from local CLI usage.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThis PR introduces a Changes
Review Notes
|
There was a problem hiding this comment.
Review Summary
| File | Status | Notes |
|---|---|---|
src/utils/version.ts |
OK | Clean helper, consistent with isWebCliMode() pattern used elsewhere |
src/base-command.ts |
OK | SDK agents option correctly switched to dynamic key |
src/commands/status.ts |
OK | Ably-Agent header updated consistently |
src/services/control-api.ts |
OK | Ably-Agent header updated consistently |
test/unit/base-command/agent-header.test.ts |
OK | Both modes covered; afterEach cleanup is correct |
No issues found
This is a clean, minimal change. The implementation correctly reads ABLY_WEB_CLI_MODE at call time (not at import time), so the agent name is resolved dynamically on every request — correct for env-var-driven mode switching. The abstraction through getAgentName() ensures all three callsites (SDK agents, status check header, Control API header) stay in sync automatically.
One pre-existing test oddity worth noting for future cleanup (not introduced by this PR): the "Version Format" describe block in agent-header.test.ts constructs `ably-cli/${version}` locally and checks its regex format, rather than calling getAgentName(). It always passes regardless of what getAgentName() returns, so it does not validate the Web CLI header format. Not a blocker — just worth a follow-up.
Ready to merge.
|
Btw, are we planning to deploy web CLI to ably domain, currently it's deployed on cli-web-cli.vercel.app |
A couple of things:
|
Intent
We need to be able to split CLI usage tracking by the web cli vs "actual" cli usage
Summary
getAgentName()helper insrc/utils/version.tsthat returnsably-web-cliwhenABLY_WEB_CLI_MODE=trueandably-cliotherwise.agentsoption (src/base-command.ts) and theAbly-Agentheader on both the status check (src/commands/status.ts) and Control API requests (src/services/control-api.ts) through the new helper, so hosted Web CLI traffic is attributable separately from local CLI usage.Test plan
pnpm preparepnpm exec eslinton changed files (0 errors)pnpm test test/unit/base-command/agent-header.test.ts(3 passed)🤖 Generated with Claude Code