Skip to content

Commit 8a8bc1b

Browse files
authored
fix(posthog): set email and name on person profile at signup (#4152)
1 parent 48d5101 commit 8a8bc1b

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

apps/sim/lib/auth/auth.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ import { sendEmail } from '@/lib/messaging/email/mailer'
8080
import { getFromEmailAddress, getPersonalEmailFrom } from '@/lib/messaging/email/utils'
8181
import { quickValidateEmail } from '@/lib/messaging/email/validation'
8282
import { scheduleLifecycleEmail } from '@/lib/messaging/lifecycle'
83-
import { captureServerEvent } from '@/lib/posthog/server'
83+
import { captureServerEvent, getPostHogClient } from '@/lib/posthog/server'
8484
import { syncAllWebhooksForCredentialSet } from '@/lib/webhooks/utils.server'
8585
import { disableUserResources } from '@/lib/workflows/lifecycle'
8686
import { SSO_TRUSTED_PROVIDERS } from '@/ee/sso/constants'
@@ -196,6 +196,21 @@ export const auth = betterAuth({
196196
// Telemetry should not fail the operation
197197
}
198198

199+
try {
200+
const client = getPostHogClient()
201+
if (client) {
202+
client.identify({
203+
distinctId: user.id,
204+
properties: {
205+
...(user.email ? { email: user.email } : {}),
206+
...(user.name ? { name: user.name } : {}),
207+
},
208+
})
209+
}
210+
} catch {
211+
// Telemetry should not fail the operation
212+
}
213+
199214
try {
200215
await handleNewUser(user.id)
201216
} catch (error) {
@@ -396,6 +411,7 @@ export const auth = betterAuth({
396411
: SSO_TRUSTED_PROVIDERS.includes(providerId)
397412
? 'sso'
398413
: 'oauth'
414+
399415
captureServerEvent(
400416
account.userId,
401417
'user_created',

0 commit comments

Comments
 (0)