From 8cbcd413713a686d6ccd7ce2f9090945a8b1cad2 Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Wed, 18 Nov 2026 12:52:15 -0800 Subject: [PATCH 1/4] ci: prune unused Docker publish workflows and telemetry secrets Remove the never-run migra and pg_prove Docker Hub publish workflows, read the PostHog endpoint from a repository variable, and stop passing the Sentry DSN that no current build reads. Generated with AI Co-Authored-By: Claude --- .github/workflows/build-cli-artifacts.yml | 7 +- .github/workflows/publish-migra.yml | 93 ----------------------- .github/workflows/publish-pg-prove.yml | 93 ----------------------- .github/workflows/release-shared.yml | 8 -- .github/workflows/release.yml | 2 - 5 files changed, 1 insertion(+), 202 deletions(-) delete mode 100644 .github/workflows/publish-migra.yml delete mode 100644 .github/workflows/publish-pg-prove.yml diff --git a/.github/workflows/build-cli-artifacts.yml b/.github/workflows/build-cli-artifacts.yml index a66ca86419..817d3128cc 100644 --- a/.github/workflows/build-cli-artifacts.yml +++ b/.github/workflows/build-cli-artifacts.yml @@ -33,12 +33,8 @@ on: type: number default: 4 secrets: - SENTRY_DSN: - required: false POSTHOG_API_KEY: required: false - POSTHOG_ENDPOINT: - required: false DF_FIREWALL_TOKEN: required: false @@ -52,9 +48,8 @@ jobs: timeout-minutes: ${{ inputs.timeout_minutes }} env: VERSION: ${{ inputs.version }} - SENTRY_DSN: ${{ secrets.SENTRY_DSN }} POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} - POSTHOG_ENDPOINT: ${{ secrets.POSTHOG_ENDPOINT }} + POSTHOG_ENDPOINT: ${{ vars.POSTHOG_ENDPOINT }} # Fail the build if the macOS signing tool is missing — release artifacts # must be signed (CLI-1621). Local builds without rcodesign degrade to a # warning instead. diff --git a/.github/workflows/publish-migra.yml b/.github/workflows/publish-migra.yml deleted file mode 100644 index ac061f0d3c..0000000000 --- a/.github/workflows/publish-migra.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: Publish migra - -on: - workflow_dispatch: -permissions: - contents: read - -jobs: - settings: - runs-on: ubuntu-latest - outputs: - image_tag: supabase/migra:${{ steps.version.outputs.migra }} - steps: - - uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0 - - uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 - with: - load: true - context: https://github.com/djrobstep/migra.git - tags: supabase/migra:builder - - id: version - # Replace space with equal to get the raw version string, ie. migra=3.0.1663481299 - run: | - docker run --rm -a STDOUT supabase/migra:builder pip show migra \ - | grep 'Version' \ - | sed -E 's/Version: (.*)/migra=\1/g' \ - >> "$GITHUB_OUTPUT" - shell: bash - - build_image: - needs: - - settings - strategy: - matrix: - include: - - runner: [self-hosted, X64] - arch: amd64 - - runner: arm-runner - arch: arm64 - runs-on: ${{ matrix.runner }} - timeout-minutes: 180 - steps: - - run: docker context create builders - - uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0 - with: - endpoint: builders - - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - id: build - uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 - with: - push: true - context: https://github.com/djrobstep/migra.git - tags: ${{ needs.settings.outputs.image_tag }}_${{ matrix.arch }} - platforms: linux/${{ matrix.arch }} - cache-from: type=gha,scope=${{ github.ref_name }}-migra-${{ matrix.arch }} - cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-migra-${{ matrix.arch - }} - - merge_manifest: - needs: - - settings - - build_image - runs-on: ubuntu-latest - steps: - - uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0 - - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Merge multi-arch manifests - env: - IMAGE_TAG: ${{ needs.settings.outputs.image_tag }} - run: | - docker buildx imagetools create -t "${IMAGE_TAG}" \ - "${IMAGE_TAG}_amd64" \ - "${IMAGE_TAG}_arm64" - - publish: - needs: - - settings - - merge_manifest - permissions: - contents: read - packages: write - id-token: write - # Call workflow explicitly because events from actions cannot trigger more actions - uses: ./.github/workflows/mirror-image.yml - with: - image: ${{ needs.settings.outputs.image_tag }} - secrets: - PROD_AWS_ROLE: ${{ secrets.PROD_AWS_ROLE }} diff --git a/.github/workflows/publish-pg-prove.yml b/.github/workflows/publish-pg-prove.yml deleted file mode 100644 index f2b1ad1c07..0000000000 --- a/.github/workflows/publish-pg-prove.yml +++ /dev/null @@ -1,93 +0,0 @@ -name: Publish pg_prove - -on: - workflow_dispatch: -permissions: - contents: read - -jobs: - settings: - runs-on: ubuntu-latest - outputs: - image_tag: supabase/pg_prove:${{ steps.version.outputs.pg_prove }} - steps: - - uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0 - - uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 - with: - load: true - context: https://github.com/horrendo/pg_prove.git - target: builder - tags: supabase/pg_prove:builder - - id: version - # Replace space with equal to get the raw version string, ie. pg_prove=3.36 - run: | - docker run --rm -a STDOUT supabase/pg_prove:builder pg_prove --version \ - | tr ' ' '=' \ - >> "$GITHUB_OUTPUT" - shell: bash - - build_image: - needs: - - settings - strategy: - matrix: - include: - - runner: [self-hosted, X64] - arch: amd64 - - runner: arm-runner - arch: arm64 - runs-on: ${{ matrix.runner }} - timeout-minutes: 180 - steps: - - run: docker context create builders - - uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0 - with: - endpoint: builders - - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - id: build - uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 - with: - push: true - context: https://github.com/horrendo/pg_prove.git - tags: ${{ needs.settings.outputs.image_tag }}_${{ matrix.arch }} - platforms: linux/${{ matrix.arch }} - cache-from: type=gha,scope=${{ github.ref_name }}-pg_prove-${{ matrix.arch }} - cache-to: type=gha,mode=max,scope=${{ github.ref_name }}-pg_prove-${{ - matrix.arch }} - - merge_manifest: - needs: - - settings - - build_image - runs-on: ubuntu-latest - steps: - - uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0 - - uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Merge multi-arch manifests - env: - IMAGE_TAG: ${{ needs.settings.outputs.image_tag }} - run: | - docker buildx imagetools create -t "${IMAGE_TAG}" \ - "${IMAGE_TAG}_amd64" \ - "${IMAGE_TAG}_arm64" - - publish: - needs: - - settings - - merge_manifest - permissions: - contents: read - packages: write - id-token: write - # Call workflow explicitly because events from actions cannot trigger more actions - uses: ./.github/workflows/mirror-image.yml - with: - image: ${{ needs.settings.outputs.image_tag }} - secrets: - PROD_AWS_ROLE: ${{ secrets.PROD_AWS_ROLE }} diff --git a/.github/workflows/release-shared.yml b/.github/workflows/release-shared.yml index 4fa19bbd07..6c8245a40f 100644 --- a/.github/workflows/release-shared.yml +++ b/.github/workflows/release-shared.yml @@ -39,12 +39,8 @@ on: type: string default: supabase secrets: - SENTRY_DSN: - required: false POSTHOG_API_KEY: required: false - POSTHOG_ENDPOINT: - required: false GH_APP_PRIVATE_KEY: required: false ANTHROPIC_API_KEY: @@ -64,9 +60,7 @@ jobs: with: version: ${{ inputs.version }} secrets: - SENTRY_DSN: ${{ secrets.SENTRY_DSN }} POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} - POSTHOG_ENDPOINT: ${{ secrets.POSTHOG_ENDPOINT }} DF_FIREWALL_TOKEN: ${{ secrets.DF_FIREWALL_TOKEN }} build-github: @@ -79,9 +73,7 @@ jobs: timeout_minutes: 45 build_timeout_minutes: 20 secrets: - SENTRY_DSN: ${{ secrets.SENTRY_DSN }} POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} - POSTHOG_ENDPOINT: ${{ secrets.POSTHOG_ENDPOINT }} DF_FIREWALL_TOKEN: ${{ secrets.DF_FIREWALL_TOKEN }} smoke-test: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6f32d098ac..9a0fd6e88e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -356,9 +356,7 @@ jobs: dry_run: ${{ needs.plan.outputs.dry_run == 'true' }} channel: ${{ needs.plan.outputs.channel }} secrets: - SENTRY_DSN: ${{ secrets.SENTRY_DSN }} POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} - POSTHOG_ENDPOINT: ${{ secrets.POSTHOG_ENDPOINT }} GH_APP_PRIVATE_KEY: ${{ secrets.GH_APP_PRIVATE_KEY }} ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} DF_FIREWALL_TOKEN: ${{ secrets.DF_FIREWALL_TOKEN }} From c7112c1cf107978b27682f9186265766a84f5444 Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Thu, 19 Nov 2026 10:41:53 -0800 Subject: [PATCH 2/4] docs(cli): remove the outdated telemetry design doc docs/telemetry.md described Sentry as the live telemetry backend. Analytics and tracing are documented in apps/cli/docs, so ADR 0002 now links there. Generated with AI Co-Authored-By: Claude --- apps/cli/docs/analytics.md | 1 - docs/adr/0002-cli-product-metrics.md | 3 +- docs/telemetry.md | 441 --------------------------- 3 files changed, 2 insertions(+), 443 deletions(-) delete mode 100644 docs/telemetry.md diff --git a/apps/cli/docs/analytics.md b/apps/cli/docs/analytics.md index fba2781e52..c0b7fd48e3 100644 --- a/apps/cli/docs/analytics.md +++ b/apps/cli/docs/analytics.md @@ -243,7 +243,6 @@ That means: - analytics gets one or a few meaningful events per command - traces remain in the tracing path -- Sentry and PostHog remain distinct telemetry systems with different responsibilities In short: diff --git a/docs/adr/0002-cli-product-metrics.md b/docs/adr/0002-cli-product-metrics.md index 95ef28136c..b973bbbebf 100644 --- a/docs/adr/0002-cli-product-metrics.md +++ b/docs/adr/0002-cli-product-metrics.md @@ -152,4 +152,5 @@ Three-state model: `"pending" | "granted" | "denied"`, stored in `~/.supabase/te ## See Also -- [Telemetry Implementation](../telemetry.md): Collection architecture, identity resolution, consent flow, local storage, remote export, and metric derivation +- [CLI Analytics](../../apps/cli/docs/analytics.md): PostHog events, identity, and consent +- [CLI Tracing and Monitoring](../../apps/cli/docs/tracing-monitoring.md): Opt-in local traces and OTLP export diff --git a/docs/telemetry.md b/docs/telemetry.md deleted file mode 100644 index 164e6f11b5..0000000000 --- a/docs/telemetry.md +++ /dev/null @@ -1,441 +0,0 @@ -# Telemetry Implementation - -> Extracted from [ADR 0002](adr/0002-cli-product-metrics.md). This document covers the implementation details of the CLI telemetry system. For the metric categories, event schema contract, and architectural decisions, see the ADR. - -## Unified Infrastructure - -ADR 0001 Pillar 5 and ADR 0002 share infrastructure. No separate metrics SDK and tracing SDK — one telemetry event schema, one write path, one consent model. A single OpenTelemetry-based pipeline handles all concerns, with the backend evolving in phases: - -| Phase | Backend | Purpose | Status | -| ----------- | ------------------------------ | ---------------------------------------------------------------- | ------ | -| **Phase 1** | **Sentry** (via `@sentry/bun`) | All 5 metric categories + error diagnostics + performance traces | Now | -| **Phase 2** | **Grafana** (company-owned) | Long-term analytics + custom observability dashboards | Future | - -``` -┌─────────────────────────────────────────────┐ -│ Command Execution │ -│ │ -│ handler logic → withTelemetry() middleware │ -└──────────────────┬──────────────────────────┘ - │ - ▼ - ┌─────────────────┐ - │ OTel Span(s) │ - │ (single schema) │ - └────────┬────────┘ - │ - ┌─────────────┼─────────────┐ - ▼ ▼ ▼ -Trace file or Span console Remote -own OTLP on stderr export -collector (opt-in) (opt-in) -(opt-in) │ │ - │ │ ┌─────┴─────┐ - ▼ ▼ ▼ ▼ -Observability Observability Sentry Grafana -(ADR 0027) (ADR 0027) (Phase 1) (Phase 2, - future) -``` - -Sentry receives every command span via its native OpenTelemetry integration and powers error diagnostics, performance monitoring, and product analytics dashboards for all 5 metric categories from ADR 0002. In Phase 2, spans will also be exported to a company-owned Grafana instance via OTLP for long-term retention and custom analytics. The CLI code does not change between phases — only the exporter configuration. - -The trace file and user-owned OTLP collector are chosen per run with `SUPABASE_TRACE_FILE` or -`SUPABASE_OTLP_ENDPOINT`, and the span console with `SUPABASE_DEBUG=1` or -`SUPABASE_TELEMETRY_DEBUG=1`; see [ADR 0027](adr/0027-cli-tracing-conventions.md). - -## Collection Architecture - -`withTelemetry()` middleware wrapping Stricli command handlers. The middleware: - -- Records `startup_ms` (time from process start to handler entry) -- Creates a root OTel span for the command invocation -- Runs the handler -- Records `duration_ms`, `exit_code`, `error_code` as span attributes -- Collects API stats from an injected API client -- Sets span status and ends the span -- Handlers never interact with telemetry directly - -Pattern: - -```typescript -function withTelemetry(handler: CommandHandler): CommandHandler { - return async (flags) => { - const tracer = trace.getTracer("supabase-cli"); - return tracer.startActiveSpan(`cli.command.${flags.__command}`, async (span) => { - const start = performance.now(); - span.setAttributes({ - "cli.command": flags.__command, - "cli.startup_ms": start - globalThis.__processStart, - "cli.device_id": getDeviceId(), - "cli.session_id": getSessionId(), - "cli.is_first_run": isFirstRun(), - "cli.is_tty": process.stdout.isTTY ?? false, - "cli.is_ci": Boolean(process.env.CI), - "cli.version": CLI_VERSION, - "os.type": process.platform, - "host.arch": process.arch, - }); - - const result = await handler(flags); - - const exitCode = result.ok ? 0 : exitCodeFromError(result.error); - span.setAttributes({ - "cli.exit_code": exitCode, - "cli.duration_ms": performance.now() - start, - "cli.api_request_count": apiClient.requestCount, - "cli.api_request_duration_ms": apiClient.requestDurationMs, - "cli.api_request_errors": apiClient.requestErrors, - }); - - if (!result.ok) { - span.setStatus({ code: SpanStatusCode.ERROR, message: result.error.message }); - span.setAttribute("cli.error_code", result.error.code); - } else { - span.setStatus({ code: SpanStatusCode.OK }); - } - - span.end(); - return result; - }); - }; -} -``` - -Integration with Stricli's lazy imports: - -```typescript -command({ - func: async (flags) => { - const { runDev } = await import("./dev.handler"); - return withTelemetry(runDev)(flags); - }, -}); -``` - -## Identity - -**Anonymous phase** — before login: - -`device_id`: random UUID generated on first run, persisted in `/telemetry.json`. Never changes unless the file is deleted. This is the only identity before the user runs `supabase login`. It is attached to every span as the `cli.device_id` resource attribute. - -`session_id`: random UUID that rotates after 30 minutes of inactivity (no CLI commands). This defines "session" for the Engagement metrics. - -`is_first_run`: true only on the very first CLI execution ever (when `telemetry.json` doesn't exist yet). Powers the Onboarding metrics. - -Note: `user_id` (Supabase account UUID) is a future enhancement, pending a profile endpoint that returns the account UUID from the auth token. When available, it will be attached as `cli.user_id` resource attribute and will enable cross-device identity linking. - -**OTel resource attributes**: - -```typescript -// Resource attributes set once at SDK initialization -const resource = new Resource({ - "service.name": "supabase-cli", - "service.version": CLI_VERSION, - "cli.device_id": getDeviceId(), // always present, never rotates - "os.type": process.platform, - "host.arch": process.arch, -}); -``` - -**Identity lifecycle**: - -``` -┌─────────────────────────────────┐ -│ Anonymous │ -│ │ -│ cli.device_id ✓ (always set) │ -│ cli.user_id ✗ (future) │ -└─────────────────────────────────┘ -``` - -Privacy guarantees: - -| What we track | What we never track | -| ----------------------------------------- | -------------------------------------- | -| Random device UUID | IP address, username, hostname | -| Command name and exit code | Command arguments or flag values | -| Timing and error codes | File paths, SQL content, project names | -| OS and architecture | Environment variables | -| Stack traces (via span.recordException()) | Email, name, or other profile data | - -## Local Traces - -Local traces are opt-in per run: `SUPABASE_TRACE_FILE` appends sanitized OTLP/JSON batches to a -file, `SUPABASE_OTLP_ENDPOINT` sends them to a collector the user runs, and `SUPABASE_DEBUG=1` or -`SUPABASE_TELEMETRY_DEBUG=1` prints the top of the span tree and every failed span to stderr. -`--debug` does not print spans. The CLI no longer writes `/traces/`. See -the [tracing how-to](../apps/cli/docs/tracing-monitoring.md) and -[ADR 0027](adr/0027-cli-tracing-conventions.md). - -## Remote Export - -Single pipeline, one consent gate, phased backends: - -### Phase 1: Sentry (now) - -- Uses `@sentry/bun` SDK which has native OpenTelemetry integration — no separate `@opentelemetry/exporter-trace-otlp-http` needed -- Sentry SDK is lazy-loaded (only imported when consent is granted) -- PII filtering via Sentry's `beforeSendTransaction` / `beforeSend` hooks — strips file paths, environment variables, and usernames before data leaves the CLI -- Error spans → Sentry Issues; performance spans → Sentry Performance; custom span attributes → Sentry tags -- Error spans include stack traces and error context for debugging and alerting - -```typescript -// Phase 1: Sentry — initialized once when consent is granted -import * as Sentry from "@sentry/bun"; - -Sentry.init({ - dsn: SENTRY_DSN, - release: `supabase-cli@${CLI_VERSION}`, - tracesSampleRate: 1.0, - beforeSendTransaction(event) { - return stripPii(event); - }, - beforeSend(event) { - return stripPii(event); - }, -}); -``` - -### Phase 2: Grafana (future) - -- Add `@opentelemetry/exporter-trace-otlp-http` alongside Sentry -- Both exporters receive the same spans via a composite span processor -- Sentry continues for real-time alerting and error triage; Grafana provides long-term retention and custom dashboards -- The CLI code does not change — only the exporter configuration - -### Shared behavior - -- Does not send data unless consent is `granted` -- Does not block command execution -- Lazy-loaded to avoid startup cost when consent is `denied` - -Performance: total overhead < 1ms per command (span construction + non-blocking SDK calls). - -### End-to-end example: `supabase projects list` - -**Success path** — user runs `supabase projects list` and gets a list of projects: - -```typescript -// 1. withTelemetry() creates a root span -const span = tracer.startSpan("cli.command.projects list"); -const start = performance.now(); // 45ms after process start - -// 2. Set attributes at span start -span.setAttributes({ - "cli.command": "projects list", - "cli.startup_ms": 45, - "cli.device_id": "a1b2c3d4-...", - "cli.session_id": "e5f6g7h8-...", - "cli.is_first_run": false, - "cli.is_tty": true, - "cli.is_ci": false, - "cli.version": "0.1.0", - "os.type": "darwin", - "host.arch": "arm64", -}); - -// 3. Handler runs -const result = await listProjects(flags); // { ok: true, data: [...] } - -// 4. Set outcome attributes and end span -span.setAttributes({ - "cli.exit_code": 0, - "cli.duration_ms": 234, - "cli.api_request_count": 1, - "cli.api_request_duration_ms": 189, - "cli.api_request_errors": 0, -}); -span.setStatus({ code: SpanStatusCode.OK }); -span.end(); - -// 5. Only when SUPABASE_TRACE_FILE is set: append the sanitized OTLP batch to that file - -// 6. If consent === "granted": Sentry SDK exports the span -// Non-blocking — SDK batches internally -``` - -**Error path** — user runs `supabase projects list` but their token has expired: - -```typescript -// 1. withTelemetry() creates a root span (same as success) -const span = tracer.startSpan("cli.command.projects list"); - -// 2. Set initial attributes (same as success) -span.setAttributes({ - "cli.command": "projects list", - "cli.startup_ms": 45, - // ... identity and environment attributes ... -}); - -// 3. Handler returns an error -const result = await listProjects(flags); -// { ok: false, error: { code: "AUTH_TOKEN_EXPIRED", message: "..." } } - -// 4. Set error attributes, record exception, set ERROR status -span.setAttributes({ - "cli.exit_code": 1, // error - "cli.duration_ms": 12, // fast failure - "cli.error_code": "AUTH_TOKEN_EXPIRED", - "cli.api_request_count": 1, - "cli.api_request_duration_ms": 8, - "cli.api_request_errors": 1, -}); -span.recordException(result.error); // attaches stack trace as span event -span.setStatus({ - code: SpanStatusCode.ERROR, - message: "AUTH_TOKEN_EXPIRED", -}); -span.end(); - -// 5. Only when SUPABASE_TRACE_FILE is set: append the sanitized OTLP batch (same as success) - -// 6. If consent === "granted": Sentry SDK exports the error span -// Sentry alerts if AUTH_TOKEN_EXPIRED spikes across devices -``` - -**Workflow command** — `supabase dev` with child spans (connects to ADR 0007): - -```typescript -// Root span for the command -const rootSpan = tracer.startSpan("cli.command.dev"); - -// Child spans for each phase — created by the handler via context propagation -const configSpan = tracer.startSpan("cli.phase.config.load", { parent: rootSpan }); -// ... config loads ... -configSpan.setAttribute("cli.phase.duration_ms", 12); -configSpan.end(); - -const dockerSpan = tracer.startSpan("cli.phase.docker.start", { parent: rootSpan }); -// ... docker starts ... -dockerSpan.setAttribute("cli.phase.duration_ms", 890); -dockerSpan.end(); - -const healthSpan = tracer.startSpan("cli.phase.healthcheck.wait", { parent: rootSpan }); -// ... healthcheck passes ... -healthSpan.setAttribute("cli.phase.duration_ms", 230); -healthSpan.end(); - -// Root span outcome -rootSpan.setAttributes({ - "cli.exit_code": 0, - "cli.duration_ms": 1200, - "cli.startup_ms": 38, -}); -rootSpan.setStatus({ code: SpanStatusCode.OK }); -rootSpan.end(); - -// Sentry receives a full trace with parent + child spans: -// enables per-phase latency dashboards (e.g. "p95 cli.phase.docker.start duration") - -// SUPABASE_TRACE_FILE or SUPABASE_OTLP_ENDPOINT captures the same tree locally: -// supabase dev (total: 1.2s) -// ├── config.load: 12ms -// ├── docker.start: 890ms -// └── healthcheck.wait: 230ms -``` - -## Consent Implementation - -Three-state model stored in `/telemetry.json`: - -```typescript -type ConsentState = "pending" | "granted" | "denied"; -``` - -Flow: - -``` -First CLI run - │ - ▼ -Is TTY? ──No──→ consent = "denied" (no prompt for CI/LLMs) - │ - Yes - │ - ▼ -Prompt user (via Clack): -"Help improve the Supabase CLI by sending anonymous usage data? (y/N)" - │ - ├─ y → consent = "granted" - └─ N → consent = "denied" - -At any time: - supabase telemetry enable → "granted" - supabase telemetry disable → "denied" - supabase telemetry status → show current state - -Environment override: - SUPA_TELEMETRY=off → treated as "denied" (skips prompt) - SUPA_TELEMETRY=on → treated as "granted" (skips prompt) -``` - -Non-TTY defaults to `denied` without prompting — this means LLM agents and CI pipelines never see a consent prompt, and no data is sent unless explicitly enabled via env var or `supabase telemetry enable`. - -## Deriving Metrics from Events - -Mapping every metric from the 5 categories to a query over span attributes. Queries use TraceQL-like syntax referencing span attributes: - -| Category | Metric | Derived from | -| ---------- | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | -| Adoption | Monthly Active Users (MAU) | `count(distinct resource.cli.device_id) where span.cli.command exists and timestamp > now() - 30d` | -| Adoption | New installs per week | `count(distinct resource.cli.device_id) where span.cli.is_first_run = true and timestamp > now() - 7d` | -| Adoption | LLM vs human split | `count(*) by span.cli.is_tty` (false = LLM/CI, true = human) | -| Engagement | Commands per session | `count(*) by span.cli.session_id` → average | -| Engagement | Command frequency distribution | `count(*) by span.cli.command order by count desc` | -| Engagement | Multi-command chains | `count(distinct span.cli.session_id) where session_span_count >= 3` | -| Retention | Week 1 retention | `resource.cli.device_id` seen in both week 0 and week 1 after `span.cli.is_first_run = true` | -| Retention | Month 1 retention | `resource.cli.device_id` seen in both month 0 and month 1 after `span.cli.is_first_run = true` | -| Retention | Churn by command | Last `span.cli.command` before a `resource.cli.device_id` stops appearing | -| Quality | Command success rate | `count(span.cli.exit_code = 0) / count(*)` | -| Quality | Error code distribution | `count(*) by span.cli.error_code where span.cli.error_code exists` | -| Quality | p50/p95 command latency | `histogram_quantile(0.50, span.cli.duration_ms)`, `histogram_quantile(0.95, span.cli.duration_ms)` | -| Onboarding | Time to first successful command | `min(timestamp where span.cli.exit_code = 0) - min(timestamp) where span.cli.is_first_run = true` per `resource.cli.device_id` | -| Onboarding | Drop-off funnel | Sequential presence of `is_first_run → cli.command='login' → cli.command='dev' OR cli.command='link'` per `resource.cli.device_id` | - -**Phase 1 (Sentry)**: Metrics are derived via Sentry Discover queries filtering on span tags (`cli.command`, `cli.device_id`, etc.). Error code distribution and crash diagnostics use native Sentry Issues. - -**Phase 2 (Grafana)**: The same span attributes power Grafana dashboards via TraceQL or PromQL. Long-term retention enables cohort analysis for retention and onboarding metrics that require multi-week time windows. - -Completeness check — every span attribute is used by at least one metric: - -| Attribute | Used by | -| ---------------------------------------- | ---------------------------------------------------- | -| `resource.cli.device_id` | MAU, retention, churn, onboarding funnel | -| `span.cli.session_id` | Commands per session, multi-command chains | -| `span.cli.is_first_run` | New installs, retention cohorts, onboarding funnel | -| `span.cli.command` | Command frequency, churn by command, drop-off funnel | -| `span.cli.exit_code` | Command success rate | -| `span.cli.duration_ms` | p50/p95 latency | -| `span.cli.startup_ms` | Performance monitoring (ADR 0001 budgets) | -| `span.cli.error_code` | Error code distribution | -| `span.cli.is_tty` | LLM vs human split | -| `span.cli.is_ci` | LLM vs human split (refinement) | -| `resource.os.type`, `resource.host.arch` | Segment any metric by platform | -| `resource.service.version` | Segment any metric by version, track regression | -| `span.cli.api_request_count` | Performance analysis | -| `span.cli.api_request_duration_ms` | Performance analysis | -| `span.cli.api_request_errors` | Quality analysis (backend reliability) | -| child spans (phases) | Per-phase latency breakdown for workflow commands | - -Note: `cli.user_id` (Supabase account UUID) is omitted from v1. It will be added as a future enhancement when a profile endpoint is available, enabling cross-device identity linking and per-account error lookup. - -Performance impact: - -| Operation | Cost | -| ------------------------- | --------- | -| Span construction | < 0.1ms | -| Sentry SDK export (async) | < 0.1ms | -| **Total per command** | **< 1ms** | - -## Implementation Status - -| Area | Current State | Target State | -| ----------------- | ---------------------------------------- | ---------------------------------------------- | -| Tracing framework | LogTape structured logging (flat events) | OTel spans via `@sentry/bun` | -| ConsentState | 2-state (`"granted" \| "denied"`) | 3-state (`"pending" \| "granted" \| "denied"`) | -| Default consent | `"granted"` when no config exists | `"denied"` for non-TTY; prompt for TTY | -| API metrics | Fields in type but not collected | Collect from injected API client | -| Remote export | None (opt-in trace file or collector) | Sentry SDK (Phase 1) | -| PII filtering | None | `beforeSend` hooks in Sentry config | -| `cli_version` | Hardcoded `"0.1.0"` | Read from package.json or build constant | -| Child spans | Not implemented | Per-phase spans for workflow commands | From b7f6f0103c198263090aa9ae01cde758a8778895 Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Thu, 19 Nov 2026 10:53:59 -0800 Subject: [PATCH 3/4] revert: move the telemetry design doc removal to its own PR This reverts commit c7112c1cf107978b27682f9186265766a84f5444. Generated with AI Co-Authored-By: Claude --- apps/cli/docs/analytics.md | 1 + docs/adr/0002-cli-product-metrics.md | 3 +- docs/telemetry.md | 441 +++++++++++++++++++++++++++ 3 files changed, 443 insertions(+), 2 deletions(-) create mode 100644 docs/telemetry.md diff --git a/apps/cli/docs/analytics.md b/apps/cli/docs/analytics.md index c0b7fd48e3..fba2781e52 100644 --- a/apps/cli/docs/analytics.md +++ b/apps/cli/docs/analytics.md @@ -243,6 +243,7 @@ That means: - analytics gets one or a few meaningful events per command - traces remain in the tracing path +- Sentry and PostHog remain distinct telemetry systems with different responsibilities In short: diff --git a/docs/adr/0002-cli-product-metrics.md b/docs/adr/0002-cli-product-metrics.md index b973bbbebf..95ef28136c 100644 --- a/docs/adr/0002-cli-product-metrics.md +++ b/docs/adr/0002-cli-product-metrics.md @@ -152,5 +152,4 @@ Three-state model: `"pending" | "granted" | "denied"`, stored in `~/.supabase/te ## See Also -- [CLI Analytics](../../apps/cli/docs/analytics.md): PostHog events, identity, and consent -- [CLI Tracing and Monitoring](../../apps/cli/docs/tracing-monitoring.md): Opt-in local traces and OTLP export +- [Telemetry Implementation](../telemetry.md): Collection architecture, identity resolution, consent flow, local storage, remote export, and metric derivation diff --git a/docs/telemetry.md b/docs/telemetry.md new file mode 100644 index 0000000000..164e6f11b5 --- /dev/null +++ b/docs/telemetry.md @@ -0,0 +1,441 @@ +# Telemetry Implementation + +> Extracted from [ADR 0002](adr/0002-cli-product-metrics.md). This document covers the implementation details of the CLI telemetry system. For the metric categories, event schema contract, and architectural decisions, see the ADR. + +## Unified Infrastructure + +ADR 0001 Pillar 5 and ADR 0002 share infrastructure. No separate metrics SDK and tracing SDK — one telemetry event schema, one write path, one consent model. A single OpenTelemetry-based pipeline handles all concerns, with the backend evolving in phases: + +| Phase | Backend | Purpose | Status | +| ----------- | ------------------------------ | ---------------------------------------------------------------- | ------ | +| **Phase 1** | **Sentry** (via `@sentry/bun`) | All 5 metric categories + error diagnostics + performance traces | Now | +| **Phase 2** | **Grafana** (company-owned) | Long-term analytics + custom observability dashboards | Future | + +``` +┌─────────────────────────────────────────────┐ +│ Command Execution │ +│ │ +│ handler logic → withTelemetry() middleware │ +└──────────────────┬──────────────────────────┘ + │ + ▼ + ┌─────────────────┐ + │ OTel Span(s) │ + │ (single schema) │ + └────────┬────────┘ + │ + ┌─────────────┼─────────────┐ + ▼ ▼ ▼ +Trace file or Span console Remote +own OTLP on stderr export +collector (opt-in) (opt-in) +(opt-in) │ │ + │ │ ┌─────┴─────┐ + ▼ ▼ ▼ ▼ +Observability Observability Sentry Grafana +(ADR 0027) (ADR 0027) (Phase 1) (Phase 2, + future) +``` + +Sentry receives every command span via its native OpenTelemetry integration and powers error diagnostics, performance monitoring, and product analytics dashboards for all 5 metric categories from ADR 0002. In Phase 2, spans will also be exported to a company-owned Grafana instance via OTLP for long-term retention and custom analytics. The CLI code does not change between phases — only the exporter configuration. + +The trace file and user-owned OTLP collector are chosen per run with `SUPABASE_TRACE_FILE` or +`SUPABASE_OTLP_ENDPOINT`, and the span console with `SUPABASE_DEBUG=1` or +`SUPABASE_TELEMETRY_DEBUG=1`; see [ADR 0027](adr/0027-cli-tracing-conventions.md). + +## Collection Architecture + +`withTelemetry()` middleware wrapping Stricli command handlers. The middleware: + +- Records `startup_ms` (time from process start to handler entry) +- Creates a root OTel span for the command invocation +- Runs the handler +- Records `duration_ms`, `exit_code`, `error_code` as span attributes +- Collects API stats from an injected API client +- Sets span status and ends the span +- Handlers never interact with telemetry directly + +Pattern: + +```typescript +function withTelemetry(handler: CommandHandler): CommandHandler { + return async (flags) => { + const tracer = trace.getTracer("supabase-cli"); + return tracer.startActiveSpan(`cli.command.${flags.__command}`, async (span) => { + const start = performance.now(); + span.setAttributes({ + "cli.command": flags.__command, + "cli.startup_ms": start - globalThis.__processStart, + "cli.device_id": getDeviceId(), + "cli.session_id": getSessionId(), + "cli.is_first_run": isFirstRun(), + "cli.is_tty": process.stdout.isTTY ?? false, + "cli.is_ci": Boolean(process.env.CI), + "cli.version": CLI_VERSION, + "os.type": process.platform, + "host.arch": process.arch, + }); + + const result = await handler(flags); + + const exitCode = result.ok ? 0 : exitCodeFromError(result.error); + span.setAttributes({ + "cli.exit_code": exitCode, + "cli.duration_ms": performance.now() - start, + "cli.api_request_count": apiClient.requestCount, + "cli.api_request_duration_ms": apiClient.requestDurationMs, + "cli.api_request_errors": apiClient.requestErrors, + }); + + if (!result.ok) { + span.setStatus({ code: SpanStatusCode.ERROR, message: result.error.message }); + span.setAttribute("cli.error_code", result.error.code); + } else { + span.setStatus({ code: SpanStatusCode.OK }); + } + + span.end(); + return result; + }); + }; +} +``` + +Integration with Stricli's lazy imports: + +```typescript +command({ + func: async (flags) => { + const { runDev } = await import("./dev.handler"); + return withTelemetry(runDev)(flags); + }, +}); +``` + +## Identity + +**Anonymous phase** — before login: + +`device_id`: random UUID generated on first run, persisted in `/telemetry.json`. Never changes unless the file is deleted. This is the only identity before the user runs `supabase login`. It is attached to every span as the `cli.device_id` resource attribute. + +`session_id`: random UUID that rotates after 30 minutes of inactivity (no CLI commands). This defines "session" for the Engagement metrics. + +`is_first_run`: true only on the very first CLI execution ever (when `telemetry.json` doesn't exist yet). Powers the Onboarding metrics. + +Note: `user_id` (Supabase account UUID) is a future enhancement, pending a profile endpoint that returns the account UUID from the auth token. When available, it will be attached as `cli.user_id` resource attribute and will enable cross-device identity linking. + +**OTel resource attributes**: + +```typescript +// Resource attributes set once at SDK initialization +const resource = new Resource({ + "service.name": "supabase-cli", + "service.version": CLI_VERSION, + "cli.device_id": getDeviceId(), // always present, never rotates + "os.type": process.platform, + "host.arch": process.arch, +}); +``` + +**Identity lifecycle**: + +``` +┌─────────────────────────────────┐ +│ Anonymous │ +│ │ +│ cli.device_id ✓ (always set) │ +│ cli.user_id ✗ (future) │ +└─────────────────────────────────┘ +``` + +Privacy guarantees: + +| What we track | What we never track | +| ----------------------------------------- | -------------------------------------- | +| Random device UUID | IP address, username, hostname | +| Command name and exit code | Command arguments or flag values | +| Timing and error codes | File paths, SQL content, project names | +| OS and architecture | Environment variables | +| Stack traces (via span.recordException()) | Email, name, or other profile data | + +## Local Traces + +Local traces are opt-in per run: `SUPABASE_TRACE_FILE` appends sanitized OTLP/JSON batches to a +file, `SUPABASE_OTLP_ENDPOINT` sends them to a collector the user runs, and `SUPABASE_DEBUG=1` or +`SUPABASE_TELEMETRY_DEBUG=1` prints the top of the span tree and every failed span to stderr. +`--debug` does not print spans. The CLI no longer writes `/traces/`. See +the [tracing how-to](../apps/cli/docs/tracing-monitoring.md) and +[ADR 0027](adr/0027-cli-tracing-conventions.md). + +## Remote Export + +Single pipeline, one consent gate, phased backends: + +### Phase 1: Sentry (now) + +- Uses `@sentry/bun` SDK which has native OpenTelemetry integration — no separate `@opentelemetry/exporter-trace-otlp-http` needed +- Sentry SDK is lazy-loaded (only imported when consent is granted) +- PII filtering via Sentry's `beforeSendTransaction` / `beforeSend` hooks — strips file paths, environment variables, and usernames before data leaves the CLI +- Error spans → Sentry Issues; performance spans → Sentry Performance; custom span attributes → Sentry tags +- Error spans include stack traces and error context for debugging and alerting + +```typescript +// Phase 1: Sentry — initialized once when consent is granted +import * as Sentry from "@sentry/bun"; + +Sentry.init({ + dsn: SENTRY_DSN, + release: `supabase-cli@${CLI_VERSION}`, + tracesSampleRate: 1.0, + beforeSendTransaction(event) { + return stripPii(event); + }, + beforeSend(event) { + return stripPii(event); + }, +}); +``` + +### Phase 2: Grafana (future) + +- Add `@opentelemetry/exporter-trace-otlp-http` alongside Sentry +- Both exporters receive the same spans via a composite span processor +- Sentry continues for real-time alerting and error triage; Grafana provides long-term retention and custom dashboards +- The CLI code does not change — only the exporter configuration + +### Shared behavior + +- Does not send data unless consent is `granted` +- Does not block command execution +- Lazy-loaded to avoid startup cost when consent is `denied` + +Performance: total overhead < 1ms per command (span construction + non-blocking SDK calls). + +### End-to-end example: `supabase projects list` + +**Success path** — user runs `supabase projects list` and gets a list of projects: + +```typescript +// 1. withTelemetry() creates a root span +const span = tracer.startSpan("cli.command.projects list"); +const start = performance.now(); // 45ms after process start + +// 2. Set attributes at span start +span.setAttributes({ + "cli.command": "projects list", + "cli.startup_ms": 45, + "cli.device_id": "a1b2c3d4-...", + "cli.session_id": "e5f6g7h8-...", + "cli.is_first_run": false, + "cli.is_tty": true, + "cli.is_ci": false, + "cli.version": "0.1.0", + "os.type": "darwin", + "host.arch": "arm64", +}); + +// 3. Handler runs +const result = await listProjects(flags); // { ok: true, data: [...] } + +// 4. Set outcome attributes and end span +span.setAttributes({ + "cli.exit_code": 0, + "cli.duration_ms": 234, + "cli.api_request_count": 1, + "cli.api_request_duration_ms": 189, + "cli.api_request_errors": 0, +}); +span.setStatus({ code: SpanStatusCode.OK }); +span.end(); + +// 5. Only when SUPABASE_TRACE_FILE is set: append the sanitized OTLP batch to that file + +// 6. If consent === "granted": Sentry SDK exports the span +// Non-blocking — SDK batches internally +``` + +**Error path** — user runs `supabase projects list` but their token has expired: + +```typescript +// 1. withTelemetry() creates a root span (same as success) +const span = tracer.startSpan("cli.command.projects list"); + +// 2. Set initial attributes (same as success) +span.setAttributes({ + "cli.command": "projects list", + "cli.startup_ms": 45, + // ... identity and environment attributes ... +}); + +// 3. Handler returns an error +const result = await listProjects(flags); +// { ok: false, error: { code: "AUTH_TOKEN_EXPIRED", message: "..." } } + +// 4. Set error attributes, record exception, set ERROR status +span.setAttributes({ + "cli.exit_code": 1, // error + "cli.duration_ms": 12, // fast failure + "cli.error_code": "AUTH_TOKEN_EXPIRED", + "cli.api_request_count": 1, + "cli.api_request_duration_ms": 8, + "cli.api_request_errors": 1, +}); +span.recordException(result.error); // attaches stack trace as span event +span.setStatus({ + code: SpanStatusCode.ERROR, + message: "AUTH_TOKEN_EXPIRED", +}); +span.end(); + +// 5. Only when SUPABASE_TRACE_FILE is set: append the sanitized OTLP batch (same as success) + +// 6. If consent === "granted": Sentry SDK exports the error span +// Sentry alerts if AUTH_TOKEN_EXPIRED spikes across devices +``` + +**Workflow command** — `supabase dev` with child spans (connects to ADR 0007): + +```typescript +// Root span for the command +const rootSpan = tracer.startSpan("cli.command.dev"); + +// Child spans for each phase — created by the handler via context propagation +const configSpan = tracer.startSpan("cli.phase.config.load", { parent: rootSpan }); +// ... config loads ... +configSpan.setAttribute("cli.phase.duration_ms", 12); +configSpan.end(); + +const dockerSpan = tracer.startSpan("cli.phase.docker.start", { parent: rootSpan }); +// ... docker starts ... +dockerSpan.setAttribute("cli.phase.duration_ms", 890); +dockerSpan.end(); + +const healthSpan = tracer.startSpan("cli.phase.healthcheck.wait", { parent: rootSpan }); +// ... healthcheck passes ... +healthSpan.setAttribute("cli.phase.duration_ms", 230); +healthSpan.end(); + +// Root span outcome +rootSpan.setAttributes({ + "cli.exit_code": 0, + "cli.duration_ms": 1200, + "cli.startup_ms": 38, +}); +rootSpan.setStatus({ code: SpanStatusCode.OK }); +rootSpan.end(); + +// Sentry receives a full trace with parent + child spans: +// enables per-phase latency dashboards (e.g. "p95 cli.phase.docker.start duration") + +// SUPABASE_TRACE_FILE or SUPABASE_OTLP_ENDPOINT captures the same tree locally: +// supabase dev (total: 1.2s) +// ├── config.load: 12ms +// ├── docker.start: 890ms +// └── healthcheck.wait: 230ms +``` + +## Consent Implementation + +Three-state model stored in `/telemetry.json`: + +```typescript +type ConsentState = "pending" | "granted" | "denied"; +``` + +Flow: + +``` +First CLI run + │ + ▼ +Is TTY? ──No──→ consent = "denied" (no prompt for CI/LLMs) + │ + Yes + │ + ▼ +Prompt user (via Clack): +"Help improve the Supabase CLI by sending anonymous usage data? (y/N)" + │ + ├─ y → consent = "granted" + └─ N → consent = "denied" + +At any time: + supabase telemetry enable → "granted" + supabase telemetry disable → "denied" + supabase telemetry status → show current state + +Environment override: + SUPA_TELEMETRY=off → treated as "denied" (skips prompt) + SUPA_TELEMETRY=on → treated as "granted" (skips prompt) +``` + +Non-TTY defaults to `denied` without prompting — this means LLM agents and CI pipelines never see a consent prompt, and no data is sent unless explicitly enabled via env var or `supabase telemetry enable`. + +## Deriving Metrics from Events + +Mapping every metric from the 5 categories to a query over span attributes. Queries use TraceQL-like syntax referencing span attributes: + +| Category | Metric | Derived from | +| ---------- | -------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------- | +| Adoption | Monthly Active Users (MAU) | `count(distinct resource.cli.device_id) where span.cli.command exists and timestamp > now() - 30d` | +| Adoption | New installs per week | `count(distinct resource.cli.device_id) where span.cli.is_first_run = true and timestamp > now() - 7d` | +| Adoption | LLM vs human split | `count(*) by span.cli.is_tty` (false = LLM/CI, true = human) | +| Engagement | Commands per session | `count(*) by span.cli.session_id` → average | +| Engagement | Command frequency distribution | `count(*) by span.cli.command order by count desc` | +| Engagement | Multi-command chains | `count(distinct span.cli.session_id) where session_span_count >= 3` | +| Retention | Week 1 retention | `resource.cli.device_id` seen in both week 0 and week 1 after `span.cli.is_first_run = true` | +| Retention | Month 1 retention | `resource.cli.device_id` seen in both month 0 and month 1 after `span.cli.is_first_run = true` | +| Retention | Churn by command | Last `span.cli.command` before a `resource.cli.device_id` stops appearing | +| Quality | Command success rate | `count(span.cli.exit_code = 0) / count(*)` | +| Quality | Error code distribution | `count(*) by span.cli.error_code where span.cli.error_code exists` | +| Quality | p50/p95 command latency | `histogram_quantile(0.50, span.cli.duration_ms)`, `histogram_quantile(0.95, span.cli.duration_ms)` | +| Onboarding | Time to first successful command | `min(timestamp where span.cli.exit_code = 0) - min(timestamp) where span.cli.is_first_run = true` per `resource.cli.device_id` | +| Onboarding | Drop-off funnel | Sequential presence of `is_first_run → cli.command='login' → cli.command='dev' OR cli.command='link'` per `resource.cli.device_id` | + +**Phase 1 (Sentry)**: Metrics are derived via Sentry Discover queries filtering on span tags (`cli.command`, `cli.device_id`, etc.). Error code distribution and crash diagnostics use native Sentry Issues. + +**Phase 2 (Grafana)**: The same span attributes power Grafana dashboards via TraceQL or PromQL. Long-term retention enables cohort analysis for retention and onboarding metrics that require multi-week time windows. + +Completeness check — every span attribute is used by at least one metric: + +| Attribute | Used by | +| ---------------------------------------- | ---------------------------------------------------- | +| `resource.cli.device_id` | MAU, retention, churn, onboarding funnel | +| `span.cli.session_id` | Commands per session, multi-command chains | +| `span.cli.is_first_run` | New installs, retention cohorts, onboarding funnel | +| `span.cli.command` | Command frequency, churn by command, drop-off funnel | +| `span.cli.exit_code` | Command success rate | +| `span.cli.duration_ms` | p50/p95 latency | +| `span.cli.startup_ms` | Performance monitoring (ADR 0001 budgets) | +| `span.cli.error_code` | Error code distribution | +| `span.cli.is_tty` | LLM vs human split | +| `span.cli.is_ci` | LLM vs human split (refinement) | +| `resource.os.type`, `resource.host.arch` | Segment any metric by platform | +| `resource.service.version` | Segment any metric by version, track regression | +| `span.cli.api_request_count` | Performance analysis | +| `span.cli.api_request_duration_ms` | Performance analysis | +| `span.cli.api_request_errors` | Quality analysis (backend reliability) | +| child spans (phases) | Per-phase latency breakdown for workflow commands | + +Note: `cli.user_id` (Supabase account UUID) is omitted from v1. It will be added as a future enhancement when a profile endpoint is available, enabling cross-device identity linking and per-account error lookup. + +Performance impact: + +| Operation | Cost | +| ------------------------- | --------- | +| Span construction | < 0.1ms | +| Sentry SDK export (async) | < 0.1ms | +| **Total per command** | **< 1ms** | + +## Implementation Status + +| Area | Current State | Target State | +| ----------------- | ---------------------------------------- | ---------------------------------------------- | +| Tracing framework | LogTape structured logging (flat events) | OTel spans via `@sentry/bun` | +| ConsentState | 2-state (`"granted" \| "denied"`) | 3-state (`"pending" \| "granted" \| "denied"`) | +| Default consent | `"granted"` when no config exists | `"denied"` for non-TTY; prompt for TTY | +| API metrics | Fields in type but not collected | Collect from injected API client | +| Remote export | None (opt-in trace file or collector) | Sentry SDK (Phase 1) | +| PII filtering | None | `beforeSend` hooks in Sentry config | +| `cli_version` | Hardcoded `"0.1.0"` | Read from package.json or build constant | +| Child spans | Not implemented | Per-phase spans for workflow commands | From 37a730860ead845e1a71c6eb4b1e90bdeda0ffe1 Mon Sep 17 00:00:00 2001 From: Kanad Gupta Date: Thu, 19 Nov 2026 10:54:27 -0800 Subject: [PATCH 4/4] ci: note that migra and pg_prove are no longer published Generated with AI Co-Authored-By: Claude --- .github/dependabot.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index c24da2c9cc..2d59521e94 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -66,8 +66,8 @@ updates: # These lines are generated from packages/stack/src/Artifacts.ts (the single version table # for slim-capable services); updates to them arrive through slim-release-published.yml, not # Dependabot. Kong and pg14 (supabase/postgres) have no slim build either, but are bumped by - # hand, not by Dependabot. Dependabot keeps bumping only the images that remain genuinely - # upstream-only: migra, pg_prove, pgadmin-schema-diff. + # hand, not by Dependabot. Dependabot still watches migra, pg_prove, and pgadmin-schema-diff, + # but nothing publishes new migra or pg_prove tags, so those two stay at their current pins. ignore: - dependency-name: "library/kong" - dependency-name: "axllent/mailpit"