Skip to content

Fill the empty account charts in PostHog by syncing keys from Vercel - #26

Merged
The1UNeed merged 1 commit into
mainfrom
fix/account-analytics-env
Nov 4, 2026
Merged

The1UNeed merged 1 commit into
mainfrom
fix/account-analytics-env

Conversation

@The1UNeed

@The1UNeed The1UNeed commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

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 daily account_stats report does nothing) or CLERK_WEBHOOK_SECRET (so the Clerk webhook returns 503 and account_created/account_deleted never 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.sh now 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 environment

Values go in through stdin, so they never show up in the command line or the build log. Preview builds don't touch production.

Testing

  • Ran the script with a stub pnpm for 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.
  • Piped a throwaway variable into the real Convex CLI on the dev deployment, read it back, and removed it.

After merge, the first account_stats point lands at the 00:05 UTC cron.

Proved by running the build script against a stub pnpm for 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-5 using 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_KEY or CLERK_WEBHOOK_SECRET, while the team could not set those on Convex directly.

scripts/vercel-build.sh now runs only for VERCEL_ENV=production with a prod: deploy key: a new sync_convex_env helper pipes Vercel values into convex env set via stdin (so they are not echoed in logs), mapping NEXT_PUBLIC_POSTHOG_KEY → POSTHOG_PROJECT_KEY and CLERK_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.example and README.md now 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.

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>
@vercel

vercel Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
pseudoeditor.dev Error Error Nov 4, 2026 11:51am UTC

Request Review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 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
📝 Code Review ✅ Completed 2026-11-04T11:52:55.640277Z fc2d3b4 PR opened
ℹ️ 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.

@The1UNeed
The1UNeed merged commit 1e6a41a into main Nov 4, 2026
6 of 7 checks passed

This branch had an error being deployed

1 failed deployment
Preview — fc2d3b40 Deployed Nov 4, 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

None yet

Development

Successfully merging this pull request may close these issues.

1 participant