feat: telemetry for the workspace link lifecycle, usage, engine and starter

Merged
RA
1mo ago
+3525-301

Issue for this PR

Closes #1508
Closes #1510
Closes #1512
Closes #1601

Type of change

  • New feature

What does this PR do?

  • Link lifecycle: workspace_linked, workspace_unlinked, workspace_switched, workspace_link_failed (reason class) and workspace_created, on the API's answer. Failed workspace calls report workspace_api_error, or workspace_auth_expired on a 401, with the endpoint masked. A status the caller handles as an answer (a lookup's or unlink's 404) is not a failure and reports nothing, and GET /users/me is not a workspace call.

  • Usage: the contract's rows name the turn's workspace_id, never stamped ambiently. Skills gain a workspace source, memory injection a workspace scope and block count, workspace MCP calls via_workspace, and session end the use counters. New: starter_shown, workspace_memory_contributed and workspace_sync_failed.

  • Engine: workspace_engine_attach on each changed attach outcome, workspace_engine_install_prompt from shown to installed or declined, workspace_engine_precedence on a changed snapshot, workspace_engine_redirect on a refused datamate call, and workspace_engine_error.

  • Starter: starter_action_picked for each pick in the TUI starter, never the prompt text.

  • Docs: the telemetry reference lists every new event, the client property, workspace_id on existing rows, and how endpoint is masked.

  • Sign-in link: when Config.get() cannot run, cli_context reads the opt-out from the config files and leaves out machine_id when it is set or cannot be read.

Merge order: #1501 has merged, and main is merged into this branch. The config-file reader now comes from main. The one conflict, in the telemetry module's session block, is resolved in that merge.

No tracker awaits the network or throws into its caller.

Why

Nothing recorded that a project was linked, whether the workspace was used, whether its engine was there, or what the user did with the starter. These are the funnel stages from link to value.

How did you verify your code works?

  • New suites per part against stubbed backends: lifecycle and failure classes, masking, turn-scoped ids and counters, engine outcomes and dedupes, the starter's workspace join.
  • Head: typecheck clean, workspace and telemetry suites pass. The full suite fails only tests that fail the same way on the previous head (MCP headers and HttpApi, write permissions, trace pruning: local environment).

Follow-ups

  • An org-level telemetry opt-out set through account or remote config. When Config.get() cannot run, the sign-in context reads config files only. If that becomes a real case, the fix belongs in #1501's reader, for both the sign-in context and telemetry init.
  • The shared config reader, which this branch now takes from main as #1501 merged it, still keeps its own copy of the loader's per-source rules. Replacing it with a contained parseConfigSource refactor would be a follow-up to #1501.

Cost side effects

Fixed-size rows per event, and fewer rows than before: an unlinked project's lookups no longer send a row. No model calls, queries or cloud resources grow with user data.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR
  • I checked for cost side effects (model calls, queries or cloud resources that grow with user data) and described them, or wrote "none"

Supersedes #1509, #1511 and #1602.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YNasdD5tQMNtzXsuMEy82X

Summary by CodeRabbit

  • New Features
    • Publish locally authored project skills to a linked workspace, with ownership and supported-file checks. Existing skills can be updated when they match the workspace and are owned by you.
    • Workspace setup prompts provide clearer feedback when copying an install command cannot be confirmed.
  • Bug Fixes
    • Workspace engine connection failures are handled and reported instead of being silently swallowed.
    • Telemetry settings are respected when configuration cannot be fully loaded, using the linked project’s settings during browser handoff.
  • Documentation
    • Added reference information about workspace-related telemetry events and fields.