Add X-Gusto-CLI-Command request header per command - #166
Open
azrosen92 wants to merge 2 commits into
Open
Conversation
Stamp every Gusto API request with an X-Gusto-CLI-Command header carrying a slug of the command that issued it (e.g. employee-list, api-request), so request-log analytics can break CLI traffic down by command. Both structured commands and the raw `api request` escape hatch now carry it. Threaded via GlobalFlags -> buildApiClient -> ApiClient with no handler or helper signature changes: the runner injects the dispatched command onto a fresh globals copy, buildApiClient slugs it, and the client sets the header alongside the existing Authorization/Accept/version/User-Agent headers. The header rides every attempt, including a 404'd request. Surfaces with no command context (OAuth login) send nothing. Signed-off-by: Aaron Rosen <aaron.rosen@gusto.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The feedback command and any callMcpTool request build their client via the same buildApiClient path as the REST surfaces, so they carry X-Gusto-CLI-Command too. This is intended: the header attributes each API request to the command that issued it, and feedback is a real command. Add a focused unit test that stubs the transport, drives callMcpTool with a feedback command context, and asserts the outbound request carries the `feedback` slug. Also reflow a runner test line to satisfy the formatter. Signed-off-by: Aaron Rosen <aaron.rosen@gusto.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
jeff-gusto
approved these changes
Aug 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds an
X-Gusto-CLI-Command: <slug>request header to every Gusto API request the CLI makes. The slug is derived from the command name (e.g.api-request,employee-list), threaded viaGlobalFlags → buildApiClient → ApiClient. No handler or helper signatures change.Why
Today every request carries an identical
User-Agent, so requests can be identified as coming from the CLI but not attributed to which command produced them — a rawgusto api request(the escape hatch) is indistinguishable from a first-class command. This header makes CLI traffic breakable-down by command for observability; the raw escape hatch surfaces ascommand:api-request, which is a command-gap signal.The server-side consumer that turns this header into a span tag / metric ships separately.
Notes
callMcpTool, used bygusto feedback) also goes throughbuildApiClient, so those requests carry the header with their command slug — intended, accurate attribution.Testing
Unit tests cover: the header set with the expected slug and omitted when absent;
commandSlugmappings; the header riding through a 404; and the MCP path carrying the slug.typecheck+lintpass.Related: AINT-805. This is one of three CLI PRs for the ticket; it and the feedback-nudge PR both touch
runner.ts, so whichever merges second needs a trivial rebase.🤖 Generated with Claude Code