diff --git a/apps/api/src/auth/base.ts b/apps/api/src/auth/base.ts index 27a8c73c..162d5553 100644 --- a/apps/api/src/auth/base.ts +++ b/apps/api/src/auth/base.ts @@ -15,6 +15,7 @@ import { } from './token.js' import { createWorkspace } from '../workspace/index.js' import { isWorkspaceNameValid } from '../utils/validation.js' +import { captureWorkspaceCreated } from '../events/posthog.js' type BaseAuthConfig = { FRONTEND_URL: string @@ -67,6 +68,7 @@ export default function getRouter( name: z.string().trim(), email: z.string().trim().email(), password: z.string(), + shareEmail: z.boolean(), }) .safeParse(req.body) @@ -77,7 +79,7 @@ export default function getRouter( return } - const { email, password } = payload.data + const { email, password, shareEmail } = payload.data if (!isValidPassword(password)) { res.status(400).json({ reason: 'invalid-password', @@ -115,6 +117,8 @@ export default function getRouter( return { workspace, user } }) + captureWorkspaceCreated(user, workspace, shareEmail) + const loginLink = createLoginLink(user.id, config.FRONTEND_URL) res.status(201).json({ workspace, loginLink }) diff --git a/apps/api/src/events/posthog.ts b/apps/api/src/events/posthog.ts index 174c9758..b3f1706c 100644 --- a/apps/api/src/events/posthog.ts +++ b/apps/api/src/events/posthog.ts @@ -18,7 +18,8 @@ export function getPostHogClient() { export const captureWorkspaceCreated = async ( sender: ApiUser, - workspace: ApiWorkspace + workspace: ApiWorkspace, + shareEmail: boolean ) => { const posthog = getPostHogClient() posthog?.capture({ @@ -26,10 +27,8 @@ export const captureWorkspaceCreated = async ( event: 'workspace_created', properties: { workspaceId: workspace.id, - workspaceUseContext: workspace.useContext, - workspaceUseCases: workspace.useCases, - workspaceSource: workspace.source, creatorId: sender.id, + ownerEmail: shareEmail ? sender.email : null, }, }) } diff --git a/apps/web/src/components/setup/UserForm.tsx b/apps/web/src/components/setup/UserForm.tsx index 4ecea5fc..39d042dc 100644 --- a/apps/web/src/components/setup/UserForm.tsx +++ b/apps/web/src/components/setup/UserForm.tsx @@ -7,6 +7,7 @@ import { UseFormRegister, } from 'react-hook-form' import Spin from '../Spin' +import { Tooltip } from '../Tooltips' export type UserStepFormValues = { firstName: string @@ -14,6 +15,7 @@ export type UserStepFormValues = { email: string password: string confirmPassword: string + shareEmail: boolean } interface Props { @@ -100,6 +102,32 @@ function UserSetupForm(props: Props) { })} /> +
+ + + + + + {'That will help us a lot!'} + + + +
diff --git a/apps/web/src/pages/setup.tsx b/apps/web/src/pages/setup.tsx index 1698159a..b21ec348 100644 --- a/apps/web/src/pages/setup.tsx +++ b/apps/web/src/pages/setup.tsx @@ -54,6 +54,9 @@ function SetupForm() { } = useForm({ mode: 'onSubmit', reValidateMode: 'onSubmit', + defaultValues: { + shareEmail: true, + }, }) const [formValues, setFormValues] = useState< @@ -65,6 +68,7 @@ function SetupForm() { email: '', password: '', confirmPassword: '', + shareEmail: true, }) const [currentStep, setCurrentStep] = useState<'workspace' | 'user'>( @@ -94,6 +98,7 @@ function SetupForm() { name: `${payload.firstName} ${payload.lastName}`, email: payload.email, password: payload.password, + shareEmail: payload.shareEmail, }), } )