-
Notifications
You must be signed in to change notification settings - Fork 7.1k
Open
Description
Context
When a user purchases a subscription before Clerk auth is wired, the subscription/entitlement/customer records in Convex are keyed to a crypto.randomUUID() stored in localStorage (wm-anon-id). This anonymous ID is the only link between the payment and the user.
Problem
If the user:
- Switches to another browser or device
- Clears storage / uses private browsing
- Later creates a real account (post Clerk auth)
- Has their browser data wiped
...there is no automatic path to reconnect their subscription to their new identity. They paid but the app shows them as free.
Solution
A claimSubscription(anonId) mutation has been added to convex/payments/billing.ts (PR #2024). It reassigns all payment records (subscriptions, entitlements, customers, payment events) from an anonymous ID to the currently authenticated user.
Remaining work
- Wire the claim flow into the Clerk auth integration: On first authenticated session, check if
localStoragehas awm-anon-idand callclaimSubscription(anonId)to migrate records - Handle edge cases: What if the anon ID has already been claimed? What if the real user already has a different subscription?
- Consider email-based fallback: Dodo has the customer email from checkout — if the Clerk account email matches, we could auto-claim without needing the anon ID
- Add a manual "Claim Purchase" UI: For users who lost their anon ID, provide a way to enter their Dodo order ID or email to reclaim
Related
- PR feat: Dodo Payments integration + entitlement engine & webhook pipeline #2024 — Dodo Payments integration (adds
claimSubscriptionmutation) - PR feat(auth): integrate clerk.dev #1812 — Clerk auth integration (will wire the claim flow)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels