Skip to content

feat: anon ID → Clerk account subscription claim path #2078

@SebastienMelki

Description

@SebastienMelki

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

  1. Wire the claim flow into the Clerk auth integration: On first authenticated session, check if localStorage has a wm-anon-id and call claimSubscription(anonId) to migrate records
  2. Handle edge cases: What if the anon ID has already been claimed? What if the real user already has a different subscription?
  3. 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
  4. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions