Skip to content

Commit 0ee66f5

Browse files
author
Theodore Li
committed
Adjust event shape
1 parent d7fff9f commit 0ee66f5

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

apps/sim/app/(auth)/signup/signup-form.tsx

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ function SignupFormContent({
262262
token = await widget.getResponsePromise()
263263
} catch {
264264
captureEvent(posthog, 'signup_failed', {
265-
reason: 'captcha_client_failure',
265+
error_code: 'captcha_client_failure',
266266
})
267267
setFormError('Captcha verification failed. Please try again.')
268268
setIsLoading(false)
@@ -287,9 +287,9 @@ function SignupFormContent({
287287
logger.error('Signup error:', ctx.error)
288288
const errorMessage: string[] = ['Failed to create account']
289289

290-
let reason = 'unknown'
290+
let errorCode = 'unknown'
291291
if (ctx.error.code?.includes('USER_ALREADY_EXISTS')) {
292-
reason = 'user_already_exists'
292+
errorCode = 'user_already_exists'
293293
errorMessage.push(
294294
'An account with this email already exists. Please sign in instead.'
295295
)
@@ -298,30 +298,30 @@ function SignupFormContent({
298298
ctx.error.code?.includes('BAD_REQUEST') ||
299299
ctx.error.message?.includes('Email and password sign up is not enabled')
300300
) {
301-
reason = 'signup_disabled'
301+
errorCode = 'signup_disabled'
302302
errorMessage.push('Email signup is currently disabled.')
303303
setEmailError(errorMessage[0])
304304
} else if (ctx.error.code?.includes('INVALID_EMAIL')) {
305-
reason = 'invalid_email'
305+
errorCode = 'invalid_email'
306306
errorMessage.push('Please enter a valid email address.')
307307
setEmailError(errorMessage[0])
308308
} else if (ctx.error.code?.includes('PASSWORD_TOO_SHORT')) {
309-
reason = 'password_too_short'
309+
errorCode = 'password_too_short'
310310
errorMessage.push('Password must be at least 8 characters long.')
311311
setPasswordErrors(errorMessage)
312312
setShowValidationError(true)
313313
} else if (ctx.error.code?.includes('PASSWORD_TOO_LONG')) {
314-
reason = 'password_too_long'
314+
errorCode = 'password_too_long'
315315
errorMessage.push('Password must be less than 128 characters long.')
316316
setPasswordErrors(errorMessage)
317317
setShowValidationError(true)
318318
} else if (ctx.error.code?.includes('network')) {
319-
reason = 'network_error'
319+
errorCode = 'network_error'
320320
errorMessage.push('Network error. Please check your connection and try again.')
321321
setPasswordErrors(errorMessage)
322322
setShowValidationError(true)
323323
} else if (ctx.error.code?.includes('rate limit')) {
324-
reason = 'rate_limited'
324+
errorCode = 'rate_limited'
325325
errorMessage.push('Too many requests. Please wait a moment before trying again.')
326326
setPasswordErrors(errorMessage)
327327
setShowValidationError(true)
@@ -330,10 +330,7 @@ function SignupFormContent({
330330
setShowValidationError(true)
331331
}
332332

333-
captureEvent(posthog, 'signup_failed', {
334-
reason,
335-
error_code: ctx.error.code,
336-
})
333+
captureEvent(posthog, 'signup_failed', { error_code: errorCode })
337334
},
338335
}
339336
)
@@ -362,8 +359,7 @@ function SignupFormContent({
362359
} catch (error) {
363360
logger.error('Signup error:', error)
364361
captureEvent(posthog, 'signup_failed', {
365-
reason: 'unexpected_error',
366-
error_code: error instanceof Error ? error.message : undefined,
362+
error_code: 'unexpected_error',
367363
})
368364
setIsLoading(false)
369365
}

apps/sim/lib/posthog/events.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ export interface PostHogEventMap {
1717
signup_page_viewed: Record<string, never>
1818

1919
signup_failed: {
20-
reason: string
21-
error_code?: string
20+
error_code: string
2221
}
2322

2423
subscription_created: {

0 commit comments

Comments
 (0)