: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
chore(frontend): use WrappingLoadingSkeleton for Suspense fallbacks (#58118)
Paul D'Ambraf94cfc74b38d
diff --git a/frontend/src/exporter/Exporter.tsx b/frontend/src/exporter/Exporter.tsxindex ae5cde1786bf..89a737957d45 100644--- a/frontend/src/exporter/Exporter.tsx+++ b/frontend/src/exporter/Exporter.tsx@@ -10,6 +10,7 @@ import { useResizeObserver } from 'lib/hooks/useResizeObserver'import { useThemedHtml } from 'lib/hooks/useThemedHtml'import { LemonMarkdown } from 'lib/lemon-ui/LemonMarkdown'import { Link } from 'lib/lemon-ui/Link'+import { WrappingLoadingSkeleton } from 'lib/ui/WrappingLoadingSkeleton/WrappingLoadingSkeleton'import { humanFriendlyDuration } from 'lib/utils'import { AUTO_REFRESH_INITIAL_INTERVAL_SECONDS } from 'scenes/dashboard/dashboardConstants'import { teamLogic } from 'scenes/teamLogic'@@ -25,6 +26,14 @@ const LazyInsightScene = lazy(() => import('./scenes/ExporterInsightScene'))const LazyNotebookScene = lazy(() => import('./scenes/ExporterNotebookScene'))const LazyRecordingScene = lazy(() => import('./scenes/ExporterRecordingScene'))+function ExportedSceneSkeleton(): JSX.Element {+ return (+ <WrappingLoadingSkeleton fullWidth>+ <span className="block w-full h-screen" />+ </WrappingLoadingSkeleton>+ )+}+function resolveForcedTheme(theme?: 'light' | 'dark' | 'system'): 'light' | 'dark' | null {if (theme === 'light' || theme === 'dark') {return theme@@ -149,7 +158,7 @@ export function Exporter(props: ExportedData): JSX.Element {</div></div>)}- <Suspense fallback={null}>+ <Suspense fallback={<ExportedSceneSkeleton />}><LazyNotebookScenenotebook={notebook}insights={insights}@@ -158,15 +167,15 @@ export function Exporter(props: ExportedData): JSX.Element {</Suspense></div>) : insight ? (- <Suspense fallback={null}>+ <Suspense fallback={<ExportedSceneSkeleton />}><LazyInsightScene insight={insight} themes={themes!} exportOptions={exportOptions} /></Suspense>) : dashboard ? (- <Suspense fallback={null}>+ <Suspense fallback={<ExportedSceneSkeleton />}><LazyDashboardScene dashboard={dashboard} type={type} themes={themes} /></Suspense>) : recording ? (- <Suspense fallback={null}>+ <Suspense fallback={<ExportedSceneSkeleton />}><LazyRecordingScenerecording={recording}mode={props.mode}@@ -177,7 +186,7 @@ export function Exporter(props: ExportedData): JSX.Element {/></Suspense>) : type === ExportType.Heatmap ? (- <Suspense fallback={null}>+ <Suspense fallback={<ExportedSceneSkeleton />}><LazyHeatmapScene /></Suspense>) : (diff --git a/frontend/src/lib/components/HighlightedJSONViewer.tsx b/frontend/src/lib/components/HighlightedJSONViewer.tsxindex 18771cf6ef2d..790c8e82a5d8 100644--- a/frontend/src/lib/components/HighlightedJSONViewer.tsx+++ b/frontend/src/lib/components/HighlightedJSONViewer.tsx@@ -6,7 +6,7 @@ import {HighlightedContentWrapper,} from 'products/llm_analytics/frontend/ConversationDisplay/HighlightedContentWrapper'-import { JSONViewerInner } from './JSONViewer'+import { JSONViewerInner, JSONViewerSkeleton } from './JSONViewer'interface HighlightedJSONViewerProps extends ReactJsonViewProps {searchQuery?: string@@ -63,7 +63,7 @@ export function HighlightedJSONViewer({ searchQuery, ...props }: HighlightedJSON: props.collapsedreturn (- <Suspense fallback={null}>+ <Suspense fallback={<JSONViewerSkeleton />}><HighlightedContentWrapper searchQuery={searchQuery} expandSelectors={jsonExpandSelectors} delay={50}><JSONViewerInner {...props} collapsed={effectiveCollapsed} /></HighlightedContentWrapper>diff --git a/frontend/src/lib/components/JSONViewer.tsx b/frontend/src/lib/components/JSONViewer.tsxindex b6bb76f38244..ec160a797670 100644--- a/frontend/src/lib/components/JSONViewer.tsx+++ b/frontend/src/lib/components/JSONViewer.tsx@@ -4,6 +4,8 @@ import type { ReactJsonViewProps } from '@microlink/react-json-view'import { useValues } from 'kea'import { Suspense, lazy } from 'react'+import { WrappingLoadingSkeleton } from 'lib/ui/WrappingLoadingSkeleton/WrappingLoadingSkeleton'+import { themeLogic } from '~/layout/navigation-3000/themeLogic'const ReactJson = lazy(() => import('@microlink/react-json-view'))@@ -42,9 +44,22 @@ export function JSONViewerInner({)}+export function JSONViewerSkeleton(): JSX.Element {+ return (+ <WrappingLoadingSkeleton fullWidth>+ <span className="block font-mono text-xs leading-5">+ <span className="block">{'{'}</span>+ <span className="block pl-4">"loading": "json content",</span>+ <span className="block pl-4">"please": "wait"</span>+ <span className="block">{'}'}</span>+ </span>+ </WrappingLoadingSkeleton>+ )+}+export function JSONViewer(props: ReactJsonViewProps): JSX.Element {return (- <Suspense fallback={null}>+ <Suspense fallback={<JSONViewerSkeleton />}><JSONViewerInner {...props} /></Suspense>)diff --git a/frontend/src/scenes/trends/Trends.tsx b/frontend/src/scenes/trends/Trends.tsxindex 5737fbc896b2..e0ea2cd61801 100644--- a/frontend/src/scenes/trends/Trends.tsx+++ b/frontend/src/scenes/trends/Trends.tsx@@ -5,6 +5,7 @@ import { LemonButton } from '@posthog/lemon-ui'import { FEATURE_FLAGS } from 'lib/constants'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { WrappingLoadingSkeleton } from 'lib/ui/WrappingLoadingSkeleton/WrappingLoadingSkeleton'import { insightLogic } from 'scenes/insights/insightLogic'import { BoldNumber } from 'scenes/insights/views/BoldNumber'import { InsightsTable } from 'scenes/insights/views/InsightsTable/InsightsTable'@@ -124,7 +125,15 @@ export function TrendInsight({ view, context, embedded, inSharedMode, editMode }<>{series && (<div className={embedded ? 'InsightCard__viz' : `TrendsInsight TrendsInsight--${display}`}>- <Suspense fallback={null}>{renderViz()}</Suspense>+ <Suspense+ fallback={+ <WrappingLoadingSkeleton fullWidth>+ <span className="block w-full h-72" />+ </WrappingLoadingSkeleton>+ }+ >+ {renderViz()}+ </Suspense></div>)}{!embedded &&