docs icon indicating copy to clipboard operation
docs copied to clipboard

Add comment for merging Clerk user metadata

Open calebpdx opened this issue 4 months ago • 1 comments

Added a comment explaining how to merge existing public metadata with new metadata in Clerk user updates.

I ran into this issue in development implementing the dub partners. The existing code overwrote my metadata I used to check for onboarding putting the user into an endless onboarding loop.

Onboarding flow was loosely based off Clerk's own documentation: https://clerk.com/docs/guides/development/add-onboarding-flow

Hope this helps!

Summary by CodeRabbit

  • Documentation
    • Added comprehensive code examples and guidance demonstrating best practices for preserving existing metadata when updating user information in Clerk integrations. Includes detailed examples for both server-side actions and API route handler approaches to help prevent data loss during metadata updates.

calebpdx avatar Oct 24 '25 21:10 calebpdx

Walkthrough

Two commented code examples were added to demonstrate preserving existing public metadata in Clerk when updating a user. The examples show fetching current user data and merging new dubClickId values with existing publicMetadata, appearing in both server action and API route handler contexts.

Changes

Cohort / File(s) Summary
Clerk metadata preservation guidance
conversions/leads/clerk.mdx
Added two commented code blocks illustrating how to merge new dubClickId into existing publicMetadata without overwriting other data using spread operator pattern

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Poem

🐰 A rabbit hops through code so fine,
With comments clear, like morning shine,
Preserve the data, merge with care,
No metadata lost anywhere! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "Add comment for merging Clerk user metadata" accurately reflects the main change in the changeset. The PR adds commented code blocks demonstrating how to merge existing public metadata with new metadata when updating Clerk users, which directly aligns with what the title describes. The title is concise, specific to the technical domain (Clerk user metadata), and clearly communicates the primary objective without vague language or unnecessary noise. A teammate reviewing the commit history would immediately understand that this PR adds guidance for preserving metadata during updates.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot] avatar Oct 24 '25 21:10 coderabbitai[bot]