Skip to content

Commit fa31d25

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 fa31d25

File tree

3 files changed

+7
-1
lines changed

3 files changed

+7
-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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { ErrorCode } from "./errorCodes";
1212
import { IS_BILLING_ENABLED } from "@/ee/features/billing/stripe";
1313
import { incrementOrgSeatCount } from "@/ee/features/billing/serverUtils";
1414
import { getOrgFromDomain } from "@/data/org";
15+
import { captureEvent } from "@/lib/posthog";
1516

1617
const logger = createLogger('web-auth-utils');
1718
const auditService = getAuditService();
@@ -107,7 +108,7 @@ export const onCreateUser = async ({ user }: { user: AuthJsUser }) => {
107108
type: "org"
108109
}
109110
});
110-
} else if (!defaultOrg.memberApprovalRequired) {
111+
} else if (!defaultOrg.memberApprovalRequired) {
111112
const hasAvailability = await orgHasAvailability(defaultOrg.domain);
112113
if (!hasAvailability) {
113114
logger.warn(`onCreateUser: org ${SINGLE_TENANT_ORG_ID} has reached max capacity. User ${user.id} was not added to the org.`);
@@ -123,6 +124,7 @@ export const onCreateUser = async ({ user }: { user: AuthJsUser }) => {
123124
});
124125
}
125126

127+
await captureEvent('wa_user_created', { userId: user.id });
126128
};
127129

128130

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)