Open source alternative to Semrush and Ahrefs
TypeScript backlink-analysisgoogle-search-console-mcpkeyword-researchmcpseoseo-agentseo-auditseo-automationseo-skillsseo-toolssite-audit
Simplify Loops signup contact sync (#202)
Ben Senescu7fa4d5cade9e
diff --git a/src/lib/auth.ts b/src/lib/auth.tsindex 6316fec0..98791c18 100644--- a/src/lib/auth.ts+++ b/src/lib/auth.ts@@ -9,7 +9,7 @@ import { getOrCreateDefaultHostedOrganization } from "@/server/auth/default-hostimport {sendHostedPasswordResetEmail,sendHostedVerificationEmail,- upsertHostedVerifiedContact,+ upsertHostedSignupContact,} from "@/server/email/loops";const hostedBaseUrlSchema = z@@ -55,9 +55,6 @@ function createAuth() {confirmationUrl: url,});},- afterEmailVerification: async (user) => {- await syncHostedVerifiedContact(user, "email verification");- },},socialProviders: getSocialProviders(),trustedOrigins: getTrustedOrigins(baseUrl),@@ -68,12 +65,8 @@ function createAuth() {databaseHooks: {user: {create: {- after: async (user, context) => {- if (context?.path !== "/callback/google") {- return;- }-- await syncHostedVerifiedContact(user, "Google sign up");+ after: async (user) => {+ await syncHostedSignupContact(user);},},},@@ -104,18 +97,19 @@ function createAuth() {let authInstance: ReturnType<typeof createAuth> | null = null;-async function syncHostedVerifiedContact(- user: { id: string; email: string; name?: string | null },- context: string,-) {+async function syncHostedSignupContact(user: {+ id: string;+ email: string;+ name?: string | null;+}) {try {- await upsertHostedVerifiedContact({+ await upsertHostedSignupContact({userId: user.id,email: user.email,name: user.name,});} catch (error) {- console.error(`Failed to sync Loops profile after ${context}:`, {+ console.error("Failed to sync Loops profile after user creation:", {userId: user.id,email: user.email,error,diff --git a/src/server/email/loops.ts b/src/server/email/loops.tsindex d4cc3970..86a3c40a 100644--- a/src/server/email/loops.ts+++ b/src/server/email/loops.ts@@ -91,7 +91,7 @@ function getContactNameParts(name: string | null | undefined) {};}-export async function upsertHostedVerifiedContact({+export async function upsertHostedSignupContact({userId,email,name,@@ -104,7 +104,7 @@ export async function upsertHostedVerifiedContact({if (!apiKey) {console.warn(- "Skipping Loops verified contact sync: LOOPS_API_KEY is not set",+ "Skipping Loops signup contact sync: LOOPS_API_KEY is not set",);return;}@@ -129,14 +129,14 @@ export async function upsertHostedVerifiedContact({}const errorPayload = await response.json().catch(() => null);- console.error("Loops verified contact sync error:", {+ console.error("Loops signup contact sync error:", {status: response.status,email,userId,errorPayload,});- throw new Error(`Failed to sync Loops verified contact (${response.status})`);+ throw new Error(`Failed to sync Loops signup contact (${response.status})`);}export async function sendHostedVerificationEmail({