Skip to content

API: recordDesktopInstallation, record the OpenBot Desktop installation the caller signed in from - #2932

Draft
ACl365 wants to merge 3 commits into
mainfrom
alex/2026-12-04/record-desktop-installation-spec
Draft

ACl365 wants to merge 3 commits into
mainfrom
alex/2026-12-04/record-desktop-installation-spec

Conversation

@ACl365

@ACl365 ACl365 commented Dec 4, 2026 •

Copy link
Copy Markdown
Contributor

What this changes

Adds one operation to the spec, recordDesktopInstallation (POST /api/v2/people/me/desktop-installations), so usage data can join what an OpenBot Desktop installation did before a sign-in with what the person does after it. Spec first: the spec, the bundle, the generated clients and a spec test. No app sends it yet and no server answers it yet; that comes in the follow-up.

OpenBot Cloud only. Desktop hands the id to the page, or sends it itself, only when the address it signed in to is OpenBot Cloud: a self-hosted OpenBot never receives it from Desktop, and the server still drops a valid report where product telemetry is off. The callers are the window's page with its session, and Desktop with its own sign-in, which today is Move to Cloud's.

  • Window sign-in (OpenBot Cloud). Desktop hands the page the installation's usage-data id in the same fragment as the code, only while the person shares usage data. Once the page has traded the code, it sends the id with its own session, with keepalive, and goes on to next without waiting. Desktop never uses the window's cookie.
  • Relay sign-in (Move to Cloud's, today). Desktop sends the same body with its own sign-in (appOAuth; Desktop's openbot scope covers conversations:write).

The body is one field, installationId: the random (version 4) UUID Desktop sends its usage data under at the sign-in, which Desktop's own events already carry as their deployment_id. Desktop makes a new one when usage data is turned off and on again, or when the account it is tied to changes or signs out. Any other UUID version (v1 carries a time and a hardware address, v7 a time) and any other field are refused. The answer is 204, including where product telemetry is off and the report is dropped.

A client sends it once per sign-in with a new Idempotency-Key, waits on nothing, and treats any answer but 204 alike, never retrying. So an older OpenBot that answers 404 changes nothing; Desktop is often newer than the OpenBot it connects to, and the window's page always comes from the same server it calls. The server's event id is a hash of the deployment scope, the caller's pseudonym and the lower-cased installation id, so it repeats for the same caller and installation, and distinct ids count each link once per deployment.

Dedupe: the event id is made from the deployment, the caller's pseudonym and the lower-cased installation id, so the window and Move to Cloud sending it for one person count once.

When the server half lands, it sends oss.runtime.openbot.desktop_installation_linked with the common properties, installation_id (lower-cased), and credential (session or app_token), which the server reads from the credential itself, never from the body. docs/TELEMETRY.md gains that line with it.

API keys are left out on purpose. The other product events accept one. This one records a sign-in from an installation, which an API key never is, and leaving it out is the direction that can change later: a scheme can be added, never taken away.

Why it sits outside an organization

The window's page has just traded the code when it sends this, and it knows no organization yet: /desktop/signed-in is outside the signed-in area, and the current organization is unknown until the organization list answers. A fresh relay sign-in names none either. An installation is the person's, not an organization's, and the event's pseudonym doesn't depend on one. So the address sits beside /api/v2/people/me/organizations, as /api/v2/app-errors and account deletion do, and the lint rule's list of addresses outside an organization gains it with that reason; api/redocly/rules.test.ts pins it.

The alternative turned down: /api/v2/organizations/{organizationId}/desktop-installations, sent once the client knows an organization. The page would have to wait for the organization list before it moves on from the sign-in, and Desktop would have to read the caller's organizations page by page on the relay path, for an organization the event doesn't use.

Where it runs

  • New state that outlives a request? Only the Idempotency-Key record every write keeps. The stable event id is a hash, so nothing is stored to make it.
  • What happens on the second replica? Any replica answers. Replicas that share deployment_id and KEY_ENCRYPTION_KEY give the same pseudonym and event id.
  • Anything serialised? No.
  • Anything fanned out to a browser? No.
  • New listener, port, or schedule? No: one new operation on the existing API.

Boundary and audit

  • Every acting call still goes through the gateway. A link is product telemetry, not an action, like the nudges' count.
  • New refusals and new failures each write a row? No row, as for the other product events. A refusal is a problem answer (400, 401, 403, 409, 413, 429).
  • Nothing new is trusted from the client that the server can resolve itself. The person comes from the session or the token. Whether the report came through the window or the relay sign-in is the server's to tell from the credential, so the body doesn't carry it. Only the installation id comes from the client, and only as a version 4 UUID.

API and database

  • This changes api/ and keeps every rule in docs/api-and-migrations.md: one new operation, and nothing removed, renamed, retyped or tightened. No app's requests change yet. There is no database change and no release-policy.json change. This box gets ticked once CI's box below is.
  • I read this page.
  • Nothing a released app uses is removed, renamed, retyped or tightened in place.
  • No existing operation gains an input; no response enum is added.
  • Nothing is deprecated.
  • Nothing new in api/accepted-breaking-changes.md. The file is unchanged.
  • bun run api:generate run, with sources, bundle and clients committed together. At the head it changes nothing, and bun run api:lint is valid.
  • No database change.
  • release-policy.json unchanged.
  • CI's API spec job is green on the exact head. It hasn't run yet; see CI below.

Changelog

API.

  • Added to the spec: POST /api/v2/people/me/desktop-installations (recordDesktopInstallation). Says which OpenBot Desktop installation the caller signed in from, by the installation's random usage-data id, and only while the person shares usage data. It is best effort, and is accepted and dropped where product telemetry is off. No app sends it and no server answers it in this release.

Proof

Tests across each boundary

  • api/openapi-desktop-installations.test.ts (new, 5 tests) reads the bundle the server and clients are built from: one POST with a required Idempotency-Key; 204 as the only success, with no body; no organization parameter and no 404; exactly webSession or appOAuth conversations:write, the scope the other product events ask for; Desktop's openbot scope (connected/address.rs) covers it; the body is one installationId, and the generated schema, made strict as the server reads it, accepts the spec's own example and upper-case hex, and refuses not-a-uuid, {}, v1, v7, the nil UUID, and any extra field (email, organizationId, signInPath). The fifth pins the description's lines on who may receive the id (OpenBot Cloud only), every caller, and the dedupe key.
  • api/redocly/rules.test.ts pins the new address on the list outside an organization.
  • The Desktop sender and the page come in the follow-up, each tested against this spec.

Routes

The operation has one address and two callers. Every way a sign-in reaches it is the follow-up's route table (window sign-in with usage data on or off, a failed trade, a page from an older server, relay sign-in, sign in again, a resumed saved sign-in, sign-out or opt-out mid-flight, a server without the operation). This PR adds none of those code paths.

Red/green

  • On origin/main's bundle, the new test file fails 4 of 4. On this branch, 4 of 4 pass.
  • With origin/main's api/redocly/rules.mjs, bun run api:lint refuses the address: "/api/v2/people/me/desktop-installations is not under /api/v2/organizations/{organizationId}/". With this branch's, it is valid.

Local runs

  • bun run api:generate, twice: the second run changes nothing.
  • bun run api:lint: valid.
  • oasdiff breaking against origin/main's bundle with the flags in docs/api-and-migrations.md: no breaking changes.
  • bun test api/openapi-desktop-installations.test.ts api/redocly/rules.test.ts api/client-boundary.test.ts api/openapi-request-bodies.test.ts api/openapi-request-id.test.ts api/openapi-text-patterns.test.ts api/openapi-rate-limit.test.ts: 25 pass, 0 fail. The whole bun test api/: 141 pass, 14 skip, 0 fail.
  • bunx biome format .: no fixes.

Real build

None: nothing in this PR runs in an app or on a server.

CI

Green on the first head (35 pass, 3 skipped), after two re-runs of unrelated browser tests that failed on timing. Running on this head.

Merge order

Any order with #2927. Both add a line after nudge-events in api/openapi/conversations.yaml's product events and regenerate product-events.*. Whichever merges second runs bun run api:bundle && bun run api:generate after the rebase and commits what changes.

Rollback

Revert the commit. No app sends it and no server answers it yet.

…on the caller signed in from

A new operation, POST /api/v2/people/me/desktop-installations, so usage
data can join what an OpenBot Desktop installation did before a sign-in
with what the person does after it. One operation for both ways Desktop
signs in: where the window holds the sign-in, Desktop hands the page the
installation's usage-data id with the sign-in's code, and the page sends
it with its own session once the code is traded; where Desktop signs in
itself, Desktop sends it with that sign-in. Desktop hands the id over only
while the person shares usage data.

The body is one random (version 4) UUID, installationId, and nothing
else; any other version is refused. A client sends it once per sign-in
with a new Idempotency-Key and never retries, so an older server's 404
changes nothing. The server sends it with its product
telemetry beside the caller's pseudonym, with an event id that repeats for
the same caller and installation, and accepts and drops it where product
telemetry is off (204 either way). webSession and appOAuth
(conversations:write, which Desktop's openbot scope covers) may send it;
an API key may not.

It sits outside an organization: an installation is the person's, and the
window's page has just signed in and names none. The lint rule's list of
addresses outside an organization gains it, with that reason.

api/openapi-desktop-installations.test.ts holds the spec to that: one
POST with an Idempotency-Key, 204 as the one success, the two sign-ins and
nothing else, and a strict body that refuses other UUID versions and any
other field. Spec only: no client sends it yet, and no server serves it.
…oud's sign-in as a caller

Desktop's usage-data switch is consent to CopilotKit, not to a company's
own server, so the description now says the id goes to OpenBot Cloud only:
Desktop hands it to the page, or sends it itself, only when the address
it signed in to is OpenBot Cloud, and a self-hosted OpenBot never
receives it from Desktop. The server still accepts and drops it where
product telemetry is off, whoever sends it.

It names Move to Cloud's sign-in as the caller where Desktop signs in
itself, and states the dedupe key: the event id is made from the
deployment, the caller's pseudonym and the lower-cased installation id,
so the window and Move to Cloud sending it for one person count once.

The spec test pins those three lines of the description.

This branch has not been deployed

No deployments
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.

1 participant