Repository navigation
feat(telemetry): send the CLI's usage analytics and the service ping to Mixpanel through the Zitadel cloud - #2296
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 70439a4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 25 packages
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 |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
fdd79c3 to
0b5e53a
Compare
There was a problem hiding this comment.
🔵 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.jsonrewrite/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 passpathto 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/clichangeset.
| 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
…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>
92fd025 to
70439a4
Compare
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.
vercel.jsongets 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.preview.zitadel.comwith the path prefix/telemetry/mixpanel, set through the Mixpanel SDK'spathoption.ZITADEL_TELEMETRY_REGION=usstill 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 carryip: 0, so Mixpanel doesn't locate them by the proxy's address either.ip: 0and an$insert_id, with thepoc_prefix in both places. It sends nodistinct_id, because the server has no install id yet.service_ping.vercel_endpoint(formerlyservice_ping.endpoint),service_ping.mixpanel_endpointandservice_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.service_pinglists both destinations, and the server's context gainsipand$insert_id. Its Vercel copy keeps the six properties, and amixpanelblock gives the prefix. The Go catalog test checks what the ping sends to each destination.config.test.tsfails when the CLI's path and the rewrite drift apart, or when the rewrite falls behind the catch-all.cli:testlistsvercel.jsonas an input, in moon and turbo.AGENTS.mdand the cloud runbook say where events go, and that released CLIs and servers depend on the path.Validation
vitest runinapps/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 -land the repo's analyzers on both packages: clean.biome checkon the changed files;tsc --noEmitfor both CLI projects and fore2e; the CLI build: clean.node scripts/check-moon-graph.mjs: ok.node scripts/check-pr-title.mjs --title "…": ok.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 APIpassed indeployment-checks / console (Preview)on0b5e53a(run).{"error":null,"status":1}. So Mixpanel takes it without adistinct_id, with the time in milliseconds, a 32-character$insert_idandip: 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 allowpreview.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
distinct_id, Mixpanel counts pings, not installs. An anonymous install id kept in the database would add that, and it's left for later./_vercel/insights/eventpath. 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.config.tsand ininternal/serviceping.preview.zitadel.comis the cloud's production host. A host of its own, such astelemetry.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.main, which then needsmainmerged in. A PR in a stack goes into the merge queue through themerge-asyncAPI, notgh pr merge.🤖 Generated with Claude Code