Skip to content

Commit 70e3669

Browse files
feat: telemetry for the workspace link lifecycle, usage, engine and starter (#1513)
* feat: telemetry for the workspace link lifecycle workspace_linked, workspace_created, workspace_switched, workspace_unlinked on the API success response; workspace_link_failed with a reason class; every failed workspace call reports workspace_api_error or workspace_auth_expired; every envelope carries client. The create-and-link hand-off follows the telemetry module's own decision when the config is unreadable. Closes #1508 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: report workspace_created on the unbound create path too The create-then-rebind flow for an already-linked project creates through createWorkspaceUnbound(); it now tracks workspace_created (how: create_unbound) on the success response and workspace_link_failed otherwise. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: attribute recovery-path unlinks, report bad 2xx bodies, mask every id The no-local-row unlink carries the server-found workspace id; an empty, unparseable or oversized 2xx body reports status_class "response"; endpoint masking keeps only route words, so memory and skill public ids never reach telemetry; the plugin test isolates OPENCODE_DISABLE_TELEMETRY. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: carry the server-found workspace id through a recovery-path unlink When no local row exists, manage.ts looks the binding up on the server before unlinking; the id it finds now reaches workspace_unlinked. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: send workspace ids as envelope properties, not measurements The envelope builder routed every number to measurements, so the new numeric workspace ids landed in customMeasurements; *_id fields now go to properties as strings, where the dashboards join on them. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: mask endpoints by route vocabulary, keep the status of a body that fails after the answer Only known static route words survive in the endpoint label, so an id spelled like a word is still masked; a body refused after the server answered (readBounded's cap) reports that answer's status class. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: mask endpoint ids by route position; keep the status when the body stalls On identifier-first routers (skills, memory) the first subpath segment is masked whatever it is spelled like; a body that times out after the server answered reports that answer's status class with the status. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: label endpoints from a route table Each router lists the shapes of its subpaths; ids and file paths are masked whatever they contain, and an unlisted shape or router is masked entirely. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * test: keep the id-properties test clear of the telemetry disable flags Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: keep the answered status on a failed link; check the created id inside the attempt A body that fails after the server answered now throws with that status, so the link failure is not classed as network; a create whose id is unusable is a failed link step, not a created workspace. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: classify a failed link by the answered status A 403, 404, 409 or 412 whose body then fails is the same class as a readable answer with that status, not other. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * feat: the bound workspace rides on every event of a session Each prompt turn resolves the project's local binding (no network) into the telemetry context, and the envelope builder stamps workspace_id on every row of the session; a row's own id wins. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * feat: usage rows of a linked workspace Workspace skills, memory and integration calls carry a workspace value and are counted per session for session_end and task_outcome_signal; new starter_shown, workspace_memory_contributed and workspace_sync_failed; skill_published carries the workspace id. Closes #1510 Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: track workspace integration calls where MCP tools run MCP tools never pass through Tool.define, so the via_workspace row and the integrations count now come from the MCP execution path, keyed on the client name; the id-prefix test in tool.ts is gone, so datamate_manager no longer counts. The TUI publish event carries workspace_id like the CLI and serve paths. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: stamp the workspace id at track time; keep the memory failure detail A serve process can move the context to another session before the batch is serialised, and the memory sync record flattened every failure to one text, so its reason class was always other. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: stamp the workspace of the event's own session A serve process runs sessions side by side, so the process-wide context can belong to another session's turn when an event is tracked; the workspace is now kept per session and read by the event's session_id. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: address cubic's review of the usage rows Session entries end with the turn, not at shutdown; the engine key counts only in a bound turn; only project cloud blocks are workspace memory; skill source scoped to this project; unknown starter contents omitted; documents counter removed; failure text keeps the status and is redacted. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: count injected workspace memory per turn; report only project write-backs Memory is injected on every step, so the count keeps the largest injection instead of summing; a global block's live mirror reports nothing; the injection row names the injecting session. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * test: reset the telemetry context after the tool-call suite Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: track session_end before ending the turn's entries; end only the current turn The session_end row was stamped after its own workspace entry was deleted, and a cancelled turn unwinding late could end the replacement's entries. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: issue turn tokens from one counter so an evicted session cannot reuse one Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: name the turn's own workspace on the loop's end-of-turn rows A cancelled turn unwinding after its replacement started took the replacement's session entry; the loop now stamps the workspace it resolved. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: name the turn's workspace on workspace tool-call rows and on an unbound turn's end rows Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: pass the writer's session to the memory mirror; report the write-back once durable; gate counts by turn Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: name the writer's session on the memory_operation row too Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: key the workspace-use counters by turn Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: name the workspace explicitly on every row; no ambient stamping `track()` no longer stamps `workspace_id` from a process-wide or per-session fallback (five rounds of cancelled-turn attribution bugs came from it). `setContext` returns a turn token; loop, tool, skill, memory and first-job rows carry their turn's workspace explicitly; counters key on the turn. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: the tool hook input carries the turn's workspace; batch and warehouse rows name it `tool.execute.after` gains `workspaceId`, set by the three trigger sites from the turn that ran the tool, so `first_job_completed` names it without asking the session for its current turn. `batch` passes `workspaceId`/`turn` to its inner contexts; `warehouse_add`'s suggestion failure names the turn's workspace. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: a pending task's context carries the turn's workspace; the warehouse failure row names the tool's session Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: count workspace skills only in a bound turn; attachment reads carry the binding Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * feat: telemetry for the workspace engine Attach outcomes, the install prompt and what the user did with it, the precedence snapshot, refusals of datamate_manager and engine errors, each reported once per session when it changes. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: count the local connections the engine shadows The precedence row summed served capabilities; it now reports the registry connections whose type the engine serves, the count the inventory line uses, and re-reports when that count moves. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: skip the retry sentinel in attach telemetry; report an install that rejects The in-session retry records a transient connect-failed before the real outcome; it no longer reports, and the next settled outcome is compared with the last reported one. A throw past installEngine's result now tracks the same failure rows as a reported failure. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: name the refreshed session on a precedence error row Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: address cubic's review of the engine events Rows name their session and workspace explicitly; shown is reported by the surface that rendered the offer; a retry add that throws settles as a failure; turn-hook attach errors are tracked; dedupe signatures cover the escape hatch and extensions; the registry is read only for an enabled snapshot. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: report an attach again after a relink; keep the session on a create's add Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: dedupe attach rows on the account-scoped workspace identity Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: dedupe precedence rows on the account-scoped workspace identity Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: count the shadowed types the session can route Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: name the linked workspace on a disabled precedence row Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: an unbound attach row names no workspace explicitly Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: track `copied` only on a confirmed copy; an unbound precedence row names no workspace `confirmedCopy` writes and reads back; the dialog tracks `copied` only when the clipboard then holds the command. `precedenceEvent` sets `workspace_id` explicitly (undefined when unbound and unlinked), as the attach row does. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: an attached run reports the bus offer it prints as shown The offer command carries the offer's telemetry fields and the server's node major (`arguments`, JSON); `run --attach` reports `shown` with surface `bus` from them when it prints the line. The server's publish is not a display. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * fix: no node probe on the offer's dispatch path; no writer is no copy The bus offer carries the offer's fields only, so publishing no longer awaits `node --version` ahead of the turn boundary; the printed-offer row has no node fields. `confirmedCopy` returns false without a writer, whatever the clipboard holds. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_011AhtJPr3nmT1Po92ZQk4VE * feat: report `starter_action_picked` from the TUI starter One row per selection in either TUI starter dialog: the action, the prompt's index, and the starter's own workspace, never the prompt text. Nothing before the starter arrives. The served starter now carries its workspace id. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YNasdD5tQMNtzXsuMEy82X * fix: address cubic review of the workspace telemetry rows - training saves pass the writer's session to the memory write-back - workspace tool-call errors also lose the user and host name - an untracked tool call reports false - `fetch failed` is a network sync failure Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YNasdD5tQMNtzXsuMEy82X * fix: report no `workspace_api_error` for expected answers; 403 is not expired auth Callers declare expected statuses: a lookup's or unlink's 404, and a gone skill's owner 404, report no row. `/users/me` reports nothing. Only 401 is `workspace_auth_expired`. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YNasdD5tQMNtzXsuMEy82X * fix: drop the unread context workspace; `turn` on a failed tool row; typed knowledge `setContext` no longer holds a workspace id nobody reads. A failed workspace tool call's row carries its turn. `starter_shown.knowledge` is an enum. A test pins that the workspace rows are dropped when telemetry is off. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YNasdD5tQMNtzXsuMEy82X * docs: list the workspace telemetry events A row per new workspace event, the `client` property, `workspace_id` on existing rows, workspace `tool_call` rows, the `workspace` skill source, and how `endpoint` is masked. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YNasdD5tQMNtzXsuMEy82X * fix: read the config telemetry opt-out without an Instance `TelemetryConfig.disabledState()` reads `telemetry.disabled` from the config files and says disabled, enabled or unreadable. Shared with the opt-out PR; files as of its head 49a3dbe. Its init changes stay there. (cherry picked from commit f751255) Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YNasdD5tQMNtzXsuMEy82X * fix: no `machine_id` in `cli_context` when the config opts out or cannot be read Without an Instance, the sign-in context reads `telemetry.disabled` from the config files. An opt-out or unreadable files omit the id. Only a readable enabled config follows the telemetry state. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YNasdD5tQMNtzXsuMEy82X * chore: keep the opt-out reader import apart from the shared telemetry import The opt-out PR adds the same `Telemetry` import line; a neighbouring addition there turned that identical change into a merge conflict. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YNasdD5tQMNtzXsuMEy82X * fix: read the sign-in opt-out from the linked project's config `buildCliContext` takes the project directory, and the workspace hand-off passes the linked project's path. A project-level opt-out then holds when the command starts elsewhere. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YNasdD5tQMNtzXsuMEy82X * fix: the config opt-out probe emits no telemetry of its own The probe parses with `track: false`, so reading a config that uses env interpolation queues no `config_env_interpolation` row. Its tests set aside every global config source and both inline-config variables. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YNasdD5tQMNtzXsuMEy82X (cherry picked from commit 12b9f6e) * docs: `workspace_created` comes from the CLI or the TUI Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YNasdD5tQMNtzXsuMEy82X * test: the probe's no-telemetry check waits on the import, not a timer Also restores the env variable it sets instead of deleting it. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YNasdD5tQMNtzXsuMEy82X (cherry picked from commit 38c790d) * fix: the opt-out probe rejects any source the config loader would reject Each source is parsed with missing `{file:}` references as errors and validated by the loader's own schema step (`validateLoaded`); any failure makes the read unreadable. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YNasdD5tQMNtzXsuMEy82X (cherry picked from commit 78babdd) * fix: the opt-out probe parses a whitespace-only source, as the loader does Only an empty source is skipped; whitespace goes to the parser and fails, so the read is unreadable. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01YNasdD5tQMNtzXsuMEy82X (cherry picked from commit 8c76390) * test: read the starter row's `session_id` through `objectContaining` The event union now carries the opt-out row, which has no session, so the direct property read no longer type-checks. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01VEmKQuB7SVUWpabSm51jon --------- Co-authored-by: Claude Fable 5.1 <[email protected]>
1 parent b59c98c commit 70e3669

64 files changed

Lines changed: 3525 additions & 301 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎docs/docs/reference/telemetry.md‎

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ We collect the following categories of events:
3737
| `error_recovered` | Successful recovery from a transient error (error type, strategy, attempt count) |
3838
| `mcp_server_census` | MCP server capabilities after connect (tool and resource counts, but no tool names) |
3939
| `context_overflow_recovered` | Context overflow is handled (strategy) |
40-
| `skill_used` | A skill is loaded (skill name, source — `builtin`, `global`, or `project`, and trigger — `user`, `auto`, or `suggestion` — no skill content) |
40+
| `skill_used` | A skill is loaded (skill name, source — `builtin`, `global`, `project`, or `workspace`, and trigger — `user`, `auto`, or `suggestion` — no skill content) |
4141
| `plan_revision` | A plan revision occurs in Plan mode (revision_number, action: `refine`, `approve`, `reject`, or `cap_reached`) |
4242
| `feature_suggestion` | A post-connection feature suggestion is shown (suggestion_type, suggestions_shown, warehouse_type — no user input) |
4343
| `sql_execute_failure` | A SQL execution fails (warehouse type, query type, error message, PII-masked SQL — no raw values) |
@@ -77,6 +77,37 @@ We collect the following categories of events:
7777

7878
Each event includes a timestamp, session ID, a per-launch correlation ID (`launch_id` — a random value regenerated every process start, not persisted and not derived from your machine or identity; it exists only to group events from the same run), CLI version, and a machine ID (a random UUID stored in `~/.altimate/machine-id`, generated once and not derived from your hardware or identity). When the machine is signed in to Altimate, each event also carries `user_id` and `tenant`, described under [User Identification](#new-user-identification).
7979

80+
### Workspace events
81+
82+
These events describe projects linked to an Altimate workspace. A workspace is identified only by its numeric id (`workspace_id`, or `to_workspace_id` and `from_workspace_id` on a switch). No workspace name, project path, repository remote, skill content, memory content or prompt text is sent.
83+
84+
| Event | Description |
85+
|-------|-------------|
86+
| `workspace_linked` | A project was linked to a workspace and the server confirmed it. `how` is `bind_existing`, `create_and_bind`, `rebind_remote` or `rebind_path`. |
87+
| `workspace_created` | A workspace was created from the CLI or the TUI. `how` is `create_and_bind`, or `create_unbound` when the link follows as a separate step. |
88+
| `workspace_link_failed` | A link step failed. `how` names the step, and `reason` is a class: `auth`, `not_found`, `network`, `conflict` or `other`. No error text. |
89+
| `workspace_unlinked` | A project was unlinked, with the workspace id when the CLI knew it. |
90+
| `workspace_switched` | A linked project was moved to another workspace. `how` is `rebind_remote` or `rebind_path`. |
91+
| `workspace_auth_expired` | A workspace call was answered 401: the sign-in has expired. Carries `endpoint` and `status`. |
92+
| `workspace_api_error` | A workspace call failed. `status_class` is `4xx`, `5xx`, `network`, `timeout`, or `response` (a success status with an empty or unreadable body), plus the HTTP `status` when there was one. A 403 is reported here, not as expired auth. A status the caller handles as an answer is not a failure and is not reported, such as a 404 from the link lookups ("not linked") or from an unlink ("already unlinked"). `GET /users/me` is not a workspace call and is not reported. |
93+
| `starter_shown` | The "what this workspace provides" starter was served after a link: to the TUI, to the IDE extension's chat, or printed by `altimate-code link`. It counts the starter being served, so a client that closes before rendering it is still counted. Contains the counts of skills and integrations when known, `knowledge` (`off`, `all`, `selected` or `unknown`) and `memory_enabled`. |
94+
| `starter_action_picked` | The user chose an option from the TUI starter: `action` is `prompt`, `open` or `done`, with `prompt_index` (its position) for a suggested prompt. Never the prompt's text. |
95+
| `workspace_memory_contributed` | A memory block was written back to the workspace's shared memory, including the existing blocks seeded when a project is linked. `block_count` is per write. No memory content. |
96+
| `workspace_sync_failed` | Syncing the workspace's skills or memory to this project changed to failing. `kind` is `skills` or `memory`, and `reason` is a class. Sent once per change, not on every retry. |
97+
| `workspace_engine_attach` | A session's connection to the workspace integration engine settled on an outcome (`attached`, `engine_missing`, `engine_too_old`, `connect_failed`, `disabled` or `unbound`), with the engine version and counts of integrations. Sent when the outcome changes, not every turn. |
98+
| `workspace_engine_install_prompt` | The offer to install or update the engine: `action` is `shown`, `accepted`, `installed`, `install_failed`, `copied` or `declined`, with the `reason` and whether Node.js was found and its major version. |
99+
| `workspace_engine_precedence` | Whether the workspace's integrations take precedence over the project's own connections, with counts of shadowed connection types and connections. Sent when the state changes. |
100+
| `workspace_engine_redirect` | A `datamate_manager` call was refused because the project is linked to a workspace. Contains the tool and operation names. |
101+
| `workspace_engine_error` | The engine failed at a stage (`attach`, `install` or `precedence`). `message` is masked (paths, credentials and quoted strings are replaced) and capped at 200 characters. |
102+
103+
Other rows gain workspace fields in a linked project:
104+
105+
- Every event carries `client: "altimate-code"`, which names the product that sent it. `source` still says how the CLI was launched.
106+
- Rows of a turn in a linked project carry that project's `workspace_id`: `session_start`, `session_end`, `first_prompt_sent`, `first_job_completed`, `skill_used`, `skill_published`, `memory_injection`, `agent_outcome`, `task_classified`, `task_outcome_signal`, `tool_chain_outcome`, `core_failure`, `error_fingerprint`, `plan_revision`, `sql_quality` and `tool_call`.
107+
- `session_end` counts the workspace skills, memory blocks and integration calls the session used. `memory_injection` counts the workspace's blocks. `task_outcome_signal` says whether workspace context was used.
108+
- A call to a workspace integration through the engine is reported as a `tool_call` with `tool_type: "mcp"` and `via_workspace: true`. As for other tools, there are no arguments or outputs, and an error message is masked and capped at 500 characters.
109+
- An `endpoint` value is a route label with every id and path segment replaced by `:id`, for example `POST /datamate-project-bindings/bind`. It never contains an id, a file path or a query string.
110+
80111
### Notes on the review events
81112

82113
- `degraded` is a fidelity flag, not a warehouse flag. It is set when a review found no reviewable

‎packages/opencode/src/altimate/plugin/altimate.ts‎

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import { Config } from "@/config/config"
1212
import { Flag } from "@/flag/flag"
1313
import { InstallationVersion } from "@opencode-ai/core/installation/version"
1414
import { Log } from "@/altimate/util/log"
15+
// altimate_change — reads the config telemetry opt-out without an Instance
16+
import { TelemetryConfig } from "../telemetry/config-state"
1517

1618
/**
1719
* Why a failure reason is attached at the rejection site rather than inferred from the message:
@@ -75,7 +77,9 @@ const log = Log.create({ service: "altimate-plugin" })
7577
// and `cli_version` are strings, treat `cli_version: "local"` as a valid dev
7678
// build, and treat the payload as untrusted (anyone can craft a URL). An absent
7779
// `machine_id` means "do not attribute" — it must never be aliased on.
78-
export async function buildCliContext(machineIdPath?: string): Promise<string> {
80+
/** `directory`: the project the command acts on, whose config may opt out; the process's working
81+
* directory when the command has none (`auth login`). */
82+
export async function buildCliContext(machineIdPath?: string, directory?: string): Promise<string> {
7983
// altimate_change start — honour both telemetry opt-out gates, mirroring
8084
// telemetry/index.ts::doInit:
8185
// 1. ALTIMATE_TELEMETRY_DISABLED / OPENCODE_DISABLE_TELEMETRY env vars
@@ -90,17 +94,25 @@ export async function buildCliContext(machineIdPath?: string): Promise<string> {
9094
} catch (err) {
9195
// Config was unreadable — NOT the normal path. Server routes run inside
9296
// Instance.provide() (AsyncLocalStorage-propagated across awaits), so
93-
// Config.get() resolves during an ordinary browser authorize(). The known
94-
// exception is `altimate auth login <url>`, which deliberately skips
95-
// instance bootstrap (ProvidersLoginCommand `instance: (args) => !isAuthProviderUrl(args.target)`);
96-
// on that path this fires. Fail CLOSED — omit the durable machine_id rather
97-
// than transmit it for a user who may have opted out via config; a missed
98-
// correlation beats leaking a stable identifier. Log so a low correlation
99-
// rate is traceable here instead of being mistaken for a lost reply.
100-
log.warn("cli_context: config unreadable, omitting machine_id (fail-closed)", {
97+
// Config.get() resolves during an ordinary browser authorize(). It fires on
98+
// the paths that skip instance bootstrap: `altimate auth login <url>` and the
99+
// create-and-link hand-off of `altimate-code link`. Read `telemetry.disabled`
100+
// from the config files directly: an opt-out there, or files that cannot be
101+
// read (an opt-out may be behind them), omit the id. Only a config that
102+
// readably leaves telemetry on defers to the telemetry module's own state
103+
// (opted out by env, no sink, test runner).
104+
const state = await TelemetryConfig.disabledState(directory)
105+
if (state === "enabled") {
106+
await Telemetry.init().catch(() => {})
107+
disabled = !Telemetry.isEnabled()
108+
} else {
109+
disabled = true
110+
}
111+
log.info("cli_context: config unavailable, read the opt-out from the files", {
101112
code: (err as NodeJS.ErrnoException)?.code,
113+
state,
114+
enabled: !disabled,
102115
})
103-
disabled = true
104116
}
105117
}
106118
let machineId = ""

‎packages/opencode/src/altimate/plugin/onboarding-telemetry.ts‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,13 @@ export async function OnboardingTelemetryPlugin(_input: PluginInput): Promise<Ho
261261
OnboardingTelemetry.isSelectedJob(input.sessionID, job) &&
262262
OnboardingTelemetry.claimFirstJobCompleted(input.sessionID)
263263
) {
264-
void OnboardingTelemetry.emit({ type: "first_job_completed", job }, input.sessionID)
264+
// altimate_change — the workspace of the turn that ran the tool, carried by the hook input
265+
// from the trigger site: a tool returning after its turn was cancelled and replaced still
266+
// names its own turn's workspace, not the replacement's.
267+
void OnboardingTelemetry.emit(
268+
{ type: "first_job_completed", job, workspace_id: input.workspaceId },
269+
input.sessionID,
270+
)
265271
}
266272
},
267273
}

‎packages/opencode/src/altimate/telemetry/error-detail.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ export function buildErrorFingerprintEvent(
411411
recovered: boolean
412412
recoveryTool: string
413413
},
414-
): Telemetry.Event {
414+
): Extract<Telemetry.Event, { type: "error_fingerprint" }> {
415415
return {
416416
type: "error_fingerprint",
417417
timestamp: Date.now(),

0 commit comments

Comments
 (0)