send User-Agent: insta-cli/<version> to the platform - #172
Conversation
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
There was a problem hiding this comment.
Reviewed by Yang Dong
This centralizes CLI version resolution and adds the versioned User-Agent to every control-plane request, including authentication refreshes. The npm and standalone-binary version paths remain correct, so I would approve this change.
No findings.
There was a problem hiding this comment.
Reviewed by Wang Miao
Every control-plane request now carries User-Agent: insta-cli/<version>, and the two copy-pasted version resolvers in index.ts and commands/feedback.ts collapse into a single src/version.ts. I checked the relative package.json path from the new module's location in both layouts (src/version.ts → repo root under tsx/vitest, dist/version.js → package root under npm, --define for the bun binary), confirmed api.ts is the only client that talks to the platform, and confirmed insta-platform actually consumes the header (src/server.ts:282, threaded into the auth/session records). npm run typecheck and the 693-test suite pass. The injected fetchImpl seam matches how telemetry.ts, upgrade.ts, feedback.ts and storage.ts already take one.
No findings.
Every platform call now carries
User-Agent: insta-cli/<version>so the platform can attribute analytics events to the CLI (insta-platform's analytics readsinsta-cli/<v>/insta-mcp/<v>; everything else isother). The version comes from the existing sources —INSTA_CLI_VERSIONbaked bybun build --define, else the installedpackage.json— now resolved in one place,src/version.ts, replacing the two identical resolvers insrc/index.tsandsrc/commands/feedback.ts.ApiClienttakes an injectablefetchImpl(same shape asFeedbackDeps.fetchImpl) so the header is testable without stubbing globals.Verification:
npm run typecheck && npm testgreen (49 files, 693 tests);test/user-agent.test.tspins the header toinsta-cli/${cliVersion()}.🤖 Generated with Claude Code
Summary by cubic
Every platform call now sends
User-Agent: insta-cli/<version>so the platform can attribute analytics events to the CLI.Refactors
src/version.ts, replacing the duplicate resolvers insrc/index.tsandsrc/commands/feedback.ts.ApiClienttakes an injectablefetchImpl, so the header is testable without stubbing globals.Written for commit 933494b. Summary will update on new commits.