feat(with-privy): add account linking and one-liner Privy identify - #129
Draft
yosriady wants to merge 1 commit into
Draft
feat(with-privy): add account linking and one-liner Privy identify#129yosriady wants to merge 1 commit into
yosriady wants to merge 1 commit into
Conversation
Demonstrates Privy's account-linking flow and how Formo clusters a
multi-wallet Privy user into a single user.
- New LinkedAccounts component using useLinkAccount: link buttons for 15
account types (hiding already-linked ones, except wallets and passkeys
which Privy allows many of), per-account unlink routed to the matching
Privy method, and a live parsePrivyProperties() preview of exactly what
identify() sends.
- Unlink is routed by account type; unlinkOAuth handles both built-in
<provider>_oauth types and custom "custom:<provider>" ones. Types with no
unlink method (custom_auth, guest) are disabled rather than left to fail,
and unlink is disabled entirely when only one account remains, since
Privy requires a user to keep at least one.
- page.tsx replaces the manual parsePrivyProperties loop with
formo.identify(user, { privy: true, activeAddress }), which identifies
every linked wallet under the user's DID in one call.
- The identify effect depends on the active address string rather than the
useWallets() array, which returns a new reference on many renders and
would otherwise re-run the effect every render. It deliberately does not
re-identify from the link callbacks: `user` is reactive, so the effect
already re-runs, and identifying from a callback can run against a
pre-link user and emit a redundant, out-of-order identify.
Requires @formo/analytics 1.34.0 for the identify(user, { privy: true })
form, which is not published yet — see the PR description.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Dependency limit exceeded — report not shown. This pull request scan exceeded the 10,000-dependency limit applied to this scan, so the results are incomplete and may be inaccurate. To avoid reporting false positives, Socket has not posted a report. Upgrade your plan to raise the dependency limit and get complete reports, or view the partial scan in the dashboard. Socket is always free for open source. If this is a non-commercial open source project, contact us to request a free Team account. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Demonstrates Privy account linking and how Formo clusters a multi-wallet Privy user into a single user.
Important
Draft — blocked on the SDK release. This example uses
formo.identify(user, { privy: true }), added in getformo/sdk#304 and not yet published.package.jsontherefore requires@formo/analytics ^1.34.0, so CI'spnpm install --frozen-lockfilewill fail until that version is on npm. Once it publishes: runpnpm installinwith-privy/to refresh the lockfile, then mark this ready for review.The problem
A Privy user is one account (a DID) with many linked wallets. Formo's analytics is address-keyed, so one person with 8 wallets becomes 8 Formo users — retention, conversion, and user counts are all wrong.
What changed
src/components/LinkedAccounts.tsx(new) — the account-linking surface:useLinkAccountwith link buttons for 15 account types. Already-linked types are hidden, except wallets and passkeys, which Privy allows many of.unlinkOAuthcovers both built-in<provider>_oauthtypes and customcustom:<provider>ones. Types with no unlink method (custom_auth,guest) are disabled rather than left to throw, and unlink is disabled entirely when one account remains, since Privy requires a user to keep at least one.parsePrivyProperties(user)preview showing exactly whatidentify()sends.src/app/page.tsx— replaces the manualparsePrivyPropertiesloop with the one-liner:This identifies every linked wallet under the user's DID in one call. Only the active wallet takes over event attribution; the rest are recorded for clustering.
Two React details worth reviewing
useWallets()array — that array is a new reference on many renders and would re-run the effect every render.useris reactive, so the effect already re-runs after every link/unlink; identifying from a callback can run against a pre-linkuserand emit a redundant, out-of-order identify just before the effect emits the correct one.Verification
tsc --noEmitclean andnext buildsucceeds against a local build of the SDK branch.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.