Skip to content

Commit 98e4bc4

Browse files
Add user_first_signup PostHog event for reliable server-side signup tracking (#2554)
* Add user_first_signup PostHog event for reliable server-side signup tracking --------- Co-authored-by: [email protected] <[email protected]>
1 parent 9cd60f1 commit 98e4bc4

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

apps/web/client/src/server/api/routers/user/user.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { trackEvent } from '@/utils/analytics/server';
12
import { callUserWebhook } from '@/utils/n8n/webhook';
23
import { toUser, userInsertSchema, users, type User } from '@onlook/db';
34
import { extractNames } from '@onlook/utility';
@@ -69,6 +70,18 @@ export const userRouter = createTRPCRouter({
6970
}).returning();
7071

7172
if (!existingUser) {
73+
await trackEvent({
74+
distinctId: input.id,
75+
event: 'user_first_signup',
76+
properties: {
77+
email: userData.email,
78+
firstName: userData.firstName,
79+
lastName: userData.lastName,
80+
displayName: userData.displayName,
81+
source: 'web beta',
82+
},
83+
});
84+
7285
await callUserWebhook({
7386
email: userData.email,
7487
firstName: userData.firstName,
@@ -91,4 +104,4 @@ function getUserName(authUser: SupabaseUser) {
91104
firstName,
92105
lastName,
93106
};
94-
}
107+
}

bun.lockb

520 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)