Skip to content

feat: attribute CLI requests and call the v1.0 API - #88

Merged
roryist merged 6 commits into
mainfrom
roryist/doist-platform-header
Oct 21, 2026
Merged

roryist merged 6 commits into
mainfrom
roryist/doist-platform-header

Conversation

@roryist

@roryist roryist commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

TL;DR

Every request the CLI makes now tells Comms who it is (Doist-Platform: cli plus Doist-Version with the CLI's own release) and calls the canonical v1.0 API. What the requests do is unchanged.

Why

Comms tags every request's traces, metrics and logs with the calling platform and its version, so we can watch old versions drain off and know when it's safe to turn things off. The CLI was invisible in that picture: it sent no attribution headers, so its traffic showed up as unknown.

The SDK couldn't carry extra headers until comms-sdk#104 and #105 shipped in v3.7.0 today, so this PR started with just the one search call that bypasses the SDK, and now covers both.

What changes

Request path Before After
SDK-routed calls (everything else) no attribution Doist-Platform: cli + Doist-Version
Direct-fetch search no attribution Doist-Platform: cli + Doist-Version

The SDK dependency moves 3.4.0 → 3.8.1 (feature releases only, no breaking changes), which also flips the default API version to v1.0 (comms-sdk#107). The direct-fetch search path derives its version from the SDK's DEFAULT_API_VERSION instead of hardcoding it, and both paths share one exported headers constant, so neither the version nor the attribution can drift between them. The Doist-Version value is the CLI's own package.json version, the same one tdc --version prints.

No new metrics here: the server side already counts these tags (comms-backend#1122/#1124/#1127); healthy looks like platform:cli replacing a slice of platform:unknown once this releases.

Things to look at

  • The two existing client-construction tests now expect the headers object; a loosened matcher (stringMatching) keeps them from breaking on every release bump.
  • The SDK merges custom headers case-insensitively since v3.7.0, so these can't clobber Authorization.

References

Part of the client-attribution work: comms-web#1456, comms-ios#803, Todoist#30806.

(Written by Rory's agent)

🤖 Generated with Claude Code

The backend attributes traffic by the Doist-Platform header; without it the CLI's requests show up as 'unknown'. This covers the CLI's one direct fetch (extended search). SDK-routed requests follow once @doist/comms-sdk ships its new headers option.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The SDK's headers option shipped in @doist/comms-sdk 3.7.0, so the CLI
can now attribute every request, not just the direct-fetch search path.
Both paths send Doist-Platform: cli and Doist-Version (the package
version).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@roryist roryist changed the title feat: send Doist-Platform header on search requests feat: attribute CLI requests to Comms via Doist headers Oct 21, 2026
@roryist roryist added the 👀 Show PR requires passing checks before merge and independent human review before or after merge. label Oct 21, 2026
@roryist
roryist marked this pull request as ready for review October 21, 2026 09:17

@doistbot doistbot 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.

This PR cleanly adds Doist-Platform: cli and Doist-Version attribution headers to both the SDK-routed requests and the direct-fetch search call, with tests updated to match and no inline issues flagged.

I also included a few optional follow-up notes in the details below.

Optional follow-up notes (2)
  • P3 src/lib/search-api.ts:109: The attribution headers ('Doist-Platform'/'Doist-Version' plus the packageJson import) are now duplicated in api.ts and search-api.ts. Search is exactly the path that was missed when attribution was first added, so drift here is plausible. Consider exporting a shared constant (e.g. from a small lib module) and using it in both places.
  • P3 src/lib/api.test.ts:138: Doist-Version is only checked for semver shape, so a hardcoded placeholder like 0.0.0 would pass even though the stated contract is that the value is package.json.version. Importing packageJson in the test and asserting equality is just as release-bump-proof as stringMatching and matches the existing pattern in src/commands/update/update.test.ts. The same matcher is used at src/lib/api.test.ts:150 and src/lib/search-api.test.ts:56.

Share Feedback • Review Logs

roryist and others added 4 commits October 21, 2026 11:33
Review follow-ups: one exported constant instead of two copies, and
tests pin Doist-Version to package.json's version rather than a shape.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The version was hardcoded three times; DEFAULT_API_VERSION is a root
SDK export, so search now moves with the SDK-routed calls on any bump.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@doist/comms-sdk 3.8.1 defaults to v1.0; the search path derives its
version from the same constant, so both flip together.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@roryist roryist changed the title feat: attribute CLI requests to Comms via Doist headers feat: attribute CLI requests and call the v1.0 API Oct 21, 2026
@roryist
roryist merged commit 78685f4 into main Oct 21, 2026
7 checks passed
@roryist
roryist deleted the roryist/doist-platform-header branch October 21, 2026 12:20
doist-release-bot Bot added a commit that referenced this pull request Oct 21, 2026
## [3.7.0](v3.6.6...v3.7.0) (2026-10-21)

### Features

* attribute CLI requests and call the v1.0 API ([#88](#88)) ([78685f4](78685f4))
@doist-release-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 3.7.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released 👀 Show PR requires passing checks before merge and independent human review before or after merge.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants