From e7e8c475b08ad8c1f40b37d941cb7ada42fc3c07 Mon Sep 17 00:00:00 2001 From: Caleb White Date: Fri, 24 Oct 2025 14:05:25 -0700 Subject: [PATCH] Add comment for merging Clerk user metadata Added a comment explaining how to merge existing public metadata with new metadata in Clerk user updates. --- conversions/leads/clerk.mdx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/conversions/leads/clerk.mdx b/conversions/leads/clerk.mdx index 83949fe9..414dbdc0 100644 --- a/conversions/leads/clerk.mdx +++ b/conversions/leads/clerk.mdx @@ -218,6 +218,20 @@ Here's a quick summary of the steps: dubClickId: dubId || "n/a", }, }); + + /** + If have existing public metadata in your clerk user you will want to merge the existing metadata with the new metadata. + This is to avoid losing any existing metadata. + + const usermetadata = await clerk.users.getUser(id); + + await clerk.users.updateUser(id, { + publicMetadata: { + ...usermetadata.publicMetadata, + dubClickId: dubId || 'n/a', + }); + */ + const res = NextResponse.json({ ok: true }); // Delete the dub_id cookie res.cookies.set("dub_id", "", {