Skip to content

fix(posthog): set email and name on person profile at signup#4152

Merged
waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1/posthog-server-set
Apr 14, 2026
Merged

fix(posthog): set email and name on person profile at signup#4152
waleedlatif1 merged 1 commit intostagingfrom
waleedlatif1/posthog-server-set

Conversation

@waleedlatif1
Copy link
Copy Markdown
Collaborator

Summary

  • Add server-side posthog.identify() in user.create.after hook to $set email and name on the person profile
  • Previously, person properties were only set client-side via posthog.identify() in session-provider, which gets blocked by ad blockers
  • No-op when PostHog is disabled (env var not set)

Type of Change

  • Bug fix

Testing

Tested manually

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)

@vercel
Copy link
Copy Markdown

vercel bot commented Apr 14, 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 14, 2026 5:10am

Request Review

@cursor
Copy link
Copy Markdown

cursor bot commented Apr 14, 2026

PR Summary

Low Risk
Low risk telemetry-only change: adds a guarded server-side PostHog identify call during user creation, wrapped in try/catch and a no-op when PostHog is disabled.

Overview
Ensures PostHog person profiles get email and name populated at signup by calling server-side posthog.identify() in the databaseHooks.user.create.after hook.

Imports getPostHogClient() and conditionally identifies the new user (no-op when PostHog is disabled), while leaving existing user_created event capture behavior unchanged.

Reviewed by Cursor Bugbot for commit 4e983b6. Configure here.

Comment thread apps/sim/app/workspace/[workspaceId]/home/home.tsx Outdated
@waleedlatif1 waleedlatif1 force-pushed the waleedlatif1/posthog-server-set branch from 3d65a93 to 4e983b6 Compare April 14, 2026 05:10
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

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 4e983b6. Configure here.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Apr 14, 2026

Greptile Summary

Adds a server-side posthog.identify() call in the user.create.after database hook to set email and name on the PostHog person profile at signup. This complements the existing client-side identify in the session provider, which ad blockers often suppress. The call is guarded by getPostHogClient() (no-op when PostHog is disabled), wrapped in a try-catch so it never fails the signup flow, and fires before the user_created event — ensuring person properties are in place when that event is processed.

Confidence Score: 5/5

  • Safe to merge — the change is minimal, isolated to telemetry, and cannot affect the signup flow.
  • No P0 or P1 findings. The identify call is correctly guarded, wrapped in a try-catch, and follows the pre-existing fire-and-forget pattern used throughout the file. The previous flush concern was addressed in prior review discussion.
  • No files require special attention.

Important Files Changed

Filename Overview
apps/sim/lib/auth/auth.ts Adds a server-side PostHog identify call in user.create.after to set email and name on the person profile; wrapped in try-catch, no-ops when PostHog is disabled, and fires before the user_created event capture — correct ordering.

Sequence Diagram

sequenceDiagram
    participant U as User
    participant Auth as BetterAuth
    participant Hook as DB Hook
    participant PH as PostHog Server
    participant App as App Init

    U->>Auth: Sign up
    Auth->>Hook: user.create.before (domain check)
    Hook->>Auth: pass
    Auth->>Hook: user.create.after
    Hook->>PH: client.identify(userId, set email + name)
    Note over PH: Server-side bypass of ad blockers
    Hook->>App: handleNewUser(userId)
    Auth->>Hook: account.create.after
    Hook->>PH: captureServerEvent user_created
Loading

Reviews (2): Last reviewed commit: "fix(posthog): set email and name on pers..." | Re-trigger Greptile

Comment thread apps/sim/lib/auth/auth.ts
@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1
Copy link
Copy Markdown
Collaborator Author

@cursor review

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 4e983b6. Configure here.

@waleedlatif1 waleedlatif1 merged commit 8a8bc1b into staging Apr 14, 2026
14 checks passed
@waleedlatif1 waleedlatif1 deleted the waleedlatif1/posthog-server-set branch April 14, 2026 05:19
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