| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
Add getCliUserAgent() to sdk.mts that builds the CLI's full user agent string for direct (non-SDK) API calls, including the CLI product token, Node.js version, and OS platform/arch: socket/1.1.96 node/v22.0.0 linux/arm64 Add User-Agent header to queryApi() and sendApiRequest() which both go through apiFetch() bypassing the SDK. For SDK-routed calls the userAgent option already passes just the CLI product token (socket/1.1.96 ...) and the SDK constructs the full UA by prepending its own base including node/OS.
Adds the CLI's full user agent string to the env vars forwarded to the coana subprocess. Coana reads SOCKET_CALLER_USER_AGENT and appends it to its own base UA, producing a chain like: coana-tech-cli/15.3.0 node/v22.0.0 linux/arm64 socket/1.1.96 node/v22.0.0 linux/arm64
There was a problem hiding this comment.
This PR adds a full CLI User-Agent string for direct (non-SDK) HTTP calls and wires it into the raw API request helpers (plus propagates it to the Coana dlx environment) so backend services can reliably identify the CLI runtime.
Changes:
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/utils/sdk.mts | Adds getCliUserAgent() to generate/cached full CLI user agent string for non-SDK calls. |
| src/utils/dlx.mts | Propagates CLI UA to Coana via SOCKET_CALLER_USER_AGENT. |
| src/utils/api.mts | Sets User-Agent header on raw API calls made via apiFetch(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Sorry, something went wrong.
|
John-David Dalton (@jdalton) did this functionality land elsewhere or should I keep this PR around? |
Sorry, something went wrong.
api.test.mts and dlx.test.mts mocked ./sdk.mts without getCliUserAgent, so any test exercising queryApi/sendApiRequest or spawnCoanaDlx threw at the User-Agent call site instead of asserting real behavior. Add the missing mock export, assert the outgoing User-Agent header in api.mts requests, cover getCliUserAgent's format and caching in sdk.mts, and cover SOCKET_CALLER_USER_AGENT injection (and caller-env precedence) in spawnCoanaDlx.
|
We'll land and tweak when the SDK bump comes in, it's good to land this now, and optimize/reduce once we can, |
Sorry, something went wrong.
…1320) queryApi and sendApiRequest bypass the SDK, so the Socket API saw only the lib's generic agent and could not attribute the traffic to a CLI version. getCliUserAgent lives in its own module rather than sdk.mts, which the suite mocks wholesale.
| Back | FazBrowse Home | New Git URL |
Add getCliUserAgent() to sdk.mts that builds the CLI's full user agent
string for direct (non-SDK) API calls, including the CLI product token,
Node.js version, and OS platform/arch:
socket/1.1.96 node/v22.0.0 linux/arm64
Add User-Agent header to queryApi() and sendApiRequest() which both go
through apiFetch() bypassing the SDK.
For SDK-routed calls the userAgent option already passes just the CLI
product token (socket/1.1.96 ...) and the SDK constructs the full UA
by prepending its own base including node/OS.
Depends on: SocketDev/socket-sdk-js#638 https://github.com/coana-tech/coana-package-manager/pull/2225
Note
Cursor Bugbot is generating a summary for commit 3778a64. Configure here.