:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(product-analytics): quill editor panel sections on the rail (#130218)
Sam Penningtona8fac25f7219
diff --git a/frontend/src/lib/components/ChartOptions/displayOptions.ts b/frontend/src/lib/components/ChartOptions/displayOptions.tsindex 2947b2f50c4a..4eef8f31674c 100644--- a/frontend/src/lib/components/ChartOptions/displayOptions.ts+++ b/frontend/src/lib/components/ChartOptions/displayOptions.ts@@ -242,6 +242,7 @@ export const DISPLAY_OPTIONS = [max: 9,placeholder: String(DEFAULT_DECIMAL_PLACES),},+ { name: 'funnelBinCount', label: 'Bins', group: 'display', control: 'custom' },{name: 'retentionDashboardDisplay',label: 'On dashboards',diff --git a/products/product_analytics/frontend/insights/editor/EditorFilterGroup.tsx b/products/product_analytics/frontend/insights/editor/EditorFilterGroup.tsxindex cfa020f76ff1..3e569519eaa3 100644--- a/products/product_analytics/frontend/insights/editor/EditorFilterGroup.tsx+++ b/products/product_analytics/frontend/insights/editor/EditorFilterGroup.tsx@@ -1,6 +1,9 @@+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'+import type { InsightEditorFilterGroup, InsightLogicProps } from '~/types'import { EditorFilterGroupTile } from './EditorFilterGroupTile'+import { QuillEditorFilterGroupTile } from './QuillEditorFilterGroupTile'export interface EditorFilterGroupProps {editorFilterGroup: InsightEditorFilterGroup@@ -9,7 +12,15 @@ export interface EditorFilterGroupProps {}export function EditorFilterGroup({ insightProps, editorFilterGroup, queryKind }: EditorFilterGroupProps): JSX.Element {- return (+ const todayRailNav = useFeatureFlag('TODAY_RAIL_NAV')++ return todayRailNav ? (+ <QuillEditorFilterGroupTile+ insightProps={insightProps}+ editorFilterGroup={editorFilterGroup}+ queryKind={queryKind}+ />+ ) : (<EditorFilterGroupTileinsightProps={insightProps}editorFilterGroup={editorFilterGroup}diff --git a/products/product_analytics/frontend/insights/editor/EditorFilterGroupTile.tsx b/products/product_analytics/frontend/insights/editor/EditorFilterGroupTile.tsxindex 3fb95487c6bc..8c7e96f35134 100644--- a/products/product_analytics/frontend/insights/editor/EditorFilterGroupTile.tsx+++ b/products/product_analytics/frontend/insights/editor/EditorFilterGroupTile.tsx@@ -1,5 +1,4 @@import clsx from 'clsx'-import posthog from 'posthog-js'import { IconCollapse, IconExpand } from '@posthog/icons'@@ -9,6 +8,7 @@ import { slugify } from 'lib/utils/strings'import type { InsightEditorFilterGroup, InsightLogicProps } from '~/types'import { EditorFilterItems } from './EditorFilterItems'+import { captureEditorGroupToggle } from './editorFilterUtils'import { useEditorGroupExpansion } from './useEditorGroupExpansion'export interface EditorFilterGroupTileProps {@@ -34,11 +34,7 @@ export function EditorFilterGroupTile({onClick={() => {const newState = !isRowExpandedsetIsRowExpanded(newState)- posthog.capture('editor panel section toggled', {- section: title,- action: newState ? 'opened' : 'closed',- query_kind: queryKind,- })+ captureEditorGroupToggle(title, newState, queryKind)}}sideIcon={isRowExpanded ? <IconCollapse /> : <IconExpand />}title={isRowExpanded ? 'Show less' : 'Show more'}diff --git a/products/product_analytics/frontend/insights/editor/EditorFilters.tsx b/products/product_analytics/frontend/insights/editor/EditorFilters.tsxindex 1c9f3801d69d..50d6a08164c7 100644--- a/products/product_analytics/frontend/insights/editor/EditorFilters.tsx+++ b/products/product_analytics/frontend/insights/editor/EditorFilters.tsx@@ -5,6 +5,7 @@ import { IconInfo } from '@posthog/icons'import { Link, Tooltip } from '@posthog/lemon-ui'import { NON_BREAKDOWN_DISPLAY_TYPES } from 'lib/constants'+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'import { retryImport } from 'lib/utils/retryImport'import { pluralize } from 'lib/utils/strings'import { ChunkLoadErrorBoundary } from 'scenes/ChunkLoadErrorBoundary'@@ -92,6 +93,7 @@ export function EditorFilters({ query, showing, embedded }: EditorFiltersProps):} = useValues(insightVizDataLogic(insightProps))const { isStepsFunnel, isTrendsFunnel } = useValues(funnelDataLogic(insightProps))+ const todayRailNav = useFeatureFlag('TODAY_RAIL_NAV')if (!querySource) {return null@@ -163,7 +165,9 @@ export function EditorFilters({ query, showing, embedded }: EditorFiltersProps):show: !isRetention,defaultExpanded: true,headerExtra:- isFunnels && (querySource as FunnelsQuery)?.funnelsFilter?.funnelVizType !== FunnelVizTypeEnum.Flow ? (+ !todayRailNav &&+ isFunnels &&+ (querySource as FunnelsQuery)?.funnelsFilter?.funnelVizType !== FunnelVizTypeEnum.Flow ? (<Tooltip docLink="https://posthog.com/docs/product-analytics/funnels#graph-type">{/* span so the tooltip has a ref-able anchor — FunnelVizType is a plain function component */}<span className="inline-flex">diff --git a/products/product_analytics/frontend/insights/editor/InsightDisplayConfig.tsx b/products/product_analytics/frontend/insights/editor/InsightDisplayConfig.tsxindex 27cbaa726883..88959a3c1f2d 100644--- a/products/product_analytics/frontend/insights/editor/InsightDisplayConfig.tsx+++ b/products/product_analytics/frontend/insights/editor/InsightDisplayConfig.tsx@@ -22,6 +22,7 @@ import { ChartDisplayType } from '~/types'import { InsightDateFilter } from 'products/product_analytics/frontend/insights/editor/filters/InsightDateFilter'import { FunnelBinsPicker } from 'products/product_analytics/frontend/insights/funnels/filters/FunnelBinsPicker'import { FunnelDisplayLayoutPicker } from 'products/product_analytics/frontend/insights/funnels/filters/FunnelDisplayLayoutPicker'+import { QuillFunnelVizType } from 'products/product_analytics/frontend/insights/funnels/filters/QuillFunnelVizType'import { funnelDataLogic } from 'products/product_analytics/frontend/insights/funnels/funnelDataLogic'import { PathStepPicker } from 'products/product_analytics/frontend/insights/paths/filters/PathStepPicker'import { RetentionBreakdownFilter } from 'products/product_analytics/frontend/insights/retention/filters/RetentionBreakdownFilter'@@ -174,12 +175,17 @@ export function InsightDisplayConfig({ chartTypeControl }: { chartTypeControl?:<RetentionChartPicker /></ConfigFilter>)}- {!!isStepsFunnel && (+ {todayRailNav && isFunnels && (+ <ConfigFilter>+ <QuillFunnelVizType insightProps={insightProps} disabledReason={editingDisabledReason} />+ </ConfigFilter>+ )}+ {!!isStepsFunnel && !todayRailNav && (<ConfigFilter><FunnelDisplayLayoutPicker /></ConfigFilter>)}- {!!isTimeToConvertFunnel && (+ {!!isTimeToConvertFunnel && !todayRailNav && (<ConfigFilter><FunnelBinsPicker /></ConfigFilter>diff --git a/products/product_analytics/frontend/insights/editor/QuillEditorFilterGroupTile.tsx b/products/product_analytics/frontend/insights/editor/QuillEditorFilterGroupTile.tsxnew file mode 100644index 000000000000..58c966c7fd4d--- /dev/null+++ b/products/product_analytics/frontend/insights/editor/QuillEditorFilterGroupTile.tsx@@ -0,0 +1,64 @@+import { Card, Collapsible, CollapsibleContent, CollapsibleHeader, CollapsibleTrigger } from '@posthog/quill'++import { slugify } from 'lib/utils/strings'++import type { EditorFilterGroupTileProps } from './EditorFilterGroupTile'+import { captureEditorGroupToggle } from './editorFilterUtils'+import { QuillEditorFilterItems } from './QuillEditorFilterItems'+import { useEditorGroupExpansion } from './useEditorGroupExpansion'++export function QuillEditorFilterGroupTile({+ insightProps,+ editorFilterGroup,+ queryKind,+}: EditorFilterGroupTileProps): JSX.Element {+ const { title, defaultExpanded, editorFilters, collapsedSummary, headerExtra } = editorFilterGroup+ const [isRowExpanded, setIsRowExpanded, isExpandable] = useEditorGroupExpansion(defaultExpanded, !!collapsedSummary)++ const items = (+ <div className="flex min-w-0 flex-col gap-3 px-3 pt-1 pb-3">+ <QuillEditorFilterItems editorFilters={editorFilters} insightProps={insightProps} />+ </div>+ )++ if (!isExpandable) {+ return (+ <Card size="sm" className="m-px min-w-0 gap-0 py-0">+ <div className="flex items-center justify-between gap-2 px-3 py-2">+ <span className="font-semibold">{title}</span>+ {headerExtra}+ </div>+ {items}+ </Card>+ )+ }++ return (+ <Card size="sm" className="m-px min-w-0 gap-0 py-0">+ <Collapsible+ variant="folder"+ open={isRowExpanded}+ onOpenChange={(open) => {+ setIsRowExpanded(open)+ captureEditorGroupToggle(title, open, queryKind)+ }}+ >+ <CollapsibleHeader className="gap-0">+ <CollapsibleTrigger+ className="h-10 w-auto min-w-0 flex-1 rounded-none ps-2 pe-3"+ data-attr={'editor-filter-group-collapse-' + slugify(title)}+ >+ <span className="shrink-0 font-semibold">{title}</span>+ {!isRowExpanded && collapsedSummary && (+ <span className="truncate text-muted-foreground">{collapsedSummary}</span>+ )}+ </CollapsibleTrigger>+ {headerExtra && <div className="shrink-0 pe-2">{headerExtra}</div>}+ </CollapsibleHeader>+ <CollapsibleContent keepMounted className="p-0">+ {items}+ </CollapsibleContent>+ </Collapsible>+ </Card>+ )+}diff --git a/products/product_analytics/frontend/insights/editor/QuillEditorFilterItems.tsx b/products/product_analytics/frontend/insights/editor/QuillEditorFilterItems.tsxnew file mode 100644index 000000000000..591ee3b30c6d--- /dev/null+++ b/products/product_analytics/frontend/insights/editor/QuillEditorFilterItems.tsx@@ -0,0 +1,46 @@+import { IconInfo } from '@posthog/icons'+import { Field, FieldTitle, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'++import type { EditorFilterItemsProps } from './EditorFilterItems'++export function QuillEditorFilterItems({ editorFilters, insightProps }: EditorFilterItemsProps): JSX.Element {+ return (+ <>+ {editorFilters.map(({ label: Label, tooltip, showOptional, key, component: Component }) => {+ if (Component && Component.name === 'component') {+ throw new Error(+ `Component for filter ${key} is an anonymous function, which is not a valid React component! Use a named function instead.`+ )+ }+ const label = typeof Label === 'function' ? <Label insightProps={insightProps} /> : Label+ return (+ <Field key={key} className="min-w-0 gap-1.5">+ {(label || tooltip) && (+ <FieldTitle className="flex items-center gap-1">+ {label}+ {showOptional && <span className="font-normal text-muted-foreground">(optional)</span>}+ {tooltip && (+ <Tooltip>+ <TooltipTrigger+ render={<span className="inline-flex text-muted-foreground" />}+ aria-label="More info"+ >+ <IconInfo className="size-4" />+ </TooltipTrigger>+ <TooltipContent>{tooltip}</TooltipContent>+ </Tooltip>+ )}+ </FieldTitle>+ )}+ {Component ? (+ // The fields are still LemonUI, which reads colour variables that quill redefines.+ <div data-not-quill className="min-w-0">+ <Component insightProps={insightProps} />+ </div>+ ) : null}+ </Field>+ )+ })}+ </>+ )+}diff --git a/products/product_analytics/frontend/insights/editor/editorFilterUtils.ts b/products/product_analytics/frontend/insights/editor/editorFilterUtils.tsindex 370715f11655..a4af9563bc1d 100644--- a/products/product_analytics/frontend/insights/editor/editorFilterUtils.ts+++ b/products/product_analytics/frontend/insights/editor/editorFilterUtils.ts@@ -1,3 +1,5 @@+import posthog from 'posthog-js'+import { formatEventName } from 'lib/insights/entityFilterNames'import { pluralize } from 'lib/utils/strings'@@ -15,6 +17,14 @@ function formatPropertyName(name: string): string {return name}+export function captureEditorGroupToggle(section: string, opened: boolean, queryKind?: string): void {+ posthog.capture('editor panel section toggled', {+ section,+ action: opened ? 'opened' : 'closed',+ query_kind: queryKind,+ })+}+/** An InsightEditorFilter with an optional `show` field. When `show` is false, null, or undefined, the filter is excluded. */export type ConditionalEditorFilter = InsightEditorFilter & { show?: boolean | null }diff --git a/products/product_analytics/frontend/insights/editor/insightDisplayOptions.tsx b/products/product_analytics/frontend/insights/editor/insightDisplayOptions.tsxindex 4f0f908320e4..709daa700c58 100644--- a/products/product_analytics/frontend/insights/editor/insightDisplayOptions.tsx+++ b/products/product_analytics/frontend/insights/editor/insightDisplayOptions.tsx@@ -15,6 +15,7 @@ import {import { smoothingOptions } from 'lib/components/SmoothingFilter/smoothings'import { UnitPicker } from 'lib/components/UnitPicker/UnitPicker'import { PART_OF_WHOLE_DISPLAY_TYPES, PIE_DISPLAY_TYPES } from 'lib/constants'+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'import { insightLogic, type insightLogicType } from 'scenes/insights/insightLogic'import { insightVizDataLogic, type insightVizDataLogicType } from 'scenes/insights/insightVizDataLogic'@@ -22,6 +23,7 @@ import { hasBreakdownFilter, isFunnelsQuery, isRetentionQuery, isTrendsQuery } fimport type { RetentionFilter, TrendsFilter } from '~/queries/schema/schema-general'import { ChartDisplayType, RetentionDashboardDisplayType } from '~/types'+import { QuillFunnelBinCountOption } from 'products/product_analytics/frontend/insights/funnels/filters/QuillFunnelBinCountOption'import { funnelDataLogic } from 'products/product_analytics/frontend/insights/funnels/funnelDataLogic'import {INTERVAL_TO_DEFAULT_MOVING_AVERAGE_PERIOD,@@ -81,6 +83,9 @@ interface InsightDisplayContextPick<insightLogicType['values'], 'canEditInsight' | 'editingDisabledReason'>,Pick<VizActions, 'updateInsightFilter' | 'updateQuerySource' | 'updateVizSpecificOptions'> {isTrendsFunnel: boolean+ isTimeToConvertFunnel: boolean+ funnelBinCount: number | undefined+ todayRailNav: booleanisMetric: booleanisBoxPlot: booleanisPie: boolean@@ -143,7 +148,13 @@ function useInsightDisplayContext(): InsightDisplayContext {const { updateInsightFilter, updateQuerySource, updateVizSpecificOptions } = useActions(insightVizDataLogic(insightProps))- const isTrendsFunnel = !!useValues(funnelDataLogic(insightProps)).isTrendsFunnel+ const {+ isTrendsFunnel: trendsFunnel,+ isTimeToConvertFunnel,+ funnelsFilter,+ } = useValues(funnelDataLogic(insightProps))+ const isTrendsFunnel = !!trendsFunnel+ const todayRailNav = useFeatureFlag('TODAY_RAIL_NAV')const {showValuesOnSeries,mightContainFractionalNumbers,@@ -206,6 +217,9 @@ function useInsightDisplayContext(): InsightDisplayContext {isStickiness,isLifecycle,isTrendsFunnel,+ isTimeToConvertFunnel: !!isTimeToConvertFunnel,+ funnelBinCount: typeof funnelsFilter?.binCount === 'number' ? funnelsFilter.binCount : undefined,+ todayRailNav,isMetric,isBoxPlot,isPie,@@ -455,6 +469,17 @@ const INSIGHT_BINDINGS: DisplayOptionBindings<InsightDisplayContext> = {posthog.capture('decimal places changed', { decimal_places: decimalPlaces })},},+ funnelBinCount: {+ showCondition: (c) => c.todayRailNav && c.isTimeToConvertFunnel,+ render: (c) => (+ <QuillFunnelBinCountOption+ value={c.funnelBinCount}+ onChange={(binCount) => c.updateInsightFilter({ binCount })}+ disabledReason={c.editingDisabledReason}+ />+ ),+ changedCount: (c) => c.funnelBinCount !== undefined,+ },retentionDashboardDisplay: {showCondition: (c) => c.isRetention && c.canEditInsight,value: (c) => c.retentionFilter?.dashboardDisplay || RetentionDashboardDisplayType.TableOnly,diff --git a/products/product_analytics/frontend/insights/funnels/filters/FunnelVizType.tsx b/products/product_analytics/frontend/insights/funnels/filters/FunnelVizType.tsxindex b478fdc6cbeb..35036f1367e5 100644--- a/products/product_analytics/frontend/insights/funnels/filters/FunnelVizType.tsx+++ b/products/product_analytics/frontend/insights/funnels/filters/FunnelVizType.tsx@@ -1,13 +1,8 @@-import { useActions, useValues } from 'kea'--import { IconClock, IconFilter, IconTrending } from '@posthog/icons'-import { LemonSelect } from 'lib/lemon-ui/LemonSelect'-import { FunnelsFilter } from '~/queries/schema/schema-general'import { EditorFilterProps, FunnelVizType as VizType } from '~/types'-import { funnelDataLogic } from '../funnelDataLogic'+import { useFunnelVizType } from './useFunnelVizType'type LabelProps = {icon: JSX.Element@@ -34,62 +29,22 @@ const LabelInMenu = ({ icon, title, description }: LabelInMenuProps): JSX.Elemen)export function FunnelVizType({ insightProps }: Pick<EditorFilterProps, 'insightProps'>): JSX.Element | null {- const { aggregationTargetLabel } = useValues(funnelDataLogic(insightProps))- const { insightFilter } = useValues(funnelDataLogic(insightProps))- const { updateInsightFilter } = useActions(funnelDataLogic(insightProps))+ const { value, options, setValue } = useFunnelVizType({ insightProps })- const { funnelVizType } = (insightFilter || {}) as FunnelsFilter-- if (funnelVizType === VizType.Flow) {+ if (value === VizType.Flow) {return null}- const options = [- {- value: VizType.Steps,- label: <Label icon={<IconFilter className="text-secondary" />} title="Conversion steps" />,- labelInMenu: (- <LabelInMenu- icon={<IconFilter className="text-secondary" />}- title="Conversion steps"- description={`Track ${aggregationTargetLabel.plural} progress between steps of the funnel`}- />- ),- },- {- value: VizType.TimeToConvert,- label: <Label icon={<IconClock className="text-secondary" />} title="Time to convert" />,- labelInMenu: (- <LabelInMenu- icon={<IconClock className="text-secondary" />}- title="Time to convert"- description={`Track how long it takes for ${aggregationTargetLabel.plural} to convert`}- />- ),- },- {- value: VizType.Trends,- label: <Label icon={<IconTrending className="text-secondary" />} title="Historical trends" />,- labelInMenu: (- <LabelInMenu- icon={<IconTrending className="text-secondary" />}- title="Historical trends"- description="Track how this funnel's conversion rate is trending over time"- />- ),- },- ]-return (<LemonSelectsize="small"- value={funnelVizType || VizType.Steps}- onChange={(value) => {- if (funnelVizType !== value) {- updateInsightFilter({ funnelVizType: value })- }- }}- options={options}+ value={value}+ onChange={setValue}+ options={options.map(({ value, title, description, icon }) => ({+ value,+ label: <Label icon={icon} title={title} />,+ labelInMenu: <LabelInMenu icon={icon} title={title} description={description} />,+ }))}dropdownMatchSelectWidth={false}data-attr="funnel-viz-type-select"/>diff --git a/products/product_analytics/frontend/insights/funnels/filters/QuillFunnelBinCountOption.tsx b/products/product_analytics/frontend/insights/funnels/filters/QuillFunnelBinCountOption.tsxnew file mode 100644index 000000000000..9c9c1c99735f--- /dev/null+++ b/products/product_analytics/frontend/insights/funnels/filters/QuillFunnelBinCountOption.tsx@@ -0,0 +1,131 @@+import { useEffect, useId, useRef, useState } from 'react'++import {+ Button,+ Field,+ InputGroup,+ InputGroupAddon,+ InputGroupInput,+ InputGroupText,+ Select,+ SelectContent,+ SelectItem,+ SelectSeparator,+ SelectTrigger,+ SelectValue,+} from '@posthog/quill'++import { QuillChartOptionLabel } from 'lib/components/ChartOptions/QuillChartOptionLabel'+import { BIN_COUNT_AUTO } from 'lib/constants'++// Limits from the time to convert query on the backend.+const MIN_BINS = 1+const MAX_BINS = 90+const PRESETS = [5, 15, 25, 50, 90]+const CUSTOM = 'custom'++type BinChoice = number | typeof BIN_COUNT_AUTO | typeof CUSTOM++export function QuillFunnelBinCountOption({+ value,+ onChange,+ disabledReason,+}: {+ value: number | undefined+ onChange: (binCount: number | undefined) => void+ disabledReason?: string | null+}): JSX.Element {+ const id = useId()+ const [draft, setDraft] = useState<string | null>(null)+ const [customPicked, setCustomPicked] = useState(false)+ const inputRef = useRef<HTMLInputElement>(null)+ const editing = draft !== null++ useEffect(() => {+ if (!editing) {+ return+ }+ // The closing list hands focus back to its trigger after this field mounts.+ const frame = requestAnimationFrame(() => inputRef.current?.focus())+ return () => cancelAnimationFrame(frame)+ }, [editing])+ const counts = [...new Set([...PRESETS, ...(value === undefined ? [] : [value])])].sort((a, b) => a - b)++ const commit = (): void => {+ const parsed = draft === null ? NaN : parseInt(draft, 10)+ if (parsed >= MIN_BINS && parsed <= MAX_BINS) {+ onChange(parsed)+ }+ setDraft(null)+ }++ return (+ <Field orientation="horizontal" className="justify-between">+ <QuillChartOptionLabel htmlFor={id} label="Bins" />+ {draft !== null ? (+ <InputGroup className="w-28">+ <InputGroupInput+ id={id}+ type="text"+ inputMode="numeric"+ ref={inputRef}+ value={draft}+ placeholder={`${MIN_BINS}-${MAX_BINS}`}+ onChange={(event) => setDraft(event.target.value)}+ onBlur={commit}+ onKeyDown={(event) => {+ if (event.key === 'Enter') {+ commit()+ } else if (event.key === 'Escape') {+ event.stopPropagation()+ setDraft(null)+ }+ }}+ data-attr="funnel-bin-count-custom"+ />+ <InputGroupAddon align="inline-end">+ <InputGroupText>bins</InputGroupText>+ </InputGroupAddon>+ </InputGroup>+ ) : (+ <Select<BinChoice>+ value={value ?? BIN_COUNT_AUTO}+ onValueChange={(next: BinChoice | null) => {+ if (next === CUSTOM) {+ setCustomPicked(true)+ } else if (next !== null) {+ onChange(next === BIN_COUNT_AUTO ? undefined : next)+ }+ }}+ onOpenChangeComplete={(open: boolean) => {+ if (!open && customPicked) {+ setCustomPicked(false)+ setDraft(value === undefined ? '' : String(value))+ }+ }}+ disabled={!!disabledReason}+ >+ <SelectTrigger+ id={id}+ render={<Button variant="outline" left disabledReason={disabledReason || undefined} />}+ data-attr="funnel-bin-count"+ >+ <SelectValue>+ {(selected: BinChoice) => (selected === BIN_COUNT_AUTO ? 'Auto' : `${selected} bins`)}+ </SelectValue>+ </SelectTrigger>+ <SelectContent align="start" alignItemWithTrigger={false}>+ <SelectItem value={BIN_COUNT_AUTO}>Auto</SelectItem>+ {counts.map((count) => (+ <SelectItem key={count} value={count}>+ {count} bins+ </SelectItem>+ ))}+ <SelectSeparator />+ <SelectItem value={CUSTOM}>Custom…</SelectItem>+ </SelectContent>+ </Select>+ )}+ </Field>+ )+}diff --git a/products/product_analytics/frontend/insights/funnels/filters/QuillFunnelVizType.tsx b/products/product_analytics/frontend/insights/funnels/filters/QuillFunnelVizType.tsxnew file mode 100644index 000000000000..769b3ce038b1--- /dev/null+++ b/products/product_analytics/frontend/insights/funnels/filters/QuillFunnelVizType.tsx@@ -0,0 +1,148 @@+import { useActions, useValues } from 'kea'++import { IconFunnels, IconGraph, IconLineGraph } from '@posthog/icons'+import {+ Button,+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuGroup,+ DropdownMenuLabel,+ DropdownMenuRadioGroup,+ DropdownMenuRadioItem,+ DropdownMenuTrigger,+ SelectTriggerIcon,+} from '@posthog/quill'++import { FunnelLayout } from 'lib/constants'++import { FunnelsFilter } from '~/queries/schema/schema-general'+import { EditorFilterProps, FunnelVizType as VizType } from '~/types'++import { funnelDataLogic } from '../funnelDataLogic'+import { useFunnelVizType } from './useFunnelVizType'++interface FunnelDisplayChoice {+ key: string+ vizType: VizType+ layout?: FunnelLayout+ label: string+ buttonLabel: string+ icon: JSX.Element+}++const CHOICE_GROUPS: { title: string; choices: FunnelDisplayChoice[] }[] = [+ {+ title: 'Steps',+ choices: [+ {+ key: 'steps-vertical',+ vizType: VizType.Steps,+ layout: FunnelLayout.vertical,+ label: 'Left to right',+ buttonLabel: 'Steps, left to right',+ icon: <IconFunnels className="-rotate-90" />,+ },+ {+ key: 'steps-horizontal',+ vizType: VizType.Steps,+ layout: FunnelLayout.horizontal,+ label: 'Top to bottom',+ buttonLabel: 'Steps, top to bottom',+ icon: <IconFunnels />,+ },+ ],+ },+ {+ title: 'Over time',+ choices: [+ {+ key: 'time-to-convert',+ vizType: VizType.TimeToConvert,+ label: 'Time to convert',+ buttonLabel: 'Time to convert',+ icon: <IconGraph />,+ },+ {+ key: 'trends',+ vizType: VizType.Trends,+ label: 'Conversion rate',+ buttonLabel: 'Conversion rate',+ icon: <IconLineGraph />,+ },+ ],+ },+]++const CHOICES = CHOICE_GROUPS.flatMap((group) => group.choices)++export function QuillFunnelVizType({+ insightProps,+ disabledReason,+}: Pick<EditorFilterProps, 'insightProps'> & { disabledReason?: string | null }): JSX.Element | null {+ const { value, options } = useFunnelVizType({ insightProps })+ const { funnelsFilter } = useValues(funnelDataLogic(insightProps))+ const { updateInsightFilter } = useActions(funnelDataLogic(insightProps))++ if (value === VizType.Flow) {+ return null+ }++ const layout = funnelsFilter?.layout || FunnelLayout.vertical+ const current = CHOICES.find(+ (choice) => choice.vizType === value && (choice.layout === undefined || choice.layout === layout)+ )+ const descriptionFor = (vizType: VizType): string | undefined =>+ options.find((option) => option.value === vizType)?.description++ const choose = (key: string): void => {+ const choice = CHOICES.find((c) => c.key === key)+ if (!choice) {+ return+ }+ const changes: Partial<FunnelsFilter> = {}+ if (choice.vizType !== value) {+ changes.funnelVizType = choice.vizType+ }+ if (choice.layout && choice.layout !== layout) {+ changes.layout = choice.layout+ }+ if (Object.keys(changes).length > 0) {+ updateInsightFilter(changes)+ }+ }++ return (+ <DropdownMenu>+ <DropdownMenuTrigger+ disabled={!!disabledReason}+ render={+ <Button variant="outline" left disabledReason={disabledReason} data-attr="funnel-viz-type-select" />+ }+ >+ {current?.icon}+ <span>{current?.buttonLabel}</span>+ <SelectTriggerIcon />+ </DropdownMenuTrigger>+ <DropdownMenuContent align="end">+ <DropdownMenuRadioGroup value={current?.key ?? ''} onValueChange={(key) => choose(key as string)}>+ {CHOICE_GROUPS.map((group) => (+ <DropdownMenuGroup key={group.title}>+ <DropdownMenuLabel>{group.title}</DropdownMenuLabel>+ {group.choices.map((choice) => (+ <DropdownMenuRadioItem+ key={choice.key}+ value={choice.key}+ tooltip={descriptionFor(choice.vizType)}+ closeOnClick+ >+ {choice.icon}+ {choice.label}+ </DropdownMenuRadioItem>+ ))}+ </DropdownMenuGroup>+ ))}+ </DropdownMenuRadioGroup>+ </DropdownMenuContent>+ </DropdownMenu>+ )+}diff --git a/products/product_analytics/frontend/insights/funnels/filters/useFunnelVizType.tsx b/products/product_analytics/frontend/insights/funnels/filters/useFunnelVizType.tsxnew file mode 100644index 000000000000..b3b8ed62b93d--- /dev/null+++ b/products/product_analytics/frontend/insights/funnels/filters/useFunnelVizType.tsx@@ -0,0 +1,54 @@+import { useActions, useValues } from 'kea'++import { IconClock, IconFilter, IconTrending } from '@posthog/icons'++import { FunnelsFilter } from '~/queries/schema/schema-general'+import { EditorFilterProps, FunnelVizType as VizType } from '~/types'++import { funnelDataLogic } from '../funnelDataLogic'++export interface FunnelVizTypeOption {+ value: VizType+ title: string+ description: string+ icon: JSX.Element+}++export function useFunnelVizType({ insightProps }: Pick<EditorFilterProps, 'insightProps'>): {+ value: VizType+ options: FunnelVizTypeOption[]+ setValue: (value: VizType) => void+} {+ const { aggregationTargetLabel, insightFilter } = useValues(funnelDataLogic(insightProps))+ const { updateInsightFilter } = useActions(funnelDataLogic(insightProps))+ const { funnelVizType } = (insightFilter || {}) as FunnelsFilter++ return {+ value: funnelVizType || VizType.Steps,+ options: [+ {+ value: VizType.Steps,+ title: 'Conversion steps',+ description: `Track ${aggregationTargetLabel.plural} progress between steps of the funnel`,+ icon: <IconFilter className="text-secondary" />,+ },+ {+ value: VizType.TimeToConvert,+ title: 'Time to convert',+ description: `Track how long it takes for ${aggregationTargetLabel.plural} to convert`,+ icon: <IconClock className="text-secondary" />,+ },+ {+ value: VizType.Trends,+ title: 'Historical trends',+ description: "Track how this funnel's conversion rate is trending over time",+ icon: <IconTrending className="text-secondary" />,+ },+ ],+ setValue: (value) => {+ if (funnelVizType !== value) {+ updateInsightFilter({ funnelVizType: value })+ }+ },+ }+}