: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(shortcuts): instrument keybind usage (#64590)
Fernando Gomes97ea95a35b07
diff --git a/frontend/src/lib/components/AppShortcuts/appShortcutLogic.tsx b/frontend/src/lib/components/AppShortcuts/appShortcutLogic.tsxindex 8b2650061d80..e80d20ed2e30 100644--- a/frontend/src/lib/components/AppShortcuts/appShortcutLogic.tsx+++ b/frontend/src/lib/components/AppShortcuts/appShortcutLogic.tsx@@ -1,5 +1,6 @@import { actions, afterMount, beforeUnmount, kea, path, reducers } from 'kea'+import posthog from 'lib/posthog-typed'import { isMac } from 'lib/utils/dom'import { Scene } from 'scenes/sceneTypes'@@ -58,7 +59,19 @@ function getSequenceKeys(keybind: string[]): string[] {return keybind.filter((key) => key !== 'then')}-function triggerShortcut(shortcut: AppShortcutType): void {+function formatKeybind(keybind: string[]): string {+ return isSequenceKeybind(keybind) ? getSequenceKeys(keybind).join(' then ') : keybind.join('+')+}++function triggerShortcut(shortcut: AppShortcutType, triggeredKeybind: string[]): void {+ posthog.capture('keybind triggered', {+ name: shortcut.name,+ intent: shortcut.intent,+ keybind: formatKeybind(triggeredKeybind),+ interaction: shortcut.interaction,+ scope: shortcut.scope ?? 'global',+ })+if (shortcut.interaction === 'click') {shortcut.ref.current?.click()} else if (shortcut.interaction === 'focus') {@@ -173,7 +186,7 @@ export const appShortcutLogic = kea<appShortcutLogicType>([if (matchingShortcut && !values.disabledShortcutNames.includes(matchingShortcut.name)) {event.preventDefault()event.stopPropagation()- triggerShortcut(matchingShortcut)+ triggerShortcut(matchingShortcut, pressedKeys)}return}@@ -200,7 +213,7 @@ export const appShortcutLogic = kea<appShortcutLogicType>([event.stopPropagation()cache.sequenceKeys = []cache.sequenceShortcut = null- triggerShortcut(singleKeyMatch)+ triggerShortcut(singleKeyMatch, [key])return}@@ -241,7 +254,7 @@ export const appShortcutLogic = kea<appShortcutLogicType>([cache.sequenceShortcut = nullif (!values.disabledShortcutNames.includes(matchingShortcut.name)) {event.preventDefault()- triggerShortcut(matchingShortcut)+ triggerShortcut(matchingShortcut, keybind)}} else {// Partial match - keep tracking