Skip to content

Commit 66f1879

Browse files
msukkariclaude
andcommitted
feat: add wa_user_created PostHog event on successful sign-up
Fire a `wa_user_created` telemetry event in the NextAuth `onCreateUser` handler so we can track successful sign-ups in PostHog, closing a gap in the visitor-to-sign-up conversion funnel. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 649671b commit 66f1879

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1111
- Added PostHog events for chat UI interactions (details card expand/collapse, copy answer, table of contents toggle) and repo tracking in `wa_chat_message_sent`. [#922](https://github.com/sourcebot-dev/sourcebot/pull/922)
1212
- Added Bitbucket Cloud OAuth identity provider support (`provider: "bitbucket-cloud"`) for SSO and account-linked permission syncing. [#924](https://github.com/sourcebot-dev/sourcebot/pull/924)
1313
- Added permission syncing support for Bitbucket Cloud. [#925](https://github.com/sourcebot-dev/sourcebot/pull/925)
14+
- Added `wa_user_created` PostHog event fired on successful user sign-up. [#933](https://github.com/sourcebot-dev/sourcebot/pull/933)
1415

1516
### Changed
1617
- Hide version upgrade toast for askgithub deployment (`EXPERIMENT_ASK_GH_ENABLED`). [#931](https://github.com/sourcebot-dev/sourcebot/pull/931)

packages/web/src/lib/authUtils.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ export const onCreateUser = async ({ user }: { user: AuthJsUser }) => {
107107
type: "org"
108108
}
109109
});
110-
} else if (!defaultOrg.memberApprovalRequired) {
110+
} else if (!defaultOrg.memberApprovalRequired) {
111111
const hasAvailability = await orgHasAvailability(defaultOrg.domain);
112112
if (!hasAvailability) {
113113
logger.warn(`onCreateUser: org ${SINGLE_TENANT_ORG_ID} has reached max capacity. User ${user.id} was not added to the org.`);
@@ -123,6 +123,10 @@ export const onCreateUser = async ({ user }: { user: AuthJsUser }) => {
123123
});
124124
}
125125

126+
// Dynamic import to avoid circular dependency:
127+
// authUtils -> posthog -> auth -> authUtils
128+
const { captureEvent } = await import("@/lib/posthog");
129+
await captureEvent('wa_user_created', { userId: user.id });
126130
};
127131

128132

packages/web/src/lib/posthogEvents.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,9 @@ export type PosthogEventMap = {
227227
chatId: string,
228228
isExpanded: boolean,
229229
},
230+
wa_user_created: {
231+
userId: string,
232+
},
230233
//////////////////////////////////////////////////////////////////
231234
wa_demo_docs_link_pressed: {},
232235
wa_demo_search_example_card_pressed: {

0 commit comments

Comments
 (0)