Skip to content

send User-Agent: insta-cli/<version> to the platform - #172

Merged
Fermionic-Lyu merged 1 commit into
mainfrom
feat/user-agent
Sep 2, 2026
Merged

send User-Agent: insta-cli/<version> to the platform#172
Fermionic-Lyu merged 1 commit into
mainfrom
feat/user-agent

Conversation

@Fermionic-Lyu

@Fermionic-Lyu Fermionic-Lyu commented Sep 2, 2026

Copy link
Copy Markdown
Member

Every platform call now carries User-Agent: insta-cli/<version> so the platform can attribute analytics events to the CLI (insta-platform's analytics reads insta-cli/<v> / insta-mcp/<v>; everything else is other). The version comes from the existing sources — INSTA_CLI_VERSION baked by bun build --define, else the installed package.json — now resolved in one place, src/version.ts, replacing the two identical resolvers in src/index.ts and src/commands/feedback.ts. ApiClient takes an injectable fetchImpl (same shape as FeedbackDeps.fetchImpl) so the header is testable without stubbing globals.

Verification: npm run typecheck && npm test green (49 files, 693 tests); test/user-agent.test.ts pins the header to insta-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

  • Consolidates version resolution into src/version.ts, replacing the duplicate resolvers in src/index.ts and src/commands/feedback.ts.
  • ApiClient takes an injectable fetchImpl, so the header is testable without stubbing globals.

Written for commit 933494b. Summary will update on new commits.

Review in cubic

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>

@agent-zhang-beihai agent-zhang-beihai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@agent-zhang-beihai agent-zhang-beihai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jwfing jwfing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - approved.

@Fermionic-Lyu
Fermionic-Lyu merged commit bc13b09 into main Sep 2, 2026
3 checks passed
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.

2 participants