From 4e983b60221b83c8c872ffba224e5ad5803d58d6 Mon Sep 17 00:00:00 2001 From: Waleed Latif Date: Mon, 13 Apr 2026 22:08:37 -0700 Subject: [PATCH] fix(posthog): set email and name on person profile at signup --- apps/sim/lib/auth/auth.ts | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/apps/sim/lib/auth/auth.ts b/apps/sim/lib/auth/auth.ts index b08d15d743..0a593a5bf6 100644 --- a/apps/sim/lib/auth/auth.ts +++ b/apps/sim/lib/auth/auth.ts @@ -80,7 +80,7 @@ import { sendEmail } from '@/lib/messaging/email/mailer' import { getFromEmailAddress, getPersonalEmailFrom } from '@/lib/messaging/email/utils' import { quickValidateEmail } from '@/lib/messaging/email/validation' import { scheduleLifecycleEmail } from '@/lib/messaging/lifecycle' -import { captureServerEvent } from '@/lib/posthog/server' +import { captureServerEvent, getPostHogClient } from '@/lib/posthog/server' import { syncAllWebhooksForCredentialSet } from '@/lib/webhooks/utils.server' import { disableUserResources } from '@/lib/workflows/lifecycle' import { SSO_TRUSTED_PROVIDERS } from '@/ee/sso/constants' @@ -196,6 +196,21 @@ export const auth = betterAuth({ // Telemetry should not fail the operation } + try { + const client = getPostHogClient() + if (client) { + client.identify({ + distinctId: user.id, + properties: { + ...(user.email ? { email: user.email } : {}), + ...(user.name ? { name: user.name } : {}), + }, + }) + } + } catch { + // Telemetry should not fail the operation + } + try { await handleNewUser(user.id) } catch (error) { @@ -396,6 +411,7 @@ export const auth = betterAuth({ : SSO_TRUSTED_PROVIDERS.includes(providerId) ? 'sso' : 'oauth' + captureServerEvent( account.userId, 'user_created',