Skip to content

: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.

perf(web-analytics): load the live tab only when it opens (#119080)

Paul D'Ambrab4b795f4264b
diff --git a/frontend/bin/check-eager-graph.mjs b/frontend/bin/check-eager-graph.mjs
index 64dba10615f8..d383adf158aa 100644
--- a/frontend/bin/check-eager-graph.mjs
+++ b/frontend/bin/check-eager-graph.mjs
@@ -177,6 +177,17 @@ const ROOTS = [
'src/scenes/web-analytics/tiles/WebAnalyticsTile.tsx',
],
},
+ {
+ root: 'src/scenes/web-analytics/WebAnalyticsScene.tsx',
+ label: 'web analytics scene',
+ // 2026-10-17: 9.85 MiB (3651 files), stable CSS included. ~10% headroom.
+ budgetBytes: 11_360_000,
+ forbidden: [
+ // Only the live tab renders this dashboard. Its world map holds about 1 MiB of country shapes.
+ 'src/scenes/web-analytics/LiveMetricsDashboard/LiveWebAnalyticsMetrics.tsx',
+ 'products/product_analytics/frontend/insights/trends/WorldMap/countryVectors.tsx',
+ ],
+ },
{
root: 'src/scenes/session-recordings/detail/SessionRecordingDetail.tsx',
label: 'replay detail scene',
diff --git a/frontend/src/scenes/web-analytics/WebAnalyticsDashboard.tsx b/frontend/src/scenes/web-analytics/WebAnalyticsDashboard.tsx
index 59ea58821130..239acb0f89e3 100644
--- a/frontend/src/scenes/web-analytics/WebAnalyticsDashboard.tsx
+++ b/frontend/src/scenes/web-analytics/WebAnalyticsDashboard.tsx
@@ -1,6 +1,6 @@
import clsx from 'clsx'
import { BindLogic, useActions, useMountedLogic, useValues } from 'kea'
-import React, { useEffect, useState } from 'react'
+import React, { Suspense, useEffect, useState } from 'react'
import { IconExpand45, IconInfo, IconLineGraph, IconOpenSidebar, IconX } from '@posthog/icons'
import { LemonSegmentedButton, LemonSegmentedDropdown, LemonSelect, LemonSkeleton } from '@posthog/lemon-ui'
@@ -23,6 +23,8 @@ import { Popover } from 'lib/lemon-ui/Popover'
import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { isNotNil } from 'lib/utils/guards'
import { addProductIntentForCrossSell } from 'lib/utils/product-intents'
+import { lazyWithRetry } from 'lib/utils/retryImport'
+import { ChunkLoadErrorBoundary } from 'scenes/ChunkLoadErrorBoundary'
import { Scene } from 'scenes/sceneTypes'
import { QuickSurveyType } from 'scenes/surveys/quick-create/types'
import { QuickSurveyModal } from 'scenes/surveys/QuickSurveyModal'
@@ -69,13 +71,17 @@ import { BotAnalyticsFilters } from './BotAnalyticsFilters'
import { botAnalyticsLogic } from './botAnalyticsLogic'
import { HealthStatusTab, webAnalyticsHealthLogic } from './health'
import { LiveBotTiles } from './LiveMetricsDashboard/LiveBotTiles'
-import { LiveWebAnalyticsMetrics } from './LiveMetricsDashboard/LiveWebAnalyticsMetrics'
import { PagePerformance } from './PagePerformance'
import { PagePerformanceFilters } from './PagePerformanceFilters'
import { WebAnalyticsExport } from './WebAnalyticsExport'
import { WebAnalyticsFilters } from './WebAnalyticsFilters'
import { webAnalyticsModalLogic } from './webAnalyticsModalLogic'
+// Only the live tab renders this dashboard, and its world map holds about 1 MiB of country shapes.
+const LiveWebAnalyticsMetrics = lazyWithRetry(() =>
+ import('./LiveMetricsDashboard/LiveWebAnalyticsMetrics').then((m) => ({ default: m.LiveWebAnalyticsMetrics }))
+)
+
export const Tiles = (props: { tiles?: WebAnalyticsTile[]; compact?: boolean }): JSX.Element => {
const { tiles: tilesFromProps, compact = false } = props
const { tiles: tilesFromLogic, productTab } = useValues(webAnalyticsLogic)
@@ -682,7 +688,13 @@ const MainContent = (): JSX.Element => {
}
if (productTab === ProductTab.LIVE) {
- return <LiveWebAnalyticsMetrics />
+ return (
+ <ChunkLoadErrorBoundary>
+ <Suspense fallback={<LemonSkeleton className="h-96 w-full" />}>
+ <LiveWebAnalyticsMetrics />
+ </Suspense>
+ </ChunkLoadErrorBoundary>
+ )
}
if (productTab === ProductTab.BOT_ANALYTICS) {