Repository navigation
feat: send the shared Doist CLI usage headers on every request - #114
Merged
Merged
Conversation
comms-cli only sent Doist-Platform and Doist-Version. It now uses @doist/cli-core's createUsageTracking (1.9.0), the same set todoist-cli and automations-cli send: User-Agent comms-cli/<version>, doist-platform, doist-version, doist-os, a request-id per request, a session-id per run and cli-command naming the command that made the request. The headers go on every Comms SDK request (worked out per request), the raw search fetch, and the OAuth token and refresh requests. A preAction hook records the command, and `tdc view <url>` relabels its requests to the routed command (thread:view, msg:view, ...). src/lib/attribution.ts is replaced by src/lib/usage-tracking.ts.
doistbot
reviewed
Nov 10, 2026
doistbot
left a comment
Member
There was a problem hiding this comment.
This PR swaps the old static attribution headers for the shared Doist CLI usage-tracking set from cli-core 1.9.0, wiring it consistently across the SDK client, the raw search fetch, the OAuth token/refresh requests, and both command programs (including the tdc view routing proxy). The implementation reuses cli-core's createUsageTracking/mergeHeaders rather than reimplementing header construction, tests cover the header flow through real program.parseAsync runs, and no security, privacy, or reuse issues were found.
Few things worth tightening:
- The test named "a new request ID across the requests of a run" actually compares headers from two separate runs, so it would pass even if
request-idwere generated once per command invocation. Capture two headers from the sameheadersSentBy('thread', ...)call and assert they differ to pin per-request uniqueness.
The test compared a tdc user run with a tdc thread run, so a request ID made once per run would still have passed. It now takes the two requests of one tdc thread run and checks they share a session ID but not a request ID.
doist-release-bot Bot
added a commit
that referenced
this pull request
Nov 10, 2026
## [4.1.0](v4.0.0...v4.1.0) (2026-11-10) ### Features * send the shared Doist CLI usage headers on every request ([#114](#114)) ([c09e909](c09e909))
Contributor
|
🎉 This PR is included in version 4.1.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Summary
comms-cli only told the backend
Doist-Platform: cliandDoist-Version. It now sends the shared Doist CLI header set from@doist/cli-core1.9.0 (createUsageTracking, todoist/cli-core#176), the same set todoist-cli sends and automations-cli is moving to, so Comms API logs can tell which command, OS and CLI run a request came from.User-Agentcomms-cli/<version>doist-platformclidoist-versiondoist-osmacos/linux/windows/unknownrequest-idsession-idcli-commandthread:view,searchNo identifying data is added: both IDs are random and nothing is persisted.
What changed
src/lib/usage-tracking.tsreplacessrc/lib/attribution.ts: one tracker per process,trackCommandUsage(program)(thepreActionhook that records the command) andwithUsageHeaders(fetch)for requests that bypass the SDK.headers: () => usageTracking.headers(), so each request gets its ownrequest-id.comms-cli/<version>as theirUser-Agentinstead of the OAuth library's.tdc view <url>puts the hook on its routing program as well, so its requests are labelled with the routed command (thread:view) rather thanview.The Comms backend already reads the
doist-*headers intoclient_info, sodoist-osshould show up in Datadog straight away.request-id,session-idandcli-commandaren't read by the backend yet; recording them is a backend follow-up.Test plan
npm run verifyprogram.parseAsyncand assert the headers reaching the SDK: the full set fortdc user,thread:viewfortdc thread <id>,tdc thread view <id>andtdc view <thread URL>, one session ID and different request IDs across a run. The search, OAuth exchange and refresh tests assert the headers on the raw fetch.tdc usersentcli-command: userandtdc thread id:…sentcli-command: thread:viewon boththreads/getoneandcomments/get, sharing onesession-idwith a differentrequest-ideach