feat(vercel): add connectable account flow for linking existing orgs#49112
feat(vercel): add connectable account flow for linking existing orgs#49112
Conversation
Implements the "Link Existing Account" flow for the Vercel Marketplace integration. When a user installs PostHog from Vercel and already has an existing PostHog account, they can now link their org instead of being forced to create a new one. Billing stays with PostHog for connected accounts. Backend: - OAuth code exchange via POST /v2/oauth/access_token - Cache-based session flow with 10min TTL - Org selection API with admin permission checks - Creates OrganizationIntegration with type=connectable Frontend: - VercelConnect scene (popup) for org selection - Handles login redirect, org picker, success/error states Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add 18 tests for connectable account flow (callback, session, complete) - Handle integration.configuration-removed webhook to clean up OrganizationIntegration records on uninstall - Remove VERCEL_EXTERNAL_REDIRECT_URI env var, use SITE_URL instead - Update webhook tests to cover deauthorization Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Include X-CSRFToken header in the POST to /api/vercel/connect/complete - Add Scenario 5 (Link Existing Account) to manual testing checklist - Update README architecture section for connectable account flow Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Size Change: +704 B (0%) Total Size: 106 MB ℹ️ View Unchanged
|
- Validate next_url against allowed Vercel domains to prevent open redirects - Add capture_exception on error paths for monitoring - Sanitize error messages to avoid leaking Vercel internals to clients - Fix N+1 query in session_info (batch lookup for linked orgs) - Add OAuth response field validation with proper error handling - Distinguish connectable vs native integrations in deauthorize webhook (native uses VercelIntegration.delete_installation for billing cleanup) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
⏭️ Skipped snapshot commit because branch advanced to The new commit will trigger its own snapshot update workflow. If you expected this workflow to succeed: This can happen due to concurrent commits. To get a fresh workflow run, either:
|
Visual regression: Storybook UI snapshots updatedChanges: 1 snapshots (1 modified, 0 added, 0 deleted) What this means:
Next steps:
|
|
⏭️ Skipped snapshot commit because branch advanced to The new commit will trigger its own snapshot update workflow. If you expected this workflow to succeed: This can happen due to concurrent commits. To get a fresh workflow run, either:
|
Cast request.user to User in authenticated views to satisfy mypy's User | AnonymousUser type check. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Query snapshots: Backend query snapshots updatedChanges: 1 snapshots (1 modified, 0 added, 0 deleted) What this means:
Next steps:
|
…able-account # Conflicts: # frontend/__snapshots__/replay-tabs-home-success--recordings-play-list-with-pinned-recordings--light.png
Query snapshots: Backend query snapshots updatedChanges: 1 snapshots (1 modified, 0 added, 0 deleted) What this means:
Next steps:
|
|
🎭 Playwright report · View test results →
These issues are not necessarily caused by your changes. |
rafaeelaudibert
left a comment
There was a problem hiding this comment.
Makes sense! Left some nits
…49112) Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Problem
Vercel Marketplace integrations support a "Link Existing Account" (connectable account) flow where users can connect their existing PostHog organization to Vercel without going through the full installation flow. This enables billing to stay with PostHog rather than migrating to Vercel's billing.
Currently there is no support for this flow.
Changes
Backend
/connect/vercel/callback): Exchanges Vercel OAuth code for access token, caches session data, redirects to login if needed/api/vercel/connect/session): Returns user's admin+ orgs with linked status for the frontend dropdown/api/vercel/connect/complete): CreatesOrganizationIntegrationwithtype=connectableconfigintegration.configuration-removedevents, distinguishing connectable (direct delete) from native (billing cleanup viaVercelIntegration.delete_installation)oauth_token_exchange()for the/v2/oauth/access_tokenendpoint with response field validationFrontend
/connect/vercel/link): Org selector UI with loading, error, and success statesSecurity
next_urlvalidated against allowed Vercel domainscapture_exceptionon error paths for monitoringHow did you test this code?
Automated tests
Manual testing
/connect/vercel/callbackwith OAuth codeChangelog
Yes - adds Vercel "Link Existing Account" support for connecting existing PostHog orgs.
🤖 Generated with Claude Code