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(frontend): lazy-load WebVitals query nodes, fix taxonomy duplicate import (#58650)

Paul D'Ambra97423ac640a2
diff --git a/frontend/src/queries/Query/Query.tsx b/frontend/src/queries/Query/Query.tsx
index 24442a4f8e75..f6e953699f63 100644
--- a/frontend/src/queries/Query/Query.tsx
+++ b/frontend/src/queries/Query/Query.tsx
@@ -1,7 +1,8 @@
import { BuiltLogic, LogicWrapper } from 'kea'
-import { useEffect, useState } from 'react'
+import { Suspense, lazy, useEffect, useState } from 'react'
import { LemonDivider } from 'lib/lemon-ui/LemonDivider'
+import { Spinner } from 'lib/lemon-ui/Spinner'
import { HogDebug } from 'scenes/debug/HogDebug'
import { MarketingAnalyticsOverview } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/components/MarketingAnalyticsOverview/MarketingAnalyticsOverview'
@@ -10,7 +11,6 @@ import { DataNode } from '~/queries/nodes/DataNode/DataNode'
import { DataTable } from '~/queries/nodes/DataTable/DataTable'
import { InsightViz, insightVizDataNodeKey } from '~/queries/nodes/InsightViz/InsightViz'
import { WebOverview } from '~/queries/nodes/WebOverview/WebOverview'
-import { WebVitals } from '~/queries/nodes/WebVitals/WebVitals'
import { QueryEditor } from '~/queries/QueryEditor/QueryEditor'
import {
AnyResponseType,
@@ -34,7 +34,6 @@ import {
import { DataTableVisualization } from '../nodes/DataVisualization/DataVisualization'
import { SavedInsight } from '../nodes/SavedInsight/SavedInsight'
-import { WebVitalsPathBreakdown } from '../nodes/WebVitals/WebVitalsPathBreakdown'
import {
isDataTableNode,
isDataVisualizationNode,
@@ -54,6 +53,11 @@ import {
isWebVitalsQuery,
} from '../utils'
+const WebVitals = lazy(() => import('~/queries/nodes/WebVitals/WebVitals').then((m) => ({ default: m.WebVitals })))
+const WebVitalsPathBreakdown = lazy(() =>
+ import('../nodes/WebVitals/WebVitalsPathBreakdown').then((m) => ({ default: m.WebVitalsPathBreakdown }))
+)
+
export interface QueryProps<Q extends Node> {
/** An optional key to identify the query */
uniqueKey?: string | number
@@ -268,21 +272,25 @@ export function Query<Q extends Node>(props: QueryProps<Q>): JSX.Element | null
)
} else if (isWebVitalsQuery(query)) {
component = (
- <WebVitals
- attachTo={props.attachTo}
- query={query}
- cachedResults={props.cachedResults}
- context={queryContext}
- />
+ <Suspense fallback={<Spinner />}>
+ <WebVitals
+ attachTo={props.attachTo}
+ query={query}
+ cachedResults={props.cachedResults}
+ context={queryContext}
+ />
+ </Suspense>
)
} else if (isWebVitalsPathBreakdownQuery(query)) {
component = (
- <WebVitalsPathBreakdown
- attachTo={props.attachTo}
- query={query}
- cachedResults={props.cachedResults}
- context={queryContext}
- />
+ <Suspense fallback={<Spinner />}>
+ <WebVitalsPathBreakdown
+ attachTo={props.attachTo}
+ query={query}
+ cachedResults={props.cachedResults}
+ context={queryContext}
+ />
+ </Suspense>
)
} else if (isHogQuery(query)) {
component = (
diff --git a/frontend/src/taxonomy/taxonomy.tsx b/frontend/src/taxonomy/taxonomy.tsx
index 25c7f7b75c47..e9ba72b87280 100644
--- a/frontend/src/taxonomy/taxonomy.tsx
+++ b/frontend/src/taxonomy/taxonomy.tsx
@@ -6,7 +6,7 @@ import {
import { CoreFilterDefinition } from '~/types'
-import * as coreFilterDefinitionsByGroup from './core-filter-definitions-by-group.json'
+import coreFilterDefinitionsByGroup from './core-filter-definitions-by-group.json'
import { transformFilterDefinitions } from './transformations'
export type CoreFilterDefinitionsGroup = Exclude<keyof typeof coreFilterDefinitionsByGroup, '//'>