Skip to content

feat(telemetry): send the CLI's usage analytics and the service ping to Mixpanel through the Zitadel cloud - #2296

Merged
fforootd merged 2 commits into
mainfrom
claude/analytics-mixpanel-proxy
Oct 24, 2026
Merged

fforootd merged 2 commits into
mainfrom
claude/analytics-mixpanel-proxy

Conversation

@fforootd

@fforootd fforootd commented Oct 24, 2026 •

Copy link
Copy Markdown
Member

Stacked on #2253, which sits on #2292: review those first. This PR adds the Mixpanel proxy, and sends the CLI's events and the service ping through it.

Summary

The CLI's usage analytics and the server's service ping now reach Mixpanel through the Zitadel cloud, so released CLIs and servers name an address we own rather than Mixpanel's.

  • The cloud: vercel.json gets an external rewrite, /telemetry/mixpanel/:path(.*) → https://api-eu.mixpanel.com/:path, ahead of the server's catch-all. It belongs to no service and runs no code: Vercel forwards the request and returns Mixpanel's answer.
  • The CLI: the EU endpoint, the default because our projects are in the EU, is now preview.zitadel.com with the path prefix /telemetry/mixpanel, set through the Mixpanel SDK's path option. ZITADEL_TELEMETRY_REGION=us still sends straight to Mixpanel's US host. The Vercel copy's endpoint takes the same host constant. What the CLI sends is unchanged, and its events already carry ip: 0, so Mixpanel doesn't locate them by the proxy's address either.
  • The service ping now goes to Mixpanel too, through the same proxy, into the CLI's project. It sends the six properties it sends Vercel, plus ip: 0 and an $insert_id, with the poc_ prefix in both places. It sends no distinct_id, because the server has no install id yet.
    • Config: service_ping.vercel_endpoint (formerly service_ping.endpoint), service_ping.mixpanel_endpoint and service_ping.mixpanel_token. They default to the Vercel intake, the proxy and the CLI's production token, which is write-only and published like the CLI's copy.
    • A destination without an endpoint, or Mixpanel without a token, is skipped. A failure at one destination is logged and doesn't stop the other.
  • The catalog: service_ping lists both destinations, and the server's context gains ip and $insert_id. Its Vercel copy keeps the six properties, and a mixpanel block gives the prefix. The Go catalog test checks what the ping sends to each destination.
  • What holds them together:
    • config.test.ts fails when the CLI's path and the rewrite drift apart, or when the rewrite falls behind the catch-all. cli:test lists vercel.json as an input, in moon and turbo.
    • The console's deployment suite posts an event without a token through the proxy, on every deployment, and expects Mixpanel's refusal, which records nothing.
  • Docs: the telemetry page, the CLI's AGENTS.md and the cloud runbook say where events go, and that released CLIs and servers depend on the path.

Validation

  • vitest run in apps/cli: 4224 tests in 223 files pass. The ping change touches no CLI code; the catalog and config tests pass again after it, on the rebased stack.
  • go test ./internal/serviceping/ ./cmd/server/, go vet, gofmt -l and the repo's analyzers on both packages: clean.
  • biome check on the changed files; tsc --noEmit for both CLI projects and for e2e; the CLI build: clean.
  • node scripts/check-moon-graph.mjs: ok. node scripts/check-pr-title.mjs --title "…": ok.
  • Mixpanel's answer to an event without a token, sent straight to api-eu.mixpanel.com/track?verbose=1: {"error":"token, missing or empty","status":0}, HTTP 200. Through the proxy on this PR's preview deployment, the deployment test got the same answer: /telemetry/mixpanel/* reaches Mixpanel's EU API passed in deployment-checks / console (Preview) on 0b5e53a (run).
  • One event shaped exactly like the ping's Mixpanel event, sent to the CLI's development project, came back {"error":null,"status":1}. So Mixpanel takes it without a distinct_id, with the time in milliseconds, a 32-character $insert_id and ip: 0.

Release notes / changeset

  • .changeset/cli-telemetry-proxy.md (@zitadel/cli, minor): the CLI sends its usage analytics through the Zitadel cloud, which passes them on to Mixpanel. What it sends is unchanged; a network that allows only Mixpanel's address now has to allow preview.zitadel.com.
  • .changeset/server-service-ping-mixpanel.md (@zitadel/server, minor): the opt-in service ping also reports to Mixpanel through the Zitadel cloud, with the same properties, no install id and no location by IP address.

Notes

  • No install id yet: without a distinct_id, Mixpanel counts pings, not installs. An anonymous install id kept in the database would add that, and it's left for later.
  • Only Mixpanel is proxied. The Vercel copy and the ping's Vercel event already post to our host, on Vercel's own /_vercel/insights/event path. A rewrite in front of that would hide the path, but the intake would then see the proxy's IP address, which is what Vercel counts visitors and works out locations by.
  • The cloud now sees the requests: each CLI event and ping passes through Vercel, with the sender's IP address, on its way to Mixpanel.
  • The token now exists twice, in the CLI's config.ts and in internal/serviceping.
  • The address: preview.zitadel.com is the cloud's production host. A host of its own, such as telemetry.zitadel.com, would keep telemetry apart from the product's domain; that takes a DNS record and a domain on the project, not code. Mixpanel also offers first-party domains, a DNS record pointed at Mixpanel, as an alternative to a proxy.
  • Stack: feat(telemetry): add surface to the zitadel CLI's usage analytics events #2292, then feat(telemetry): send CLI usage events and a service ping to Vercel Web Analytics #2253, then this one. When the PR below lands, GitHub retargets the next one to main, which then needs main merged in. A PR in a stack goes into the merge queue through the merge-async API, not gh pr merge.

🤖 Generated with Claude Code

@vercel

vercel Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
cloud Ready Ready Preview Oct 24, 2026 4:42am UTC

Request Review

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦋 Changeset detected

Latest commit: 70439a4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 25 packages
Name Type
@zitadel/cli Minor
@zitadel/server Minor
@zitadel/testing Minor
@zitadel/server-linux-x64 Minor
@zitadel/server-linux-arm64 Minor
@zitadel/server-darwin-x64 Minor
@zitadel/server-darwin-arm64 Minor
@zitadel/server-win32-x64 Minor
@zitadel/api Minor
@zitadel/config Minor
@zitadel/components Minor
@zitadel/sdk-core Minor
@zitadel/sdk-next Minor
@zitadel/sdk-nuxt Minor
@zitadel/sdk-react Minor
@zitadel/sdk-vue Minor
@zitadel/sdk-angular Minor
@zitadel/sdk-solid Minor
@zitadel/sdk-svelte Minor
@zitadel/sdk-qwik Minor
@zitadel/sdk-sveltekit Minor
@zitadel/sdk-solid-start Minor
@zitadel/sdk-qwik-router Minor
@zitadel/sdk-tanstack-start Minor
@zitadel/website Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@fforootd
fforootd added this pull request to stack #2295 October 24, 2026 03:47
@fforootd
fforootd marked this pull request as ready for review October 24, 2026 04:00
Copilot AI balanced review requested due to automatic review settings October 24, 2026 04:00
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-10-24T04:06:16.230897Z fdd79c3 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

It changes production cloud routing by introducing an externally reachable forwarding proxy and alters where released CLIs send telemetry, operational and security-sensitive decisions that warrant human sign-off.

No open issues 🎉

What changed in this PR

This PR routes the zitadel CLI's Mixpanel usage analytics through the Zitadel cloud (preview.zitadel.com/telemetry/mixpanel) instead of sending them straight to api-eu.mixpanel.com, so released CLIs name an address Zitadel owns. It adds a token-agnostic Vercel external rewrite that forwards to Mixpanel's EU API, wires the CLI's EU endpoint through the Mixpanel SDK's path option, and adds unit/deployment tests plus docs that keep the CLI path and the rewrite in lockstep. It is the top of a stack on #2253 and #2292.

Changes:

  • Added a vercel.json rewrite /telemetry/mixpanel/:path(.*) → https://api-eu.mixpanel.com/:path, ahead of the server catch-all.
  • Reworked CLI telemetry config to resolve a {host, path} endpoint (EU via cloud proxy, US direct) and pass path to the Mixpanel client.
  • Added a unit test binding the CLI path to the rewrite, a console deployment test probing the proxy, docs, AGENTS note, moon/turbo inputs, and a @zitadel/cli changeset.
File Description
vercel.json Adds the external Mixpanel proxy rewrite ahead of the server catch-all.
apps/​cli/​src/​lib/​telemetry/​config.ts Replaces host-only resolution with {host, path} endpoints; adds CLOUD_HOST.
apps/​cli/​src/​lib/​telemetry/​index.ts Builds the Mixpanel client from the resolved endpoint, passing path.
apps/​cli/​src/​lib/​telemetry/​vercel.ts Derives the Vercel intake URL from the shared CLOUD_HOST.
apps/​cli/​src/​types/​mixpanel.d.ts Declares the path init option used for the proxy prefix.
apps/​cli/​tests/​unit/​lib/​telemetry/​config.test.ts Tests endpoint resolution and that the rewrite matches the CLI path, ahead of the catch-all.
e2e/​console/​src-deployment/​routes.spec.ts Deployment check that the proxy reaches Mixpanel's EU API.
apps/​cli/​moon.yml, apps/​cli/​turbo.json Add vercel.json as a cli:test input.
apps/​cli/​AGENTS.md, apps/​docs/​.../​telemetry.mdx, docs/​runbooks/​cloud.md Document the proxy path and dependency.
.changeset/​cli-telemetry-proxy.md Customer-facing @zitadel/cli minor note.

Review effort: Balanced

@fforootd fforootd changed the title feat(telemetry): send the zitadel CLI's usage analytics to Mixpanel through the Zitadel cloud feat(telemetry): send the CLI's usage analytics and the service ping to Mixpanel through the Zitadel cloud Oct 24, 2026
@fforootd
fforootd added this pull request to the merge queue Oct 24, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue because a pull request earlier in the stack was removed Oct 24, 2026
Base automatically changed from claude/analytics-cloud-self-hosted-ec32c3 to main October 24, 2026 04:39
fforootd and others added 2 commits October 24, 2026 04:39
…he cloud

vercel.json forwards /telemetry/mixpanel/* to api-eu.mixpanel.com, and
the CLI's EU endpoint is now preview.zitadel.com with that path prefix,
so released CLIs name our address rather than Mixpanel's. A unit test
holds the CLI's path and the rewrite together, and the console's
deployment suite checks that the proxy reaches Mixpanel.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The ping also posts to Mixpanel's track API behind the cloud's proxy,
into the CLI's project: its six properties plus ip: 0 and an $insert_id,
and no distinct_id, as the server has no install id yet. Each
destination has its own endpoint, and a failure at one does not stop
the other. The catalog lists both destinations, and the Go catalog test
checks what each one gets.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@fforootd
fforootd force-pushed the claude/analytics-mixpanel-proxy branch from 92fd025 to 70439a4 Compare October 24, 2026 04:39
@fforootd
fforootd enabled stacked auto-merge October 24, 2026 04:40
@fforootd
fforootd added this pull request to the merge queue Oct 24, 2026
Merged via the queue into main with commit 1a29816 Oct 24, 2026
16 checks passed
@fforootd
fforootd deleted the claude/analytics-mixpanel-proxy branch October 24, 2026 04:51
@github-project-automation github-project-automation Bot moved this from Inbox to Done in Engineering Kanban Oct 24, 2026

This branch was successfully deployed

1 active deployment
Preview — 70439a48 Deployed Oct 24, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

2 participants