: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
perf(conversations): load the support tab unread count after the shell renders (#127270)
Paul D'Ambra8317484fcbde
diff --git a/frontend/bin/check-eager-graph.mjs b/frontend/bin/check-eager-graph.mjsindex 9b8fd1830221..52ef06d7330f 100644--- a/frontend/bin/check-eager-graph.mjs+++ b/frontend/bin/check-eager-graph.mjs@@ -150,6 +150,9 @@ const ROOTS = ['products/subscriptions/frontend/components/Subscriptions/exportNudge/exportNudgeLogic.ts',// The pay gate loads the payment logic on click. It pulls in the billing product logic.'src/scenes/billing/paymentEntryLogic.ts',+ // The support tab icon loads after the shell renders. Its ticket logic pulls in zod.+ 'products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts',+ 'node_modules/zod/',// The login scene's logics. Shell code reads the login redirect from lib/utils/loginRedirect.'src/scenes/authentication/auth/loginLogic.ts','src/scenes/authentication/shared/passkeyLogic.ts',diff --git a/frontend/bin/layer-baseline.txt b/frontend/bin/layer-baseline.txtindex 69fa281033bb..79543cdfc792 100644--- a/frontend/bin/layer-baseline.txt+++ b/frontend/bin/layer-baseline.txt@@ -12,7 +12,6 @@ frontend/src/layout/navigation-3000/sidepanel/panels/activity/sidePanelNotificatfrontend/src/layout/navigation-3000/sidepanel/panels/max/SidePanelMax.tsx -> frontend/src/scenes/max/maxLogic.tsxfrontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsx -> products/conversations/frontend/components/SidePanel/SidePanelTickets.tsxfrontend/src/layout/navigation-3000/sidepanel/panels/support/SidePanelSupport.tsx -> products/conversations/frontend/components/SidePanel/sidepanelTicketsLogic.ts-frontend/src/layout/navigation-3000/sidepanel/sidePanelTabs.tsx -> products/conversations/frontend/components/SidePanel/SidePanelSupportIcon.tsxfrontend/src/layout/navigation/projectNoticeLogic.tsx -> frontend/src/scenes/activity/live/liveEventsLogic.tsxfrontend/src/layout/navigation/projectNoticeLogic.tsx -> frontend/src/scenes/authentication/verify-email/verifyEmailLogic.tsfrontend/src/layout/navigation/projectNoticeLogic.tsx -> frontend/src/scenes/insights/EmptyStates/sampleDataStateLogic.tsdiff --git a/frontend/src/layout/navigation-3000/sidepanel/panels/support/LazySidePanelSupportIcon.test.tsx b/frontend/src/layout/navigation-3000/sidepanel/panels/support/LazySidePanelSupportIcon.test.tsxnew file mode 100644index 000000000000..24a8264b226d--- /dev/null+++ b/frontend/src/layout/navigation-3000/sidepanel/panels/support/LazySidePanelSupportIcon.test.tsx@@ -0,0 +1,23 @@+import { render, waitFor } from '@testing-library/react'++import { LazySidePanelSupportIcon } from './LazySidePanelSupportIcon'++jest.mock('products/conversations/frontend/components/SidePanel/SidePanelSupportIcon', () => ({+ SidePanelSupportIcon: () => {+ const error = new Error('Loading chunk SidePanelSupportIcon failed')+ error.name = 'ChunkLoadError'+ throw error+ },+}))++describe('LazySidePanelSupportIcon', () => {+ it('shows the plain support icon when the badge chunk fails', async () => {+ const consoleError = jest.spyOn(console, 'error').mockImplementation(() => {})++ const { container } = render(<LazySidePanelSupportIcon className="test-icon" />)++ // The Suspense fallback looks the same, so wait until the boundary has caught the failure.+ await waitFor(() => expect(consoleError).toHaveBeenCalled())+ expect(container.querySelector('span.test-icon svg')).not.toBeNull()+ })+})diff --git a/frontend/src/layout/navigation-3000/sidepanel/panels/support/LazySidePanelSupportIcon.tsx b/frontend/src/layout/navigation-3000/sidepanel/panels/support/LazySidePanelSupportIcon.tsxnew file mode 100644index 000000000000..eaba20c1f9d6--- /dev/null+++ b/frontend/src/layout/navigation-3000/sidepanel/panels/support/LazySidePanelSupportIcon.tsx@@ -0,0 +1,31 @@+import clsx from 'clsx'+import { Suspense } from 'react'++import { IconSupport } from '@posthog/icons'+import { PostHogErrorBoundary } from '@posthog/react'++import { lazyWithRetry } from 'lib/utils/retryImport'++// The unread count comes from the support ticket logic, which holds the whole ticket flow.+const SidePanelSupportIcon = lazyWithRetry(() =>+ import('products/conversations/frontend/components/SidePanel/SidePanelSupportIcon').then((m) => ({+ default: m.SidePanelSupportIcon,+ }))+)++/** The support tab icon. It shows the unread count when its chunk has loaded. */+export function LazySidePanelSupportIcon({ className }: { className?: string }): JSX.Element {+ const plainIcon = (+ <span className={clsx('relative inline-flex', className)}>+ <IconSupport />+ </span>+ )+ // Not ChunkLoadErrorBoundary: a missing unread badge does not justify reloading the page.+ return (+ <PostHogErrorBoundary fallback={plainIcon}>+ <Suspense fallback={plainIcon}>+ <SidePanelSupportIcon className={className} />+ </Suspense>+ </PostHogErrorBoundary>+ )+}diff --git a/frontend/src/layout/navigation-3000/sidepanel/sidePanelTabs.tsx b/frontend/src/layout/navigation-3000/sidepanel/sidePanelTabs.tsxindex ddb96cc0e540..a81038e52d17 100644--- a/frontend/src/layout/navigation-3000/sidepanel/sidePanelTabs.tsx+++ b/frontend/src/layout/navigation-3000/sidepanel/sidePanelTabs.tsx@@ -4,12 +4,11 @@ import { lazyWithRetry } from 'lib/utils/retryImport'import { SidePanelTab } from '~/types'-import { SidePanelSupportIcon } from 'products/conversations/frontend/components/SidePanel/SidePanelSupportIcon'-import { SidePanelActivityIcon } from './panels/activity/SidePanelActivityIcon'import { SidePanelDiscussionIcon } from './panels/discussion/SidePanelDiscussionIcon'import { SidePanelExportsIcon } from './panels/exports/SidePanelExportsIcon'import { SidePanelInfo, SidePanelInfoIcon } from './panels/info/SidePanelInfo'+import { LazySidePanelSupportIcon } from './panels/support/LazySidePanelSupportIcon'const SidePanelMax = lazyWithRetry(() => import('./panels/max/SidePanelMax').then((m) => ({ default: m.SidePanelMax })))const NotebookPanel = lazyWithRetry(() =>@@ -52,7 +51,7 @@ export const SIDE_PANEL_TABS: Record<SidePanelTab, { label: string; Icon: any; C},[SidePanelTab.Support]: {label: 'Support',- Icon: SidePanelSupportIcon,+ Icon: LazySidePanelSupportIcon,Content: SidePanelSupport,},[SidePanelTab.Exports]: {