Skip to content

feat(telemetry): add default-on usage analytics and detached batch delivery - #76

Open
littleDogWang wants to merge 10 commits into
mainfrom
codex/cli-analytics
Open

littleDogWang wants to merge 10 commits into
mainfrom
codex/cli-analytics

Conversation

@littleDogWang

@littleDogWang littleDogWang commented Nov 16, 2026 •

Copy link
Copy Markdown
Collaborator

Add usage analytics for Recipes, init and project creation across shell and MCP. Capture defaults to enabled when a valid collector is configured, with a first-use shell notice, MCP initialization instructions and saved/runtime opt-out controls.

  • Collect each operation in memory, then hand one JSON batch through stdin to a detached sender. Send one HTTP request with a ten-second timeout, without retry or a persistent queue.
  • Bound the local pipe handoff to 100 ms. Remove streaming queues and the two-child admission gate so consecutive MCP calls can flush independently while earlier senders wait for responses.
  • Honor proxy and certificate environment settings while isolating business credentials. Preserve the 64 KiB request limit; drop oversized operations as a whole.
  • Record project creation at the shared API call boundary, independently of later setup failures. Use installation/operation IDs and validated project App IDs; exclude credentials, account identities, user content, paths, full commands and raw errors.
  • Label Recipe and Quickstart attempts at startup. Include a Recipe ID after the public catalog confirms it, and report unresolved Recipe attempts separately. Classify an existing target directory as local_validate.
  • On Windows, verify the detached sender uses the configured HTTPS proxy and check the installation ID file's ACL. The ACL test recognizes the machine's built-in Administrator account.
  • Preserve the runtime opt-out meaning of enabled in shell and MCP status. Report savedPreference, transportConfigured and captureActive separately and document the JSON contract.

Validation: go test -count=1 ./..., go vet, and the command reference and error code checks passed. golangci-lint 2.12.2 reported zero issues for the Linux target using Go 1.26.5 in a temporary checkout. GitHub Actions passed on Ubuntu, macOS, and Windows, including the Windows proxy and installation ID ACL tests. The separate govulncheck job still fails. Local CLI → SSP → mock PostHog verification captured 20 events in 10 requests, including matching shell and MCP Recipe attribution and directory conflict results.

Deploy the collector change in SSP #62 and publish the updated public telemetry disclosure before enabling this CLI build.

The embedded collector URL remains empty. An operation interrupted before handoff can lose its entire in-memory batch, and long operations are visible only after completion. Production capture and real PostHog ingestion remain unverified.

Companion collector PR: https://github.com/AgoraLab/ssp-service/pull/62.

Review follow-up

  • Clarify that Agora App IDs can be associated with projects and companies.
  • Return the disclosure in MCP initialization instructions. MCP no longer marks the shell notice as shown. Whether the host displays the instructions depends on the host.
  • Shell notice and first capture can still occur in the same invocation. Confirm the default-on disclosure policy before configuring a release collector.
  • Local verification passed with go test ./... and go run ./cmd/gendocs -check. Regression coverage includes DO_NOT_TRACK and the MCP notice marker.

Add anonymous core-flow events, optional webpage attribution, Agent classification and bounded collector delivery. Honor live MCP opt-out and Retry-After, classify EOF as failure, and emit each init validation stage once. Include privacy documentation and regression coverage.
@digitallysavvy

Copy link
Copy Markdown
Contributor

@littleDogWang,

Overall, I like the approach here, especially the effort to limit what's collected and exclude sensitive data.

A few things I'd like us to revisit before merging:

  1. Consent: Do we need to require an explicit opt-in for all of these events? Most of what we're collecting is basic product usage and operational metrics. I'd like to separate aggregate telemetry from persistent user/installation tracking and confirm what we can collect without interrupting the developer workflow.
  2. Web attribution: The browser-to-CLI tracking is useful for understanding conversions, but I'd treat this separately from general CLI telemetry. We should verify that we're respecting website consent and avoid passing persistent tracking IDs through shell commands or agent prompts.
  3. Performance: The five-second telemetry drain concerns me. We shouldn't potentially delay a CLI command or MCP tool call by several seconds just to deliver analytics.
  4. Collection scope: The events and metadata look reasonable. I like that we're capturing init failures and stages without sending raw errors, project names, credentials, or source code.

I'd also like to verify the BFF/PostHog privacy configuration before we enable collection in a release.

My preference is to keep basic operational analytics as frictionless as legally permissible, while giving developers clear controls and treating cross-session attribution separately.

@littleDogWang littleDogWang changed the title feat(telemetry): add opt-in usage analytics for recipes and init feat(telemetry): add default-on usage analytics and detached delivery Nov 17, 2026
@littleDogWang littleDogWang changed the title feat(telemetry): add default-on usage analytics and detached delivery feat(telemetry): add default-on usage analytics and detached batch delivery Nov 19, 2026

@shczhen shczhen left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified Recipe attribution, local validation for directory conflicts, and the passing Linux, macOS, and Windows checks. Before release, upgrade Go in CI and release builds, then rerun govulncheck. The baseline scan reports the same 13 standard library vulnerabilities.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants