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(replay): don't load recordings query on the collections tab (#63883)

Paul D'Ambra92eb6ec049fd
diff --git a/frontend/src/scenes/session-recordings/SessionRecordings.tsx b/frontend/src/scenes/session-recordings/SessionRecordings.tsx
index ce25332a0256..a86617264775 100644
--- a/frontend/src/scenes/session-recordings/SessionRecordings.tsx
+++ b/frontend/src/scenes/session-recordings/SessionRecordings.tsx
@@ -188,6 +188,18 @@ function Warnings(): JSX.Element {
)
}
+// Keeps the recordings logic mounted for the scene's lifetime so its state survives tab
+// switches. Rendered only on the Home tab so landing on Collections/Templates does not mount
+// it — which would otherwise fire a wasted loadSessionRecordings ClickHouse query on load.
+function AttachScenePlaylistLogic({
+ playlistLogicProps,
+}: {
+ playlistLogicProps: SessionRecordingPlaylistLogicProps
+}): null {
+ useAttachedLogic(sessionRecordingsPlaylistLogic(playlistLogicProps), sessionReplaySceneLogic())
+ return null
+}
+
function MainPanel(): JSX.Element {
const { tab } = useValues(sessionReplaySceneLogic)
const isRedesignEnabled = useFeatureFlag('REPLAY_UI_REDESIGN_2026', 'test')
@@ -197,8 +209,6 @@ function MainPanel(): JSX.Element {
updateSearchParams: true,
}
- useAttachedLogic(sessionRecordingsPlaylistLogic(playlistLogicProps), sessionReplaySceneLogic())
-
return (
<div className={cn('flex flex-col gap-y-4', ReplayTabs.Home === tab && 'grow')}>
<Warnings />
@@ -207,6 +217,7 @@ function MainPanel(): JSX.Element {
<Spinner />
) : tab === ReplayTabs.Home ? (
<div className="SessionRecordingPlaylistHeightWrapper grow">
+ <AttachScenePlaylistLogic playlistLogicProps={playlistLogicProps} />
{isRedesignEnabled ? (
<SessionRecordingsPlaylistRedesign {...playlistLogicProps} />
) : (