PostHog / PostHog/posthog

feat: environment mapping in Vercel connect flow

Open
#52,604 0 comments 0 reactions 1 assignee View on GitHub

@MattBro is already working on this.

Since Mar 27, 2026.

Dominant language
Python
Stars
39.9k
Forks
3.4k
Avg merge
6h 51m
Merged PRs (30d)
232

Description

Problem

When connecting an existing PostHog account to Vercel, users can only link one PostHog project. But many users have separate PostHog projects for prod vs dev (e.g., a sandbox project for development). They want to map different PostHog projects to different Vercel environments:

  • Vercel production → PostHog prod project
  • Vercel preview/dev → PostHog sandbox project

Currently we push one set of env vars (NEXT_PUBLIC_POSTHOG_PROJECT_TOKEN, NEXT_PUBLIC_POSTHOG_HOST) for all environments. Vercel's API supports environmentOverrides to set different values per environment, and we already have the serializer for it.

Reported by Valentin (dotworld) in the support thread.

Solution

Update the connect flow to show environment mapping in the project picker:

  • After selecting an org, show a mapping UI: one row per Vercel environment (production, preview, development) with a PostHog project dropdown each
  • Default all three to the same project (current behavior)
  • If the user has multiple projects, they can assign different ones per environment
  • On submit, create Integration resources for each unique team, call import_resource with environmentOverrides in secrets
  • Flag sync comes from the production project

What exists today

  • Vercel secrets API supports environmentOverrides (development, preview, production)
  • VercelSecretEnvironmentOverridesSerializer already exists in vercel_resource.py
  • The connect flow already has org + project pickers (from #52480)

Work

  • Update VercelConnectLinkSerializer to accept environment mappings instead of single team_id
  • Update complete endpoint to handle multiple teams and pass environmentOverrides to import_resource
  • Update VercelConnect.tsx to show environment mapping UI
  • Update flag sync to use the production team as primary

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.