Skip to content

Send wk-cli/<version> User-Agent so telemetry can attribute releases#83

Open
waprin wants to merge 4 commits into
workato-devs:developfrom
waprin:add-user-agent-version
Open

Send wk-cli/<version> User-Agent so telemetry can attribute releases#83
waprin wants to merge 4 commits into
workato-devs:developfrom
waprin:add-user-agent-version

Conversation

@waprin

@waprin waprin commented Jun 29, 2026

Copy link
Copy Markdown
Collaborator

Problem

The backend telemetry pipeline attributes CLI requests by their User-Agent header (the old workato-platform-cli sends workato-platform-cli/<version>). In this CLI the header was a hardcoded const userAgent = "wk/dev", so every release reported wk/dev and could not be told apart by version. The MCP client sent no User-Agent at 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 the wk version command, not the HTTP clients.

Change

  • Add internal/version — single source of truth for the build version, exposing UserAgent() -> wk-cli/<version>.
  • main.go records the ldflags values via version.Set. The main.version/commit/date var names are unchanged, so the existing -X flags keep working.
  • internal/commands — removed the duplicated version state + SetVersionInfo; the version command now reads from the shared package.
  • internal/api — replaced const userAgent = "wk/dev" and its three call sites with version.UserAgent().
  • internal/mcp — added the User-Agent header (it had none) and wired the real version into clientInfo.
  • Normalize leading v in Set() so the token is consistent across build paths (goreleaser strips v, the Makefile does not).
  • Testsinternal/version/version_test.go covers 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 keyword sub-field. A 2-char token like wk collides with stray wk tokens in unrelated user-agents (e.g. Customer.io), forcing fragile exclusion filters in dashboards. wk-cli filters cleanly as a phrase, and it matches the token the original beta builds already sent — so telemetry stays continuous. The command itself stays wk; only the telemetry token changes.

Result

Build User-Agent
dev / go build wk-cli/dev
release v1.0.6-beta wk-cli/1.0.6-beta

Verification

go build, go vet, go test ./... all pass; a release build (-X main.version=v1.0.6-beta) reports 1.0.6-beta and sends wk-cli/1.0.6-beta.

🤖 Generated with Claude Code

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>
@waprin waprin requested a review from cmworkato June 29, 2026 20:53
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>
@waprin waprin changed the title Send wk/<version> User-Agent so telemetry can attribute releases Send workato-cli/<version> User-Agent so telemetry can attribute releases Jun 30, 2026
waprin and others added 2 commits June 30, 2026 13:34
…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>
@waprin waprin changed the title Send workato-cli/<version> User-Agent so telemetry can attribute releases Send wk-cli/<version> User-Agent so telemetry can attribute releases Jun 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant