: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
fix(settings): stop the global settings scene handling embedded setting routes (#121946)
Hayne Ryuede56f08943e
diff --git a/frontend/src/layout/scenes/components/sceneSettingsUrl.ts b/frontend/src/layout/scenes/components/sceneSettingsUrl.tsindex 65cd309e5624..0e03da139f1e 100644--- a/frontend/src/layout/scenes/components/sceneSettingsUrl.ts+++ b/frontend/src/layout/scenes/components/sceneSettingsUrl.ts@@ -6,7 +6,6 @@ import { ProductKey } from '~/queries/schema/schema-general'const SETTINGS_SECTION_BY_PRODUCT: Partial<Record<ProductKey, SettingSectionId>> = {[ProductKey.PRODUCT_ANALYTICS]: 'environment-product-analytics',[ProductKey.WEB_ANALYTICS]: 'environment-web-analytics',- [ProductKey.SESSION_REPLAY]: 'environment-replay',[ProductKey.FEATURE_FLAGS]: 'environment-feature-flags',[ProductKey.EXPERIMENTS]: 'environment-experiments',[ProductKey.SURVEYS]: 'environment-surveys',diff --git a/frontend/src/scenes/settings/settingsLogic.ts b/frontend/src/scenes/settings/settingsLogic.tsindex 152cd048a87f..c38adb692800 100644--- a/frontend/src/scenes/settings/settingsLogic.ts+++ b/frontend/src/scenes/settings/settingsLogic.ts@@ -9,6 +9,7 @@ import { createFuse } from 'lib/utils/fuseSearch'import { billingLogic } from 'scenes/billing/billingLogic'import { organizationLogic } from 'scenes/organizationLogic'import { preflightLogic } from 'scenes/PreflightCheck/preflightLogic'+import type { Params } from 'scenes/sceneTypes'import { organizationIntegrationsLogic } from 'scenes/settings/organization/organizationIntegrationsLogic'import { teamLogic } from 'scenes/teamLogic'import { userLogic } from 'scenes/userLogic'@@ -807,7 +808,7 @@ export const settingsLogic = kea<settingsLogicType>([]},})),- urlToAction(({ actions, values }) => ({+ urlToAction(({ actions, values, props }) => ({// A section with a scene of its own has no section selection, so its route moves the pane to its tab....Object.fromEntries(SETTINGS_SECTION_SCENES.flatMap(({ level, url, legacyUrl }) =>@@ -816,6 +817,16 @@ export const settingsLogic = kea<settingsLogicType>([.map((root) => [`${root}(/*)`, () => actions.setNavLevel(level)]))),+ // The settings scene instance outlives a scene change, and its selectSetting pushes `/settings/...`.+ ...(props.logicKey === 'settingsScene' ? {} : embeddedSettingsRoutes(actions, values)),+ })),+])++function embeddedSettingsRoutes(+ actions: settingsLogicType['actions'],+ values: settingsLogicType['values']+): Record<string, (params: Params, searchParams: Params, hashParams: Params) => void> {+ return {['*/replay/settings']: (_, __, hashParams) => {const { selectedSetting } = hashParamsconst selectedSettingId = selectedSetting as SettingId@@ -841,5 +852,5 @@ export const settingsLogic = kea<settingsLogicType>([actions.selectSetting(selectedSettingId)}},- })),-])+ }+}diff --git a/frontend/src/scenes/settings/settingsSceneLogic.test.ts b/frontend/src/scenes/settings/settingsSceneLogic.test.tsindex 2e5f0ab10130..d0ec582b6475 100644--- a/frontend/src/scenes/settings/settingsSceneLogic.test.ts+++ b/frontend/src/scenes/settings/settingsSceneLogic.test.ts@@ -1,6 +1,8 @@import { router } from 'kea-router'import { expectLogic } from 'kea-test-utils'+import { removeProjectIdIfPresent } from 'lib/utils/kea-router'+import { initKeaTests } from '~/test/init'import { settingsSceneLogic } from './settingsSceneLogic'@@ -20,6 +22,19 @@ describe('settingsSceneLogic', () => {logic.mount()})+ it.each([+ ['/replay/settings', 'replay-log-capture'],+ ['/logs', 'logs-drop-rules'],+ ])('leaves %s alone when its embedded settings hash changes', async (pathname, setting) => {+ router.actions.push('/settings/project-replay')+ await expectLogic(logic).toMatchValues({ selectedSectionId: 'project-replay' })++ router.actions.push(pathname, {}, { selectedSetting: setting })+ await expectLogic(logic).delay(10)++ expect(removeProjectIdIfPresent(router.values.location.pathname)).toBe(pathname)+ })+it('reads filters from the URL', async () => {router.actions.push('/settings/project-product-analytics', {}, { 'person-display-name': true })