: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
fix(data-warehouse): show the group type when editing a group property (#83783)
Tom Owers8fb211fe40f4
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomPropertyModal.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomPropertyModal.tsxindex 0067d806907d..42c1a0c2d00a 100644--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomPropertyModal.tsx+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomPropertyModal.tsx@@ -11,6 +11,7 @@ import {LemonModal,LemonSearchableSelect,LemonSelect,+ LemonSkeleton,LemonSwitch,LemonTag,LemonTextArea,@@ -91,6 +92,28 @@ function ReadOnlyWarehouseTable({)}+// The group type an existing group property attaches to. Create-only on the backend, so it's shown as+// text — but it still has to be shown, since it's part of what the property is.+function ReadOnlyGroupType({ label, loading }: { label: string | null; loading: boolean }): JSX.Element {+ return (+ <div className="flex flex-col gap-1">+ <LemonLabel>Group type</LemonLabel>+ {loading ? (+ <LemonSkeleton className="h-4 w-24" />+ ) : label ? (+ <span>{label}</span>+ ) : (+ <span className="text-secondary">+ This group type isn't available. It may have been removed from the project.+ </span>+ )}+ <span className="text-secondary text-xs">+ You can't change the group type after the property is created.+ </span>+ </div>+ )+}+// An existing source's column mappings. Create-only on the backend, so they're listed rather than// edited: what a property reads is the thing you open the modal to check.function ReadOnlyColumnMappings({@@ -147,7 +170,7 @@ function PersonSourceEditor(): JSX.Element {} = useValues(customPropertyDefinitionsLogic)const { setCustomPropertyFormValue, loadSelectedTableColumns, loadWarehouseTables } =useActions(customPropertyDefinitionsLogic)- const { groupTypes } = useValues(groupsModel)+ const { groupTypes, groupTypesLoading } = useValues(groupsModel)const isGroup = customPropertyForm.targetType === 'group'const entityLabel = isGroup ? 'group' : 'person'@@ -177,6 +200,8 @@ function PersonSourceEditor(): JSX.Element {value: groupType.group_type_index,label: groupType.name_singular || groupType.group_type,}))+ const selectedGroupTypeLabel =+ groupTypeOptions.find((option) => option.value === customPropertyForm.groupTypeIndex)?.label ?? null// Only block on missing tables while creating a source — an existing source still needs its// key column and enabled switch editable even if its table was later deleted or filtered out.@@ -191,19 +216,28 @@ function PersonSourceEditor(): JSX.Element {return (<>- {isGroup && !hasExistingSource && (- <LemonField name="groupTypeIndex" label="Group type" help="Which group type this property attaches to.">- {({ value, onChange }) => (- <LemonSelect- value={value}- onChange={onChange}- options={groupTypeOptions}- placeholder="Select a group type"- fullWidth- />- )}- </LemonField>- )}+ {/* group_type_index is create-only on the backend, so on edit it's read-only text rather+ than a picker whose value would be dropped. */}+ {isGroup &&+ (editingDefinition ? (+ <ReadOnlyGroupType label={selectedGroupTypeLabel} loading={groupTypesLoading} />+ ) : (+ <LemonField+ name="groupTypeIndex"+ label="Group type"+ help="Which group type this property attaches to."+ >+ {({ value, onChange }) => (+ <LemonSelect+ value={value}+ onChange={onChange}+ options={groupTypeOptions}+ placeholder="Select a group type"+ fullWidth+ />+ )}+ </LemonField>+ ))}{hasExistingSource ? (<ReadOnlyWarehouseTableentityPlural={entityPlural}diff --git a/products/customer_analytics/frontend/scenes/WarehousePropertiesScene/WarehousePropertiesScene.stories.tsx b/products/customer_analytics/frontend/scenes/WarehousePropertiesScene/WarehousePropertiesScene.stories.tsxindex 0034bb49dbfe..f16bce1dd215 100644--- a/products/customer_analytics/frontend/scenes/WarehousePropertiesScene/WarehousePropertiesScene.stories.tsx+++ b/products/customer_analytics/frontend/scenes/WarehousePropertiesScene/WarehousePropertiesScene.stories.tsx@@ -176,6 +176,18 @@ const meta: Meta = {{ count: definitions.length, next: null, previous: null, results: definitions },],'/api/users/@me/': () => [200, userWithGroupAnalytics],+ // The group definition attaches to group type 0, so the tab needs that type to exist.+ '/api/projects/:team_id/groups_types/': () => [+ 200,+ [+ {+ group_type: 'organization',+ group_type_index: 0,+ name_singular: 'Organization',+ name_plural: 'Organizations',+ },+ ],+ ],// Expanding a row loads its run history, which carries the link to the table's// warehouse syncs.'/api/projects/:team_id/custom_property_sources/:source_id/runs/': () => [