From 9cbfab8f694189e79080b4887b42d8e0aa40ea50 Mon Sep 17 00:00:00 2001 From: theDakshJaitly Date: Wed, 9 Sep 2026 19:36:08 +0530 Subject: [PATCH 1/3] feat: add bounded CLI and Hub usage telemetry --- .github/workflows/ci.yml | 5 + .mex/ROUTER.md | 11 + .mex/context/architecture.md | 2 +- .mex/context/setup.md | 2 +- .mex/patterns/INDEX.md | 1 + .mex/patterns/usage-telemetry.md | 75 + README.es.md | 6 +- README.md | 6 +- README.pt-BR.md | 6 +- README.zh-CN.md | 6 +- TELEMETRY.md | 196 +- docs/design/0.8.1-release-plan.md | 28 +- .../design/telemetry-performance-results.json | 4499 +++++++++++++++++ docs/design/telemetry-v2.md | 135 + package-lock.json | 22 - package.json | 6 +- packages/hub-web/src/api/client.test.ts | 29 + packages/hub-web/src/api/client.ts | 20 + packages/hub-web/src/api/telemetry.ts | 25 + packages/hub-web/src/app/HubLayout.tsx | 2 + .../hub-web/src/app/PageViewObserver.test.tsx | 46 + packages/hub-web/src/app/PageViewObserver.tsx | 17 + packages/hub-web/src/pages/HomeOverview.tsx | 19 +- scripts/benchmark-telemetry.mjs | 417 ++ scripts/benchmark-telemetry.test.js | 104 + src/cli-telemetry.ts | 56 + src/cli.ts | 187 +- src/feedback/index.ts | 2 +- src/global-config.ts | 151 +- src/hub/__tests__/command-telemetry.test.ts | 73 + src/hub/__tests__/telemetry.test.ts | 69 + src/hub/app.ts | 51 +- src/hub/command.ts | 14 +- src/hub/http/__tests__/app.test.ts | 79 + src/hub/http/request.ts | 14 +- src/hub/jobs/__tests__/job-manager.test.ts | 64 +- src/hub/jobs/index.ts | 18 + src/hub/telemetry.ts | 80 + src/telemetry/index.ts | 444 +- src/telemetry/outbox.ts | 193 + src/telemetry/schema.ts | 140 + src/telemetry/transport.ts | 95 + test/capabilities.test.ts | 4 +- test/cli-telemetry.test.ts | 81 + test/cli.test.ts | 25 +- .../team-inbox-spec-authoring.contract.ts | 9 +- test/feedback.test.ts | 4 +- test/graph-cli-agent.test.ts | 27 +- .../__screenshots__/darwin/hub-home.png | Bin 236011 -> 235125 bytes test/telemetry-delivery.test.ts | 456 ++ test/telemetry.test.ts | 37 +- test/wiki-architecture.test.ts | 87 +- vitest.config.ts | 1 + 53 files changed, 7492 insertions(+), 654 deletions(-) create mode 100644 .mex/patterns/usage-telemetry.md create mode 100644 docs/design/telemetry-performance-results.json create mode 100644 docs/design/telemetry-v2.md create mode 100644 packages/hub-web/src/api/telemetry.ts create mode 100644 packages/hub-web/src/app/PageViewObserver.test.tsx create mode 100644 packages/hub-web/src/app/PageViewObserver.tsx create mode 100644 scripts/benchmark-telemetry.mjs create mode 100644 scripts/benchmark-telemetry.test.js create mode 100644 src/cli-telemetry.ts create mode 100644 src/hub/__tests__/command-telemetry.test.ts create mode 100644 src/hub/__tests__/telemetry.test.ts create mode 100644 src/hub/telemetry.ts create mode 100644 src/telemetry/outbox.ts create mode 100644 src/telemetry/schema.ts create mode 100644 src/telemetry/transport.ts create mode 100644 test/cli-telemetry.test.ts create mode 100644 test/telemetry-delivery.test.ts diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 517ed20d..881d86b4 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -46,6 +46,9 @@ jobs: - run: npm ci - run: npm run typecheck - run: npm run test + - name: Test isolated telemetry benchmark transport + if: matrix.node-version == '22.22.0' + run: npm run benchmark:telemetry:test - name: Run evaluator tests if: matrix.node-version == '22.22.0' run: npm run eval:test @@ -102,6 +105,8 @@ jobs: src/team/workflow/__tests__/repository-team-workflow-port.test.ts test/team-inbox-spec-authoring-real.contract.test.ts test/capabilities.test.ts + test/telemetry.test.ts + test/telemetry-delivery.test.ts src/logging/__tests__/policy.test.ts src/wiki/operations/__tests__/durability.test.ts src/wiki/operations/__tests__/identity-precision.test.ts diff --git a/.mex/ROUTER.md b/.mex/ROUTER.md index 557fbfde..363f8fd2 100644 --- a/.mex/ROUTER.md +++ b/.mex/ROUTER.md @@ -152,6 +152,17 @@ Then read this file fully before doing anything else in this session. all memory and other limits stay unchanged. A clean enforcing run on the new calibrated head remains required. Local same-code memory/latency evidence is retained in `docs/design/graph-isolation-diagnostic.json`. +- Graph performance PR #180 passed the final checks (run `34291831733`) and + merged into `codex/0.8.1` as `d64f171`; the preceding calibration notes are + historical. Main remains separate. +- Telemetry v2 is implemented and locally verified on + `codex/0.8.1-telemetry`, based on that merge; PR/platform CI remains pending. + The approved random installation UUID is shared across CLI and Hub; no project + UUID, content, paths, queries, or contact data enters the event catalog. + Namespaced CLI outcomes, explicit Hub actions/pages, and terminal jobs use a + bounded per-user queue and cancellable delivery. Pure discovery/read commands + remain quiet. CLI feedback uses the existing Hub hosted form without an + analytics identity. See `docs/design/telemetry-v2.md` for validation status. - Targeted graph get/query/impact consumers use one provenance-bound immutable snapshot and discard output if graph or exact source identity changes. - The graph half of Checkpoint 2 is working in the Project Hub: grouped symbol diff --git a/.mex/context/architecture.md b/.mex/context/architecture.md index be912807..f1c948e5 100644 --- a/.mex/context/architecture.md +++ b/.mex/context/architecture.md @@ -99,7 +99,7 @@ revision: 1 can use Claude Code, Codex, or OpenCode, and prompt-only fallback works with any file-reading agent. - A local browser connects only to the loopback Project Hub and exchanges a one-use bootstrap token for a private session. -- **posthog-node** — optional anonymous CLI telemetry; disabled for the development repository and by `DO_NOT_TRACK=1` or `MEX_TELEMETRY=0`. +- **PostHog ingestion** — optional pseudonymous CLI/Hub events share one random installation UUID, with no project identity or content. A bounded per-user outbox and cancellable Node HTTP transport replace the SDK. Development checkouts and opt-out controls disable collection/delivery; see `TELEMETRY.md`.