diff --git a/CHANGELOG.md b/CHANGELOG.md index cb05995bc..584f6aa3b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - 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) - 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) - Added permission syncing support for Bitbucket Cloud. [#925](https://github.com/sourcebot-dev/sourcebot/pull/925) +- Added `wa_user_created` PostHog event fired on successful user sign-up. [#933](https://github.com/sourcebot-dev/sourcebot/pull/933) +- Added `wa_askgh_login_wall_prompted` PostHog event fired when an unauthenticated user attempts to ask a question on Ask GitHub. [#933](https://github.com/sourcebot-dev/sourcebot/pull/933) ### Changed - Hide version upgrade toast for askgithub deployment (`EXPERIMENT_ASK_GH_ENABLED`). [#931](https://github.com/sourcebot-dev/sourcebot/pull/931) diff --git a/packages/web/src/app/[domain]/askgh/[owner]/[repo]/components/landingPage.tsx b/packages/web/src/app/[domain]/askgh/[owner]/[repo]/components/landingPage.tsx index 9e29dd46c..d54bb030c 100644 --- a/packages/web/src/app/[domain]/askgh/[owner]/[repo]/components/landingPage.tsx +++ b/packages/web/src/app/[domain]/askgh/[owner]/[repo]/components/landingPage.tsx @@ -14,6 +14,7 @@ import type { IdentityProviderMetadata } from "@/lib/identityProviders"; import { Descendant, Transforms } from "slate"; import { useSlate } from "slate-react"; import { useCallback, useEffect, useMemo, useState, useRef } from "react"; +import { captureEvent } from "@/hooks/useCaptureEvent"; const PENDING_MESSAGE_KEY = "askgh_pending_message"; @@ -55,6 +56,7 @@ export const LandingPage = ({ // Intercept submit to check auth status const handleSubmit = useCallback((children: Descendant[]) => { if (!isAuthenticated) { + captureEvent('wa_askgh_login_wall_prompted', {}); // Store message in sessionStorage to survive OAuth redirect sessionStorage.setItem(PENDING_MESSAGE_KEY, JSON.stringify(children)); setIsLoginModalOpen(true); diff --git a/packages/web/src/lib/authUtils.ts b/packages/web/src/lib/authUtils.ts index e11942a49..f250ad233 100644 --- a/packages/web/src/lib/authUtils.ts +++ b/packages/web/src/lib/authUtils.ts @@ -107,7 +107,7 @@ export const onCreateUser = async ({ user }: { user: AuthJsUser }) => { type: "org" } }); - } else if (!defaultOrg.memberApprovalRequired) { + } else if (!defaultOrg.memberApprovalRequired) { const hasAvailability = await orgHasAvailability(defaultOrg.domain); if (!hasAvailability) { 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 }) => { }); } + // Dynamic import to avoid circular dependency: + // authUtils -> posthog -> auth -> authUtils + const { captureEvent } = await import("@/lib/posthog"); + await captureEvent('wa_user_created', { userId: user.id }); }; diff --git a/packages/web/src/lib/posthogEvents.ts b/packages/web/src/lib/posthogEvents.ts index b2daa28dc..285035ddd 100644 --- a/packages/web/src/lib/posthogEvents.ts +++ b/packages/web/src/lib/posthogEvents.ts @@ -227,6 +227,11 @@ export type PosthogEventMap = { chatId: string, isExpanded: boolean, }, + wa_user_created: { + userId: string, + }, + ////////////////////////////////////////////////////////////////// + wa_askgh_login_wall_prompted: {}, ////////////////////////////////////////////////////////////////// wa_demo_docs_link_pressed: {}, wa_demo_search_example_card_pressed: {