: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
feat(navigation): instrument zen mode enter/exit events (#68270)
Paul D'Ambra6fc9affd86f2
diff --git a/frontend/src/layout/GlobalShortcuts.tsx b/frontend/src/layout/GlobalShortcuts.tsxindex af30f0424782..d9a6ac58412d 100644--- a/frontend/src/layout/GlobalShortcuts.tsx+++ b/frontend/src/layout/GlobalShortcuts.tsx@@ -79,7 +79,7 @@ export function GlobalShortcuts(): null {keybind: [keyBinds.zenMode],intent: 'Toggle zen mode',interaction: 'function',- callback: toggleZenMode,+ callback: () => toggleZenMode('shortcut'),})useShortcut({diff --git a/frontend/src/layout/navigation-3000/components/ZenModeButton.tsx b/frontend/src/layout/navigation-3000/components/ZenModeButton.tsxindex 5dbb8cf5cc0f..ef5ea65e275a 100644--- a/frontend/src/layout/navigation-3000/components/ZenModeButton.tsx+++ b/frontend/src/layout/navigation-3000/components/ZenModeButton.tsx@@ -18,7 +18,7 @@ export function ZenModeButton(): JSX.Element | null {type="secondary"size="small"icon={<IconX />}- onClick={() => setZenMode(false)}+ onClick={() => setZenMode(false, 'exit_button')}tooltip="Exit zen mode">Exit zen modediff --git a/frontend/src/layout/navigation-3000/navigationLogic.tsx b/frontend/src/layout/navigation-3000/navigationLogic.tsxindex 4c845e011ef8..c068e7b30cc3 100644--- a/frontend/src/layout/navigation-3000/navigationLogic.tsx+++ b/frontend/src/layout/navigation-3000/navigationLogic.tsx@@ -57,6 +57,8 @@ export const ITEM_KEY_PART_SEPARATOR = '::'export type Navigation3000Mode = 'none' | 'minimal' | 'zen' | 'full'+export type ZenModeTrigger = 'shortcut' | 'account_menu' | 'help_menu' | 'exit_button' | 'url'+const MINIMUM_SIDEBAR_WIDTH_PX: number = 192const DEFAULT_SIDEBAR_WIDTH_PX: number = 288const MAXIMUM_SIDEBAR_WIDTH_PX: number = 1024@@ -107,8 +109,8 @@ export const navigation3000Logic = kea<navigation3000LogicType>([focusPreviousItem: true,toggleAccordion: (key: string) => ({ key }),toggleListItemAccordion: (key: string) => ({ key }),- setZenMode: (zenMode: boolean) => ({ zenMode }),- toggleZenMode: true,+ setZenMode: (zenMode: boolean, trigger: ZenModeTrigger) => ({ zenMode, trigger }),+ toggleZenMode: (trigger: ZenModeTrigger) => ({ trigger }),}),reducers({isSidebarShown: [@@ -240,11 +242,16 @@ export const navigation3000Logic = kea<navigation3000LogicType>([{ persist: true },{setZenMode: (_, { zenMode }) => zenMode,- toggleZenMode: (state) => !state,},],}),listeners(({ actions, values }) => ({+ setZenMode: ({ zenMode, trigger }) => {+ posthog.capture('zen mode toggled', { enabled: zenMode, trigger })+ },+ toggleZenMode: ({ trigger }) => {+ actions.setZenMode(!values.zenMode, trigger)+ },initiateNewItemInCategory: ({ category: categoryKey }) => {let category = values.activeNavbarItem?.logic.values.contents?.find((item) => item.key === categoryKey)if (!category) {@@ -820,7 +827,7 @@ export const navigation3000Logic = kea<navigation3000LogicType>([// Enable zen mode when URL parameter is present (e.g., ?zen or ?zen=true)// Only enable, never disable from URL - user can manually disableif (zenModeFromUrl && !values.zenMode) {- actions.setZenMode(true)+ actions.setZenMode(true, 'url')}},})),diff --git a/frontend/src/lib/components/Account/AccountMenu.tsx b/frontend/src/lib/components/Account/AccountMenu.tsxindex ae5603909dfb..ad59212ef0ff 100644--- a/frontend/src/lib/components/Account/AccountMenu.tsx+++ b/frontend/src/lib/components/Account/AccountMenu.tsx@@ -315,7 +315,7 @@ export function AccountMenu({ trigger, ...props }: AccountMenuProps): JSX.Elemen<ButtonPrimitivetooltip="Hide navigation and focus on content"tooltipPlacement="right"- onClick={toggleZenMode}+ onClick={() => toggleZenMode('account_menu')}menuItem><IconExpand45 />diff --git a/frontend/src/lib/components/HelpMenu/HelpMenu.tsx b/frontend/src/lib/components/HelpMenu/HelpMenu.tsxindex ac93ce971e07..ce96a0eb5cc9 100644--- a/frontend/src/lib/components/HelpMenu/HelpMenu.tsx+++ b/frontend/src/lib/components/HelpMenu/HelpMenu.tsx@@ -385,7 +385,7 @@ export function HelpMenu({ iconOnly = false }: { iconOnly?: boolean }): JSX.Elem}/><Menu.Item- onClick={toggleZenMode}+ onClick={() => toggleZenMode('help_menu')}render={<ButtonPrimitive menuItem data-attr="more-menu-zen-mode-button"><IconExpand45 />