: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): add explainer cards to pinned and analytics nav rows (#123571)
ruby childsd0becaad96cd
diff --git a/frontend/src/layout/panel-layout/sidebarProductMeta.ts b/frontend/src/layout/panel-layout/sidebarProductMeta.tsindex 405a0d74f426..b479df91c4c9 100644--- a/frontend/src/layout/panel-layout/sidebarProductMeta.ts+++ b/frontend/src/layout/panel-layout/sidebarProductMeta.ts@@ -31,7 +31,7 @@ const descriptions: Record<string, string> = {'LLM analytics':'Follow your AI application from prompts to responses. Inspect traces, latency, token usage, and cost to understand quality and performance.',Persons:- 'Explore the people behind your events, including their properties and activity. Connect an individual experience with the patterns in your analytics.',+ 'Explore the people and groups behind your events, including their properties and activity. Connect an individual experience with the patterns in your analytics.',Cohorts:'Group people by what they do and who they are. Reuse those audiences in analysis, feature targeting, and experiments.','SQL variables':@@ -151,6 +151,12 @@ const examples: Record<string, string> = {'Warehouse properties': 'Add account attributes from a warehouse table to your groups.',}+// Pinned pages that have no scene config of their own to carry a docs link.+const docsHrefs: Record<string, string> = {+ Activity: 'https://posthog.com/docs/data/events',+ Persons: 'https://posthog.com/docs/data/persons',+}+export interface SidebarProductMeta {example?: stringdescription?: string@@ -170,6 +176,6 @@ export function sidebarProductMeta(product: FileSystemImport): SidebarProductMet? 'Explore the organizations, accounts, or other groups behind your events. Understand usage at the group level.': (descriptions[product.path] ?? sceneConfig?.description),example: isGroup ? 'Compare activity across customer accounts.' : examples[product.path],- docsHref: sceneConfig?.docsHref,+ docsHref: sceneConfig?.docsHref ?? docsHrefs[product.path],}}diff --git a/frontend/src/layout/today/TodayAnalyticsSidebar.tsx b/frontend/src/layout/today/TodayAnalyticsSidebar.tsxindex 80b186b1592c..9e3aa1c37774 100644--- a/frontend/src/layout/today/TodayAnalyticsSidebar.tsx+++ b/frontend/src/layout/today/TodayAnalyticsSidebar.tsx@@ -1,5 +1,6 @@import { useActions, useValues } from 'kea'import { router } from 'kea-router'+import { Fragment, useMemo } from 'react'import { IconBell, IconBox, IconList, IconNotification, IconPerson, IconPinFilled } from '@posthog/icons'import { Button, Tooltip, TooltipContent, TooltipTrigger } from '@posthog/quill'@@ -20,6 +21,51 @@ import { TodayAnalyticsSection, todayAnalyticsLogic } from './todayAnalyticsLogiimport { TodayPaneRow } from './TodayPaneRow'import { TodayPaneSearchList } from './TodayPaneSearchList'import { TodayPaneSection } from './TodayPaneSection'+import { TodayExplainerPreview, productPreview } from './todayPreviewCards'+import { TodayPreviewTrigger } from './TodayPreviewTrigger'++// Module constants, so the shared hover card gets the same payload on every render.+const EXPLAINERS = {+ all: {+ kind: 'explainer',+ label: 'View all',+ icon: <IconList />,+ description:+ 'Browse every canvas, dashboard, notebook, and insight your project shares. Filter by type, creator, or collection.',+ example: 'Find the retention dashboard a teammate made last month.',+ },+ mine: {+ kind: 'explainer',+ label: 'My work',+ icon: <IconPerson />,+ description: 'See everything you created, including work you have not shared with your project yet.',+ example: 'Pick up a draft insight you started yesterday.',+ },+ collections: {+ kind: 'explainer',+ label: 'Collections',+ icon: <IconBox />,+ description:+ 'Keep related analytics together where your team can find it. Pin a collection to show it in this sidebar.',+ example: 'Keep all the growth team’s dashboards and insights in one collection.',+ },+ alerts: {+ kind: 'explainer',+ label: 'Alerts',+ icon: <IconBell />,+ description: 'Watch the metrics in your insights and get a notification when a value crosses a threshold.',+ example: 'Get an email when daily signups drop below 100.',+ docsHref: 'https://posthog.com/docs/alerts',+ },+ subscriptions: {+ kind: 'explainer',+ label: 'Subscriptions',+ icon: <IconNotification />,+ description:+ 'Get insights and dashboards delivered on a schedule by email or Slack. Manage the subscriptions you have set up.',+ example: 'Send the weekly activation dashboard to your team every Monday.',+ },+} satisfies Record<string, TodayExplainerPreview>/** The Analytics sub-nav: the ways to browse, pinned collections, recently viewed items, PostHog's own analytics, and what to keep an eye on. */export function TodayAnalyticsSidebar(): JSX.Element {@@ -35,6 +81,10 @@ export function TodayAnalyticsSidebar(): JSX.Element {? analyticsListFiltersFromUrl(searchParams): nullconst openFolder = path === urls.analyticsList() ? (listFilters?.folder ?? null) : null+ const fromPostHogPreviews = useMemo(+ () => new Map(fromPostHog.map((product) => [product.key, productPreview(product.label, product.item)])),+ [fromPostHog]+ )return (<div className="TodayPane group/colorful-product-icons colorful-product-icons-true" data-quill>@@ -54,30 +104,36 @@ export function TodayAnalyticsSidebar(): JSX.Element {onToggle={() => toggleSection('browse')}dataAttr="analytics-section-browse">- <TodayPaneRow- value="browse:all"- label="View all"- icon={<IconList />}- to={urls.analyticsList()}- active={path === urls.analyticsList() && openFolder === null}- dataAttr="analytics-sidebar-browse"- />- <TodayPaneRow- value="browse:mine"- label="My work"- icon={<IconPerson />}- to={urls.analyticsMine()}- active={path === urls.analyticsMine()}- dataAttr="analytics-sidebar-browse"- />- <TodayPaneRow- value="browse:spaces"- label="Collections"- icon={<IconBox />}- to={urls.analyticsSpaces()}- active={path === urls.analyticsSpaces()}- dataAttr="analytics-sidebar-browse"- />+ <TodayPreviewTrigger payload={EXPLAINERS.all}>+ <TodayPaneRow+ value="browse:all"+ label="View all"+ icon={<IconList />}+ to={urls.analyticsList()}+ active={path === urls.analyticsList() && openFolder === null}+ dataAttr="analytics-sidebar-browse"+ />+ </TodayPreviewTrigger>+ <TodayPreviewTrigger payload={EXPLAINERS.mine}>+ <TodayPaneRow+ value="browse:mine"+ label="My work"+ icon={<IconPerson />}+ to={urls.analyticsMine()}+ active={path === urls.analyticsMine()}+ dataAttr="analytics-sidebar-browse"+ />+ </TodayPreviewTrigger>+ <TodayPreviewTrigger payload={EXPLAINERS.collections}>+ <TodayPaneRow+ value="browse:spaces"+ label="Collections"+ icon={<IconBox />}+ to={urls.analyticsSpaces()}+ active={path === urls.analyticsSpaces()}+ dataAttr="analytics-sidebar-browse"+ />+ </TodayPreviewTrigger>{pinnedSpaces.map((space) => (<TodayPaneRowkey={space.path}@@ -150,9 +206,8 @@ export function TodayAnalyticsSidebar(): JSX.Element {>{fromPostHog.map((product) => {const productPath = product.href.split(/[?#]/)[0]- return (+ const row = (<TodayPaneRow- key={product.key}value={`by-posthog:${product.key}`}label={product.label}icon={iconForType(@@ -164,6 +219,14 @@ export function TodayAnalyticsSidebar(): JSX.Element {dataAttr="analytics-sidebar-by-posthog"/>)+ const preview = fromPostHogPreviews.get(product.key)+ return preview?.description ? (+ <TodayPreviewTrigger key={product.key} payload={preview}>+ {row}+ </TodayPreviewTrigger>+ ) : (+ <Fragment key={product.key}>{row}</Fragment>+ )})}</TodayPaneSection>)}@@ -176,22 +239,26 @@ export function TodayAnalyticsSidebar(): JSX.Element {dividerdataAttr="analytics-section-monitor">- <TodayPaneRow- value="monitor:alerts"- label="Alerts"- icon={<IconBell />}- to={urls.alerts()}- active={path === urls.alerts()}- dataAttr="analytics-sidebar-monitor"- />- <TodayPaneRow- value="monitor:subscriptions"- label="Subscriptions"- icon={<IconNotification />}- to={`${urls.subscriptions()}?tab=mine`}- active={path === urls.subscriptions()}- dataAttr="analytics-sidebar-monitor"- />+ <TodayPreviewTrigger payload={EXPLAINERS.alerts}>+ <TodayPaneRow+ value="monitor:alerts"+ label="Alerts"+ icon={<IconBell />}+ to={urls.alerts()}+ active={path === urls.alerts()}+ dataAttr="analytics-sidebar-monitor"+ />+ </TodayPreviewTrigger>+ <TodayPreviewTrigger payload={EXPLAINERS.subscriptions}>+ <TodayPaneRow+ value="monitor:subscriptions"+ label="Subscriptions"+ icon={<IconNotification />}+ to={`${urls.subscriptions()}?tab=mine`}+ active={path === urls.subscriptions()}+ dataAttr="analytics-sidebar-monitor"+ />+ </TodayPreviewTrigger></TodayPaneSection></TodayPaneSearchList></div>diff --git a/frontend/src/layout/today/TodayPreviewCardProvider.tsx b/frontend/src/layout/today/TodayPreviewCardProvider.tsxindex d36dad6176a5..25d72e91e95e 100644--- a/frontend/src/layout/today/TodayPreviewCardProvider.tsx+++ b/frontend/src/layout/today/TodayPreviewCardProvider.tsx@@ -93,7 +93,7 @@ export function TodayPreviewCardProvider({<TodayChatHoverCard preview={payload} onAction={close} />) : payload.kind === 'object' ? (<TodayObjectHoverCard preview={payload} onAction={close} />- ) : payload.kind === 'product' ? (+ ) : payload.kind === 'product' || payload.kind === 'explainer' ? (<TodayProductHoverCard preview={payload} onAction={close} />) : (<TodaySessionHoverCard preview={payload} onAction={close} />diff --git a/frontend/src/layout/today/TodayProductHoverCard.tsx b/frontend/src/layout/today/TodayProductHoverCard.tsxindex 27a5561a5832..2087b0d1b797 100644--- a/frontend/src/layout/today/TodayProductHoverCard.tsx+++ b/frontend/src/layout/today/TodayProductHoverCard.tsx@@ -5,13 +5,13 @@ import { LinkPrimitive } from 'lib/lemon-ui/Link'import { NavProductIcon } from '~/layout/panel-layout/navbar/tabs/NavProductIcon'-import { TodayProductPreview } from './todayPreviewCards'+import { TodayExplainerPreview, TodayProductPreview } from './todayPreviewCards'export function TodayProductHoverCard({preview,onAction,}: {- preview: TodayProductPreview+ preview: TodayProductPreview | TodayExplainerPreviewonAction: () => void}): JSX.Element {return (@@ -23,7 +23,7 @@ export function TodayProductHoverCard({className="flex size-4 shrink-0 items-center justify-center group/colorful-product-icons colorful-product-icons-true [&_svg]:size-4"aria-hidden>- <NavProductIcon item={preview.product} />+ {preview.kind === 'product' ? <NavProductIcon item={preview.product} /> : preview.icon}</span><span className="min-w-0 flex-1 font-semibold">{preview.label}</span></ItemTitle>diff --git a/frontend/src/layout/today/TodayProductsSidebar.tsx b/frontend/src/layout/today/TodayProductsSidebar.tsxindex ab5bce6d73af..dae376d88773 100644--- a/frontend/src/layout/today/TodayProductsSidebar.tsx+++ b/frontend/src/layout/today/TodayProductsSidebar.tsx@@ -1,4 +1,5 @@import { useActions, useValues } from 'kea'+import { Fragment, useMemo } from 'react'import { Text } from '@posthog/quill'@@ -11,6 +12,8 @@ import { TodayPaneRow } from './TodayPaneRow'import { analyticsTypesForPaneSearch } from './todayPaneSearch'import { TodayPaneSearchList } from './TodayPaneSearchList'import { TodayPaneSection } from './TodayPaneSection'+import { productPreview } from './todayPreviewCards'+import { TodayPreviewTrigger } from './TodayPreviewTrigger'import { TodayProductRow } from './TodayProductRow'import { TodayProductsAnalyticsHint } from './TodayProductsAnalyticsHint'import { todayProductsLogic } from './todayProductsLogic'@@ -31,6 +34,11 @@ export function TodayProductsSidebar(): JSX.Element {const searching = !!search.trim()const searchedAnalyticsTypes = analyticsTypesForPaneSearch(search)const hasProducts = pinnedProducts.length > 0 || starredProducts.length > 0 || productCount > 0+ // The shared card stores the payload, so it must keep its identity between renders.+ const pinnedPreviews = useMemo(+ () => new Map(pinnedProducts.map((item) => [item.href, productPreview(productsItemName(item), item)])),+ [pinnedProducts]+ )// A product can show in Starred and in its category, so the group keeps the rows apart on the keyboard path.const renderProduct = (item: FileSystemImport, group: string): JSX.Element => (@@ -64,17 +72,26 @@ export function TodayProductsSidebar(): JSX.Element {))}{pinnedProducts.length > 0 && (<div className="flex flex-col gap-px pb-2">- {pinnedProducts.map((item) => (- <TodayPaneRow- key={item.href}- value={`pinned:${item.href}`}- label={productsItemName(item)}- icon={<NavProductIcon item={item} />}- to={item.href ?? ''}- active={item.href === activeHref}- dataAttr="today-tool-pinned"- />- ))}+ {pinnedProducts.map((item) => {+ const row = (+ <TodayPaneRow+ value={`pinned:${item.href}`}+ label={productsItemName(item)}+ icon={<NavProductIcon item={item} />}+ to={item.href ?? ''}+ active={item.href === activeHref}+ dataAttr="today-tool-pinned"+ />+ )+ const preview = pinnedPreviews.get(item.href)+ return preview?.description ? (+ <TodayPreviewTrigger key={item.href} payload={preview}>+ {row}+ </TodayPreviewTrigger>+ ) : (+ <Fragment key={item.href}>{row}</Fragment>+ )+ })}</div>)}{starredProducts.length > 0 && (diff --git a/frontend/src/layout/today/TodayShell.tsx b/frontend/src/layout/today/TodayShell.tsxindex 11f37057cdcb..423c5954af45 100644--- a/frontend/src/layout/today/TodayShell.tsx+++ b/frontend/src/layout/today/TodayShell.tsx@@ -16,6 +16,7 @@ import { lazyWithRetry } from 'lib/utils/retryImport'import { QuillSceneHeader } from '~/layout/scenes/components/QuillSceneHeader'import { TodayPhoneHeader } from './TodayPhoneHeader'+import { TodayPreviewCardProvider } from './TodayPreviewCardProvider'import { TodayRail } from './TodayRail'import { TODAY_PANES } from './todayRailItems'import { TODAY_RAIL_WIDTH, TODAY_SIDEBAR_CLOSE_THRESHOLD, clampSidebarWidth, todayShellLogic } from './todayShellLogic'@@ -92,7 +93,9 @@ export function TodayShell({ className }: { className?: string }): JSX.Element {{activePane === 'home' ? null : activePane === 'spaces' ? (<TodaySpacesPane />) : activePane === 'analytics' ? (- <TodayAnalyticsSidebar />+ <TodayPreviewCardProvider disabled={phoneLayout}>+ <TodayAnalyticsSidebar />+ </TodayPreviewCardProvider>) : activePane === 'settings' ? (<TodaySettingsSidebar />) : (diff --git a/frontend/src/layout/today/todayPreviewCards.ts b/frontend/src/layout/today/todayPreviewCards.tsindex fcebff887a88..9e9aee97bc67 100644--- a/frontend/src/layout/today/todayPreviewCards.ts+++ b/frontend/src/layout/today/todayPreviewCards.ts@@ -58,7 +58,19 @@ export interface TodayProductPreview extends SidebarProductMeta {product: FileSystemImport}-export type TodayPreviewPayload = TodaySessionPreview | TodayChatPreview | TodayObjectPreview | TodayProductPreview+/** Explains a sidebar row that is not a product, such as a way to browse Analytics. */+export interface TodayExplainerPreview extends SidebarProductMeta {+ kind: 'explainer'+ label: string+ icon: JSX.Element+}++export type TodayPreviewPayload =+ | TodaySessionPreview+ | TodayChatPreview+ | TodayObjectPreview+ | TodayProductPreview+ | TodayExplainerPreviewexport function sessionPreview(item: TodayWorkItem,