Send wk-cli/<version> User-Agent so telemetry can attribute releases#83
Open
waprin wants to merge 4 commits into
Open
Send wk-cli/<version> User-Agent so telemetry can attribute releases#83waprin wants to merge 4 commits into
waprin wants to merge 4 commits into
Conversation
The backend telemetry pipeline attributes CLI requests by their User-Agent header (the old workato-platform-cli sends "workato-platform-cli/<version>"). Here the header was a hardcoded const userAgent = "wk/dev", so every release reported "wk/dev" and its traffic was indistinguishable across versions. The MCP client sent no User-Agent at all. Build-time version info is already injected via goreleaser ldflags into main.version/commit/date, but only flowed to the `version` command, not the HTTP clients. This wires it through: - Add internal/version: single source of truth for build version, exposing UserAgent() -> "wk/<version>" (keeps the existing "wk" product token; mirrors the old CLI's product/version convention). - main.go records the ldflags values via version.Set (var names kept as main.version/commit/date so existing -X flags keep working). - Remove the duplicated version state from internal/commands; the version command now reads from the shared package. - Replace the hardcoded `const userAgent = "wk/dev"` and its three call sites (api do/doRaw and package upload) with version.UserAgent(). - Add the User-Agent header to the MCP client (it had none) and wire the real version into its clientInfo. Verified: go build/vet/test all pass; a release build (-X main.version=1.0.6-beta) reports the injected version, and a wire test confirms the header reaches the network. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Two changes from review feedback: - Change the User-Agent product token from "wk" to "workato-cli". The nginx access-log field telemetry lands in is analyzed/tokenized, so the short "wk" token collides with stray "wk" tokens in unrelated user-agents (e.g. Customer.io), forcing fragile exclusion filters in the dashboards. "workato-cli" matches cleanly as a phrase and mirrors the old Python CLI's distinctive "workato-platform-cli" convention. The command stays `wk`; only the telemetry token changes. - Normalize a leading "v" in Set() via strings.TrimPrefix. Git tags are "v1.0.6-beta"; goreleaser strips the "v" but the Makefile's `git describe` does not, so without this the User-Agent differed by build path. Now it's consistently "workato-cli/1.0.6-beta". - Add internal/version/version_test.go covering Set/accessors, the User-Agent format, the v-prefix stripping, and the dev fallback. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
…easer Spell out, where the version vars are defined, that the values come from the linker's -X flags declared in both the Makefile (via `git describe`) and .goreleaser.yaml, and that plain `go run`/`go build` leaves the defaults. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Switch the telemetry token from workato-cli to wk-cli. wk-cli filters cleanly as a phrase (avoiding the bare "wk" collision) and matches the token the original beta builds already sent, so it reconnects with existing telemetry history instead of starting a new naming era. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
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.
Problem
The backend telemetry pipeline attributes CLI requests by their
User-Agentheader (the oldworkato-platform-clisendsworkato-platform-cli/<version>). In this CLI the header was a hardcodedconst userAgent = "wk/dev", so every release reportedwk/devand could not be told apart by version. The MCP client sent noUser-Agentat all.Build-time version info is already injected via ldflags into
main.version/commit/date(declared in the Makefile and .goreleaser.yaml), but it only flowed to thewk versioncommand, not the HTTP clients.Change
internal/version— single source of truth for the build version, exposingUserAgent()->wk-cli/<version>.main.gorecords the ldflags values viaversion.Set. Themain.version/commit/datevar names are unchanged, so the existing-Xflags keep working.internal/commands— removed the duplicated version state +SetVersionInfo; theversioncommand now reads from the shared package.internal/api— replacedconst userAgent = "wk/dev"and its three call sites withversion.UserAgent().internal/mcp— added theUser-Agentheader (it had none) and wired the real version intoclientInfo.vinSet()so the token is consistent across build paths (goreleaser stripsv, the Makefile does not).internal/version/version_test.gocovers accessors, the User-Agent format,v-prefix stripping, and the dev fallback.Why wk-cli, not bare wk
The nginx access-log field telemetry lands in is analyzed/tokenized, with no
keywordsub-field. A 2-char token likewkcollides with straywktokens in unrelated user-agents (e.g. Customer.io), forcing fragile exclusion filters in dashboards.wk-clifilters cleanly as a phrase, and it matches the token the original beta builds already sent — so telemetry stays continuous. The command itself stayswk; only the telemetry token changes.Result
go buildwk-cli/devv1.0.6-betawk-cli/1.0.6-betaVerification
go build,go vet,go test ./...all pass; a release build (-X main.version=v1.0.6-beta) reports1.0.6-betaand sendswk-cli/1.0.6-beta.🤖 Generated with Claude Code