mirror of
https://github.com/supabase/supabase.git
synced 2026-12-06 08:29:01 +00:00
The onboarding survey experiment on the new-org form is finished and the
survey version is now the default. I removed the
`onboardingSurveyPlacement` flag from Studio: the form always shows the
survey, and I deleted the old form path.
**Changed:**
- **New-org form**: always renders the name field plus the optional
"Help improve Supabase" survey card. Org type and size are saved through
the survey endpoint only, as they already were for the survey variant.
- **Experiment plumbing removed**: I deleted the flag read, its exposure
event (`onboarding_survey_placement_experiment_exposed`) and the variant
constants, so the form no longer starts on the old layout while flags
load.
- **Tests**: the survey tests keep their assertions with the flag setup
removed. I deleted the test for the old form (org type sent at creation,
no survey) because that behavior no longer exists.
**Note:** I removed the `renderFieldWrapper` option from
`OrganizationDetailsFields`, which only the old form path used. The
cloud marketplace org form still uses the component unchanged.
## To test
Tested on the PR preview:
- [x] Sign in and open `/new`: expect a Name field with no Type field
above the plan picker, and a "Help improve Supabase" card with the org
type, "What are you building?" and "Do you know how to code?" questions.
Observed: Name, Plan, then the card with "Who is this org for?" (default
Personal) and both questions.
- [x] Create a free org with the survey untouched: expect the create
request body to carry no `kind` or `size`, no `onboarding-survey`
request, and the follow-up card on the new org's projects page.
Observed: create body `{"name":"…","tier":"tier_free"}` (201), no survey
request, and the follow-up card with Answer and Skip on the org page.
- [x] Create a free org with type Company, a company size and a "What
are you building?" answer: expect one `POST
/platform/organizations/onboarding-survey` with those answers returning
204, and no follow-up card. Observed: one request with `kind:
"COMPANY"`, `size: "50"`, `building: "b2b_saas"` (204), create body
again without `kind` or `size`, no follow-up card.
- [x] Watch telemetry requests while `/new` loads: expect no
`onboarding_survey_placement_experiment_exposed` event. Observed: none
across both org creations, while `onboarding_survey_dismissed` and
`onboarding_survey_submit_button_clicked` (both `surface: org_form`)
were sent.
- [x] Added: the survey card is in the first render of `/new` and the
Name input keeps focus, with no layout switch after flags load.
## Linear
- fixes GROWTH-1562
---------
Co-authored-by: Joshen Lim <joshenlimek@gmail.com>
192 lines
6.3 KiB
TypeScript
192 lines
6.3 KiB
TypeScript
import { zodResolver } from '@hookform/resolvers/zod'
|
|
import { AnimatePresence } from 'motion/react'
|
|
import { useForm, useWatch } from 'react-hook-form'
|
|
import {
|
|
Button,
|
|
Dialog,
|
|
DialogContent,
|
|
DialogFooter,
|
|
DialogHeader,
|
|
DialogSection,
|
|
DialogSectionSeparator,
|
|
DialogTitle,
|
|
Form,
|
|
FormControl,
|
|
FormField,
|
|
Select,
|
|
SelectContent,
|
|
SelectItem,
|
|
SelectTrigger,
|
|
SelectValue,
|
|
} from 'ui'
|
|
import { FormItemLayout } from 'ui-patterns/form/FormItemLayout/FormItemLayout'
|
|
import { z } from 'zod'
|
|
|
|
import {
|
|
BUILDING_OPTIONS,
|
|
CAN_CODE_OPTIONS,
|
|
SURVEY_ORG_KIND_OPTIONS,
|
|
ORG_SIZE_DEFAULT,
|
|
ORG_SIZE_TYPES,
|
|
} from './OnboardingSurvey.constants'
|
|
import { OnboardingSurveySelect } from './OnboardingSurveySelect'
|
|
import { FormSectionCollapse } from '@/components/ui/FormSectionCollapse'
|
|
|
|
const FORM_ID = 'onboarding-survey-follow-up-form'
|
|
|
|
const FormSchema = z.object({
|
|
kind: z.string(),
|
|
size: z.string(),
|
|
building: z.string(),
|
|
can_code: z.string(),
|
|
})
|
|
|
|
export type OnboardingSurveyFollowUpValues = z.infer<typeof FormSchema>
|
|
|
|
const defaultValues: OnboardingSurveyFollowUpValues = {
|
|
kind: '',
|
|
size: ORG_SIZE_DEFAULT,
|
|
building: '',
|
|
can_code: '',
|
|
}
|
|
|
|
type OnboardingSurveyFollowUpDialogProps = {
|
|
open: boolean
|
|
isSubmitting: boolean
|
|
/** Skip, or the dialog closing any other way */
|
|
onClose: () => void
|
|
onSubmit: (values: OnboardingSurveyFollowUpValues) => void
|
|
}
|
|
|
|
export function OnboardingSurveyFollowUpDialog({
|
|
open,
|
|
isSubmitting,
|
|
onClose,
|
|
onSubmit,
|
|
}: OnboardingSurveyFollowUpDialogProps) {
|
|
const form = useForm<OnboardingSurveyFollowUpValues>({
|
|
resolver: zodResolver(FormSchema),
|
|
defaultValues,
|
|
})
|
|
|
|
const [kind, building, canCode] = useWatch({
|
|
control: form.control,
|
|
name: ['kind', 'building', 'can_code'],
|
|
})
|
|
const hasAnswer = kind !== '' || building !== '' || canCode !== ''
|
|
|
|
return (
|
|
<Dialog open={open} onOpenChange={(isOpen) => !isOpen && onClose()}>
|
|
<DialogContent size="small" aria-describedby={undefined}>
|
|
<DialogHeader>
|
|
<DialogTitle>Tell us about your organization</DialogTitle>
|
|
</DialogHeader>
|
|
<DialogSectionSeparator />
|
|
<Form {...form}>
|
|
<form id={FORM_ID} onSubmit={form.handleSubmit(onSubmit)}>
|
|
<DialogSection className="flex flex-col gap-y-5 pt-4.5 pb-5">
|
|
<p className="text-sm text-foreground-light">
|
|
All questions are optional. Your answers help us improve Supabase.
|
|
</p>
|
|
|
|
<div>
|
|
<FormField
|
|
control={form.control}
|
|
name="kind"
|
|
render={({ field }) => (
|
|
<FormItemLayout label="Who is this org for?" layout="vertical">
|
|
<FormControl>
|
|
<OnboardingSurveySelect
|
|
value={field.value}
|
|
onValueChange={field.onChange}
|
|
options={SURVEY_ORG_KIND_OPTIONS}
|
|
/>
|
|
</FormControl>
|
|
</FormItemLayout>
|
|
)}
|
|
/>
|
|
|
|
<AnimatePresence initial={false}>
|
|
{kind === 'COMPANY' && (
|
|
<FormSectionCollapse>
|
|
<div className="pt-5">
|
|
<FormField
|
|
control={form.control}
|
|
name="size"
|
|
render={({ field }) => (
|
|
<FormItemLayout label="How many people?" layout="vertical">
|
|
<FormControl>
|
|
<Select value={field.value} onValueChange={field.onChange}>
|
|
<SelectTrigger className="w-full">
|
|
<SelectValue />
|
|
</SelectTrigger>
|
|
<SelectContent>
|
|
{Object.entries(ORG_SIZE_TYPES).map(([value, label]) => (
|
|
<SelectItem key={value} value={value}>
|
|
{label}
|
|
</SelectItem>
|
|
))}
|
|
</SelectContent>
|
|
</Select>
|
|
</FormControl>
|
|
</FormItemLayout>
|
|
)}
|
|
/>
|
|
</div>
|
|
</FormSectionCollapse>
|
|
)}
|
|
</AnimatePresence>
|
|
|
|
<div className="pt-5">
|
|
<FormField
|
|
control={form.control}
|
|
name="building"
|
|
render={({ field }) => (
|
|
<FormItemLayout label="What are you building?" layout="vertical">
|
|
<FormControl>
|
|
<OnboardingSurveySelect
|
|
value={field.value}
|
|
onValueChange={field.onChange}
|
|
options={BUILDING_OPTIONS}
|
|
/>
|
|
</FormControl>
|
|
</FormItemLayout>
|
|
)}
|
|
/>
|
|
</div>
|
|
|
|
<div className="pt-5">
|
|
<FormField
|
|
control={form.control}
|
|
name="can_code"
|
|
render={({ field }) => (
|
|
<FormItemLayout label="Do you know how to code?" layout="vertical">
|
|
<FormControl>
|
|
<OnboardingSurveySelect
|
|
value={field.value}
|
|
onValueChange={field.onChange}
|
|
options={CAN_CODE_OPTIONS}
|
|
/>
|
|
</FormControl>
|
|
</FormItemLayout>
|
|
)}
|
|
/>
|
|
</div>
|
|
</div>
|
|
</DialogSection>
|
|
</form>
|
|
</Form>
|
|
|
|
<DialogFooter className="px-5 py-4">
|
|
<Button variant="default" disabled={isSubmitting} onClick={onClose}>
|
|
Skip
|
|
</Button>
|
|
<Button form={FORM_ID} type="submit" loading={isSubmitting} disabled={!hasAnswer}>
|
|
Send answers
|
|
</Button>
|
|
</DialogFooter>
|
|
</DialogContent>
|
|
</Dialog>
|
|
)
|
|
}
|