: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(replay): load the settings snapshot without settingsLogic (#119083)
Paul D'Ambra62ecce861c68
diff --git a/frontend/bin/check-eager-graph.mjs b/frontend/bin/check-eager-graph.mjsindex 7c13fd602d49..64dba10615f8 100644--- a/frontend/bin/check-eager-graph.mjs+++ b/frontend/bin/check-eager-graph.mjs@@ -180,9 +180,13 @@ const ROOTS = [{root: 'src/scenes/session-recordings/detail/SessionRecordingDetail.tsx',label: 'replay detail scene',- // 2026-10-11: 11.70 MiB (4204 files), stable CSS included. ~30% headroom.- budgetBytes: 15_785_000,- forbidden: [],+ // 2026-10-17: 8.61 MiB (3264 files), stable CSS included. ~10% headroom.+ budgetBytes: 9_930_000,+ forbidden: [+ // The player shows a snapshot of a few settings. A hit means it imports settingsLogic again,+ // which holds every settings page.+ 'src/scenes/settings/SettingsMap.tsx',+ ],},]diff --git a/frontend/src/lib/components/SettingsSnapshot.tsx b/frontend/src/lib/components/SettingsSnapshot.tsxindex cfe83c861f7c..b555ac928119 100644--- a/frontend/src/lib/components/SettingsSnapshot.tsx+++ b/frontend/src/lib/components/SettingsSnapshot.tsx@@ -2,7 +2,8 @@ import { useActions, useValues } from 'kea'import { useEffect, useMemo } from 'react'import { LemonSkeleton } from 'lib/lemon-ui/LemonSkeleton'-import { settingsLogic } from 'scenes/settings/settingsLogic'++import { settingsSnapshotLogic } from './settingsSnapshotLogic'type Props = {at?: string@@ -19,8 +20,8 @@ export function SettingsSnapshot({showHeader = true,className,}: Props): JSX.Element | null {- const { loadSettingsAsOf } = useActions(settingsLogic)- const { settingsSnapshot, settingsSnapshotLoading } = useValues(settingsLogic)+ const { loadSettingsAsOf } = useActions(settingsSnapshotLogic)+ const { settingsSnapshot, settingsSnapshotLoading } = useValues(settingsSnapshotLogic)const scopeKey = useMemo(() => scope.join('|'), [scope])diff --git a/frontend/src/lib/components/settingsSnapshotLogic.ts b/frontend/src/lib/components/settingsSnapshotLogic.tsnew file mode 100644index 000000000000..e8a39eeede7a--- /dev/null+++ b/frontend/src/lib/components/settingsSnapshotLogic.ts@@ -0,0 +1,70 @@+import { MakeLogicType, actions, kea, path } from 'kea'+import { loaders } from 'kea-loaders'++import api from 'lib/api'+import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface settingsSnapshotLogicValues {+ settingsSnapshot: Record<string, any> | null+ settingsSnapshotLoading: boolean+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface settingsSnapshotLogicActions {+ loadSettingsAsOf: (+ at: string,+ scope?: string | string[]+ ) => {+ at: string+ scope: string | string[] | undefined+ }+ loadSettingsAsOfFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ loadSettingsAsOfSuccess: (+ settingsSnapshot: Record<string, any>,+ payload?: {+ at: string+ scope: string | string[] | undefined+ }+ ) => {+ settingsSnapshot: Record<string, any>+ payload?: {+ at: string+ scope: string | string[] | undefined+ }+ }+}++export type settingsSnapshotLogicType = MakeLogicType<settingsSnapshotLogicValues, settingsSnapshotLogicActions>++export const settingsSnapshotLogic = kea<settingsSnapshotLogicType>([+ path(['lib', 'components', 'settingsSnapshotLogic']),+ actions({+ loadSettingsAsOf: (at: string, scope?: string | string[]) => ({ at, scope }),+ }),+ loaders(() => ({+ settingsSnapshot: [+ null as Record<string, any> | null,+ {+ loadSettingsAsOf: async ({ at, scope }: { at: string; scope?: string | string[] }) => {+ const scopeArray = Array.isArray(scope)+ ? scope.filter((s): s is string => !!s)+ : scope+ ? [scope]+ : undefined+ if (!at) {+ lemonToast.warning('A timestamp is required to load settings at a point in time')+ return {}+ }+ return await api.teamSettings.asOf(at, scopeArray)+ },+ },+ ],+ })),+])diff --git a/frontend/src/scenes/settings/settingsLogic.ts b/frontend/src/scenes/settings/settingsLogic.tsindex 31100273aa4d..152cd048a87f 100644--- a/frontend/src/scenes/settings/settingsLogic.ts+++ b/frontend/src/scenes/settings/settingsLogic.ts@@ -1,12 +1,9 @@import FuseClass from 'fuse.js'import { MakeLogicType, actions, connect, kea, key, listeners, path, props, reducers, selectors } from 'kea'-import { loaders } from 'kea-loaders'import { actionToUrl, router, urlToAction } from 'kea-router'import posthog from 'posthog-js'-import api from 'lib/api'import { FEATURE_FLAGS } from 'lib/constants'-import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { createFuse } from 'lib/utils/fuseSearch'import { billingLogic } from 'scenes/billing/billingLogic'@@ -117,8 +114,6 @@ export interface settingsLogicValues {selectedSettingId: SettingId | nullsettings: Setting[]settingsFuse: SettingsFuse- settingsSnapshot: Record<string, any> | null- settingsSnapshotLoading: booleanunavailableSection: UnavailableSection | null}@@ -130,33 +125,6 @@ export interface settingsLogicActions {expandGroup: (group: string) => {group: string}- loadSettingsAsOf: (- at: string,- scope?: string | string[]- ) => {- at: string- scope: string | string[] | undefined- }- loadSettingsAsOfFailure: (- error: string,- errorObject?: any- ) => {- error: string- errorObject?: any- }- loadSettingsAsOfSuccess: (- settingsSnapshot: Record<string, any>,- payload?: {- at: string- scope: string | string[] | undefined- }- ) => {- settingsSnapshot: Record<string, any>- payload?: {- at: string- scope: string | string[] | undefined- }- }navigateToSetting: (sectionId: SettingSectionId,settingId: SettingId@@ -320,7 +288,6 @@ export const settingsLogic = kea<settingsLogicType>([toggleLevelCollapse: (level: SettingLevelId) => ({ level }),toggleGroupCollapse: (group: string) => ({ group }),expandGroup: (group: string) => ({ group }),- loadSettingsAsOf: (at: string, scope?: string | string[]) => ({ at, scope }),navigateToSetting: (sectionId: SettingSectionId, settingId: SettingId) => ({ sectionId, settingId }),}),@@ -411,26 +378,6 @@ export const settingsLogic = kea<settingsLogicType>([],})),- loaders(() => ({- settingsSnapshot: [- null as Record<string, any> | null,- {- loadSettingsAsOf: async ({ at, scope }: { at: string; scope?: string | string[] }) => {- const scopeArray = Array.isArray(scope)- ? scope.filter((s): s is string => !!s)- : scope- ? [scope]- : undefined- if (!at) {- lemonToast.warning('A timestamp is required to load settings at a point in time')- return {}- }- return await api.teamSettings.asOf(at, scopeArray)- },- },- ],- })),-listeners(({ actions, values }) => ({selectSection: ({ section, level }) => {// Expand the collapsible group containing the selected section so it's visible