Skip to content

feat(posthog): Add posthog log for signup failed#3998

Merged
TheodoreSpeaks merged 3 commits intostagingfrom
fix/captcha-failure
Apr 7, 2026
Merged

feat(posthog): Add posthog log for signup failed#3998
TheodoreSpeaks merged 3 commits intostagingfrom
fix/captcha-failure

Conversation

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator

@TheodoreSpeaks TheodoreSpeaks commented Apr 6, 2026

Summary

Added posthog events for user signup failures. That way its easier to filter session recordings by user signup failures to see if we're rejecting valid users.

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Documentation
  • Other: ___________

Testing

  • Ran lint and unit tests. Will validate in prod posthog events are being captured.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

Screenshots/Videos

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Apr 7, 2026 0:28am

Request Review

@TheodoreSpeaks
Copy link
Copy Markdown
Collaborator Author

@BugBot review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 6, 2026

PR Summary

Low Risk
Low risk: adds client-side analytics events on signup failure paths without changing signup behavior or data handling beyond emitting error codes.

Overview
Adds a new PostHog analytics event, signup_failed, to the typed event catalog with an error_code property.

Updates the signup form to emit signup_failed when Turnstile captcha execution fails client-side and whenever the email signup request errors, mapping common failure cases (e.g. existing user, disabled signup, invalid email, password constraints, network/rate limits) to standardized error_code values.

Reviewed by Cursor Bugbot for commit 73f57d1. Bugbot is set up for automated code reviews on this repo. Configure here.

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit d7fff9f. Configure here.

@TheodoreSpeaks TheodoreSpeaks marked this pull request as ready for review April 6, 2026 21:22
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 6, 2026

Greptile Summary

This PR adds PostHog signup_failed analytics events to the signup form, capturing three distinct failure paths: Turnstile captcha client errors, server-side auth API errors (with specific reason codes for known error types), and unexpected thrown exceptions. The new signup_failed event type is correctly added to the typed PostHog event catalog in lib/posthog/events.ts.

  • All three failure paths in onSubmit are now instrumented
  • Known error codes (USER_ALREADY_EXISTS, INVALID_EMAIL, PASSWORD_TOO_SHORT, etc.) are mapped to clean reason strings
  • The fallthrough else branch correctly emits reason: 'unknown'
  • Minor: in the unexpected-error catch block, error.message is passed as error_code, which is inconsistent with all other usages where error_code holds a machine-readable code; consider renaming to error_message for semantic consistency

Confidence Score: 5/5

Safe to merge; the only issue is a minor semantic inconsistency in analytics property naming

All remaining findings are P2 style suggestions. The instrumentation is correct, all failure paths are covered, and no runtime behavior is affected.

apps/sim/app/(auth)/signup/signup-form.tsx — line 364-367 for the error_code naming inconsistency

Important Files Changed

Filename Overview
apps/sim/app/(auth)/signup/signup-form.tsx Adds captureEvent('signup_failed') in three failure paths; minor semantic mismatch where error.message is passed as error_code in the catch block
apps/sim/lib/posthog/events.ts Adds signup_failed event type with reason: string and optional error_code?: string; fits the existing catalog pattern cleanly

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[onSubmit] --> B{Client-side validation}
    B -- fails --> C[setIsLoading false, return]
    B -- passes --> D{Turnstile captcha?}
    D -- yes --> E[widget.execute]
    E -- throws --> F[captureEvent signup_failed\nreason: captcha_client_failure]
    F --> G[setFormError, return]
    E -- resolves --> H[client.signUp.email]
    D -- no --> H
    H -- onError --> I{map error code}
    I --> J[reason = user_already_exists / signup_disabled /\ninvalid_email / password_too_short /\npassword_too_long / network_error /\nrate_limited / unknown]
    J --> K[captureEvent signup_failed\nreason + error_code]
    H -- throws --> L[captureEvent signup_failed\nreason: unexpected_error]
    L --> M[setIsLoading false]
    H -- success --> N[refetchSession → router.push verify]
Loading

Reviews (1): Last reviewed commit: "feat(posthog): Add posthog log for signu..." | Re-trigger Greptile

Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0ee66f5. Configure here.

@TheodoreSpeaks TheodoreSpeaks merged commit 25b4a3f into staging Apr 7, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant