feat(api,desktop,trpc): client version header + per-procedure telemetry

Merged
SA
3mo ago
+134-67

Desktop cloud tRPC clients now send x-superset-client: desktop/<appVersion>; the API parses it into ctx.client, tags Sentry, and a sampled (1%) middleware on the shared procedure builders emits api_procedure_called with procedure + client product + version.

This is PR A of the API compatibility plan: it starts accumulating the per-procedure, per-client-version usage evidence that the CI contract gate and min-version floor (follow-up PRs) consume, and that the electric-proxy teardown will use as its adoption-drain signal.

Notes:

  • Absent/unparseable header = web or pre-header build, treated as always-current; ctx.client is null and nothing changes.
  • x-superset-client added to the API's CORS allow-list (renderer preflights).
  • Mobile/CLI headers intentionally deferred (mobile not in use; CLI needs version-embedding survey) — the parser already accepts mobile/… and cli/….
  • No behavior branches on version anywhere; this PR is purely observational.

https://claude.ai/code/session_01Rq18Ske93pkaTqTHByebtq


Summary by cubic

Desktop tRPC calls now include x-superset-client: desktop/<version>. The API parses it into ctx.client, tags Sentry, and samples per-procedure telemetry to track usage by client version.

  • New Features
    • Desktop renderer sends x-superset-client: desktop/<appVersion> on API requests.
    • API: CORS allows x-superset-client; parse into ctx.client; set @sentry/nextjs tag client=<product>/<version>.
    • packages/trpc: middleware (1% sample) emits api_procedure_called to posthog with procedure, client_product, client_version.
    • Parser accepts desktop|mobile|cli; missing/unparseable treated as web/pre-header (ctx.client null). No behavior changes.

Summary by CodeRabbit

  • Improvements
    • Improved API request compatibility for desktop clients by supporting client identification headers during browser security checks.
    • Desktop requests now consistently include authentication and app version information when available.
    • Added more complete client and version context to support troubleshooting and service performance monitoring.
    • Improved consistency for API calls from command-line integrations and other clients.