Repository navigation
Fill the empty account charts in PostHog by syncing keys from Vercel - #26
Merged
Merged
Conversation
The production Convex deployment never had POSTHOG_PROJECT_KEY or CLERK_WEBHOOK_SECRET, so account_stats and account_created events were never sent. Our Convex accounts can't write production variables, but the production build's deploy key can, so the build now copies both from Vercel through stdin. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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. |
This branch had an error being deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The account charts in PostHog ("Active accounts (DAU, WAU, MAU)", weekly/monthly active accounts, synced accounts, accounts created) have been empty since launch. Visitor DAU/WAU works fine; only the account numbers are missing.
Those numbers come from Convex, and the production Convex deployment never had
POSTHOG_PROJECT_KEY(so the dailyaccount_statsreport does nothing) orCLERK_WEBHOOK_SECRET(so the Clerk webhook returns 503 andaccount_created/account_deletednever fire). Our Convex accounts only have Developer access to production and can't set those variables or view deploy keys.The production build already holds an admin deploy key, so
scripts/vercel-build.shnow copies both into Convex on every production deploy, with Vercel as the single place to set them:POSTHOG_PROJECT_KEY←NEXT_PUBLIC_POSTHOG_KEY(the same public project key)CLERK_WEBHOOK_SECRET←CLERK_WEBHOOK_SECRET, when set in Vercel's Production environmentValues go in through stdin, so they never show up in the command line or the build log. Preview builds don't touch production.
Testing
pnpmfor production (both set, Clerk secret unset), preview with a preview key, and preview with a prod key: production syncs, previews never do, unset values are skipped.After merge, the first
account_statspoint lands at the 00:05 UTC cron.Proved by running the build script against a stub
pnpmfor every environment, and piping a value through the real Convex CLI on the dev deployment.Reviewed with sol-loop: 1 round with gpt-6.1-sol. Sol verdict: approved
Generated by
claude-opus-5-5using the Claude Code harness.🤖 Generated with Claude Code
Note
Medium Risk
Changes the production deploy path to write Clerk webhook and PostHog keys into Convex; logic is unchanged but a bad or leaked build env could break webhook verification or analytics until the next successful sync.
Overview
Production PostHog account charts stayed empty because the production Convex deployment never received
POSTHOG_PROJECT_KEYorCLERK_WEBHOOK_SECRET, while the team could not set those on Convex directly.scripts/vercel-build.shnow runs only forVERCEL_ENV=productionwith aprod:deploy key: a newsync_convex_envhelper pipes Vercel values intoconvex env setvia stdin (so they are not echoed in logs), mappingNEXT_PUBLIC_POSTHOG_KEY→POSTHOG_PROJECT_KEYandCLERK_WEBHOOK_SECRET→CLERK_WEBHOOK_SECRET. Unset Vercel values are skipped so Convex is left unchanged; preview builds still refuse to deploy with a production key..env.exampleandREADME.mdnow tell operators to configure those secrets in Vercel’s Production environment instead of manually on Convex, since each production deploy keeps Convex in sync.Reviewed by Cursor Bugbot for commit fc2d3b4. Bugbot is set up for automated code reviews on this repo. Configure here.