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.

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.tsx
index 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.tsx
index 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 mode
diff --git a/frontend/src/layout/navigation-3000/navigationLogic.tsx b/frontend/src/layout/navigation-3000/navigationLogic.tsx
index 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 = 192
const DEFAULT_SIDEBAR_WIDTH_PX: number = 288
const 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 disable
if (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.tsx
index 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
<ButtonPrimitive
tooltip="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.tsx
index 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 />