: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(insights): stop result color modal crashing on formula series (#72299)
Xandera71f22fe2fc5
diff --git a/frontend/src/lib/components/EntityFilterInfo.test.tsx b/frontend/src/lib/components/EntityFilterInfo.test.tsxindex 8f996aed664f..7411c973ae66 100644--- a/frontend/src/lib/components/EntityFilterInfo.test.tsx+++ b/frontend/src/lib/components/EntityFilterInfo.test.tsx@@ -88,4 +88,17 @@ describe('EntityFilterInfo', () => {userEvent.hover(screen.getByText('Signed up'))expect(await screen.findByText(/Event sent as/, {}, { timeout: 3000 })).toBeInTheDocument()})++ // Formula series carry `action: null`, so callers pass a null filter. That must render+ // nothing rather than crash the scene (getUnderlyingEntity used to dereference filter.type).+ it.each([+ ['null', null],+ ['undefined', undefined],+ ] as [string, EntityFilter | ActionFilter | null | undefined][])(+ 'renders nothing without throwing for a %s filter',+ (_, filter) => {+ const { container } = render(<EntityFilterInfo filter={filter} />)+ expect(container.querySelectorAll('.EntityFilterInfo')).toHaveLength(0)+ }+ )})diff --git a/frontend/src/lib/components/EntityFilterInfo.tsx b/frontend/src/lib/components/EntityFilterInfo.tsxindex 4229f2886b53..7452f68c6937 100644--- a/frontend/src/lib/components/EntityFilterInfo.tsx+++ b/frontend/src/lib/components/EntityFilterInfo.tsx@@ -134,7 +134,7 @@ function EntityFilterInfoTooltipTitle({}interface EntityFilterInfoProps {- filter: EntityFilter | ActionFilter+ filter?: EntityFilter | ActionFilter | nullallowWrap?: booleanshowSingleName?: booleanstyle?: React.CSSProperties@@ -155,6 +155,13 @@ export function EntityFilterInfo({showIcon = false,}: EntityFilterInfoProps): JSX.Element {const isColumn = layout === 'column'++ // `filter` is null for formula series (and can be absent for other callers); render nothing+ // rather than dereferencing it in getEntityFilterDisplayInfo.+ if (!filter) {+ return <></>+ }+const { displayName, baseName, underlying, isRenamed } = getEntityFilterDisplayInfo(filter, filterGroupType)// Reveal the underlying entity (and the tooltip) only when the label hides it — andiff --git a/frontend/src/queries/nodes/InsightViz/ResultCustomizationsModal.tsx b/frontend/src/queries/nodes/InsightViz/ResultCustomizationsModal.tsxindex 923338ca68dc..0b1e7f869d76 100644--- a/frontend/src/queries/nodes/InsightViz/ResultCustomizationsModal.tsx+++ b/frontend/src/queries/nodes/InsightViz/ResultCustomizationsModal.tsx@@ -86,15 +86,18 @@ function TrendsInfo({ dataset, resultCustomizationBy }: TrendsInfoProps): JSX.Elconst { formatPropertyValueForDisplay } = useValues(propertyDefinitionsModel)const { breakdownFilter } = useValues(insightVizDataLogic)+ // Formula series carry no entity (`action` is null), so fall back to the series label.+ const seriesName = dataset.action ? (+ <EntityFilterInfo filter={dataset.action} allowWrap={true} showSingleName={true} />+ ) : (+ dataset.label+ )+return (<>{dataset.breakdown_value ? (<p className="mb-2">- You are customizing the appearance of series{' '}- <b>- <EntityFilterInfo filter={dataset.action} allowWrap={true} showSingleName={true} />- </b>{' '}- for the breakdown{' '}+ You are customizing the appearance of series <b>{seriesName}</b> for the breakdown{' '}<b>{formatBreakdownLabel(dataset.breakdown_value,@@ -107,11 +110,7 @@ function TrendsInfo({ dataset, resultCustomizationBy }: TrendsInfoProps): JSX.El</p>) : (<p className="mb-2">- You are customizing the appearance of series{' '}- <b>- <EntityFilterInfo filter={dataset.action} allowWrap={true} showSingleName={true} />- </b>- .+ You are customizing the appearance of series <b>{seriesName}</b>.</p>)}