feat(mosaic): mosaic telemetry command (M6 CU-06-01..05) #417
Reference in New Issue
Block a user
Delete Branch "feat/mosaic-telemetry"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds the mosaic telemetry command tree (milestone M6, tasks CU-06-01 through CU-06-05).
Local half - mosaic telemetry local {status,tail,jaeger}
Remote half - mosaic telemetry {status,opt-in,opt-out,test,upload}
CU-06-01: Dependency resolution
@mosaicstack/telemetry-client-js is not yet published (404 at registry as of 2026-04-04). A forward-compat shim at packages/mosaic/src/telemetry/client-shim.ts mirrors the expected {init, captureEvent, upload, shutdown} interface. The shim throws on real-upload attempts so no false success is recorded.
CU-06-04: Consent persistence
Schema: {remoteEnabled, optedInAt, optedOutAt, lastUploadAt}. Persisted to $MOSAIC_HOME/telemetry.json via atomicWrite.
CU-06-05: Tests
18 Vitest tests in telemetry.spec.ts covering: command structure, opt-in/opt-out persistence, status output (both enabled and disabled + dry-run banner), and dry-run assertions (no fetch calls, no upload calls, banner visible).
Code review findings addressed
Quality gates
Add mosaic telemetry command tree covering CU-06-01 through CU-06-05. Local half (mosaic telemetry local {status,tail,jaeger}): - status: probes OTEL_EXPORTER_OTLP_ENDPOINT reachability via fetch - tail: explains OTLP push model and points to Jaeger + docker compose logs - jaeger: prints Jaeger UI URL (respects JAEGER_UI_URL), --open flag best-effort Remote half (mosaic telemetry {status,opt-in,opt-out,test,upload}): - Remote upload is DISABLED by default (dry-run is the default) - opt-in / opt-out: @clack/prompts consent flow persisted to telemetry.json - status: shows consent state, endpoint, last upload timestamp - test: synthesises fake event, dry-run by default; --upload path throws if shim - upload: dry-run unless MOSAIC_TELEMETRY_ENDPOINT + consent + no dry-run flag CU-06-01: @mosaicstack/telemetry-client-js is not yet published (404). Uses forward-compat shim at packages/mosaic/src/telemetry/client-shim.ts matching the expected {init, captureEvent, upload, shutdown} interface. CU-06-04: Consent persisted to $MOSAIC_HOME/telemetry.json via atomicWrite. Schema: {remoteEnabled, optedInAt, optedOutAt, lastUploadAt}. CU-06-05: 18 Vitest tests in telemetry.spec.ts covering structure, opt-in/opt-out persistence, status output (both states + dry-run banner), and dry-run assertions (no fetch, no upload() call, banner present). Code-review findings addressed: - Shim throws on real-upload attempts (blocker: no false success recorded) - init() no longer resets queue (should-fix: pending events survive re-init) - Windows --open uses cmd /c start (should-fix: start is a shell builtin) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>