: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): keep the region map from crashing with no series (#125302)
Sam Penningtonf7a99726ac71
diff --git a/products/product_analytics/frontend/insights/trends/RegionMap/RegionMap.tsx b/products/product_analytics/frontend/insights/trends/RegionMap/RegionMap.tsxindex 04bb7d17d9a0..7e09383b96d8 100644--- a/products/product_analytics/frontend/insights/trends/RegionMap/RegionMap.tsx+++ b/products/product_analytics/frontend/insights/trends/RegionMap/RegionMap.tsx@@ -52,7 +52,7 @@ function useRegionMapTooltip(showPersonsModal: boolean): React.RefObject<HTMLDivconst containerRef = useRef<HTMLDivElement>(null)const { getTooltip, showTooltip, hideTooltip, positionTooltipAt, resetTooltipPosition, measureTooltip } =useInsightTooltip()- const groupTypeLabel = aggregationLabel(series?.[0].math_group_type_index).plural+ const groupTypeLabel = aggregationLabel(series?.[0]?.math_group_type_index).pluraluseEffect(() => {if (!isTooltipShown || !currentTooltip || !tooltipCoordinates) {diff --git a/products/product_analytics/frontend/insights/trends/Trends.test.tsx b/products/product_analytics/frontend/insights/trends/Trends.test.tsxindex f330bf47b336..7feec9970e71 100644--- a/products/product_analytics/frontend/insights/trends/Trends.test.tsx+++ b/products/product_analytics/frontend/insights/trends/Trends.test.tsx@@ -1,6 +1,6 @@import '@testing-library/jest-dom'-import { cleanup, configure, screen } from '@testing-library/react'+import { cleanup, configure, screen, waitFor } from '@testing-library/react'import { InsightVizNode, NodeKind, TrendsQueryResponse } from '~/queries/schema/schema-general'import { QueryContext } from '~/queries/types'@@ -35,4 +35,21 @@ describe('TrendInsight', () => {expect(await screen.findByText(expectedText)).toBeInTheDocument()})++ it('a region map with no series renders', async () => {+ const { container } = renderInsight({+ query: buildTrendsQuery({+ series: [],+ breakdownFilter: {+ breakdowns: [+ { property: '$geoip_country_code', type: 'event' },+ { property: '$geoip_subdivision_1_code', type: 'event' },+ ],+ },+ trendsFilter: { display: ChartDisplayType.WorldMap },+ }),+ })++ await waitFor(() => expect(container.querySelector('.RegionMap')).toBeInTheDocument())+ })})