: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
import { useValues } from 'kea'
import { Link } from 'lib/lemon-ui/Link/Link'
import { DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator } from 'lib/ui/DropdownMenu/DropdownMenu'
import { projectTreeDataLogic } from '~/layout/panel-layout/ProjectTree/projectTreeDataLogic'
import { panelLayoutLogic } from '../../panelLayoutLogic'
import { CustomMenuProps } from '../types'
export function ProductAnalyticsMenuItems({ MenuItem = DropdownMenuItem, onLinkClick }: CustomMenuProps): JSX.Element {
const { treeItemsNew } = useValues(projectTreeDataLogic)
const { mainContentRef } = useValues(panelLayoutLogic)
return (
<>
<DropdownMenuLabel>Create new insight type</DropdownMenuLabel>
<DropdownMenuSeparator />
{treeItemsNew
.find(({ name }) => name === 'Insight')
?.children?.sort((a, b) => (a.visualOrder ?? 0) - (b.visualOrder ?? 0))
?.map((child) => (
<MenuItem
asChild
key={child.id}
onKeyDown={(e) => {
if (e.key === 'Enter' || e.key === ' ') {
// small delay to fight dropdown menu from taking focus
setTimeout(() => {
mainContentRef?.current?.focus()
onLinkClick?.(true)
}, 10)
}
}}
>
<Link
to={child.record?.href}
data-attr="tree-item-menu-new-insight"
buttonProps={{ menuItem: true }}
onClick={() => {
onLinkClick?.(false)
}}
>
{child.icon}
{child.name}
</Link>
</MenuItem>
))}
</>
)
}