: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(customer-analytics): search all column sources in configurator (#74938)
Arthur Moreira de Deusbcabd96fc848
diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.mdindex ee99311ba4b1..11f8a1b36218 100644--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md@@ -158,6 +158,7 @@ The operation is idempotent and skips non-creators.**Column configurator:** `AccountsColumnConfigurator.tsx` no longer persists columns itself — "Done" closes only.Column changes are saved as part of a view via `AccountsViewSelector.tsx` (the view dropdown in `AccountsTabFilters`), which offers "Save current view" (creates) and "Update '<name>'" (patches the selected view).The configurator's footer also surfaces that path (`SaveViewButton`): "Update "<name>"" when the current view is editable (disabled until dirty), otherwise "Save as new view" — both delegate to `accountsViewsLogic` (`updateView` / `setIsCreating`), the latter opening the create-view modal that `AccountsViewSelector` renders.+The available-columns picker defaults to an "All columns" category that searches across every non-freeform group at once (each result row shows its source group); picking a category in the dropdown narrows the search to it, and "SQL expression" stays a dedicated freeform entry.## Max / agent integrationdiff --git a/products/customer_analytics/frontend/components/Accounts/AccountsColumnConfigurator.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsColumnConfigurator.tsxindex 4edb8cc7643f..7a84b45ff6b1 100644--- a/products/customer_analytics/frontend/components/Accounts/AccountsColumnConfigurator.tsx+++ b/products/customer_analytics/frontend/components/Accounts/AccountsColumnConfigurator.tsx@@ -5,7 +5,7 @@ import { restrictToParentElement, restrictToVerticalAxis } from '@dnd-kit/modifiimport { SortableContext, useSortable, verticalListSortingStrategy } from '@dnd-kit/sortable'import { CSS } from '@dnd-kit/utilities'import { useActions, useValues } from 'kea'-import { useMemo, useState } from 'react'+import { useState } from 'react'import { IconPencil, IconX } from '@posthog/icons'import {@@ -29,11 +29,12 @@ import type { CustomPropertyDefinitionApi } from 'products/customer_analytics/frimport { isNumericDisplayType } from '../../scenes/CustomerAnalyticsConfigurationScene/account/customPropertyTypes'import {ACCOUNTS_NAME_COLUMN,+ ALL_COLUMNS_KEY,AccountColumnDisplayMode,AccountColumnGroup,- AccountColumnGroupKey,COLUMN_DISPLAY_WINDOW_OPTIONS,DEFAULT_COLUMN_DISPLAY_WINDOW_DAYS,+ PickerGroupKey,accountsColumnConfigLogic,} from './accountsColumnConfigLogic'import { accountsViewsLogic } from './accountsViewsLogic'@@ -361,87 +362,58 @@ function SelectedAccountColumn({}function AvailableColumnsPicker({ groups, loading }: { groups: AccountColumnGroup[]; loading: boolean }): JSX.Element {- const { selectColumns } = useValues(accountsColumnConfigLogic)- const { selectColumn } = useActions(accountsColumnConfigLogic)- const [activeGroupKey, setActiveGroupKey] = useState<AccountColumnGroupKey>('account_properties')- const [search, setSearch] = useState('')- const [sqlInput, setSqlInput] = useState('')-- const activeGroup = useMemo(- () => groups.find((g) => g.key === activeGroupKey) ?? groups[0],- [groups, activeGroupKey]- )-- const filteredOptions = useMemo(() => {- if (!activeGroup || activeGroup.isFreeform) {- return []- }- const query = search.trim().toLowerCase()- if (!query) {- return activeGroup.options- }- return activeGroup.options.filter((option) => option.name.toLowerCase().includes(query))- }, [activeGroup, search])-- const isSelected = (expression: string): boolean => selectColumns.includes(expression)-- const addSqlExpression = (): void => {- const expr = sqlInput.trim()- if (expr) {- selectColumn(expr)- setSqlInput('')- }- }-- const searchPlaceholder = activeGroup?.isFreeform- ? 'Use the SQL expression panel below'- : `Search ${activeGroup?.label.toLowerCase() ?? 'columns'}`+ const {+ pickerGroupKey,+ pickerSearch,+ pickerSqlInput,+ pickerSearchPlaceholder,+ activePickerGroup,+ filteredColumnOptions,+ } = useValues(accountsColumnConfigLogic)+ const { selectColumn, setPickerGroupKey, setPickerSearch, setPickerSqlInput, addSqlExpression } =+ useActions(accountsColumnConfigLogic)return (<div className="flex flex-col gap-2"><LemonInputtype="search"- placeholder={searchPlaceholder}- value={search}- onChange={setSearch}- disabled={activeGroup?.isFreeform}+ placeholder={pickerSearchPlaceholder}+ value={pickerSearch}+ onChange={setPickerSearch}+ disabled={activePickerGroup?.isFreeform}fullWidthdata-attr="accounts-columns-search"- suffix={- <CategoryPicker- groups={groups}- activeKey={activeGroupKey}- onChange={(key) => {- setActiveGroupKey(key)- setSearch('')- }}- />- }+ suffix={<CategoryPicker groups={groups} activeKey={pickerGroupKey} onChange={setPickerGroupKey} />}/>- {activeGroup?.isFreeform ? (- <SqlExpressionPanel value={sqlInput} onChange={setSqlInput} onAdd={addSqlExpression} />+ {activePickerGroup?.isFreeform ? (+ <SqlExpressionPanel value={pickerSqlInput} onChange={setPickerSqlInput} onAdd={addSqlExpression} />) : (<div className="AvailableColumnsList border border-border rounded">- {loading && filteredOptions.length === 0 ? (+ {loading && filteredColumnOptions.length === 0 ? (<div className="p-3 text-secondary">Loading schema…</div>- ) : filteredOptions.length === 0 ? (+ ) : filteredColumnOptions.length === 0 ? (<div className="p-3 text-secondary">- {search.trim() ? 'No matching columns' : 'No columns available'}+ {pickerSearch.trim() ? 'No matching columns' : 'No columns available'}</div>) : (<ul className="m-0 p-0 list-none">- {filteredOptions.map((option) => {- const already = isSelected(option.expression)+ {filteredColumnOptions.map((option) => {return (- <li key={option.expression} className="border-b border-border last:border-b-0">+ <li+ key={`${option.groupLabel}::${option.expression}`}+ className="border-b border-border last:border-b-0"+ ><LemonButtonfullWidthsize="small"- onClick={() => !already && selectColumn(option.expression)}- disabledReason={already ? 'Already added' : undefined}+ onClick={() => !option.isSelected && selectColumn(option.expression)}+ disabledReason={option.isSelected ? 'Already added' : undefined}data-attr={`accounts-column-option-${option.name}`}><span className="flex-1 font-mono">{option.name}</span>+ {!activePickerGroup ? (+ <span className="ml-2 text-xs text-secondary">{option.groupLabel}</span>+ ) : null}{option.type ? (<span className="ml-2 text-xs text-secondary">{option.type}</span>) : null}@@ -463,19 +435,26 @@ function CategoryPicker({onChange,}: {groups: AccountColumnGroup[]- activeKey: AccountColumnGroupKey- onChange: (key: AccountColumnGroupKey) => void+ activeKey: PickerGroupKey+ onChange: (key: PickerGroupKey) => void}): JSX.Element {return (<LemonSearchableSelectsize="xsmall"value={activeKey}- options={groups.map((group) => ({- value: group.key,- label: group.label,- 'data-attr': `accounts-columns-group-item-${group.key}`,- }))}- onChange={(key) => key && onChange(key as AccountColumnGroupKey)}+ options={[+ {+ value: ALL_COLUMNS_KEY,+ label: 'All columns',+ 'data-attr': `accounts-columns-group-item-${ALL_COLUMNS_KEY}`,+ },+ ...groups.map((group) => ({+ value: group.key,+ label: group.label,+ 'data-attr': `accounts-columns-group-item-${group.key}`,+ })),+ ]}+ onChange={(key) => key && onChange(key as PickerGroupKey)}searchPlaceholder="Search categories"dropdownPlacement="bottom-end"data-attr="accounts-columns-group"diff --git a/products/customer_analytics/frontend/components/Accounts/accountsColumnConfigLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsColumnConfigLogic.test.tsindex 04bb5429ad33..bf92ae934ba0 100644--- a/products/customer_analytics/frontend/components/Accounts/accountsColumnConfigLogic.test.ts+++ b/products/customer_analytics/frontend/components/Accounts/accountsColumnConfigLogic.test.ts@@ -6,9 +6,11 @@ import type {} from 'products/customer_analytics/frontend/generated/api.schemas'import {+ AccountColumnGroup,applyColumnDisplayToSelect,buildAccountColumnGroups,customPropertyAlias,+ filterColumnOptions,relationshipAlias,roleKeyToDefinitionMap,translateSelectColumns,@@ -138,4 +140,44 @@ describe('accountsColumnConfigLogic column groups and translation', () => {})).toEqual([scalar])})++ const pickerGroups: AccountColumnGroup[] = [+ {+ key: 'account_properties',+ label: 'Account properties',+ options: [+ { name: 'name', expression: 'name' },+ { name: 'created_at', expression: 'created_at', type: 'datetime' },+ ],+ },+ {+ key: 'accounts.billing',+ label: 'billing',+ options: [{ name: 'plan_name', expression: 'accounts.billing.plan_name AS plan_name' }],+ },+ { key: 'sql_expression', label: 'SQL expression', options: [], isFreeform: true },+ ]++ it('filterColumnOptions spans all non-freeform groups and marks already-selected expressions', () => {+ const options = filterColumnOptions(pickerGroups, null, '', ['name'])++ expect(options.map((option) => [option.name, option.groupLabel, option.isSelected])).toEqual([+ ['name', 'Account properties', true],+ ['created_at', 'Account properties', false],+ ['plan_name', 'billing', false],+ ])+ })++ it('filterColumnOptions matches the search case-insensitively across groups', () => {+ expect(filterColumnOptions(pickerGroups, null, ' PLAN ', []).map((option) => option.name)).toEqual([+ 'plan_name',+ ])+ })++ it('filterColumnOptions narrows to the active group and yields nothing for freeform groups', () => {+ expect(filterColumnOptions(pickerGroups, pickerGroups[1], '', []).map((option) => option.name)).toEqual([+ 'plan_name',+ ])+ expect(filterColumnOptions(pickerGroups, pickerGroups[2], '', [])).toEqual([])+ })})diff --git a/products/customer_analytics/frontend/components/Accounts/accountsColumnConfigLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountsColumnConfigLogic.tsindex e0df5e53f7cd..e43d88478bd6 100644--- a/products/customer_analytics/frontend/components/Accounts/accountsColumnConfigLogic.ts+++ b/products/customer_analytics/frontend/components/Accounts/accountsColumnConfigLogic.ts@@ -91,6 +91,9 @@ export type AccountColumnGroupKey =| 'sql_expression'| `accounts.${string}`+export const ALL_COLUMNS_KEY = 'all'+export type PickerGroupKey = AccountColumnGroupKey | typeof ALL_COLUMNS_KEY+// Custom property definition ids are UUIDs, which aren't valid HogQL identifiers (hyphens).// Strip them so the column alias is a clean identifier, and so the renderer can map a visible// column name back to its definition.@@ -182,6 +185,32 @@ export type AccountColumnGroup = {isFreeform?: boolean}+export type AccountPickerColumnOption = AccountColumnOption & { groupLabel: string; isSelected: boolean }++// Null activeGroup means "All columns": search spans every non-freeform group.+export function filterColumnOptions(+ groups: AccountColumnGroup[],+ activeGroup: AccountColumnGroup | null,+ search: string,+ selectColumns: string[]+): AccountPickerColumnOption[] {+ if (activeGroup?.isFreeform) {+ return []+ }+ const searchableGroups = activeGroup ? [activeGroup] : groups.filter((group) => !group.isFreeform)+ const query = search.trim().toLowerCase()+ const selected = new Set(selectColumns)+ return searchableGroups.flatMap((group) =>+ group.options+ .filter((option) => !query || option.name.toLowerCase().includes(query))+ .map((option) => ({+ ...option,+ groupLabel: group.label,+ isSelected: selected.has(option.expression),+ }))+ )+}+// Field types that point at joined tables/views (lazy joins, virtual tables,// user-defined data warehouse joins, saved queries). Each one surfaces as a// dedicated dropdown entry in the column configurator.@@ -350,6 +379,7 @@ export interface accountsColumnConfigLogicValues {currentProjectId: number | null // projectLogiccurrentTeamId: number | null // teamLogicaccountsColumnGroups: AccountColumnGroup[]+ activePickerGroup: AccountColumnGroup | nullaliasToDefinition: Record<string, CustomPropertyDefinitionApi>aliasToRelationshipDefinition: Record<string, AccountRelationshipDefinitionApi>columnConfiguratorVisible: boolean@@ -365,6 +395,11 @@ export interface accountsColumnConfigLogicValues {displayByAlias: AccountColumnDisplayStateeditingColumn: string | nulleditingColumnIndex: number | null+ filteredColumnOptions: AccountPickerColumnOption[]+ pickerGroupKey: PickerGroupKey+ pickerSearch: string+ pickerSearchPlaceholder: string+ pickerSqlInput: stringquerySelectColumns: string[]relationshipDefinitions: AccountRelationshipDefinitionApi[]relationshipDefinitionsLoaded: boolean@@ -386,6 +421,9 @@ export interface accountsColumnConfigLogicActions {force?: boolean} // databaseTableListLogicloadJoins: () => any // joinsLogic+ addSqlExpression: () => {+ value: true+ }hideColumnConfigurator: () => {value: true}@@ -445,6 +483,15 @@ export interface accountsColumnConfigLogicActions {setEditingColumnIndex: (index: number | null) => {index: number | null}+ setPickerGroupKey: (key: PickerGroupKey) => {+ key: PickerGroupKey+ }+ setPickerSearch: (search: string) => {+ search: string+ }+ setPickerSqlInput: (sqlInput: string) => {+ sqlInput: string+ }setSelectColumns: (columns: string[]) => {columns: string[]}@@ -484,6 +531,17 @@ export interface accountsColumnConfigLogicMeta {customPropertyDefinitions: CustomPropertyDefinitionApi[],relationshipDefinitions: AccountRelationshipDefinitionApi[]) => AccountColumnGroup[]+ activePickerGroup: (+ accountsColumnGroups: AccountColumnGroup[],+ pickerGroupKey: PickerGroupKey+ ) => AccountColumnGroup | null+ filteredColumnOptions: (+ accountsColumnGroups: AccountColumnGroup[],+ activePickerGroup: AccountColumnGroup | null,+ pickerSearch: string,+ selectColumns: string[]+ ) => AccountPickerColumnOption[]+ pickerSearchPlaceholder: (activePickerGroup: AccountColumnGroup | null) => stringcustomPropertyDefinitionsById: (customPropertyDefinitions: CustomPropertyDefinitionApi[]) => Record<string, CustomPropertyDefinitionApi>@@ -545,6 +603,10 @@ export const accountsColumnConfigLogic = kea<accountsColumnConfigLogicType>([setColumnDisplayConfig: (config: AccountColumnDisplayState) => ({ config }),setEditingColumnIndex: (index: number | null) => ({ index }),updateColumnExpression: (index: number, expression: string) => ({ index, expression }),+ setPickerGroupKey: (key: PickerGroupKey) => ({ key }),+ setPickerSearch: (search: string) => ({ search }),+ setPickerSqlInput: (sqlInput: string) => ({ sqlInput }),+ addSqlExpression: true,}),reducers({selectColumns: [@@ -594,6 +656,26 @@ export const accountsColumnConfigLogic = kea<accountsColumnConfigLogicType>([hideColumnConfigurator: () => false,},],+ pickerGroupKey: [+ ALL_COLUMNS_KEY as PickerGroupKey,+ {+ setPickerGroupKey: (_, { key }) => key,+ },+ ],+ pickerSearch: [+ '',+ {+ setPickerSearch: (_, { search }) => search,+ // A stale query from another category would silently hide results.+ setPickerGroupKey: () => '',+ },+ ],+ pickerSqlInput: [+ '',+ {+ setPickerSqlInput: (_, { sqlInput }) => sqlInput,+ },+ ],columnDisplay: [{} as AccountColumnDisplayState,{@@ -690,6 +772,32 @@ export const accountsColumnConfigLogic = kea<accountsColumnConfigLogicType>([relationshipDefinitions),],+ activePickerGroup: [+ (s) => [s.accountsColumnGroups, s.pickerGroupKey],+ (accountsColumnGroups: AccountColumnGroup[], pickerGroupKey: PickerGroupKey): AccountColumnGroup | null =>+ pickerGroupKey === ALL_COLUMNS_KEY+ ? null+ : (accountsColumnGroups.find((group) => group.key === pickerGroupKey) ?? null),+ ],+ filteredColumnOptions: [+ (s) => [s.accountsColumnGroups, s.activePickerGroup, s.pickerSearch, s.selectColumns],+ (+ accountsColumnGroups: AccountColumnGroup[],+ activePickerGroup: AccountColumnGroup | null,+ pickerSearch: string,+ selectColumns: string[]+ ): AccountPickerColumnOption[] =>+ filterColumnOptions(accountsColumnGroups, activePickerGroup, pickerSearch, selectColumns),+ ],+ pickerSearchPlaceholder: [+ (s) => [s.activePickerGroup],+ (activePickerGroup: AccountColumnGroup | null): string =>+ activePickerGroup?.isFreeform+ ? 'Use the SQL expression panel below'+ : activePickerGroup+ ? `Search ${activePickerGroup.label.toLowerCase()}`+ : 'Search all columns',+ ],customPropertyDefinitionsById: [(s) => [s.customPropertyDefinitions],(customPropertyDefinitions: CustomPropertyDefinitionApi[]): Record<string, CustomPropertyDefinitionApi> =>@@ -785,6 +893,13 @@ export const accountsColumnConfigLogic = kea<accountsColumnConfigLogicType>([actions.setSelectColumns(values.defaultSelectColumns)}},+ addSqlExpression: () => {+ const expression = values.pickerSqlInput.trim()+ if (expression) {+ actions.selectColumn(expression)+ actions.setPickerSqlInput('')+ }+ },})),afterMount(({ actions, values }) => {// Lazily fetch the database schema only if it isn't already in flight / loaded.