: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): put people pages under today-rail-nav (#129032)
Adam Leith342ff592ba05
diff --git a/frontend/bin/css-coupling-baseline.txt b/frontend/bin/css-coupling-baseline.txtindex 4bce40bcddb3..ef8df704f152 100644--- a/frontend/bin/css-coupling-baseline.txt+++ b/frontend/bin/css-coupling-baseline.txt@@ -6,16 +6,10 @@frontend/src/layout/navigation-3000/components/SimpleLayoutFrame.tsx -> .Navigation3000frontend/src/layout/navigation-3000/layout-modes/TodayFramedLayout.tsx -> .TodayAppLayoutfrontend/src/layout/navigation-3000/layout-modes/TodayPhoneLayout.tsx -> .TodayAppLayout-frontend/src/layout/today/TodayAnalyticsSidebar.tsx -> .TodayPanefrontend/src/layout/today/TodayContextPanelContent.tsx -> .TodayContextPanelContentfrontend/src/layout/today/TodayContextPanelLauncher.tsx -> .TodayContextPanelButton-frontend/src/layout/today/TodayPaneRow.tsx -> .TodayIconBadge-frontend/src/layout/today/TodayPaneSearchList.tsx -> .TodayPaneSearchListfrontend/src/layout/today/TodayPhoneHeader.tsx -> .TodayPhoneHeaderfrontend/src/layout/today/TodayProductHoverCard.tsx -> .TodayIconBadge-frontend/src/layout/today/TodayProductsSidebar.tsx -> .TodayPane-frontend/src/layout/today/TodaySettingsSidebar.tsx -> .TodayPane-frontend/src/layout/today/TodaySpacesSidebar.tsx -> .TodayPanefrontend/src/layout/today/TodayTabBar.tsx -> .TodayTabBarfrontend/src/layout/today/TodayTopBar.tsx -> .TodayTopBarfrontend/src/lib/components/TileDecorations/TileDecorations.tsx -> .LemonIcondiff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 027abd35f848..c8c70c832a50 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -10187,45 +10187,45 @@ snapshots:scenes-app-ai-observability-trace-view-trace-view--timeline-mode--light:hash: v1.k794b7964.356f8809b975131e3675c1c49593669b303cf9721564d91e0432622feb488f65.OvGBb2oaNLD0smdqKyJw3n2StjT4gTPXCAkHn5yhY1Uscenes-app-analytics--list--dark:- hash: v1.k794b7964.e692f466abc16179add1bb5dc8a717feeaf04a5b13523b0f716d6b4bb8811679.LQEOSA8cElMG8UsjhfDN9J_IgtUg02T1wq8RClGnENI+ hash: v1.k794b7964.754a41d15943873d0d5fb6e7afb5bffef36d2df26fe7a8e960a393603514b397.RMmz6jqKsSEmpJAkt7KdDzjIVfinFa1Y-VYSeGSHBgAscenes-app-analytics--list--light:- hash: v1.k794b7964.cfc4cafc34799e7e4afa5b0447fc6d4a5ee8d4d5f356b6f663684da23000511f.ckEaNMYDpKRELv-OeQMaoyOCX0dyEO4h1g8ThvMhXUs+ hash: v1.k794b7964.1ffb6ac3724d6f8dd30e79a7c88e65749190c8e3b3318926d8422da266a5c7b8.MftZiro1AbbzttQnD23xB-suPz2ki1wpXkBLEjPUEGAscenes-app-analytics--list-empty--dark:- hash: v1.k794b7964.afef18e8ff3928baa023aa38cd55c9ca22a2ab3619496369dadb4bebf07915cf.nWOkQRFn1glwnJrZPUld8yifo-TLr7bLXgU9jf6NPF0+ hash: v1.k794b7964.5e823cc84e1e21f5b6c69fba328e03396a44377472dc114a904d6428ba0a52f1.21xBajcfWvKmMQVZ5Kaj2DSEsXt-ReEhmpW_AZaHN4Ascenes-app-analytics--list-empty--light:- hash: v1.k794b7964.266f9116ed755293ebd904a782462013fcf6dc501343a5cf34baf77a7a49badd.dbZ5stdvTljrUnXImsToYvIOMmrsctAyfh-2WfLG7RA+ hash: v1.k794b7964.b05221a067189f981aa0bb40ed555ef8629bea98667614d5399185bd3861622e.U_0lChd1QO4xC6D0G1YFfrclk48cHeWPtmrjMY3lE8Mscenes-app-analytics--list-error--dark:- hash: v1.k794b7964.2b140e33595866ae16438a1cc907268179c2173a65621e1c0c841a377a2bb8f7.BHBb0udBzHF1sX3WkbeauIHXbf3uEawCKydwPHc-CyI+ hash: v1.k794b7964.0ea5c5b13f9e6168da335e2eaf72fa66814261a84a53b90aaed07dded03f6754.Va09kGdNP4Hhzgf37Z8i8BzQ9JILTl3wdgwtXs_cwD0scenes-app-analytics--list-error--light:- hash: v1.k794b7964.4cce0c1817aa569a4acedc0dea4d7576258cf261835b3b89493219d9ae9de45d.2FQcopLiv5Ok4q0necr9EENHFjhT8hjQ_OvLBrP1Df0+ hash: v1.k794b7964.f14ebf220e07aad04335be7da7788fb6b2c9d72368e4c241bf345ee65f5f1bc3.4wPl8rRZhjCCzRWeAcXtaqk83kyOHWshq1ZOqq0JLXoscenes-app-analytics--list-filtered--dark:- hash: v1.k794b7964.46ac5832f4bc74b4d05361de09a5da14a70b7d05107ae0e79c21f4d516f3bf20.TpvvIcoIDSmS0tRAeMqDNmn74Y1HQsCmZ5-J0wUq8G8+ hash: v1.k794b7964.4fe368cb3a911d917902ef936f25e4b821ee819f6c76cb701a629966599eab45.xBo8Ar6PzT4g_Kms5tfGjWW21iDcKq4BHEKvmU3wtjEscenes-app-analytics--list-filtered--light:- hash: v1.k794b7964.4c48c45d6c8008aac2eb30c36c64e9ec9e4d44cb185f823ffd27a9449c03c64f.QbGVGX4woZ8mezfBoXnl1pBM0FCL74VQDiDqemDSbfA+ hash: v1.k794b7964.c240f4bcfdb6e0af5d89d04b86158d400f7b6ebe96f385078c2324df55357963.SLVwdxTTFvlZWkoybWKTB7wpaUYw3289wE637xq0HhMscenes-app-analytics--list-new-insight-dialog--dark:- hash: v1.k794b7964.cffd2f5c8cdc6fb70679052aeb1ffedadbd4e9527476091a79c23f090f4a9b76.tEppGrPgtsR6utovmkCannSdGI2Ch9zPngqt-9_2KkE+ hash: v1.k794b7964.fee10698d79a4739fb3432d6d0b5a2d00ea4cb39959f9b5d0d896a39818d579d.O2ZFXaGHjJph_ThtuP2Sfp_KAENNPRagkuhJZ_BnqcEscenes-app-analytics--list-new-insight-dialog--light:- hash: v1.k794b7964.fc56f76aec640e1f0acea89c3893dc0f48abaabc6550c707a537e2f4e41c22e7.91c5PxweWpKxFDQEpx9pRIbIhz9_7yxbHNLJWWos5-A+ hash: v1.k794b7964.de1a3a1ed1b4d094c0c159c544aca1d0b8efa5890ea8efd9d85b2ee78d5230b4.1HhOQMhNoxs0rxQ2JPnsmLpFsGtfHSlm7X-VYTojtSkscenes-app-analytics--list-no-matches--dark:- hash: v1.k794b7964.a70673d68182ff6fd3a22558e415b0455cac357362222b96ed4c6bf569760671.bEoOJIvoBTlL64mgRN7wyafErow55hqveNmClOd4q1E+ hash: v1.k794b7964.335c3bd50930d4929321613f360c5b97ac065329fc8fe8513b5ee3b4359ecc6e.DDvO-FLj1gCxrOHTYlB2CMyUuWtc7kuRGv1Hc6XphxIscenes-app-analytics--list-no-matches--light:- hash: v1.k794b7964.bd8b6c57129cc71d80c05c6b67e0c259dbba1c588531d82e488af5cd8d98fc90.6NfBZ95wYFq5MIJEUjfs14-oJNJpUaB_t3E54vb5nq0+ hash: v1.k794b7964.550ce68cc45bb10e2e2b0cca6cb75d9cb78d18f025c55857ccdd0744dc6c1473.zG2k9DN8nQf0po80YKad3AHIwjS-Ca0l6y_e9FqHCdcscenes-app-analytics--list-share-dialog--dark:hash: v1.k794b7964.5d73b355d980270198e7ce6c2f8df4ad6231f74517b815e3ec48db433a612b41.qG99vq4HpkVoboXGFkQHI0RTQxHCzHbH8BIBcSJiG54scenes-app-analytics--list-share-dialog--light:hash: v1.k794b7964.d1e4f3264ce1ce3cc926bd0fd7ca481116962c956da863d14f55a18eab5ab03c.3sPci23BXnf6Gj2PoDh1z6PhFaXePUVwibiEkKVsJjAscenes-app-analytics--list-space--dark:- hash: v1.k794b7964.5b5512afeeca64aa23042dd9c37193df6e5e734fc79a058fe7ddc0f8ba914902.uBtoekT_7whVi7mtg6dly1Npr1ZGzUNANcPy23rJZ-o+ hash: v1.k794b7964.bbe28325b622e38962569f875c83c9143643e51ee06dce1993d0be8b28404ed0.TQ_7JwXGzoZmyzMnkOh52DMNOWNvXvRbCIWAvbdAxAAscenes-app-analytics--list-space--light:- hash: v1.k794b7964.9895099030383e485a4b6e930fa563b162729c1c6c7d29b9d13821967b02ae12.qa1tp8L4G2W5X4T74iJEYWEeff52ep6qV3I6OeRuQG4+ hash: v1.k794b7964.94c576538bdbc732373853037965f02754c286babcc1aa7d158629e64ca1fbce.yt7pNYU-HIG-J2zvunCY9lU2FMFM_aflMsK3GtSeojgscenes-app-analytics--mine--dark:- hash: v1.k794b7964.936d73397946b9cb8e24946f976f51ad4b5237bd6a4d95eb3f56249a2a9e17e4.FOz5cIDZwPT_oyz6sl4vdvl-2krBEM0xVrD641boc4M+ hash: v1.k794b7964.445d212eae8b2be9d21b1db843c99d839932710ed7cc48e64e0cb9eef49e61b6.1mclwGd7dwoj4FDks69m9PgyLcn1RF5X4ItnAtud_iwscenes-app-analytics--mine--light:- hash: v1.k794b7964.693dc8e2ba1a76baafdd474f55052cc9f9a7cb35c0c7d78cbe8a3e55e1151161.8n0mavfqakwMvYQEvxlvZeL5vxqPzBR782tZqe9y8IA+ hash: v1.k794b7964.4a565afbf20637e3cca3300aa3e07fe6dc21f0db0d3b1e416b18c162498b1700.aMzoWU25_YMvAxxI2pIToEXroaBvsWSHx6XD9xe_XpMscenes-app-analytics--spaces--dark:- hash: v1.k794b7964.52ed0a9a6baa86be856facd93bf6357da89252dfa633f504179c989ee38e7573.UK0vuxIqnUWDYeAqjQV08Mm2ZrlM5L5JAmaA0GMTNB0+ hash: v1.k794b7964.e43b9d5b73cc974acd8b86c4714d79ecfb73802525822ac3dc560fa370c24e9f.gP3NyVEFkh0mrlXcAOPK1pggKXuPNUS4pC9qxozvm9Mscenes-app-analytics--spaces--light:- hash: v1.k794b7964.abde1664b1047570d9848215001a0c3415b04e80d7bc78a770332054172a3aa8.5JFqQPKrigKgffi-n02FCxUESUZk0tIs3Ntw00C-o0g+ hash: v1.k794b7964.b6a50113abd09ea4dff76b0dca67c131c30b3997387d7c16dc7f7f9652e56ed3.UjMVtTyBUfQX0OlcgYmT-STIx1KT5k4ppyM4paLdJmwscenes-app-annotations--annotations--dark:hash: v1.k794b7964.651aae7146d31971a314f627499eafdaa3d35933cde8dd0ad47abc6eab722148.H9u02T71vFBWS4vd-5sVVqacwrqXc9xeeOHs7b4qnL4scenes-app-annotations--annotations--light:@@ -11451,9 +11451,9 @@ snapshots:scenes-app-errortracking--group-page-releases-stacked--light:hash: v1.k794b7964.bbd7d8f861510cc79188ecbe20e6af110f08f96a53ef27ac75ce28bbd704f48c.bBi7jDw0DwllpcX_pkQJi-DdiBG_XAmTwS_GzqDEoRwscenes-app-errortracking--group-page-today-rail-nav--dark:- hash: v1.k794b7964.7b967502dd276f40a0035c9f1fec6c4fff32e4558afd88b2605089ae34d79bf5.Qa-Nb2wVDvXbs1WAzJLiYFVpc-IJMDtPG31P0njv5lc+ hash: v1.k794b7964.4ad976c46ab08cc4b7781741395535cffe4e1ae250caa29972e10bd9d6869262.l3VjsqPg4X-5SH4Pe-Ic5EBlI64Qm2MX1V5DnW2-OKsscenes-app-errortracking--group-page-today-rail-nav--light:- hash: v1.k794b7964.195f79c54a1021066a5212c8f778741cb247edc4a77fed677d59f09d2d8b9c98.DoLnAH2gz3VSkmqa-0j8TUEIO-gAuHe1oPz5NWZf0Dw+ hash: v1.k794b7964.77bc5841c2ee6cb2232b26d309bb2c8e8c0a6ea3c6ac62e3512a4bb647fbbb9d.cvzLmg2_RTp8zLfQOTBkwfK0Xx_as_Qik_KGuT8CnIAscenes-app-errortracking--group-page-with-self-driving--dark:hash: v1.k794b7964.5b2ad716a364c83f57c4aec2fe6763b18b292b16587be3ea3dd70510e6a6d346.hy55pTTiWYd_eKLJ-L2bUXoolVsA_KhOrCaRguFMUZgscenes-app-errortracking--group-page-with-self-driving--light:diff --git a/frontend/src/layout/panel-layout/ProjectTree/customIconRegistry.tsx b/frontend/src/layout/panel-layout/ProjectTree/customIconRegistry.tsxindex 1fd9820c08f4..62e567a019e7 100644--- a/frontend/src/layout/panel-layout/ProjectTree/customIconRegistry.tsx+++ b/frontend/src/layout/panel-layout/ProjectTree/customIconRegistry.tsx@@ -6,7 +6,7 @@ import { removeProjectIdIfPresent } from 'lib/utils/kea-router'* Products can register custom icon components here to override the default static icons.* The registry maps item `type` values to React components.*/-import { SupportNavBadge } from 'products/conversations/frontend/components/SupportNavBadge'+import { SupportNavBadge, useSupportUnreadCount } from 'products/conversations/frontend/components/SupportNavBadge'/*** Map of item types to custom icon components.@@ -16,6 +16,14 @@ export const customIconRegistry: Record<string, React.ComponentType<{ className?conversations: SupportNavBadge,}+/**+ * Hooks that give a nav item's count, for navs that show the count as text instead of on the icon. They use the same+ * logic as the icons above, so a count is never fetched twice.+ */+export const customNavCountRegistry = {+ conversations: useSupportUnreadCount,+} satisfies Record<string, () => number>+/*** Get a custom icon component for the given type, or undefined if none registered.*/diff --git a/frontend/src/layout/panel-layout/sidebarProductMeta.ts b/frontend/src/layout/panel-layout/sidebarProductMeta.tsindex 4d8b11a168b3..cf2ee57f9bf8 100644--- a/frontend/src/layout/panel-layout/sidebarProductMeta.ts+++ b/frontend/src/layout/panel-layout/sidebarProductMeta.ts@@ -168,6 +168,18 @@ export interface SidebarProductMeta {docsHref?: string}+/** Group paths come from configurable group type names, so groups share this copy. */+export const SIDEBAR_GROUP_META = {+ description:+ 'Explore the organizations, accounts, or other groups behind your events. Understand usage at the group level.',+ example: 'Compare activity across customer accounts.',+}++/** The copy of one sidebar name, for a row that is not a tree item. */+export function sidebarProductCopy(name: string): SidebarProductMeta {+ return { description: descriptions[name], example: examples[name], docsHref: docsHrefs[name] }+}+/** Description and docs link for a sidebar product, both read from the product's scene config. */export function sidebarProductMeta(product: FileSystemImport): SidebarProductMeta {// Most tree items name their scene explicitly; the rest are generated with a single-scene list.@@ -178,9 +190,9 @@ export function sidebarProductMeta(product: FileSystemImport): SidebarProductMetreturn {// Group paths come from configurable group type names, which can match a built-in app name.description: isGroup- ? 'Explore the organizations, accounts, or other groups behind your events. Understand usage at the group level.'+ ? SIDEBAR_GROUP_META.description: (descriptions[product.path] ?? sceneConfig?.description),- example: isGroup ? 'Compare activity across customer accounts.' : examples[product.path],+ example: isGroup ? SIDEBAR_GROUP_META.example : examples[product.path],docsHref: sceneConfig?.docsHref ?? docsHrefs[product.path],}}diff --git a/frontend/src/layout/scenes/components/SceneMenuBar.tsx b/frontend/src/layout/scenes/components/SceneMenuBar.tsxindex 61920ba548a2..2ef0adaa6b00 100644--- a/frontend/src/layout/scenes/components/SceneMenuBar.tsx+++ b/frontend/src/layout/scenes/components/SceneMenuBar.tsx@@ -61,7 +61,7 @@ function captureSceneMenuBar(event: string, properties: Record<string, unknown>const PADDED_LAYOUTS = new Set(['app', 'app-container', 'app-full-scene-height'])type SceneMenuBarProps = {- children: ReactNode+ children?: ReactNodeclassName?: string}diff --git a/frontend/src/layout/today/AGENTS.md b/frontend/src/layout/today/AGENTS.mdnew file mode 100644index 000000000000..8e2916171a0a--- /dev/null+++ b/frontend/src/layout/today/AGENTS.md@@ -0,0 +1,10 @@+# Today shell agent guide (`frontend/src/layout/today`)++## Recents sections++These rules apply to every sidebar section that lists items a person recently opened, for example Recents in the People and Analytics panes.++- **A click on a row must not move the row.** A row that moves when it is clicked leaves the pointer over a different row.+- **The section shows the newest items, sorted by name.** Use `newestByName` from `todayNewestByName.ts`. Do not sort by recency, and do not write a second sort. The list changes only when a person opens an item that is not in the list.+- **The stored list stays newest first.** Sort in a selector or where the section's list is built. The limit needs the recency order to choose which items to keep, so do not write the sorted order over a recency order you still need.+- **A scene reports its own record.** A section reads the open record from the scene logic, for example the `TODAY_PEOPLE_RECENT_KEY` selector in `todayPeople.ts`, which is null until the record loads. Do not read a recent from breadcrumbs or the URL: they show placeholder names and the previous page while a page loads, and rows sort by name.diff --git a/frontend/src/layout/today/CLAUDE.md b/frontend/src/layout/today/CLAUDE.mdnew file mode 120000index 000000000000..47dc3e3d863c--- /dev/null+++ b/frontend/src/layout/today/CLAUDE.md@@ -0,0 +1 @@+AGENTS.md\ No newline at end of filediff --git a/frontend/src/layout/today/TodayAnalyticsSidebar.tsx b/frontend/src/layout/today/TodayAnalyticsSidebar.tsxindex abff328f2b55..a53bd25f6b8d 100644--- a/frontend/src/layout/today/TodayAnalyticsSidebar.tsx+++ b/frontend/src/layout/today/TodayAnalyticsSidebar.tsx@@ -17,7 +17,7 @@ import { urls } from 'scenes/urls'import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'import { FileSystemIconType } from '~/queries/schema/schema-general'-import { TodayAnalyticsSection, todayAnalyticsLogic } from './todayAnalyticsLogic'+import { todayAnalyticsLogic } from './todayAnalyticsLogic'import { TodayPaneRow } from './TodayPaneRow'import { TodayPaneSearchList } from './TodayPaneSearchList'import { TodayPaneSection } from './TodayPaneSection'@@ -76,14 +76,36 @@ function AnalyticsItemIcon({ type }: { type: AnalyticsType }): JSX.Element {)}+interface ExplainerRow {+ value: string+ explainer: (typeof EXPLAINERS)[keyof typeof EXPLAINERS]+ to: string+ dataAttr: string+}++/** A fixed row whose hover card explains it. Its label and icon come from the explainer. */+function ExplainerPaneRow({ row, active }: { row: ExplainerRow; active: boolean }): JSX.Element {+ return (+ <TodayPreviewTrigger payload={row.explainer}>+ <TodayPaneRow+ value={row.value}+ label={row.explainer.label}+ icon={row.explainer.icon}+ to={row.to}+ active={active}+ dataAttr={row.dataAttr}+ />+ </TodayPreviewTrigger>+ )+}+/** The Analytics sub-nav: the ways to browse, pinned items and collections, recently viewed items, PostHog's own analytics, and what to keep an eye on. */export function TodayAnalyticsSidebar(): JSX.Element {- const { collapsedSections, fromPostHog, recentAnalytics } = useValues(todayAnalyticsLogic)- const { toggleSection } = useActions(todayAnalyticsLogic)+ const { fromPostHog, recentAnalytics, searchQuery, matchesSearch, isSectionOpen } = useValues(todayAnalyticsLogic)+ const { toggleSection, setSearchQuery } = useActions(todayAnalyticsLogic)const { pinnedAnalytics } = useValues(analyticsPinnedLogic)const { location, searchParams } = useValues(router)const path = removeProjectIdIfPresent(location.pathname)- const isOpen = (section: TodayAnalyticsSection): boolean => !collapsedSections.includes(section)const listFilters =path === urls.analyticsList() || path === urls.analyticsMine()? analyticsListFiltersFromUrl(searchParams)@@ -94,58 +116,83 @@ export function TodayAnalyticsSidebar(): JSX.Element {[fromPostHog])+ const browseRows: (ExplainerRow & { active: boolean })[] = [+ {+ value: 'browse:all',+ explainer: EXPLAINERS.all,+ to: urls.analyticsList(),+ active: path === urls.analyticsList() && openFolder === null,+ dataAttr: 'analytics-sidebar-browse',+ },+ {+ value: 'browse:mine',+ explainer: EXPLAINERS.mine,+ to: urls.analyticsMine(),+ active: path === urls.analyticsMine(),+ dataAttr: 'analytics-sidebar-browse',+ },+ {+ value: 'browse:spaces',+ explainer: EXPLAINERS.collections,+ to: urls.analyticsSpaces(),+ active: path === urls.analyticsSpaces(),+ dataAttr: 'analytics-sidebar-browse',+ },+ ].filter((row) => matchesSearch(row.explainer.label))+ const monitorRows: (ExplainerRow & { active: boolean })[] = [+ {+ value: 'monitor:alerts',+ explainer: EXPLAINERS.alerts,+ to: urls.alerts(),+ active: path === urls.alerts(),+ dataAttr: 'analytics-sidebar-monitor',+ },+ {+ value: 'monitor:subscriptions',+ explainer: EXPLAINERS.subscriptions,+ to: `${urls.subscriptions()}?tab=mine`,+ active: path === urls.subscriptions(),+ dataAttr: 'analytics-sidebar-monitor',+ },+ ].filter((row) => matchesSearch(row.explainer.label))+ const pinnedRows = pinnedAnalytics.filter((pinned) =>+ matchesSearch(pinned.kind === 'collection' ? pinned.name : pinned.item.name)+ )+ const recentRows = recentAnalytics.filter((item) => matchesSearch(item.name))+ const fromPostHogRows = fromPostHog.filter((product) => matchesSearch(product.label))+ const noMatches =+ browseRows.length + monitorRows.length + pinnedRows.length + recentRows.length + fromPostHogRows.length === 0+return (<div className="TodayPane group/colorful-product-icons colorful-product-icons-true" data-quill>- {/* The rows are list options that need the pane list around them; this pane has no search, so the field stays hidden. */}<TodayPaneSearchList- query=""- onQueryChange={() => {}}+ query={searchQuery}+ onQueryChange={setSearchQuery}searchLabel="Search analytics"dataAttr="analytics-sidebar-search"- className="[&>div:first-child]:hidden">- <div className="flex flex-col gap-px pb-2">- <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>- </div>- {pinnedAnalytics.length > 0 && (+ {browseRows.length > 0 && (+ <div className="flex flex-col gap-px pb-2">+ {browseRows.map((row) => (+ <ExplainerPaneRow key={row.value} row={row} active={row.active} />+ ))}+ </div>+ )}+ {noMatches && (+ <div className="px-2 py-1 text-sm text-muted-foreground">+ Nothing in Analytics matches your search.+ </div>+ )}+ {pinnedRows.length > 0 && (<TodayPaneSectionlabel="Pinned"- open={isOpen('pinned')}- count={pinnedAnalytics.length}+ open={isSectionOpen('pinned')}+ count={pinnedRows.length}showCount={false}onToggle={() => toggleSection('pinned')}dataAttr="analytics-section-pinned">- {pinnedAnalytics.map((pinned) =>+ {pinnedRows.map((pinned) =>pinned.kind === 'collection' ? (<TodayPaneRowkey={pinned.key}@@ -189,17 +236,17 @@ export function TodayAnalyticsSidebar(): JSX.Element {)}</TodayPaneSection>)}- {recentAnalytics.length > 0 && (+ {recentRows.length > 0 && (<TodayPaneSectionlabel="Recents"- open={isOpen('recents')}- count={recentAnalytics.length}+ open={isSectionOpen('recents')}+ count={recentRows.length}showCount={false}onToggle={() => toggleSection('recents')}dividerdataAttr="analytics-section-recents">- {recentAnalytics.map((item) => (+ {recentRows.map((item) => (<TodayPaneRowkey={`${item.type}:${item.id}`}value={`recent:${item.type}:${item.id}`}@@ -218,18 +265,18 @@ export function TodayAnalyticsSidebar(): JSX.Element {))}</TodayPaneSection>)}- {fromPostHog.length > 0 && (+ {fromPostHogRows.length > 0 && (<TodayPaneSectionlabel="By PostHog"icon={<Logomark className="h-auto w-3.5" />}- open={isOpen('by-posthog')}- count={fromPostHog.length}+ open={isSectionOpen('by-posthog')}+ count={fromPostHogRows.length}showCount={false}onToggle={() => toggleSection('by-posthog')}dividerdataAttr="analytics-section-by-posthog">- {fromPostHog.map((product) => {+ {fromPostHogRows.map((product) => {const productPath = product.href.split(/[?#]/)[0]const row = (<TodayPaneRow@@ -255,36 +302,21 @@ export function TodayAnalyticsSidebar(): JSX.Element {})}</TodayPaneSection>)}- <TodayPaneSection- label="Monitor"- open={isOpen('monitor')}- count={2}- showCount={false}- onToggle={() => toggleSection('monitor')}- divider- dataAttr="analytics-section-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>+ {monitorRows.length > 0 && (+ <TodayPaneSection+ label="Monitor"+ open={isSectionOpen('monitor')}+ count={monitorRows.length}+ showCount={false}+ onToggle={() => toggleSection('monitor')}+ divider+ dataAttr="analytics-section-monitor"+ >+ {monitorRows.map((row) => (+ <ExplainerPaneRow key={row.value} row={row} active={row.active} />+ ))}+ </TodayPaneSection>+ )}</TodayPaneSearchList></div>)diff --git a/frontend/src/layout/today/TodayNewPeopleButton.tsx b/frontend/src/layout/today/TodayNewPeopleButton.tsxnew file mode 100644index 000000000000..cd006cb0c5ab--- /dev/null+++ b/frontend/src/layout/today/TodayNewPeopleButton.tsx@@ -0,0 +1,137 @@+import { useValues } from 'kea'+import { router } from 'kea-router'++import { IconFilter, IconPeople, IconPlus, IconSupport } from '@posthog/icons'+import {+ Button,+ DropdownMenu,+ DropdownMenuContent,+ DropdownMenuItem,+ DropdownMenuTrigger,+ IconStack,+ IconStackItem,+ ItemContent,+ ItemDescription,+ ItemTitle,+} from '@posthog/quill'++import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'+import { getAccessControlDisabledReason, productHasEffectiveNoneAccess } from 'lib/utils/accessControlUtils'+import { retryImport } from 'lib/utils/retryImport'+import { teamLogic } from 'scenes/teamLogic'+import { urls } from 'scenes/urls'++import { AccessControlLevel, AccessControlResourceType } from '~/types'++// The compose modal lives in the Support product. It loads on demand, so the shell does not import product code.+async function openComposeTicket(): Promise<void> {+ const { composeTicketLogic } = await retryImport(+ () => import('products/conversations/frontend/components/ComposeTicket/composeTicketLogic')+ )+ const logic = composeTicketLogic.findMounted() ?? composeTicketLogic+ if (!logic.isMounted()) {+ logic.mount()+ }+ logic.actions.openComposeModal()+}++interface NewPeopleItem {+ key: string+ title: string+ description: string+ icon: JSX.Element+ color: string+ onClick: () => void+ disabledReason?: string | null+}++function NewPeopleMenuItem({ item }: { item: NewPeopleItem }): JSX.Element {+ return (+ <DropdownMenuItem+ className="h-auto cursor-pointer items-start py-1.5 whitespace-normal"+ onClick={item.onClick}+ disabled={!!item.disabledReason}+ title={item.disabledReason ?? undefined}+ data-attr={`people-new-${item.key}`}+ >+ <IconStack className="mt-0.5 shrink-0">+ <IconStackItem color={item.color}>{item.icon}</IconStackItem>+ </IconStack>+ <ItemContent variant="menuItem">+ <ItemTitle>{item.title}</ItemTitle>+ <ItemDescription>{item.disabledReason ?? item.description}</ItemDescription>+ </ItemContent>+ </DropdownMenuItem>+ )+}++export function TodayNewPeopleButton(): JSX.Element {+ const customerAnalytics = useFeatureFlag('CUSTOMER_ANALYTICS')+ const journeys = useFeatureFlag('CUSTOMER_ANALYTICS_JOURNEYS')+ const { currentTeam } = useValues(teamLogic)++ const items: (NewPeopleItem | null)[] = [+ {+ key: 'cohort',+ title: 'Cohort',+ description: 'Save a group of people by their properties or behavior.',+ icon: <IconPeople />,+ color: 'var(--color-product-data-warehouse-light)',+ onClick: () => router.actions.push(urls.cohort('new')),+ },+ customerAnalytics && journeys+ ? {+ key: 'journey',+ title: 'Journey',+ description: 'Map the steps customers take and see where they drop off.',+ icon: <IconFilter />,+ color: 'var(--color-product-customer-analytics-light)',+ onClick: () => router.actions.push(urls.customerJourneyTemplates()),+ disabledReason: getAccessControlDisabledReason(+ AccessControlResourceType.CustomerAnalytics,+ AccessControlLevel.Editor+ ),+ }+ : null,+ // Like the Support row, the item is left out for people with no Ticket access.+ !productHasEffectiveNoneAccess(AccessControlResourceType.Ticket)+ ? {+ key: 'ticket',+ title: 'Ticket',+ description: currentTeam?.conversations_enabled+ ? 'Write to a customer, and keep the conversation in Support.'+ : 'Turn on Support for this project to write to customers.',+ icon: <IconSupport />,+ color: 'var(--color-product-support-light)',+ onClick: () =>+ currentTeam?.conversations_enabled+ ? void openComposeTicket()+ : router.actions.push(urls.supportSettings()),+ disabledReason: getAccessControlDisabledReason(+ AccessControlResourceType.Ticket,+ AccessControlLevel.Editor+ ),+ }+ : null,+ ]++ return (+ <DropdownMenu>+ <DropdownMenuTrigger+ render={+ <Button+ size="icon"+ className="-me-2 text-muted-foreground"+ aria-label="New in People"+ data-attr="today-new-people-header"+ />+ }+ >+ <IconPlus />+ </DropdownMenuTrigger>+ <DropdownMenuContent align="start" className="min-w-72">+ {items.map((item) => item && <NewPeopleMenuItem key={item.key} item={item} />)}+ </DropdownMenuContent>+ </DropdownMenu>+ )+}diff --git a/frontend/src/layout/today/TodayPaneRow.tsx b/frontend/src/layout/today/TodayPaneRow.tsxindex 72e9cacaac52..24c952e0620f 100644--- a/frontend/src/layout/today/TodayPaneRow.tsx+++ b/frontend/src/layout/today/TodayPaneRow.tsx@@ -1,3 +1,5 @@+import './TodayShell.scss'+import { cn } from '@posthog/quill'import { TodayPaneOption } from './TodayPaneOption'diff --git a/frontend/src/layout/today/TodayPaneSearchList.tsx b/frontend/src/layout/today/TodayPaneSearchList.tsxindex c2708d0283cd..596bc1d742d2 100644--- a/frontend/src/layout/today/TodayPaneSearchList.tsx+++ b/frontend/src/layout/today/TodayPaneSearchList.tsx@@ -1,7 +1,11 @@-import type { ReactNode } from 'react'+import './TodayShell.scss'++import { type ReactNode, useRef } from 'react'import { Autocomplete, AutocompleteClear, AutocompleteInput, AutocompleteList, cn } from '@posthog/quill'+import { highlightOption, toggleSectionWithArrow } from './todayPaneTreeKeys'+export interface TodayPaneSearchListProps {query: stringonQueryChange: (query: string) => void@@ -18,7 +22,8 @@ export interface TodayPaneSearchListProps {/*** A sidebar pane's search field and list, after Desktop's sidebar. The list stays open, the field filters it,- * the arrow keys move between rows and Enter opens the highlighted row.+ * the arrow keys move between rows and Enter opens the highlighted row. With the field empty, Right and Left open and+ * close a highlighted section heading, and Left on a row closes its section, like a tree.*/export function TodayPaneSearchList({query,@@ -31,6 +36,7 @@ export function TodayPaneSearchList({className,listClassName,}: TodayPaneSearchListProps): JSX.Element {+ const listRef = useRef<HTMLDivElement>(null)return (<Autocomplete<string>inline@@ -57,6 +63,16 @@ export function TodayPaneSearchList({event.preventDefault()event.stopPropagation()onQueryChange('')+ } else if (query === '') {+ const heading = toggleSectionWithArrow(+ listRef.current?.querySelector('[data-highlighted]'),+ event.key+ )+ if (heading) {+ event.preventDefault()+ // The section's rows unmount, so the highlight goes back to its heading.+ requestAnimationFrame(() => highlightOption(heading))+ }}}}>@@ -72,6 +88,7 @@ export function TodayPaneSearchList({</div>{header && <div className="mt-2 shrink-0">{header}</div>}<AutocompleteList+ ref={listRef}className={cn('TodayPaneSearchList mt-2 min-h-0 !max-h-none flex-1 overflow-y-auto !p-0 pb-6',header && 'mt-1',diff --git a/frontend/src/layout/today/TodayPaneSection.tsx b/frontend/src/layout/today/TodayPaneSection.tsxindex d15af2ed98db..92ef13195ec3 100644--- a/frontend/src/layout/today/TodayPaneSection.tsx+++ b/frontend/src/layout/today/TodayPaneSection.tsx@@ -1,11 +1,19 @@-import { ReactNode, RefCallback } from 'react'+import { ReactNode, RefCallback, useId } from 'react'import { IconChevronRight } from '@posthog/icons'-import { MenuLabel, cn } from '@posthog/quill'+import { AutocompleteItem, Button, cn } from '@posthog/quill'import { TodayPaneSectionResizeHandle } from './TodayPaneSectionResizeHandle'+import { SECTION_TOGGLE_ATTR } from './todayPaneTreeKeys'import { TodaySectionResizer } from './useTodaySectionLayout'+// The heading is a small button: it shows a hover and keyboard highlight like the rows, in the section label's type.+const TRIGGER_CLASS_NAME =+ 'min-w-0 flex-1 text-xxs font-semibold uppercase tracking-[0.075em] text-muted-foreground hover:text-foreground ' ++ 'data-highlighted:text-foreground data-highlighted:border-transparent data-highlighted:ring-0 [&>span]:gap-1 ' ++ // An open section is the usual state, so it does not take the expanded fill of a menu trigger.+ '[&[aria-expanded=true]:not(:hover,[data-highlighted])]:bg-transparent [&[aria-expanded=true]:not(:hover,[data-highlighted])]:text-muted-foreground'+export interface TodayPaneSectionProps {label: string/** Shows before the label, for a section whose source matters, such as the PostHog mark. */@@ -46,36 +54,43 @@ export function TodayPaneSection({contentRef,children,}: TodayPaneSectionProps): JSX.Element {+ const contentId = useId()+ const triggerProps = {+ 'aria-expanded': open,+ 'aria-controls': contentId,+ 'data-attr': dataAttr,+ [SECTION_TOGGLE_ATTR]: '',+ onClick: onToggle,+ }+ const trigger = <Button size="sm" left className={TRIGGER_CLASS_NAME} />+ const triggerContent = (+ <>+ {icon && (+ <span className="flex size-3.5 shrink-0 items-center justify-center [&_svg]:size-3.5" aria-hidden>+ {icon}+ </span>+ )}+ <span>{label}</span>+ <IconChevronRight className={cn('size-3 shrink-0 opacity-60', open && 'rotate-90')} />+ {!open && showCount && count > 0 && (+ <span className="ml-0.5 font-normal text-muted-foreground tabular-nums">{count}</span>+ )}+ </>+ )return (<section aria-label={label} className="flex shrink-0 flex-col"><div className={cn('relative flex h-7 shrink-0 items-center gap-1', divider && 'border-t border-border')}>{resizer && <TodayPaneSectionResizeHandle label={label} active={resizing} resizer={resizer} />}{heading ?? (- <MenuLabel- render={<button type="button" />}- aria-expanded={open}- data-attr={dataAttr}- onClick={onToggle}- className="flex min-w-0 flex-1 cursor-pointer items-center gap-1 rounded-sm py-1 text-left text-foreground/70 hover:text-foreground"- >- {icon && (- <span- className="flex size-3.5 shrink-0 items-center justify-center [&_svg]:size-3.5"- aria-hidden- >- {icon}- </span>- )}- <span>{label}</span>- <IconChevronRight className={cn('size-3 shrink-0 opacity-60', open && 'rotate-90')} />- {!open && showCount && count > 0 && (- <span className="ml-0.5 font-normal text-muted-foreground tabular-nums">{count}</span>- )}- </MenuLabel>+ // The heading is a list option, so the arrow keys reach it with the rows.+ <AutocompleteItem value={`section:${dataAttr}`} {...triggerProps} render={trigger}>+ {triggerContent}+ </AutocompleteItem>)}{open && actions && <div className="flex shrink-0 items-center">{actions}</div>}</div><div+ id={contentId}className={cn('min-h-0 shrink-0 overflow-hidden',animate && 'transition-all duration-200 ease-out motion-reduce:transition-none'diff --git a/frontend/src/layout/today/TodayPeopleNavRow.tsx b/frontend/src/layout/today/TodayPeopleNavRow.tsxnew file mode 100644index 000000000000..ff8fbce09ce5--- /dev/null+++ b/frontend/src/layout/today/TodayPeopleNavRow.tsx@@ -0,0 +1,54 @@+import { useMemo } from 'react'++import { SidebarProductMeta } from '~/layout/panel-layout/sidebarProductMeta'++import { TodayPaneRow } from './TodayPaneRow'+import { TodayPeopleRow } from './todayPeopleLogic'+import { TODAY_PEOPLE_GROUP_ICON, TODAY_PEOPLE_ROWS, todayPeopleRowIcon } from './todayPeopleRows'+import { TodayExplainerPreview } from './todayPreviewCards'+import { TodayPreviewTrigger } from './TodayPreviewTrigger'++// Group type names belong to each project, so the copy can only say what a group type is, in the project's own words.+function groupExplainer(label: string): SidebarProductMeta {+ const plural = label.toLowerCase()+ return {+ description: `Your project tracks ${plural} as a group type. Each one collects its own events, properties, and people, so you can look at usage above the level of a single person.`,+ example: `Find the ${plural} with the most activity this month.`,+ docsHref: 'https://posthog.com/docs/product-analytics/group-analytics',+ }+}++export function TodayPeopleNavRow({+ row,+ meta,+ active,+}: {+ row: TodayPeopleRow+ meta?: string+ active: boolean+}): JSX.Element {+ const icon = row.kind === 'static' ? todayPeopleRowIcon(row.key) : TODAY_PEOPLE_GROUP_ICON+ // The shared card stores the payload, so it must keep its identity between renders.+ const preview = useMemo<TodayExplainerPreview>(+ () => ({+ kind: 'explainer',+ label: row.label,+ icon,+ ...(row.kind === 'static' ? TODAY_PEOPLE_ROWS[row.key].explainer : groupExplainer(row.label)),+ }),+ [row.kind, row.key, row.label, icon]+ )+ return (+ <TodayPreviewTrigger payload={preview}>+ <TodayPaneRow+ value={`browse:${row.key}`}+ label={row.label}+ meta={meta}+ icon={icon}+ to={row.href}+ active={active}+ dataAttr={`people-sidebar-${row.key}`}+ />+ </TodayPreviewTrigger>+ )+}diff --git a/frontend/src/layout/today/TodayPeopleRecentRow.tsx b/frontend/src/layout/today/TodayPeopleRecentRow.tsxnew file mode 100644index 000000000000..4b470314e554--- /dev/null+++ b/frontend/src/layout/today/TodayPeopleRecentRow.tsx@@ -0,0 +1,49 @@+import { useMemo } from 'react'++import { IconBuilding, IconPeople, IconPerson, IconSupport } from '@posthog/icons'++import { TodayPaneRow } from './TodayPaneRow'+import { TodayPeopleRecent, TodayPeopleRecentType, peopleRecentRowKey } from './todayPeople'+import { TodayExplainerPreview } from './todayPreviewCards'+import { TodayPreviewTrigger } from './TodayPreviewTrigger'++const RECENT_ICONS: Record<TodayPeopleRecentType, JSX.Element> = {+ person: <IconPerson />,+ group: <IconBuilding />,+ cohort: <IconPeople />,+ account: <IconBuilding />,+ ticket: <IconSupport />,+}++const RECENT_DESCRIPTIONS: Record<TodayPeopleRecentType, string> = {+ person: 'A person in your project. Open their page to see their properties, events, and recordings.',+ group: 'A group in your project. Open it to see its properties and activity.',+ cohort: 'A cohort in your project. Open it to see who belongs to it and how it is defined.',+ account: 'A customer account. Open it to see its activity, notes, and related users.',+ ticket: 'A support ticket. Open it to read the conversation and reply.',+}++export function TodayPeopleRecentRow({ recent, active }: { recent: TodayPeopleRecent; active: boolean }): JSX.Element {+ // The shared card stores the payload, so it must keep its identity between renders.+ const preview = useMemo<TodayExplainerPreview>(+ () => ({+ kind: 'explainer',+ label: recent.name,+ icon: RECENT_ICONS[recent.type],+ description: RECENT_DESCRIPTIONS[recent.type],+ }),+ [recent.name, recent.type]+ )+ return (+ <TodayPreviewTrigger payload={preview}>+ <TodayPaneRow+ value={peopleRecentRowKey(recent.href)}+ label={recent.name}+ icon={RECENT_ICONS[recent.type]}+ to={recent.href}+ active={active}+ dataAttr="people-sidebar-recent"+ />+ </TodayPreviewTrigger>+ )+}diff --git a/frontend/src/layout/today/TodayPeopleSidebar.tsx b/frontend/src/layout/today/TodayPeopleSidebar.tsxnew file mode 100644index 000000000000..bd26ce0509c0--- /dev/null+++ b/frontend/src/layout/today/TodayPeopleSidebar.tsx@@ -0,0 +1,85 @@+import './TodayShell.scss'++import { useActions, useValues } from 'kea'++import { humanFriendlyLargeNumber } from 'lib/utils/numbers'++import { customNavCountRegistry } from '~/layout/panel-layout/ProjectTree/customIconRegistry'++import { TodayPaneSearchList } from './TodayPaneSearchList'+import { TodayPaneSection } from './TodayPaneSection'+import { peopleRecentRowKey } from './todayPeople'+import { TodayPeopleRow, TodayPeopleRowKey, todayPeopleLogic } from './todayPeopleLogic'+import { TodayPeopleNavRow } from './TodayPeopleNavRow'+import { TodayPeopleRecentRow } from './TodayPeopleRecentRow'++function rowMeta(key: TodayPeopleRowKey, counts: Partial<Record<TodayPeopleRowKey, number>>): string | undefined {+ const count = counts[key]+ return count === undefined ? undefined : humanFriendlyLargeNumber(count)+}++export function TodayPeopleSidebar(): JSX.Element {+ const { topRows, rowSections, counts, matchingRecentRows, activeRow, isSectionOpen, isSearching, searchQuery } =+ useValues(todayPeopleLogic)+ const { toggleSection, setSearchQuery } = useActions(todayPeopleLogic)++ // The unread ticket count comes from the logic behind the classic nav's Support badge, so it is fetched once.+ // No unread tickets shows no number, like that badge.+ const rowCounts = { ...counts, support: customNavCountRegistry.conversations() || undefined }++ const renderRow = (row: TodayPeopleRow): JSX.Element => (+ <TodayPeopleNavRow key={row.key} row={row} meta={rowMeta(row.key, rowCounts)} active={activeRow === row.key} />+ )+ const noMatches = isSearching && topRows.length === 0 && rowSections.length === 0 && matchingRecentRows.length === 0++ return (+ <div className="TodayPane group/colorful-product-icons colorful-product-icons-true" data-quill>+ <TodayPaneSearchList+ query={searchQuery}+ onQueryChange={setSearchQuery}+ searchLabel="Search people"+ dataAttr="people-sidebar-search"+ >+ {topRows.length > 0 && <div className="flex flex-col gap-px pb-2">{topRows.map(renderRow)}</div>}+ {noMatches && (+ <div className="px-2 py-1 text-sm text-muted-foreground">+ Nothing in People matches your search.+ </div>+ )}+ {matchingRecentRows.length > 0 && (+ <TodayPaneSection+ label="Recents"+ open={isSectionOpen('recents')}+ count={matchingRecentRows.length}+ showCount={false}+ onToggle={() => toggleSection('recents')}+ divider+ dataAttr="people-section-recents"+ >+ {matchingRecentRows.map((recent) => (+ <TodayPeopleRecentRow+ key={recent.href}+ recent={recent}+ active={activeRow === peopleRecentRowKey(recent.href)}+ />+ ))}+ </TodayPaneSection>+ )}+ {rowSections.map((section) => (+ <TodayPaneSection+ key={section.key}+ label={section.label}+ open={isSectionOpen(section.key)}+ count={section.rows.length}+ showCount={false}+ onToggle={() => toggleSection(section.key)}+ divider+ dataAttr={`people-section-${section.key}`}+ >+ {section.rows.map(renderRow)}+ </TodayPaneSection>+ ))}+ </TodayPaneSearchList>+ </div>+ )+}diff --git a/frontend/src/layout/today/TodayRail.tsx b/frontend/src/layout/today/TodayRail.tsxindex aded6ae9c210..97c032c8ed3a 100644--- a/frontend/src/layout/today/TodayRail.tsx+++ b/frontend/src/layout/today/TodayRail.tsx@@ -2,15 +2,15 @@ import { useActions, useValues } from 'kea'import { TodayAccountMenu } from './TodayAccountMenu'import { TodayMoreMenu } from './TodayMoreMenu'-import { TODAY_PANES, TODAY_RAIL_FOOTER_PANES, TODAY_RAIL_PANES } from './todayRailItems'+import { TODAY_PANES, TODAY_RAIL_FOOTER_PANES } from './todayRailItems'import { TodayRailTile } from './TodayRailTile'-import { TODAY_RAIL_WIDTH, TodayRailPane, railPaneHref, todayShellLogic } from './todayShellLogic'+import { TODAY_RAIL_PANES, TODAY_RAIL_WIDTH, TodayRailPane, railPaneHref, todayShellLogic } from './todayShellLogic'// pinned: autocapture data-attr. The Settings tile kept the attribute of the gear button it replaced.const RAIL_DATA_ATTRS: Partial<Record<TodayRailPane, string>> = { settings: 'today-settings' }export function TodayRail(): JSX.Element {- const { activePane, effectivePhaiView } = useValues(todayShellLogic)+ const { activePane, effectivePhaiView, featureFlags } = useValues(todayShellLogic)const { clickRailPane } = useActions(todayShellLogic)const renderTile = (pane: TodayRailPane): JSX.Element => (@@ -19,7 +19,7 @@ export function TodayRail(): JSX.Element {label={TODAY_PANES[pane].label}icon={TODAY_PANES[pane].icon}active={activePane === pane}- to={railPaneHref(pane, effectivePhaiView)}+ to={railPaneHref(pane, effectivePhaiView, featureFlags)}onClick={() => clickRailPane(pane)}dataAttr={RAIL_DATA_ATTRS[pane] ?? `today-rail-${pane}`}/>diff --git a/frontend/src/layout/today/TodayShell.tsx b/frontend/src/layout/today/TodayShell.tsxindex 37f0939ea5e5..382a2eb6d9a0 100644--- a/frontend/src/layout/today/TodayShell.tsx+++ b/frontend/src/layout/today/TodayShell.tsx@@ -29,6 +29,9 @@ const TodaySpacesPane = lazyWithRetry(() => import('./TodaySpacesPane').then((m)const TodayAnalyticsSidebar = lazyWithRetry(() =>import('./TodayAnalyticsSidebar').then((m) => ({ default: m.TodayAnalyticsSidebar })))+const TodayPeopleSidebar = lazyWithRetry(() =>+ import('./TodayPeopleSidebar').then((m) => ({ default: m.TodayPeopleSidebar }))+)const TodayProductsPane = lazyWithRetry(() =>import('./TodayProductsPane').then((m) => ({ default: m.TodayProductsPane })))@@ -96,6 +99,10 @@ export function TodayShell({ className }: { className?: string }): JSX.Element {<TodayPreviewCardProvider disabled={phoneLayout}><TodayAnalyticsSidebar /></TodayPreviewCardProvider>+ ) : activePane === 'people' ? (+ <TodayPreviewCardProvider disabled={phoneLayout}>+ <TodayPeopleSidebar />+ </TodayPreviewCardProvider>) : activePane === 'settings' ? (<TodaySettingsSidebar />) : (diff --git a/frontend/src/layout/today/TodayTabBar.tsx b/frontend/src/layout/today/TodayTabBar.tsxindex 0e55a79c91c2..8249fbce1e85 100644--- a/frontend/src/layout/today/TodayTabBar.tsx+++ b/frontend/src/layout/today/TodayTabBar.tsx@@ -5,8 +5,8 @@ import { cn } from '@posthog/quill'import { commandLogic } from 'lib/components/Command/commandLogic'-import { TODAY_PANES, TODAY_RAIL_PANES } from './todayRailItems'-import { todayShellLogic } from './todayShellLogic'+import { TODAY_PANES } from './todayRailItems'+import { TODAY_RAIL_PANES, todayShellLogic } from './todayShellLogic'const TAB_CLASS ='flex min-w-0 flex-1 cursor-pointer flex-col items-center justify-center gap-0.5 rounded-md text-xxs font-medium outline-none focus-visible:ring-2 focus-visible:ring-[var(--ring)] focus-visible:ring-inset [&_svg]:size-5'diff --git a/frontend/src/layout/today/todayAnalyticsLogic.test.ts b/frontend/src/layout/today/todayAnalyticsLogic.test.tsindex e51fdd0da6ba..db3b98315941 100644--- a/frontend/src/layout/today/todayAnalyticsLogic.test.ts+++ b/frontend/src/layout/today/todayAnalyticsLogic.test.ts@@ -69,9 +69,9 @@ describe('todayAnalyticsLogic', () => {row('dashboard', '8', 'Costs'),])expect(logic.values.recentAnalytics.map((item) => [item.type, item.name])).toEqual([- ['insight', 'Signups'],- ['dashboard', 'Revenue'],['dashboard', 'Costs'],+ ['dashboard', 'Revenue'],+ ['insight', 'Signups'],])recentItemsModel.actions.loadRecentsSuccess([])diff --git a/frontend/src/layout/today/todayAnalyticsLogic.ts b/frontend/src/layout/today/todayAnalyticsLogic.tsindex 78d2544add1b..f64f482b7f9f 100644--- a/frontend/src/layout/today/todayAnalyticsLogic.ts+++ b/frontend/src/layout/today/todayAnalyticsLogic.ts@@ -6,7 +6,6 @@ import { toast } from '@posthog/quill'import api from 'lib/api'import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'-import { getCurrentTeamIdOrNone, getCurrentUserIdOrNone } from 'lib/utils/getAppContext'import { analyticsPinnedLogic, pinKey } from 'scenes/analytics/analyticsPinnedLogic'import {AnalyticsItem,@@ -20,6 +19,10 @@ import { escapePath } from '~/layout/panel-layout/ProjectTree/utils'import { recentItemsModel } from '~/models/recentItemsModel'import { FileSystemEntry } from '~/queries/schema/schema-general'+import { newestByName } from './todayNewestByName'+import { matchesPaneQuery } from './todayPaneSearch'+import { TODAY_USER_PERSIST_OPTIONS } from './todayUserPersistOptions'+// pinned: persisted section ids and the `section` property of `analytics section toggled`.export type TodayAnalyticsSection = 'pinned' | 'recents' | 'monitor' | 'by-posthog'@@ -27,14 +30,7 @@ export const DEFAULT_COLLAPSED_SECTIONS: TodayAnalyticsSection[] = []export const TODAY_ANALYTICS_RECENTS_LIMIT = 3-// The last Recents list stays in the browser so it shows on first paint. It belongs to one person in one project,-// and without both ids nothing persists, so one account never sees another's.-const RECENTS_TEAM_ID = getCurrentTeamIdOrNone()-const RECENTS_USER_ID = getCurrentUserIdOrNone()-const RECENTS_PERSIST_OPTIONS =- RECENTS_TEAM_ID && RECENTS_USER_ID- ? { persist: true, prefix: `${RECENTS_TEAM_ID}__${RECENTS_USER_ID}__` }- : { persist: false }+// The last Recents list stays in the browser so it shows on first paint.// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface todayAnalyticsLogicValues {@@ -46,10 +42,13 @@ export interface todayAnalyticsLogicValues {creatingFolder: booleanfreshRecentAnalytics: AnalyticsItem[]fromPostHog: FromPostHogItem[]+ isSectionOpen: (section: TodayAnalyticsSection) => boolean+ matchesSearch: (label: string) => booleannewFolderDialogOpen: booleannewFolderParent: string | nullrecentAnalytics: AnalyticsItem[]savedRecentAnalytics: AnalyticsItem[]+ searchQuery: string}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -73,6 +72,9 @@ export interface todayAnalyticsLogicActions {open: booleanparent: string | null}+ setSearchQuery: (searchQuery: string) => {+ searchQuery: string+ }storeRecentAnalytics: (items: AnalyticsItem[]) => {items: AnalyticsItem[]}@@ -84,6 +86,11 @@ export interface todayAnalyticsLogicActions {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface todayAnalyticsLogicMeta {__keaTypeGenInternalSelectorTypes: {+ matchesSearch: (searchQuery: string) => (label: string) => boolean+ isSectionOpen: (+ collapsedSections: TodayAnalyticsSection[],+ searchQuery: string+ ) => (section: TodayAnalyticsSection) => booleanfromPostHog: (featureFlags: FeatureFlagsSet) => FromPostHogItem[]freshRecentAnalytics: (recents: FileSystemEntry[], pinnedShortcutIds: Map<string, string>) => AnalyticsItem[]recentAnalytics: (@@ -117,6 +124,7 @@ export const todayAnalyticsLogic = kea<todayAnalyticsLogicType>([})),actions({toggleSection: (section: TodayAnalyticsSection) => ({ section }),+ setSearchQuery: (searchQuery: string) => ({ searchQuery }),storeRecentAnalytics: (items: AnalyticsItem[]) => ({ items }),setNewFolderDialogOpen: (open: boolean, parent: string | null = null) => ({ open, parent }),createFolder: (name: string) => ({ name }),@@ -127,9 +135,10 @@ export const todayAnalyticsLogic = kea<todayAnalyticsLogicType>([// pinned: storage key for the saved Recents list. Renaming it makes everyone's Recents pop in once more.savedRecentAnalytics: [[] as AnalyticsItem[],- RECENTS_PERSIST_OPTIONS,+ TODAY_USER_PERSIST_OPTIONS,{ storeRecentAnalytics: (_, { items }) => items },],+ searchQuery: ['', { setSearchQuery: (_, { searchQuery }) => searchQuery }],// pinned: storage key for the persisted sections. Renaming it reopens everyone's sections.collapsedSections: [DEFAULT_COLLAPSED_SECTIONS,@@ -158,6 +167,20 @@ export const todayAnalyticsLogic = kea<todayAnalyticsLogicType>([],}),selectors({+ /** Whether a row's label matches the pane search. Every row matches while the search is empty. */+ matchesSearch: [+ (s) => [s.searchQuery],+ (searchQuery: string) =>+ (label: string): boolean =>+ matchesPaneQuery(label, searchQuery),+ ],+ /** A search opens every section, so no match hides in a collapsed one. */+ isSectionOpen: [+ (s) => [s.collapsedSections, s.searchQuery],+ (collapsedSections: TodayAnalyticsSection[], searchQuery: string) =>+ (section: TodayAnalyticsSection): boolean =>+ searchQuery.trim() !== '' || !collapsedSections.includes(section),+ ],fromPostHog: [(s) => [s.featureFlags],(featureFlags: FeatureFlagsSet): FromPostHogItem[] => fromPostHogItems(featureFlags),@@ -167,12 +190,15 @@ export const todayAnalyticsLogic = kea<todayAnalyticsLogicType>([freshRecentAnalytics: [(s) => [s.recents, s.pinnedShortcutIds],(recents: FileSystemEntry[], pinnedShortcutIds: Map<string, string>): AnalyticsItem[] =>- recents- .flatMap((entry) => {+ newestByName(+ recents.flatMap((entry) => {const item = fileSystemEntryToAnalytics(entry)return item && !pinnedShortcutIds.has(pinKey(item.type, item.id)) ? [item] : []- })- .slice(0, TODAY_ANALYTICS_RECENTS_LIMIT),+ }),+ (item) => item.name,+ (item) => pinKey(item.type, item.id),+ TODAY_ANALYTICS_RECENTS_LIMIT+ ),],// The saved list covers only the wait for the shared list. Once it has loaded, even empty, it is the answer.recentAnalytics: [diff --git a/frontend/src/layout/today/todayNewestByName.test.ts b/frontend/src/layout/today/todayNewestByName.test.tsnew file mode 100644index 000000000000..ba09fc64c228--- /dev/null+++ b/frontend/src/layout/today/todayNewestByName.test.ts@@ -0,0 +1,27 @@+import { newestByName } from './todayNewestByName'++describe('newestByName', () => {+ it('keeps the newest rows, lists them by name, and does not swap rows with the same name', () => {+ const name = (item: { name: string; id: string }): string => item.name+ const id = (item: { name: string; id: string }): string => item.id+ const row = (name: string, id: string = name): { name: string; id: string } => ({ name, id })+ const newestFirst = ['Pricing', 'apps', 'Zebra', 'Alerts'].map((label) => row(label))++ expect(newestByName(newestFirst, name, id, 3).map(name)).toEqual(['apps', 'Pricing', 'Zebra'])++ const twins = [row('Untitled', 'a'), row('Untitled', 'b')]+ expect(newestByName(twins, name, id, 2)).toEqual(newestByName([...twins].reverse(), name, id, 2))+ })++ it('puts numbered names in number order', () => {+ const rows = ['Ticket #10', 'Ticket #9'].map((label) => ({ name: label, id: label }))+ expect(+ newestByName(+ rows,+ (row) => row.name,+ (row) => row.id,+ 2+ ).map((row) => row.name)+ ).toEqual(['Ticket #9', 'Ticket #10'])+ })+})diff --git a/frontend/src/layout/today/todayNewestByName.ts b/frontend/src/layout/today/todayNewestByName.tsnew file mode 100644index 000000000000..769111fea6d4--- /dev/null+++ b/frontend/src/layout/today/todayNewestByName.ts@@ -0,0 +1,13 @@+/**+ * Keeps the first `limit` items of a newest-first list, then sorts them by name, so a click on a row does not move it.+ * `id` breaks ties: without it, two rows with the same name swap places when one is opened.+ */+export function newestByName<T>(items: T[], name: (item: T) => string, id: (item: T) => string, limit: number): T[] {+ return items+ .slice(0, limit)+ .sort(+ (first, second) =>+ name(first).localeCompare(name(second), undefined, { sensitivity: 'base', numeric: true }) ||+ id(first).localeCompare(id(second))+ )+}diff --git a/frontend/src/layout/today/todayPaneTreeKeys.ts b/frontend/src/layout/today/todayPaneTreeKeys.tsnew file mode 100644index 000000000000..ba8fb8c464ba--- /dev/null+++ b/frontend/src/layout/today/todayPaneTreeKeys.ts@@ -0,0 +1,36 @@+/** Marks a section heading, so the arrow keys can open and close it like a tree node. */+export const SECTION_TOGGLE_ATTR = 'data-pane-section-toggle'++/**+ * Tree keys for a pane's search list. Right opens a closed heading and Left closes an open one. Left on a row inside an open+ * section closes that section. Returns the heading that should take focus, or null when the key was not used.+ */+export function toggleSectionWithArrow(element: Element | null | undefined, key: string): HTMLElement | null {+ if (!(element instanceof HTMLElement)) {+ return null+ }+ const isHeading = element.hasAttribute(SECTION_TOGGLE_ATTR)+ const heading = isHeading+ ? element+ : key === 'ArrowLeft'+ ? element.closest('section')?.querySelector<HTMLElement>(`[${SECTION_TOGGLE_ATTR}]`)+ : null+ if (!heading) {+ return null+ }+ const expanded = heading.getAttribute('aria-expanded') === 'true'+ if ((key === 'ArrowRight' && isHeading && !expanded) || (key === 'ArrowLeft' && expanded)) {+ heading.click()+ return heading+ }+ return null+}++/**+ * Moves the list highlight to an option while focus stays in the search field. base-ui's Autocomplete has no prop or+ * action that sets the highlight, so this does what a pointer over the option does. Check for one when base-ui updates.+ */+export function highlightOption(option: HTMLElement): void {+ option.dispatchEvent(new PointerEvent('pointermove', { bubbles: true, pointerType: 'mouse' }))+ option.dispatchEvent(new MouseEvent('mousemove', { bubbles: true }))+}diff --git a/frontend/src/layout/today/todayPeople.ts b/frontend/src/layout/today/todayPeople.tsnew file mode 100644index 000000000000..e87c18e47dfb--- /dev/null+++ b/frontend/src/layout/today/todayPeople.ts@@ -0,0 +1,42 @@+import { isUnderPath } from 'lib/utils/kea-router'+import { urls } from 'scenes/urls'++export type TodayPeopleRecentType = 'person' | 'group' | 'cohort' | 'account' | 'ticket'++export interface TodayPeopleRecent {+ type: TodayPeopleRecentType+ name: string+ href: string+}++/**+ * A scene logic that opens one record has a selector with this name. It gives the record as a recent, or null until+ * the record has loaded. It reads the logic's own record, so its name and href always belong together.+ */+export const TODAY_PEOPLE_RECENT_KEY = 'todayPeopleRecent'++export function isPeopleListPath(path: string): boolean {+ return (+ path === urls.persons() ||+ path === urls.cohorts() ||+ /^\/groups\/[^/]+(\/new)?$/.test(path) ||+ isUnderPath(path, urls.customerAnalytics()) ||+ isUnderPath(path, urls.supportDashboard())+ )+}++/** One person, group or cohort. Other panes link to these, so a visit from one of them keeps that pane open. */+export function isPeopleDetailPath(path: string): boolean {+ return (+ !isPeopleListPath(path) &&+ (isUnderPath(path, '/person') ||+ isUnderPath(path, urls.persons()) ||+ isUnderPath(path, urls.cohorts()) ||+ isUnderPath(path, '/groups'))+ )+}++/** The id of a recent's row, for the active row and the row's own value. */+export function peopleRecentRowKey(href: string): string {+ return `recent:${href}`+}diff --git a/frontend/src/layout/today/todayPeopleLogic.test.ts b/frontend/src/layout/today/todayPeopleLogic.test.tsnew file mode 100644index 000000000000..c77d5bce6c66--- /dev/null+++ b/frontend/src/layout/today/todayPeopleLogic.test.ts@@ -0,0 +1,210 @@+import { expectLogic } from 'kea-test-utils'++import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { urls } from 'scenes/urls'++import { useMocks } from '~/mocks/jest'+import { GroupTab } from '~/models/groupTabs'+import { initKeaTests } from '~/test/init'+import { GroupType, GroupTypeIndex } from '~/types'++import {+ accountGroupTypeIndex,+ activePeopleRow,+ peopleRowSections,+ peopleSidebarRows,+ todayPeopleLogic,+} from './todayPeopleLogic'++const groupTypes = (...indexes: number[]): Map<GroupTypeIndex, GroupType> =>+ new Map(+ indexes.map((index) => [+ index as GroupTypeIndex,+ { group_type: `type-${index}`, group_type_index: index as GroupTypeIndex },+ ])+ )++const CUSTOMER_ANALYTICS = { [FEATURE_FLAGS.CUSTOMER_ANALYTICS]: true }+const JOURNEYS = { ...CUSTOMER_ANALYTICS, [FEATURE_FLAGS.CUSTOMER_ANALYTICS_JOURNEYS]: true }+const EVERY_TAB = {+ ...JOURNEYS,+ [FEATURE_FLAGS.CUSTOMER_ANALYTICS_CSP]: true,+ [FEATURE_FLAGS.CUSTOMER_ANALYTICS_FEATURE_REQUESTS]: true,+ [FEATURE_FLAGS.CUSTOMER_ANALYTICS_CUSTOMER_TASKS]: true,+}++const groupTabs = (...tabs: [number, string][]): GroupTab[] =>+ tabs.map(([index, label]) => ({+ key: `groups-${index}`,+ label,+ url: urls.groups(index),+ iconType: 'group',+ dataAttr: 'tab',+ }))+const ONE_TYPE = groupTabs([0, 'Organizations'])++describe('todayPeopleLogic', () => {+ test.each([+ [+ 'journeys on',+ JOURNEYS,+ 0,+ ['overview', 'persons', 'accounts', 'cohorts', 'journeys', 'configure', 'support'],+ ],+ [+ 'every tab on',+ EVERY_TAB,+ 0,+ [+ 'overview',+ 'feed',+ 'tasks',+ 'persons',+ 'accounts',+ 'cohorts',+ 'journeys',+ 'notes',+ 'announcements',+ 'feature_requests',+ 'configure',+ 'support',+ ],+ ],+ ['journeys off', CUSTOMER_ANALYTICS, 0, ['overview', 'persons', 'accounts', 'cohorts', 'configure', 'support']],+ [+ 'customer analytics off, tab flags on',+ { ...EVERY_TAB, [FEATURE_FLAGS.CUSTOMER_ANALYTICS]: false },+ 0,+ ['persons', 'groups-0', 'cohorts', 'support'],+ ],+ ['no group types', JOURNEYS, null, ['overview', 'persons', 'cohorts', 'journeys', 'configure', 'support']],+ ])('with %s, the pane shows %o', (_, flags, groupTypeIndex, keys) => {+ expect(+ peopleSidebarRows(+ flags,+ groupTypeIndex as GroupTypeIndex | null,+ groupTypeIndex === null ? [] : ONE_TYPE+ ).map((row) => row.key)+ ).toEqual(keys)+ })++ test.each([+ ['off, the group list', {}, urls.groups(0)],+ ['on, the Accounts tab', { [FEATURE_FLAGS.CUSTOMER_ANALYTICS_CSP]: true }, urls.customerAnalyticsAccounts()],+ ])('with customer-analytics-csp %s opens from Accounts', (_, flags, href) => {+ const accounts = peopleSidebarRows({ ...CUSTOMER_ANALYTICS, ...flags }, 0, ONE_TYPE).find(+ (row) => row.key === 'accounts'+ )+ expect(accounts?.href).toBe(href)+ })++ it('lists every group type by its own name, and the account group type once', () => {+ const tabs = groupTabs([0, 'Accounts'], [1, 'Projects'])+ const rowsFor = (flags: Record<string, boolean>, index: GroupTypeIndex): [string, string, string][] =>+ peopleSidebarRows(flags, index, tabs)+ .filter((row) => row.key === 'accounts' || row.key.startsWith('groups-'))+ .map((row) => [row.key, row.label, row.href])++ expect(rowsFor(CUSTOMER_ANALYTICS, 1)).toEqual([+ ['accounts', 'Accounts', urls.groups(1)],+ ['groups-0', 'Accounts', urls.groups(0)],+ ])+ expect(rowsFor({ ...CUSTOMER_ANALYTICS, [FEATURE_FLAGS.CUSTOMER_ANALYTICS_CSP]: true }, 0)).toEqual([+ ['accounts', 'Accounts', urls.customerAnalyticsAccounts()],+ ['groups-1', 'Projects', urls.groups(1)],+ ])+ })++ it('puts the core rows and Support on top, and the rest in Groups and Customer analytics', () => {+ const rows = peopleSidebarRows(EVERY_TAB, 1, groupTabs([0, 'Organizations'], [1, 'Projects']))++ expect(+ rows.filter((row) => !peopleRowSections(rows).some((s) => s.rows.includes(row))).map((row) => row.key)+ ).toEqual(['overview', 'persons', 'accounts', 'cohorts', 'support'])+ expect(peopleRowSections(rows).map((section) => [section.label, section.rows.map((row) => row.key)])).toEqual([+ ['Groups', ['groups-0']],+ [+ 'Customer analytics',+ ['feed', 'tasks', 'journeys', 'notes', 'announcements', 'feature_requests', 'configure'],+ ],+ ])+ })++ it('leaves out a section with no rows', () => {+ const rows = peopleSidebarRows(JOURNEYS, 0, ONE_TYPE)+ expect(peopleRowSections(rows).map((section) => section.key)).toEqual(['customer-analytics'])+ })++ test.each([+ ['the configured account type', 1, groupTypes(0, 1), 1],+ ['the first type when none is configured', null, groupTypes(2, 0), 0],+ ['the first type when the configured one was deleted', 3, groupTypes(1, 2), 1],+ ['nothing without group types', 0, groupTypes(), null],+ ])('the Accounts row opens %s', (_, configured, types, index) => {+ expect(accountGroupTypeIndex(configured, types)).toBe(index)+ })++ it('marks the open record active when its page has another URL than its row', () => {+ const row = { type: 'person' as const, name: 'Ada', href: urls.personByUUID('uuid-1') }+ expect(activePeopleRow('/project/1/person/ada', peopleSidebarRows(JOURNEYS, 0, ONE_TYPE), [row], row)).toBe(+ `recent:${row.href}`+ )+ })++ test.each([+ ['/project/1/person/ada%40example.com', JOURNEYS, 'persons'],+ ['/project/1/groups/0/acme', JOURNEYS, 'accounts'],+ ['/project/1/groups/0/acme', EVERY_TAB, 'accounts'],+ ['/project/1/customer_analytics/accounts/7', EVERY_TAB, 'accounts'],+ ['/project/1/customer_analytics/feature-requests/3', EVERY_TAB, 'feature_requests'],+ ['/project/1/support/tickets', JOURNEYS, 'support'],+ ['/project/1/support/tickets/12', JOURNEYS, 'support'],+ ['/project/1/cohorts', JOURNEYS, 'cohorts'],+ ['/project/1/cohorts/2', JOURNEYS, `recent:${urls.cohort('2')}`],+ ['/project/1/cohorts/9', JOURNEYS, 'cohorts'],+ ['/project/1/customer_analytics/journeys/new', JOURNEYS, 'journeys'],+ ['/project/1/insights/abc', JOURNEYS, null],+ ])('on %s with flags %o the %s row is active', (pathname, flags, active) => {+ const recents = [{ type: 'cohort' as const, name: 'Churned', href: urls.cohort('2') }]+ expect(activePeopleRow(pathname, peopleSidebarRows(flags, 0, ONE_TYPE), recents)).toBe(active)+ })++ it('keeps the other counts when one count request fails', async () => {+ useMocks({+ get: {+ '/api/projects/:team_id/accounts/': { count: 4, results: [] },+ '/api/projects/:team_id/cohorts/': () => [500, { detail: 'nope' }],+ '/api/projects/:team_id/customer_journeys/': { count: 2, results: [] },+ },+ })+ initKeaTests()+ const flags = { ...JOURNEYS, [FEATURE_FLAGS.CUSTOMER_ANALYTICS_CSP]: true }+ featureFlagLogic.actions.setFeatureFlags(Object.keys(flags), flags)+ const logic = todayPeopleLogic()+ logic.mount()++ await expectLogic(logic).toDispatchActions(['loadCountsSuccess'])+ expect(logic.values.counts).toEqual({ accounts: 4, cohorts: undefined, journeys: 2 })+ })++ it('filters every list by the search and opens collapsed sections while searching', () => {+ initKeaTests()+ featureFlagLogic.actions.setFeatureFlags(Object.keys(EVERY_TAB), EVERY_TAB)+ const logic = todayPeopleLogic()+ logic.mount()+ logic.actions.toggleSection('customer-analytics')+ expect(logic.values.isSectionOpen('customer-analytics')).toBe(false)++ logic.actions.setSearchQuery('ANNOUNCE')++ expect(logic.values.topRows).toEqual([])+ expect(logic.values.rowSections.map((section) => section.rows.map((row) => row.key))).toEqual([+ ['announcements'],+ ])+ expect(logic.values.isSectionOpen('customer-analytics')).toBe(true)++ logic.actions.setSearchQuery('')+ expect(logic.values.isSectionOpen('customer-analytics')).toBe(false)+ })+})diff --git a/frontend/src/layout/today/todayPeopleLogic.ts b/frontend/src/layout/today/todayPeopleLogic.tsnew file mode 100644index 000000000000..7d6c18a3a591--- /dev/null+++ b/frontend/src/layout/today/todayPeopleLogic.ts@@ -0,0 +1,420 @@+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'+import { loaders } from 'kea-loaders'+import { router } from 'kea-router'+import { subscriptions } from 'kea-subscriptions'+import posthog from 'posthog-js'++import api from 'lib/api'+import { FEATURE_FLAGS } from 'lib/constants'+import { GroupsAccessStatus } from 'lib/introductions/groupsAccessLogic'+import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { hogql } from 'lib/utils/hogql'+import { isUnderPath, removeProjectIdIfPresent } from 'lib/utils/kea-router'+import { teamLogic } from 'scenes/teamLogic'+import { urls } from 'scenes/urls'++import { Noun, groupsModel } from '~/models/groupsModel'+import { GroupTab, groupTabs as groupTabsFor } from '~/models/groupTabs'+import { GroupType, GroupTypeIndex, TeamPublicType, TeamType } from '~/types'++import { cohortsList } from 'products/cohorts/frontend/generated/api'+import { accountsList, customerJourneysList } from 'products/customer_analytics/frontend/generated/api'++import { matchesPaneQuery } from './todayPaneSearch'+import { TodayPeopleRecent, peopleRecentRowKey } from './todayPeople'+import { todayPeopleRecentsLogic } from './todayPeopleRecentsLogic'+import {+ TODAY_PEOPLE_ROWS,+ TODAY_PEOPLE_ROW_SECTION_LABELS,+ TodayPeopleRowSection,+ TodayPeopleSection,+ TodayPeopleStaticRowKey,+} from './todayPeopleRows'+import { TODAY_USER_PERSIST_OPTIONS } from './todayUserPersistOptions'++/** A section under Recents with its rows, in pane order. */+export interface TodayPeopleRowSectionGroup {+ key: TodayPeopleRowSection+ label: string+ rows: TodayPeopleRow[]+}++function rowSection(row: TodayPeopleRow): TodayPeopleRowSection | null {+ return row.kind === 'group' ? 'groups' : TODAY_PEOPLE_ROWS[row.key].section+}++export type TodayPeopleRowCounts = Partial<Record<'accounts' | 'cohorts' | 'journeys', number>>++export type TodayPeopleGroupRowKey = `groups-${number}`++// pinned: the row ids. Each one is part of the row's `people-sidebar-<row>` data-attr.+export type TodayPeopleRowKey = TodayPeopleStaticRowKey | TodayPeopleGroupRowKey++interface TodayPeopleRowBase {+ label: string+ href: string+ /** The paths that mark the row active. */+ paths: string[]+}++export type TodayPeopleRow =+ | (TodayPeopleRowBase & { kind: 'static'; key: TodayPeopleStaticRowKey })+ | (TodayPeopleRowBase & { kind: 'group'; key: TodayPeopleGroupRowKey })++export function accountGroupTypeIndex(+ configuredIndex: number | null | undefined,+ groupTypes: Map<GroupTypeIndex, GroupType>+): GroupTypeIndex | null {+ if (configuredIndex != null && groupTypes.has(configuredIndex as GroupTypeIndex)) {+ return configuredIndex as GroupTypeIndex+ }+ const [first] = [...groupTypes.keys()].sort((a, b) => a - b)+ return first ?? null+}++function staticRow(key: TodayPeopleStaticRowKey, href?: string, paths?: string[]): TodayPeopleRow {+ const definition = TODAY_PEOPLE_ROWS[key]+ const rowHref = href ?? definition.href()+ const rowPaths = paths ?? ('paths' in definition ? definition.paths() : [rowHref])+ return { kind: 'static', key, label: definition.label, href: rowHref, paths: rowPaths }+}++/**+ * The Accounts row and the group type rows. Accounts is a Customer analytics idea, so without that flag every group+ * type keeps its own name. With it there is one Accounts row: the Customer analytics accounts page with+ * customer-analytics-csp, which also covers the account group type's pages, else the account group type itself.+ */+function accountAndGroupRows(+ featureFlags: FeatureFlagsSet,+ groupTypeIndex: GroupTypeIndex | null,+ groupTabs: GroupTab[]+): TodayPeopleRow[] {+ const customerAnalytics = !!featureFlags[FEATURE_FLAGS.CUSTOMER_ANALYTICS]+ const accountsPage = TODAY_PEOPLE_ROWS.accounts.enabled(featureFlags)+ const accountTab = customerAnalytics ? groupTabs.find((tab) => tab.key === `groups-${groupTypeIndex}`) : undefined+ const accounts = accountsPage+ ? staticRow('accounts', undefined, [urls.customerAnalyticsAccounts(), ...(accountTab ? [accountTab.url] : [])])+ : accountTab+ ? staticRow('accounts', accountTab.url)+ : null+ const groups = groupTabs+ .filter((tab) => tab !== accountTab)+ .map(+ (tab): TodayPeopleRow => ({+ kind: 'group',+ key: tab.key,+ label: tab.label,+ href: tab.url,+ paths: [tab.url],+ })+ )+ return [...(accounts ? [accounts] : []), ...groups]+}++/**+ * The People pane rows in pane order: the rows of `TODAY_PEOPLE_ROWS` that are on, with the group types after+ * Accounts. They carry the Customer analytics tabs, which this shell hides, so the tab bars on those pages can go.+ */+export function peopleSidebarRows(+ featureFlags: FeatureFlagsSet,+ groupTypeIndex: GroupTypeIndex | null,+ groupTabs: GroupTab[] = []+): TodayPeopleRow[] {+ return (Object.keys(TODAY_PEOPLE_ROWS) as TodayPeopleStaticRowKey[]).flatMap((key) =>+ key === 'accounts'+ ? accountAndGroupRows(featureFlags, groupTypeIndex, groupTabs)+ : TODAY_PEOPLE_ROWS[key].enabled(featureFlags)+ ? [staticRow(key)]+ : []+ )+}++/** The sections under Recents, in pane order. A section with no rows is left out. */+export function peopleRowSections(rows: TodayPeopleRow[]): TodayPeopleRowSectionGroup[] {+ return (Object.keys(TODAY_PEOPLE_ROW_SECTION_LABELS) as TodayPeopleRowSection[])+ .map((key) => ({+ key,+ label: TODAY_PEOPLE_ROW_SECTION_LABELS[key],+ rows: rows.filter((row) => rowSection(row) === key),+ }))+ .filter((section) => section.rows.length > 0)+}++export function activePeopleRow(+ pathname: string,+ rows: TodayPeopleRow[],+ recents: TodayPeopleRecent[],+ openRecent: TodayPeopleRecent | null = null+): string | null {+ const path = removeProjectIdIfPresent(pathname)+ // A row keeps one URL for its record, but other pages can link to the record with another one.+ const recent = recents.find((item) => item.href === openRecent?.href || isUnderPath(path, item.href))+ if (recent) {+ return peopleRecentRowKey(recent.href)+ }+ return rows.find((row) => row.paths.some((rowPath) => isUnderPath(path, rowPath)))?.key ?? null+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface todayPeopleLogicValues {+ featureFlags: FeatureFlagsSet // featureFlagLogic+ aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun // groupsModel+ groupTypes: Map<GroupTypeIndex, GroupType> // groupsModel+ groupsAccessStatus: GroupsAccessStatus // groupsModel+ location: {+ pathname: string+ search: string+ hash: string+ } // router+ currentTeam: TeamPublicType | TeamType | null // teamLogic+ currentRecent: TodayPeopleRecent | null // todayPeopleRecentsLogic+ recentRows: TodayPeopleRecent[] // todayPeopleRecentsLogic+ recents: TodayPeopleRecent[] // todayPeopleRecentsLogic+ accountsGroupTypeIndex: GroupTypeIndex | null+ activeRow: string | null+ collapsedSections: TodayPeopleSection[]+ counts: TodayPeopleRowCounts+ countsLoading: boolean+ groupTabs: GroupTab[]+ isSearching: boolean+ isSectionOpen: (section: TodayPeopleSection) => boolean+ matchingRecentRows: TodayPeopleRecent[]+ matchingRows: TodayPeopleRow[]+ rowSections: TodayPeopleRowSectionGroup[]+ rows: TodayPeopleRow[]+ searchQuery: string+ topRows: TodayPeopleRow[]+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface todayPeopleLogicActions {+ loadCounts: () => any+ loadCountsFailure: (+ error: string,+ errorObject?: any+ ) => {+ error: string+ errorObject?: any+ }+ loadCountsSuccess: (+ counts: Partial<Record<'accounts' | 'cohorts' | 'journeys', number>>,+ payload?: any+ ) => {+ counts: Partial<Record<'accounts' | 'cohorts' | 'journeys', number>>+ payload?: any+ }+ setSearchQuery: (searchQuery: string) => {+ searchQuery: string+ }+ toggleSection: (section: TodayPeopleSection) => {+ section: TodayPeopleSection+ }+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface todayPeopleLogicMeta {+ __keaTypeGenInternalSelectorTypes: {+ accountsGroupTypeIndex: (+ currentTeam: TeamPublicType | TeamType | null,+ groupTypes: Map<GroupTypeIndex, GroupType>+ ) => GroupTypeIndex | null+ groupTabs: (+ groupTypes: Map<GroupTypeIndex, GroupType>,+ groupsAccessStatus: GroupsAccessStatus,+ aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun+ ) => GroupTab[]+ rows: (+ featureFlags: FeatureFlagsSet,+ accountsGroupTypeIndex: GroupTypeIndex | null,+ groupTabs: GroupTab[]+ ) => TodayPeopleRow[]+ activeRow: (+ location: {+ hash: string+ pathname: string+ search: string+ },+ rows: TodayPeopleRow[],+ recents: TodayPeopleRecent[],+ currentRecent: TodayPeopleRecent | null+ ) => string | null+ matchingRows: (rows: TodayPeopleRow[], searchQuery: string) => TodayPeopleRow[]+ topRows: (matchingRows: TodayPeopleRow[]) => TodayPeopleRow[]+ rowSections: (matchingRows: TodayPeopleRow[]) => TodayPeopleRowSectionGroup[]+ matchingRecentRows: (recentRows: TodayPeopleRecent[], searchQuery: string) => TodayPeopleRecent[]+ isSearching: (searchQuery: string) => boolean+ isSectionOpen: (+ collapsedSections: TodayPeopleSection[],+ isSearching: boolean+ ) => (section: TodayPeopleSection) => boolean+ }+}++export type todayPeopleLogicType = MakeLogicType<+ todayPeopleLogicValues,+ todayPeopleLogicActions,+ Record<string, any>,+ todayPeopleLogicMeta+>++export const todayPeopleLogic = kea<todayPeopleLogicType>([+ path(['layout', 'today', 'todayPeopleLogic']),+ connect(() => ({+ values: [+ featureFlagLogic,+ ['featureFlags'],+ groupsModel,+ ['groupTypes', 'groupsAccessStatus', 'aggregationLabel'],+ todayPeopleRecentsLogic,+ ['recents', 'recentRows', 'currentRecent'],+ router,+ ['location'],+ teamLogic,+ ['currentTeam'],+ ],+ })),+ actions({+ toggleSection: (section: TodayPeopleSection) => ({ section }),+ setSearchQuery: (searchQuery: string) => ({ searchQuery }),+ }),+ loaders(({ values }) => ({+ counts: [+ {} as TodayPeopleRowCounts,+ {+ // Each count stands alone: one the person cannot read leaves only its own row without a number.+ loadCounts: async (): Promise<TodayPeopleRowCounts> => {+ const projectId = values.currentTeam?.project_id+ if (!projectId) {+ return {}+ }+ const id = String(projectId)+ const { featureFlags, accountsGroupTypeIndex } = values+ const customerAnalytics = !!featureFlags[FEATURE_FLAGS.CUSTOMER_ANALYTICS]+ const accountsCount = async (): Promise<number | undefined> => {+ if (customerAnalytics && featureFlags[FEATURE_FLAGS.CUSTOMER_ANALYTICS_CSP]) {+ return (await accountsList(id, { limit: 1 })).count+ }+ if (!customerAnalytics || accountsGroupTypeIndex === null) {+ return undefined+ }+ const response = await api.queryHogQL<[number][]>(+ hogql`SELECT count() FROM groups WHERE index = ${accountsGroupTypeIndex}`,+ {+ scene: 'TodayPeopleSidebar',+ productKey: 'customer_analytics',+ name: 'today_people_accounts_count',+ }+ )+ return response.results?.[0]?.[0]+ }+ const [accounts, cohorts, journeys] = await Promise.allSettled([+ accountsCount(),+ cohortsList(id, { limit: 1 }).then((response) => response.count),+ customerAnalytics && featureFlags[FEATURE_FLAGS.CUSTOMER_ANALYTICS_JOURNEYS]+ ? customerJourneysList(id, { limit: 1 }).then((response) => response.count)+ : undefined,+ ])+ const value = (result: PromiseSettledResult<number | undefined>): number | undefined =>+ result.status === 'fulfilled' ? result.value : undefined+ return { accounts: value(accounts), cohorts: value(cohorts), journeys: value(journeys) }+ },+ },+ ],+ })),+ reducers({+ // pinned: storage key for the persisted sections. Renaming it reopens everyone's sections.+ searchQuery: [+ '',+ {+ setSearchQuery: (_, { searchQuery }) => searchQuery,+ },+ ],+ collapsedSections: [+ [] as TodayPeopleSection[],+ TODAY_USER_PERSIST_OPTIONS,+ {+ toggleSection: (state, { section }) =>+ state.includes(section) ? state.filter((id) => id !== section) : [...state, section],+ },+ ],+ }),+ selectors({+ accountsGroupTypeIndex: [+ (s) => [s.currentTeam, s.groupTypes],+ (+ currentTeam: TeamPublicType | TeamType | null,+ groupTypes: Map<GroupTypeIndex, GroupType>+ ): GroupTypeIndex | null =>+ accountGroupTypeIndex(+ currentTeam && 'customer_analytics_config' in currentTeam+ ? currentTeam.customer_analytics_config?.account_group_type_index+ : null,+ groupTypes+ ),+ ],+ groupTabs: [+ (s) => [s.groupTypes, s.groupsAccessStatus, s.aggregationLabel],+ (+ groupTypes: Map<GroupTypeIndex, GroupType>,+ groupsAccessStatus: GroupsAccessStatus,+ aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun+ ): GroupTab[] => groupTabsFor(groupTypes, groupsAccessStatus, aggregationLabel),+ ],+ rows: [+ (s) => [s.featureFlags, s.accountsGroupTypeIndex, s.groupTabs],+ (+ featureFlags: FeatureFlagsSet,+ groupTypeIndex: GroupTypeIndex | null,+ groupTabs: GroupTab[]+ ): TodayPeopleRow[] => peopleSidebarRows(featureFlags, groupTypeIndex, groupTabs),+ ],+ activeRow: [+ (s) => [s.location, s.rows, s.recents, s.currentRecent],+ (+ location: { pathname: string },+ rows: TodayPeopleRow[],+ recents: TodayPeopleRecent[],+ currentRecent: TodayPeopleRecent | null+ ): string | null => activePeopleRow(location.pathname, rows, recents, currentRecent),+ ],+ matchingRows: [+ (s) => [s.rows, s.searchQuery],+ (rows: TodayPeopleRow[], searchQuery: string): TodayPeopleRow[] =>+ rows.filter((row) => matchesPaneQuery(row.label, searchQuery)),+ ],+ topRows: [+ (s) => [s.matchingRows],+ (rows: TodayPeopleRow[]): TodayPeopleRow[] => rows.filter((row) => rowSection(row) === null),+ ],+ rowSections: [+ (s) => [s.matchingRows],+ (rows: TodayPeopleRow[]): TodayPeopleRowSectionGroup[] => peopleRowSections(rows),+ ],+ matchingRecentRows: [+ (s) => [s.recentRows, s.searchQuery],+ (recentRows: TodayPeopleRecent[], searchQuery: string): TodayPeopleRecent[] =>+ recentRows.filter((recent) => matchesPaneQuery(recent.name, searchQuery)),+ ],+ isSearching: [(s) => [s.searchQuery], (searchQuery: string): boolean => searchQuery.trim() !== ''],+ /** A search opens every section, so no match hides in a collapsed one. */+ isSectionOpen: [+ (s) => [s.collapsedSections, s.isSearching],+ (collapsedSections: TodayPeopleSection[], isSearching: boolean) =>+ (section: TodayPeopleSection): boolean =>+ isSearching || !collapsedSections.includes(section),+ ],+ }),+ listeners(({ values }) => ({+ toggleSection: ({ section }) => {+ // pinned: analytics event name and properties. Renaming them breaks dashboards.+ posthog.capture('people section toggled', {+ section,+ open: !values.collapsedSections.includes(section),+ })+ },+ })),+ subscriptions(({ actions }) => ({+ // Runs on mount, and again once group types load, because the Accounts count can depend on them.+ accountsGroupTypeIndex: () => actions.loadCounts(),+ })),+])diff --git a/frontend/src/layout/today/todayPeopleRecentsLogic.test.ts b/frontend/src/layout/today/todayPeopleRecentsLogic.test.tsnew file mode 100644index 000000000000..7416dc0f8b9c--- /dev/null+++ b/frontend/src/layout/today/todayPeopleRecentsLogic.test.ts@@ -0,0 +1,110 @@+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { sceneLogic } from 'scenes/sceneLogic'++import { initKeaTests } from '~/test/init'++import { TODAY_PEOPLE_RECENT_KEY, TodayPeopleRecent } from './todayPeople'+import { TODAY_PEOPLE_RECENTS_LIMIT, addPeopleRecent, todayPeopleRecentsLogic } from './todayPeopleRecentsLogic'++// The real logic loads every scene. This one lets a test set the active scene logic's record.+jest.mock('scenes/sceneLogic', () => {+ const { actions, kea, path, reducers } = jest.requireActual('kea')+ return {+ sceneLogic: kea([+ path(['test', 'sceneLogic']),+ actions({+ setActiveSceneLogic: (logic: unknown) => ({ logic }),+ setActiveLoadedScene: (scene: unknown) => ({ scene }),+ }),+ reducers({+ activeSceneLogic: [null, { setActiveSceneLogic: (_: unknown, { logic }: { logic: unknown }) => logic }],+ activeLoadedScene: [+ null,+ { setActiveLoadedScene: (_: unknown, { scene }: { scene: unknown }) => scene },+ ],+ }),+ ]),+ }+})++const recent = (href: string, name: string = href): TodayPeopleRecent => ({ type: 'cohort', name, href })+const sceneShowing = (record: TodayPeopleRecent | null): unknown => ({+ selectors: { [TODAY_PEOPLE_RECENT_KEY]: () => record },+})++describe('todayPeopleRecentsLogic', () => {+ it('puts a visit first, renames it in place, and keeps the list at the limit', () => {+ const a = recent('/a')+ const b = recent('/b')+ expect(addPeopleRecent([a, b], b).map((item) => item.href)).toEqual(['/b', '/a'])+ expect(addPeopleRecent([a, b], { ...a, name: 'Renamed' })).toEqual([{ ...a, name: 'Renamed' }, b])++ const unchanged = [a, b]+ expect(addPeopleRecent(unchanged, a)).toBe(unchanged)++ const full = Array.from({ length: TODAY_PEOPLE_RECENTS_LIMIT }, (_, index) => recent(`/${index}`))+ const added = addPeopleRecent(full, recent('/new'))+ expect(added).toHaveLength(TODAY_PEOPLE_RECENTS_LIMIT)+ expect(added[0].href).toBe('/new')+ })++ test.each([+ ['on', true, ['Churned']],+ ['off', false, []],+ ])('with today-rail-nav %s, a scene adds %o once its record loads', (_, enabled, names) => {+ initKeaTests()+ featureFlagLogic.mount()+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.TODAY_RAIL_NAV], {+ [FEATURE_FLAGS.TODAY_RAIL_NAV]: enabled,+ })+ sceneLogic.mount()+ const logic = todayPeopleRecentsLogic()+ logic.mount()+ const setActive = (sceneLogic.actions as any).setActiveSceneLogic++ setActive(sceneShowing(null))+ expect(logic.values.recents).toEqual([])++ setActive(sceneShowing(recent('/cohorts/5', 'Churned')))+ expect(logic.values.recents.map((item) => item.name)).toEqual(names)+ })++ it('reads the record with the props of the open scene', () => {+ initKeaTests()+ featureFlagLogic.mount()+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.TODAY_RAIL_NAV], {+ [FEATURE_FLAGS.TODAY_RAIL_NAV]: true,+ })+ sceneLogic.mount()+ const logic = todayPeopleRecentsLogic()+ logic.mount()+ const sceneActions = sceneLogic.actions as any++ // Like the cohort and group scene logics, the selector reads the record id from its props.+ sceneActions.setActiveLoadedScene({+ sceneParams: { params: { id: '7' } },+ paramsToProps: ({ params }: { params: { id: string } }) => ({ id: params.id }),+ })+ sceneActions.setActiveSceneLogic({+ selectors: {+ [TODAY_PEOPLE_RECENT_KEY]: (_: unknown, props: { id?: string }) =>+ props.id ? recent(`/cohorts/${props.id}`, `Cohort ${props.id}`) : null,+ },+ })++ expect(logic.values.recents).toEqual([recent('/cohorts/7', 'Cohort 7')])+ })++ it('stores a recent, newest first, and lists the rows by name', () => {+ initKeaTests()+ const logic = todayPeopleRecentsLogic()+ logic.mount()++ logic.actions.addRecent(recent('/cohorts/1'))+ logic.actions.addRecent(recent('/cohorts/2'))++ expect(logic.values.recents.map((item) => item.href)).toEqual(['/cohorts/2', '/cohorts/1'])+ expect(logic.values.recentRows.map((item) => item.href)).toEqual(['/cohorts/1', '/cohorts/2'])+ })+})diff --git a/frontend/src/layout/today/todayPeopleRecentsLogic.ts b/frontend/src/layout/today/todayPeopleRecentsLogic.tsnew file mode 100644index 000000000000..3aa2189e2808--- /dev/null+++ b/frontend/src/layout/today/todayPeopleRecentsLogic.ts@@ -0,0 +1,117 @@+import { MakeLogicType, actions, connect, kea, path, reducers, selectors } from 'kea'+import { subscriptions } from 'kea-subscriptions'++import { FEATURE_FLAGS } from 'lib/constants'+import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { objectsEqual } from 'lib/utils/objects'+import { sceneLogic } from 'scenes/sceneLogic'++import { newestByName } from './todayNewestByName'+import { TODAY_PEOPLE_RECENT_KEY, TodayPeopleRecent } from './todayPeople'+import { TODAY_USER_PERSIST_OPTIONS } from './todayUserPersistOptions'++export const TODAY_PEOPLE_RECENTS_LIMIT = 10++/** Puts a visit first. Reloading the same page changes nothing, so the list stays stable while a page loads. */+export function addPeopleRecent(recents: TodayPeopleRecent[], recent: TodayPeopleRecent): TodayPeopleRecent[] {+ const [first] = recents+ if (first?.href === recent.href && first.name === recent.name) {+ return recents+ }+ return [recent, ...recents.filter((item) => item.href !== recent.href)].slice(0, TODAY_PEOPLE_RECENTS_LIMIT)+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface todayPeopleRecentsLogicValues {+ featureFlags: FeatureFlagsSet // featureFlagLogic+ currentRecent: TodayPeopleRecent | null+ recentRows: TodayPeopleRecent[]+ recents: TodayPeopleRecent[]+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface todayPeopleRecentsLogicActions {+ addRecent: (recent: TodayPeopleRecent) => {+ recent: TodayPeopleRecent+ }+}++// Generated by kea-typegen. Update if you're an agent, ignore if you're human.+export interface todayPeopleRecentsLogicMeta {+ __keaTypeGenInternalSelectorTypes: {+ currentRecent: (featureFlags: FeatureFlagsSet, arg: TodayPeopleRecent | null) => TodayPeopleRecent | null+ recentRows: (recents: TodayPeopleRecent[]) => TodayPeopleRecent[]+ }+}++export type todayPeopleRecentsLogicType = MakeLogicType<+ todayPeopleRecentsLogicValues,+ todayPeopleRecentsLogicActions,+ Record<string, any>,+ todayPeopleRecentsLogicMeta+>++/** Mounted with the shell, so a person opened from any pane counts. */+export const todayPeopleRecentsLogic = kea<todayPeopleRecentsLogicType>([+ path(['layout', 'today', 'todayPeopleRecentsLogic']),+ connect(() => ({+ values: [featureFlagLogic, ['featureFlags']],+ logic: [sceneLogic],+ })),+ actions({+ addRecent: (recent: TodayPeopleRecent) => ({ recent }),+ }),+ reducers({+ recents: [+ [] as TodayPeopleRecent[],+ TODAY_USER_PERSIST_OPTIONS,+ {+ addRecent: (state, { recent }) => addPeopleRecent(state, recent),+ },+ ],+ }),+ selectors({+ // Similar to "breadcrumbs" in breadcrumbsLogic: the selector of whichever scene logic is active.+ currentRecent: [+ (s) => [+ s.featureFlags,+ (state, props): TodayPeopleRecent | null => {+ const activeSceneLogic = sceneLogic.selectors.activeSceneLogic(state, props)+ if (!activeSceneLogic || !(TODAY_PEOPLE_RECENT_KEY in activeSceneLogic.selectors)) {+ return null+ }+ const activeLoadedScene = sceneLogic.selectors.activeLoadedScene(state, props)+ try {+ return activeSceneLogic.selectors[TODAY_PEOPLE_RECENT_KEY](+ state,+ activeLoadedScene?.paramsToProps?.(activeLoadedScene?.sceneParams) || props+ )+ } catch {+ // The scene logic may not be mounted yet.+ return null+ }+ },+ ],+ (featureFlags: FeatureFlagsSet, recent: TodayPeopleRecent | null): TodayPeopleRecent | null =>+ featureFlags[FEATURE_FLAGS.TODAY_RAIL_NAV] ? recent : null,+ { resultEqualityCheck: objectsEqual },+ ],+ recentRows: [+ (s) => [s.recents],+ (recents: TodayPeopleRecent[]): TodayPeopleRecent[] =>+ newestByName(+ recents,+ (item) => item.name,+ (item) => item.href,+ TODAY_PEOPLE_RECENTS_LIMIT+ ),+ ],+ }),+ subscriptions(({ actions }) => ({+ currentRecent: (recent: TodayPeopleRecent | null) => {+ if (recent) {+ actions.addRecent(recent)+ }+ },+ })),+])diff --git a/frontend/src/layout/today/todayPeopleRows.tsx b/frontend/src/layout/today/todayPeopleRows.tsxnew file mode 100644index 000000000000..452c24646e2e--- /dev/null+++ b/frontend/src/layout/today/todayPeopleRows.tsx@@ -0,0 +1,258 @@+import {+ IconApps,+ IconBuilding,+ IconCheckbox,+ IconFeatures,+ IconFilter,+ IconGear,+ IconLetter,+ IconMegaphone,+ IconNotebook,+ IconPeople,+ IconPerson,+ IconPulse,+} from '@posthog/icons'++import { FEATURE_FLAGS } from 'lib/constants'+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'+import { FeatureFlagsSet } from 'lib/logic/featureFlagLogic'+import { productHasEffectiveNoneAccess } from 'lib/utils/accessControlUtils'+import { urls } from 'scenes/urls'++import { ProductIconWrapper } from '~/layout/panel-layout/ProjectTree/defaultTree'+import { SIDEBAR_GROUP_META, SidebarProductMeta, sidebarProductCopy } from '~/layout/panel-layout/sidebarProductMeta'+import type { ResourceType } from '~/layout/scenes/components/SceneTitleSection'+import { AccessControlResourceType, FileSystemIconColor } from '~/types'++// pinned: persisted section ids and the `section` property of `people section toggled`.+export type TodayPeopleSection = 'recents' | 'groups' | 'customer-analytics'++/** A titled section under Recents. A row with no section sits on top of the pane. */+export type TodayPeopleRowSection = Exclude<TodayPeopleSection, 'recents'>++export const TODAY_PEOPLE_ROW_SECTION_LABELS: Record<TodayPeopleRowSection, string> = {+ groups: 'Groups',+ 'customer-analytics': 'Customer analytics',+}++interface TodayPeopleRowDefinition {+ label: string+ icon: JSX.Element+ iconColor?: FileSystemIconColor+ explainer: SidebarProductMeta+ section: TodayPeopleRowSection | null+ href: () => string+ /** The paths that mark the row active. The href by default. */+ paths?: () => string[]+ /** Whether the pane shows the row. The same flags gate the Customer analytics tabs it replaces. */+ enabled: (featureFlags: FeatureFlagsSet) => boolean+}++const productColor = (product: string): FileSystemIconColor => [+ `var(--color-product-${product}-light)`,+ `var(--color-product-${product}-dark)`,+]++const always = (): boolean => true++/** On with the Customer analytics flag and every flag given. */+const withCustomerAnalytics =+ (...flags: (typeof FEATURE_FLAGS)[keyof typeof FEATURE_FLAGS][]) =>+ (featureFlags: FeatureFlagsSet): boolean =>+ !!featureFlags[FEATURE_FLAGS.CUSTOMER_ANALYTICS] && flags.every((flag) => !!featureFlags[flag])++/**+ * Every fixed row of the People pane, in pane order. Group types sit after Accounts, and `peopleSidebarRows` adds+ * them. One place holds what a row is, so the pane, its hover cards and the pages' headers cannot drift apart.+ */+// pinned: the keys are part of the row's `people-sidebar-<row>` data-attr.+export const TODAY_PEOPLE_ROWS = {+ overview: {+ label: 'Overview',+ icon: <IconApps />,+ explainer: {+ description:+ 'See how your customers use your product. Follow active users, sessions, and signups on one dashboard.',+ example: 'Check how many free users became paying customers this month.',+ docsHref: 'https://posthog.com/docs/customer-analytics',+ },+ section: null,+ href: () => urls.customerAnalyticsDashboard(),+ enabled: withCustomerAnalytics(),+ },+ feed: {+ label: 'Feed',+ icon: <IconPulse />,+ explainer: {+ description: 'Review the account changes that customer analytics scouts report.',+ example: 'See which accounts changed since last week.',+ },+ section: 'customer-analytics',+ href: () => urls.customerAnalyticsFeed(),+ enabled: withCustomerAnalytics(FEATURE_FLAGS.CUSTOMER_ANALYTICS_CSP),+ },+ tasks: {+ label: 'Tasks',+ icon: <IconCheckbox />,+ explainer: {+ description: 'See the work assigned to you across customer accounts.',+ example: 'Follow up with an account after a call.',+ },+ section: 'customer-analytics',+ href: () => urls.customerAnalyticsTasks(),+ enabled: withCustomerAnalytics(FEATURE_FLAGS.CUSTOMER_ANALYTICS_CUSTOMER_TASKS),+ },+ persons: {+ label: 'Persons',+ icon: <IconPerson />,+ iconColor: productColor('product-analytics'),+ explainer: sidebarProductCopy('Persons'),+ section: null,+ href: () => urls.persons(),+ paths: () => [urls.persons(), '/person'],+ enabled: always,+ },+ // With customer-analytics-csp this is the Customer analytics accounts page. Without it, `peopleSidebarRows`+ // points it at the account group type.+ accounts: {+ label: 'Accounts',+ icon: <IconBuilding />,+ iconColor: productColor('sources'),+ explainer: {+ description: 'Browse the companies that use your product and the activity behind each one.',+ example: SIDEBAR_GROUP_META.example,+ },+ section: null,+ href: () => urls.customerAnalyticsAccounts(),+ enabled: withCustomerAnalytics(FEATURE_FLAGS.CUSTOMER_ANALYTICS_CSP),+ },+ cohorts: {+ label: 'Cohorts',+ icon: <IconPeople />,+ iconColor: productColor('data-warehouse'),+ explainer: { ...sidebarProductCopy('Cohorts'), docsHref: 'https://posthog.com/docs/data/cohorts' },+ section: null,+ href: () => urls.cohorts(),+ enabled: always,+ },+ journeys: {+ label: 'Journeys',+ icon: <IconFilter />,+ iconColor: productColor('customer-analytics'),+ explainer: {+ description: 'Map the steps customers take through your product and see where they drop off.',+ example: 'See where new users stop on the way to their first purchase.',+ },+ section: 'customer-analytics',+ href: () => urls.customerAnalyticsJourneys(),+ enabled: withCustomerAnalytics(FEATURE_FLAGS.CUSTOMER_ANALYTICS_JOURNEYS),+ },+ notes: {+ label: 'Notes',+ icon: <IconNotebook />,+ explainer: {+ description: 'Keep notes about your customer accounts in one place, and search them later.',+ example: 'Record what an account asked for on a call.',+ },+ section: 'customer-analytics',+ href: () => urls.customerAnalyticsNotes(),+ enabled: withCustomerAnalytics(FEATURE_FLAGS.CUSTOMER_ANALYTICS_CSP),+ },+ announcements: {+ label: 'Announcements',+ icon: <IconMegaphone />,+ explainer: {+ description: 'Share product news with your customers.',+ example: 'Tell customers about a new feature.',+ },+ section: 'customer-analytics',+ href: () => urls.customerAnalyticsAnnouncements(),+ enabled: withCustomerAnalytics(FEATURE_FLAGS.CUSTOMER_ANALYTICS_CSP),+ },+ feature_requests: {+ label: 'Feature requests',+ icon: <IconFeatures />,+ explainer: {+ description: 'Track what customers ask you to build, and which accounts asked for it.',+ example: 'See which accounts want a new integration.',+ },+ section: 'customer-analytics',+ href: () => urls.customerAnalyticsFeatureRequests(),+ enabled: withCustomerAnalytics(FEATURE_FLAGS.CUSTOMER_ANALYTICS_FEATURE_REQUESTS),+ },+ configure: {+ label: 'Configure',+ icon: <IconGear />,+ explainer: {+ description:+ 'Choose the events and group type that customer analytics uses for its dashboards and accounts.',+ example: 'Pick the event that counts as a signup.',+ docsHref: 'https://posthog.com/docs/customer-analytics',+ },+ section: 'customer-analytics',+ href: () => urls.customerAnalyticsConfiguration(),+ enabled: withCustomerAnalytics(),+ },+ support: {+ label: 'Tickets',+ icon: <IconLetter />,+ explainer: {+ description: 'Read and reply to the support tickets your customers send.',+ example: 'Reply to a customer who reported a bug.',+ docsHref: 'https://posthog.com/docs/support',+ },+ section: null,+ href: () => urls.supportTickets(),+ paths: () => [urls.supportDashboard()],+ // Without Ticket access the page only says access denied.+ enabled: () => !productHasEffectiveNoneAccess(AccessControlResourceType.Ticket),+ },+} satisfies Record<string, TodayPeopleRowDefinition>++export type TodayPeopleStaticRowKey = keyof typeof TODAY_PEOPLE_ROWS++const rowDefinition = (key: TodayPeopleStaticRowKey): TodayPeopleRowDefinition => TODAY_PEOPLE_ROWS[key]++/** Group type rows share one icon. Their names belong to each project. */+export const TODAY_PEOPLE_GROUP_ICON = <IconBuilding />++/** The icon of a People pane row. */+export function todayPeopleRowIcon(key: TodayPeopleStaticRowKey): JSX.Element {+ const { icon, iconColor } = rowDefinition(key)+ return iconColor ? (+ <ProductIconWrapper type="default_icon_type" colorOverride={iconColor}>+ {icon}+ </ProductIconWrapper>+ ) : (+ icon+ )+}++/** The name of a page's People pane row under today-rail-nav, else null. For selectors, like breadcrumbs. */+export function todayPeopleRowLabel(featureFlags: FeatureFlagsSet, key: TodayPeopleStaticRowKey): string | null {+ return featureFlags[FEATURE_FLAGS.TODAY_RAIL_NAV] ? rowDefinition(key).label : null+}++export interface TodayPeopleTitle {+ name: string | null+ resourceType: ResourceType+}++/**+ * The scene title of a page under today-rail-nav: its People pane row's name and icon, so the header matches the nav.+ * Null with the flag off, so a page keeps its own title. A group type page passes 'group' and keeps its own name.+ */+export function useTodayPeopleTitle(key: TodayPeopleStaticRowKey | 'group'): TodayPeopleTitle | null {+ const todayRailNav = useFeatureFlag('TODAY_RAIL_NAV')+ if (!todayRailNav) {+ return null+ }+ if (key === 'group') {+ return { name: null, resourceType: { type: 'group', forceIcon: TODAY_PEOPLE_GROUP_ICON } }+ }+ const { label, icon, iconColor } = rowDefinition(key)+ return {+ name: label,+ resourceType: { type: 'default_icon_type', forceIcon: icon, forceIconColorOverride: iconColor },+ }+}diff --git a/frontend/src/layout/today/todayProductsLogic.test.ts b/frontend/src/layout/today/todayProductsLogic.test.tsindex 2efd2dac4891..bbc0766c99b2 100644--- a/frontend/src/layout/today/todayProductsLogic.test.ts+++ b/frontend/src/layout/today/todayProductsLogic.test.ts@@ -1,7 +1,15 @@+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { urls } from 'scenes/urls'+import { getNavProductItems } from '~/layout/panel-layout/navbar/tabs/navProductItems'+import { useMocks } from '~/mocks/jest'import { FileSystemEntry, FileSystemImport } from '~/queries/schema/schema-general'+import { initKeaTests } from '~/test/init'+import { ReplayTabs } from '~/types'-import { resolveStarredProducts } from './todayProductsLogic'+import { isPeopleListPath } from './todayPeople'+import { resolveStarredProducts, todayProductsLogic } from './todayProductsLogic'const productShortcut = (id: string, path: string, href?: string): FileSystemEntry =>({ id, path, type: 'product', href }) as FileSystemEntry@@ -23,4 +31,32 @@ describe('todayProductsLogic', () => {'Product analytics',])})++ it('leaves Persons, Customer analytics and Support to the People pane', () => {+ useMocks({ get: { '/api/projects/:team_id/file_system_shortcut/': { results: [] } } })+ initKeaTests()+ const flags = { [FEATURE_FLAGS.TODAY_RAIL_NAV]: true, [FEATURE_FLAGS.CUSTOMER_ANALYTICS]: true }+ featureFlagLogic.actions.setFeatureFlags(Object.keys(flags), flags)+ const logic = todayProductsLogic()+ logic.mount()++ const hrefs = logic.values.products.map((item) => item.href)+ expect(hrefs).not.toContain(urls.persons())+ expect(hrefs).not.toContain(urls.customerAnalytics())+ expect(hrefs).not.toContain(urls.supportTickets())+ expect(hrefs).toContain(urls.replay(ReplayTabs.Home))+ })++ // Cohorts and groups are not products in the Products pane, so the rule is tested on the paths.+ test.each([+ [urls.cohorts(), true],+ [urls.groups(0), true],+ ['/groups/0/new', true],+ [urls.supportTickets(), true],+ [urls.cohort(5), false],+ ['/groups/0/acme', false],+ ['/groups/0/acme/events', false],+ ])('isPeopleListPath(%s) is %s', (path, listed) => {+ expect(isPeopleListPath(path)).toBe(listed)+ })})diff --git a/frontend/src/layout/today/todayProductsLogic.ts b/frontend/src/layout/today/todayProductsLogic.tsindex fc66cf60b88c..cccff6fe95e7 100644--- a/frontend/src/layout/today/todayProductsLogic.ts+++ b/frontend/src/layout/today/todayProductsLogic.ts@@ -18,6 +18,8 @@ import { projectTreeDataLogic } from '~/layout/panel-layout/ProjectTree/projectTimport { findProductShortcut } from '~/layout/panel-layout/ProjectTree/utils'import { FileSystemEntry, FileSystemImport } from '~/queries/schema/schema-general'+import { isPeopleListPath } from './todayPeople'+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface todayProductsLogicValues {featureFlags: FeatureFlagsSet // featureFlagLogic@@ -117,6 +119,11 @@ export function resolveStarredProducts(})}+function peoplePaneListsProduct(item: FileSystemImport): boolean {+ const href = item.href?.split(/[?#]/)[0]+ return !!href && isPeopleListPath(href)+}+export const todayProductsLogic = kea<todayProductsLogicType>([path(['layout', 'today', 'todayProductsLogic']),connect(() => ({@@ -147,12 +154,15 @@ export const todayProductsLogic = kea<todayProductsLogicType>([],}),selectors({- // The same list as the Products tab of the current navigation. Home has its own rail item.+ // The same list as the Products tab of the current navigation. Home and People have their own rail items.products: [(s) => [s.featureFlags],(featureFlags: FeatureFlagsSet): FileSystemImport[] =>getNavProductItems(featureFlags).filter(- (item) => item.href !== urls.projectRoot() && !getProductAccessDisabledReason(item)+ (item) =>+ item.href !== urls.projectRoot() &&+ !getProductAccessDisabledReason(item) &&+ !peoplePaneListsProduct(item)),],pinnedProducts: [diff --git a/frontend/src/layout/today/todayRailItems.tsx b/frontend/src/layout/today/todayRailItems.tsxindex a8a258c2ae8b..2701138a4f0a 100644--- a/frontend/src/layout/today/todayRailItems.tsx+++ b/frontend/src/layout/today/todayRailItems.tsx@@ -1,10 +1,11 @@-import { IconApps, IconChat, IconGear, IconHome, IconSidebarClose, IconSidebarOpen } from '@posthog/icons'+import { IconApps, IconChat, IconGear, IconHome, IconPeople, IconSidebarClose, IconSidebarOpen } from '@posthog/icons'import { IconAnalyticsBars } from 'lib/lemon-ui/icons'import { isMac } from 'lib/utils/dom'import { TodayNewAnalyticsButton } from './TodayNewAnalyticsButton'import { TodayNewChatButton } from './TodayNewChatButton'+import { TodayNewPeopleButton } from './TodayNewPeopleButton'import type { TodayRailPane } from './todayShellLogic'export interface TodayPane {@@ -24,11 +25,11 @@ export const TODAY_PANES: Record<TodayRailPane, TodayPane> = {action: TodayNewChatButton,},analytics: { label: 'Analytics', title: 'Analytics', icon: <IconAnalyticsBars />, action: TodayNewAnalyticsButton },+ people: { label: 'People', title: 'People', icon: <IconPeople />, action: TodayNewPeopleButton },products: { label: 'Products', title: 'Products', icon: <IconApps /> },settings: { label: 'Settings', title: 'Settings', icon: <IconGear /> },}-export const TODAY_RAIL_PANES: TodayRailPane[] = ['home', 'spaces', 'analytics', 'products']export const TODAY_RAIL_FOOTER_PANES: TodayRailPane[] = ['settings']export function todaySidebarShortcutLabel(): string {diff --git a/frontend/src/layout/today/todayShellLogic.test.ts b/frontend/src/layout/today/todayShellLogic.test.tsindex 8df408f7aa8e..d99a3ad7b505 100644--- a/frontend/src/layout/today/todayShellLogic.test.ts+++ b/frontend/src/layout/today/todayShellLogic.test.ts@@ -47,7 +47,7 @@ describe('todayShellLogic', () => {['/project/1/dashboard/12', 'analytics'],['/project/1/notebooks', 'analytics'],['/project/1/dashboard', 'analytics'],- ['/project/1/persons', 'products'],+ ['/project/1/persons', 'people'],['/project/1/activity/events', 'products'],['/project/1/settings/project-replay', 'settings'],['/organization/billing/overview', 'settings'],@@ -59,6 +59,65 @@ describe('todayShellLogic', () => {expect(railPaneForPath(pathname)).toBe(pane)})+ test.each([+ ['/project/1/persons/0190-uuid', 'people'],+ ['/project/1/person/ada%40example.com', 'people'],+ ['/project/1/cohorts', 'people'],+ ['/project/1/cohorts/5', 'people'],+ ['/project/1/groups/0', 'people'],+ ['/project/1/groups/0/acme', 'people'],+ ['/project/1/customer_analytics/dashboard', 'people'],+ ['/project/1/customer_analytics/journeys', 'people'],+ ['/project/1/customer_analytics/journeys/new', 'people'],+ ['/project/1/customer_analytics/accounts', 'people'],+ ['/project/1/customer_analytics/accounts/1', 'people'],+ ['/project/1/customer_analytics/feed', 'people'],+ ['/project/1/support/tickets', 'people'],+ ['/project/1/support/tickets/12', 'people'],+ ['/project/1/customer_analytics/configuration', 'people'],+ ])('puts %s under %s', (pathname, pane) => {+ expect(railPaneForPath(pathname)).toBe(pane)+ })++ test.each([+ ['/project/1/person/ada%40example.com', 'analytics'],+ ['/project/1/persons/0190-uuid', 'analytics'],+ ['/project/1/groups/0/acme', 'analytics'],+ ['/project/1/cohorts/5', 'analytics'],+ ['/project/1/persons', 'people'],+ ['/project/1/groups/0', 'people'],+ ['/project/1/cohorts', 'people'],+ ])('%s opened from an insight shows the %s pane', (pathname, pane) => {+ router.actions.push('/project/1/insights/abc')+ const logic = todayShellLogic()+ logic.mount()++ router.actions.push(pathname)+ expect(logic.values.activePane).toBe(pane)+ })++ test.each([+ ['a rail pick on Analytics', '/project/1/airplane', 'analytics', 'analytics'],+ ['a fresh load of an insight', '/project/1/insights/abc', null, 'analytics'],+ ['a rail pick on Products', '/project/1/airplane', 'products', 'people'],+ ] as const)(+ 'a person opened after %s (from %s, %s picked) shows the %s pane, and the persons list shows People',+ (_, startPath, pickedPane, pane) => {+ router.actions.push(startPath)+ const logic = todayShellLogic()+ logic.mount()++ if (pickedPane) {+ logic.actions.pickPane(pickedPane)+ }+ router.actions.push('/project/1/person/ada%40example.com')+ expect(logic.values.activePane).toBe(pane)++ router.actions.push('/project/1/persons')+ expect(logic.values.activePane).toBe('people')+ }+ )+test.each([['/data-management/destinations', '/data-management/destinations?tab=all'],['/data-management/destinations/abc', '/data-management/destinations?tab=all'],@@ -119,15 +178,26 @@ describe('todayShellLogic', () => {})test.each([- ['home', 'new', urls.projectHomepage()],- ['spaces', 'new', urls.taskNewSession()],- ['spaces', 'legacy', urls.ai()],- ['analytics', 'new', urls.analyticsList()],- ['products', 'new', undefined],- ['settings', 'new', urls.settings('project')],- ] as const)('a rail pick on %s with the %s PostHog AI view opens %s', (pane, phaiView, href) => {- expect(railPaneHref(pane, phaiView)).toBe(href)- })+ ['home', 'new', {}, urls.projectHomepage()],+ ['spaces', 'new', {}, urls.taskNewSession()],+ ['spaces', 'legacy', {}, urls.ai()],+ ['analytics', 'new', {}, urls.analyticsList()],+ ['products', 'new', {}, undefined],+ ['settings', 'new', {}, urls.settings('project')],+ ['people', 'new', {}, urls.persons()],+ ['people', 'new', { [FEATURE_FLAGS.CUSTOMER_ANALYTICS]: true }, urls.customerAnalyticsDashboard()],+ [+ 'people',+ 'new',+ { [FEATURE_FLAGS.CUSTOMER_ANALYTICS]: true, [FEATURE_FLAGS.CUSTOMER_ANALYTICS_CSP]: true },+ urls.customerAnalyticsDashboard(),+ ],+ ] as const)(+ 'a rail pick on %s with the %s PostHog AI view and flags %o opens %s',+ (pane, phaiView, flags, href) => {+ expect(railPaneHref(pane, phaiView, flags)).toBe(href)+ }+ )test.each(['spaces', 'analytics', 'products'] as const)('a second rail click on %s hides the sidebar it opened',diff --git a/frontend/src/layout/today/todayShellLogic.ts b/frontend/src/layout/today/todayShellLogic.tsindex c09b33fcc9e4..b9a12104b8da 100644--- a/frontend/src/layout/today/todayShellLogic.ts+++ b/frontend/src/layout/today/todayShellLogic.ts@@ -19,7 +19,10 @@ import { navigationLogic } from '~/layout/navigation/navigationLogic'import { getNavProductPages, navProductHrefForPath } from '~/layout/panel-layout/navbar/tabs/navProductItems'import { FileSystemImport } from '~/queries/schema/schema-general'-export type TodayRailPane = 'home' | 'spaces' | 'analytics' | 'products' | 'settings'+import { isPeopleDetailPath, isPeopleListPath } from './todayPeople'+import { todayPeopleRecentsLogic } from './todayPeopleRecentsLogic'++export type TodayRailPane = 'home' | 'spaces' | 'analytics' | 'people' | 'products' | 'settings'/** What showed or hid the sidebar. `navigation` is a page change that hides the unpinned sidebar. */export type TodaySidebarToggleSource =@@ -50,17 +53,28 @@ export function todayNewChatUrl(effectivePhaiView: PhaiViewMode): string {return effectivePhaiView === 'new' ? urls.taskNewSession() : urls.ai()}+export const TODAY_RAIL_PANES: TodayRailPane[] = ['home', 'spaces', 'analytics', 'people', 'products']+/** The page a rail pick opens. Without one, a pick only opens the sidebar and the open page stays. */-const RAIL_PANE_HOMES: Partial<Record<TodayRailPane, (effectivePhaiView: PhaiViewMode) => string>> = {+const RAIL_PANE_HOMES: Partial<+ Record<TodayRailPane, (effectivePhaiView: PhaiViewMode, featureFlags: FeatureFlagsSet) => string>+> = {home: () => urls.projectHomepage(),spaces: todayNewChatUrl,analytics: () => urls.analyticsList(),+ // Not urls.customerAnalytics(): that redirect opens the Accounts page when customer-analytics-csp is on.+ people: (_, featureFlags) =>+ featureFlags[FEATURE_FLAGS.CUSTOMER_ANALYTICS] ? urls.customerAnalyticsDashboard() : urls.persons(),settings: () => urls.settings('project'),}/** The page a rail pane opens, or undefined when the pane only opens the sidebar. */-export function railPaneHref(pane: TodayRailPane, effectivePhaiView: PhaiViewMode): string | undefined {- return RAIL_PANE_HOMES[pane]?.(effectivePhaiView)+export function railPaneHref(+ pane: TodayRailPane,+ effectivePhaiView: PhaiViewMode,+ featureFlags: FeatureFlagsSet+): string | undefined {+ return RAIL_PANE_HOMES[pane]?.(effectivePhaiView, featureFlags)}const PHONE_PAGE_LIMIT = 50@@ -94,6 +108,9 @@ export function railPaneForPath(pathname: string): TodayRailPane | null {if (isUnderPath(path, '/ai') || isUnderPath(path, '/spaces')) {return 'spaces'}+ if (isPeopleListPath(path) || isPeopleDetailPath(path)) {+ return 'people'+ }// Notebooks, dashboards and insights are analytics, list pages included, so they never open the Products pane.if (isUnderPath(path, urls.analytics()) ||@@ -127,14 +144,25 @@ function productsPaneListsPath(path: string): boolean {return !!navProductHrefForPath(path, navProductPages)}-/** The pane to show after a page change: a page both panes list keeps the Products pane when it is open. */-function paneAfterNavigation(openPane: TodayRailPane | null, pathname: string): TodayRailPane | null {+/**+ * The pane to show after a page change. A page both panes list keeps the Products pane when it is open. A person,+ * group or cohort opened while Analytics shows keeps Analytics, so a drill-in from an insight does not switch the+ * rail. `shownPane` is the pane on screen before the change, which is the route's pane when nothing was picked.+ */+function paneAfterNavigation(+ openPane: TodayRailPane | null,+ pathname: string,+ shownPane: TodayRailPane | null+): TodayRailPane | null {+ const path = removeProjectIdIfPresent(pathname)const routePane = railPaneForPath(pathname)- return openPane === 'products' &&- routePane === 'analytics' &&- productsPaneListsPath(removeProjectIdIfPresent(pathname))- ? openPane- : (routePane ?? openPane)+ if (openPane === 'products' && routePane === 'analytics' && productsPaneListsPath(path)) {+ return openPane+ }+ if (shownPane === 'analytics' && routePane === 'people' && isPeopleDetailPath(path)) {+ return shownPane+ }+ return routePane ?? openPane}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -208,6 +236,9 @@ export interface todayShellLogicActions {setPhonePages: (pages: TodayPhonePage[]) => {pages: TodayPhonePage[]}+ setPickedPane: (pane: TodayRailPane | null) => {+ pane: TodayRailPane | null+ }setSidebarOpen: (open: boolean) => {open: boolean}@@ -291,10 +322,12 @@ export const todayShellLogic = kea<todayShellLogicType>([['mobileLayout'],],actions: [router, ['locationChanged']],+ logic: [todayPeopleRecentsLogic],})),actions({rememberSceneUrl: (location: { pathname: string; search: string; hash: string }) => ({ location }),pickPane: (pane: TodayRailPane) => ({ pane }),+ setPickedPane: (pane: TodayRailPane | null) => ({ pane }),goBackOnPhone: true,setPhonePages: (pages: TodayPhonePage[]) => ({ pages }),setMobileSidebarOpen: (open: boolean) => ({ open }),@@ -309,11 +342,12 @@ export const todayShellLogic = kea<todayShellLogicType>([})),reducers({// The last pane picked on the rail, or reached through a route that belongs to one, stays open on other pages.+ // The locationChanged listener sets it after a page change, because the drill-in rule reads the previous page from the cache.pickedPane: [null as TodayRailPane | null,{pickPane: (_, { pane }) => pane,- locationChanged: (state, { pathname }) => paneAfterNavigation(state, pathname),+ setPickedPane: (_, { pane }) => pane,},],sidebarOpen: [@@ -447,6 +481,9 @@ export const todayShellLogic = kea<todayShellLogicType>([})},locationChanged: ({ method, pathname }) => {+ const { pickedPane } = values+ const shownPane = pickedPane ?? railPaneForPath(cache.lastPathname ?? '')+ actions.setPickedPane(paneAfterNavigation(pickedPane, pathname, shownPane))const pageChanged = method === 'PUSH' && pathname !== cache.lastPathnamecache.lastPathname = pathname// An unpinned sidebar gives the new page room. The drawer closes on its own, and a rail pick wants it open.@@ -498,7 +535,7 @@ export const todayShellLogic = kea<todayShellLogicType>([pickPane: ({ pane }) => {// pinned: analytics event name and property. Renaming them breaks dashboards.posthog.capture('today rail pane picked', { pane, phone_layout: values.phoneLayout })- const href = railPaneHref(pane, values.effectivePhaiView)+ const href = railPaneHref(pane, values.effectivePhaiView, values.featureFlags)if (href) {cache.pickingPane = truerouter.actions.push(href)diff --git a/frontend/src/layout/today/todayUserPersistOptions.ts b/frontend/src/layout/today/todayUserPersistOptions.tsnew file mode 100644index 000000000000..4805f91ea8b0--- /dev/null+++ b/frontend/src/layout/today/todayUserPersistOptions.ts@@ -0,0 +1,11 @@+import { getCurrentTeamIdOrNone, getCurrentUserIdOrNone } from 'lib/utils/getAppContext'++const TEAM_ID = getCurrentTeamIdOrNone()+const USER_ID = getCurrentUserIdOrNone()++/**+ * Kea persist options for state that belongs to one person in one project. Without both ids nothing persists, so one+ * account never sees another's.+ */+export const TODAY_USER_PERSIST_OPTIONS =+ TEAM_ID && USER_ID ? { persist: true, prefix: `${TEAM_ID}__${USER_ID}__` } : { persist: false }diff --git a/frontend/src/models/groupTabs.ts b/frontend/src/models/groupTabs.tsnew file mode 100644index 000000000000..71190218a88a--- /dev/null+++ b/frontend/src/models/groupTabs.ts@@ -0,0 +1,50 @@+import { GroupsAccessStatus } from 'lib/introductions/groupsAccessLogic'+import { capitalizeFirstLetter } from 'lib/utils/strings'+import { urls } from 'scenes/urls'++import type { FileSystemIconType } from '~/queries/schema/schema-general'+import type { GroupType, GroupTypeIndex } from '~/types'++import type { Noun } from './groupsModel'++export interface GroupTab {+ key: `groups-${number}`+ label: string+ url: string+ iconType: FileSystemIconType+ // pinned: autocapture dashboards and Playwright select these tabs by data-attr+ dataAttr: string+}++/** One tab for each group type, or one introduction tab when the project cannot use groups yet. */+export function groupTabs(+ groupTypes: Map<GroupTypeIndex, GroupType>,+ groupsAccessStatus: GroupsAccessStatus,+ aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun+): GroupTab[] {+ const showGroupsIntroductionPage = [+ GroupsAccessStatus.HasAccess,+ GroupsAccessStatus.HasGroupTypes,+ GroupsAccessStatus.NoAccess,+ ].includes(groupsAccessStatus)++ if (showGroupsIntroductionPage) {+ return [+ {+ key: 'groups-0',+ label: 'Groups',+ url: urls.groups(0),+ iconType: 'group',+ dataAttr: 'persons-management-groups-0-tab',+ },+ ]+ }++ return Array.from(groupTypes.values()).map(({ group_type_index }) => ({+ key: `groups-${group_type_index}`,+ label: capitalizeFirstLetter(aggregationLabel(group_type_index).plural),+ url: urls.groups(group_type_index),+ iconType: `group_${group_type_index}` as FileSystemIconType,+ dataAttr: `persons-management-groups-${group_type_index}-tab`,+ }))+}diff --git a/frontend/src/scenes/activity/ActivitySceneTabs.test.tsx b/frontend/src/scenes/activity/ActivitySceneTabs.test.tsxnew file mode 100644index 000000000000..bc28941293a2--- /dev/null+++ b/frontend/src/scenes/activity/ActivitySceneTabs.test.tsx@@ -0,0 +1,47 @@+import '@testing-library/jest-dom'++import { cleanup, render, screen } from '@testing-library/react'+import { Provider } from 'kea'++import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'++import { initKeaTests } from '~/test/init'+import { ActivityTab } from '~/types'++import { ActivitySceneTabs } from './ActivitySceneTabs'+import { ActivitySceneTabKey } from './activitySceneTabsLogic'++describe('ActivitySceneTabs', () => {+ beforeEach(() => {+ initKeaTests()+ featureFlagLogic.mount()+ })++ afterEach(() => {+ cleanup()+ })++ test.each([+ // The People pane links to Persons, so its page has no tabs.+ ['persons', true, false],+ [ActivityTab.ExploreEvents, true, true],+ ['persons', false, true],+ [ActivityTab.ExploreEvents, false, true],+ ] as [ActivitySceneTabKey, boolean, boolean][])(+ 'with key %s and today-rail-nav %s, shows the tabs: %s',+ (activeKey, todayRailNav, shown) => {+ featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.TODAY_RAIL_NAV], {+ [FEATURE_FLAGS.TODAY_RAIL_NAV]: todayRailNav,+ })++ render(+ <Provider>+ <ActivitySceneTabs activeKey={activeKey} />+ </Provider>+ )++ expect(screen.queryAllByRole('tab').length > 0).toBe(shown)+ }+ )+})diff --git a/frontend/src/scenes/activity/ActivitySceneTabs.tsx b/frontend/src/scenes/activity/ActivitySceneTabs.tsxindex a1be6629b06d..e40a378ec95c 100644--- a/frontend/src/scenes/activity/ActivitySceneTabs.tsx+++ b/frontend/src/scenes/activity/ActivitySceneTabs.tsx@@ -1,11 +1,18 @@import { useValues } from 'kea'+import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'import { LemonTabs } from 'lib/lemon-ui/LemonTabs'-import { ActivitySceneTabKey, activitySceneTabsLogic } from './activitySceneTabsLogic'+import { ActivitySceneTabKey, activitySceneTabsLogic, isActivityTabKey } from './activitySceneTabsLogic'-export const ActivitySceneTabs = ({ activeKey }: { activeKey: ActivitySceneTabKey }): JSX.Element => {+export const ActivitySceneTabs = ({ activeKey }: { activeKey: ActivitySceneTabKey }): JSX.Element | null => {const { tabsForKey } = useValues(activitySceneTabsLogic)+ const todayRailNav = useFeatureFlag('TODAY_RAIL_NAV')++ // The Today rail's People pane links to Persons, Cohorts and every group type.+ if (todayRailNav && !isActivityTabKey(activeKey)) {+ return null+ }return <LemonTabs activeKey={activeKey} tabs={tabsForKey(activeKey)} sceneInset className="mb-3" />}diff --git a/frontend/src/scenes/activity/activitySceneTabsLogic.tsx b/frontend/src/scenes/activity/activitySceneTabsLogic.tsxindex 5027c819199f..fdb7a7cca4d4 100644--- a/frontend/src/scenes/activity/activitySceneTabsLogic.tsx+++ b/frontend/src/scenes/activity/activitySceneTabsLogic.tsx@@ -4,13 +4,13 @@ import { FEATURE_FLAGS } from 'lib/constants'import { GroupsAccessStatus } from 'lib/introductions/groupsAccessLogic'import { LemonTab } from 'lib/lemon-ui/LemonTabs'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'-import { capitalizeFirstLetter } from 'lib/utils/strings'import { sceneConfigurations } from 'scenes/scenes'import { Scene } from 'scenes/sceneTypes'import { urls } from 'scenes/urls'import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'import { groupsModel } from '~/models/groupsModel'+import { groupTabs } from '~/models/groupTabs'import { FileSystemIconType } from '~/queries/schema/schema-general'import { ActivityTab } from '~/types'@@ -68,7 +68,7 @@ export type activitySceneTabsLogicType = MakeLogicType<activitySceneTabsLogicMeta>-function isActivityTabKey(key: ActivitySceneTabKey): boolean {+export function isActivityTabKey(key: ActivitySceneTabKey): boolean {return (Object.values(ActivityTab) as string[]).includes(key)}@@ -103,33 +103,7 @@ export const activitySceneTabsLogic = kea<activitySceneTabsLogicType>([groupTypes: Map<GroupTypeIndex, GroupType>,groupsAccessStatus: GroupsAccessStatus,aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun- ): ActivitySceneTab[] => {- const showGroupsIntroductionPage = [- GroupsAccessStatus.HasAccess,- GroupsAccessStatus.HasGroupTypes,- GroupsAccessStatus.NoAccess,- ].includes(groupsAccessStatus)-- if (showGroupsIntroductionPage) {- return [- {- key: 'groups-0',- label: 'Groups',- url: urls.groups(0),- iconType: 'group',- dataAttr: 'persons-management-groups-0-tab',- },- ]- }-- return Array.from(groupTypes.values()).map(({ group_type_index }) => ({- key: `groups-${group_type_index}`,- label: capitalizeFirstLetter(aggregationLabel(group_type_index).plural),- url: urls.groups(group_type_index),- iconType: `group_${group_type_index}` as FileSystemIconType,- dataAttr: `persons-management-groups-${group_type_index}-tab`,- }))- },+ ): ActivitySceneTab[] => groupTabs(groupTypes, groupsAccessStatus, aggregationLabel),],sceneTabs: [(s) => [s.groupTabs, s.featureFlags],diff --git a/frontend/src/scenes/cohorts/cohortSceneLogic.test.ts b/frontend/src/scenes/cohorts/cohortSceneLogic.test.tsnew file mode 100644index 000000000000..2640a1f0a7bc--- /dev/null+++ b/frontend/src/scenes/cohorts/cohortSceneLogic.test.ts@@ -0,0 +1,31 @@+import { urls } from 'scenes/urls'++import { useMocks } from '~/mocks/jest'+import { cohortsModel } from '~/models/cohortsModel'+import { initKeaTests } from '~/test/init'+import { CohortType } from '~/types'++import { cohortSceneLogic } from './cohortSceneLogic'++describe('cohortSceneLogic', () => {+ beforeEach(() => {+ useMocks({ get: { '/api/projects/:team_id/cohorts/': { count: 0, results: [] } } })+ initKeaTests()+ cohortsModel.mount()+ })++ it('gives the loaded cohort as a People recent', () => {+ cohortsModel.actions.updateCohort({ id: 5, name: 'Churned' } as CohortType)+ const logic = cohortSceneLogic({ id: 5 })+ logic.mount()++ expect(logic.values.todayPeopleRecent).toEqual({ type: 'cohort', name: 'Churned', href: urls.cohort(5) })+ })++ it('gives no recent for a new cohort', () => {+ const logic = cohortSceneLogic({ id: 'new' })+ logic.mount()++ expect(logic.values.todayPeopleRecent).toBeNull()+ })+})diff --git a/frontend/src/scenes/cohorts/cohortSceneLogic.ts b/frontend/src/scenes/cohorts/cohortSceneLogic.tsindex 76076a47064f..b8f032a6a680 100644--- a/frontend/src/scenes/cohorts/cohortSceneLogic.ts+++ b/frontend/src/scenes/cohorts/cohortSceneLogic.ts@@ -4,6 +4,7 @@ import { Scene } from 'scenes/sceneTypes'import { urls } from 'scenes/urls'import { SIDE_PANEL_CONTEXT_KEY, SidePanelSceneContext } from '~/layout/navigation-3000/sidepanel/types'+import { TODAY_PEOPLE_RECENT_KEY, TodayPeopleRecent } from '~/layout/today/todayPeople'import { cohortsModel } from '~/models/cohortsModel'import { ActivityScope, Breadcrumb, ProjectTreeRef } from '~/types'@@ -14,11 +15,16 @@ export interface cohortSceneLogicValues {breadcrumbs: Breadcrumb[]projectTreeRef: ProjectTreeRefsidePanelContext: SidePanelSceneContext | null+ todayPeopleRecent: TodayPeopleRecent | null}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface cohortSceneLogicMeta {__keaTypeGenInternalSelectorTypes: {+ todayPeopleRecent: (+ cohortsById: Partial<Record<number | string, import('~/types').CohortType>>,+ arg: any+ ) => TodayPeopleRecent | nullbreadcrumbs: (cohortsById: Partial<Record<number | string, import('~/types').CohortType>>,arg: CohortLogicProps['id']@@ -35,6 +41,18 @@ export const cohortSceneLogic = kea<cohortSceneLogicType>([path(['scenes', 'cohorts', 'cohortLogic']),selectors({+ [TODAY_PEOPLE_RECENT_KEY]: [+ () => [cohortsModel.selectors.cohortsById, (_, props) => props.id],+ (+ cohortsById: Partial<Record<number | string, import('~/types').CohortType>>,+ cohortId: CohortLogicProps['id']+ ): TodayPeopleRecent | null => {+ const cohort = cohortId && cohortId !== 'new' ? cohortsById[cohortId] : null+ return cohort && cohortId+ ? { type: 'cohort', name: cohort.name || 'Untitled', href: urls.cohort(cohortId) }+ : null+ },+ ],breadcrumbs: [() => [cohortsModel.selectors.cohortsById, (_, props) => props.id as CohortLogicProps['id']],(diff --git a/products/conversations/frontend/components/SupportNavBadge/index.tsx b/products/conversations/frontend/components/SupportNavBadge/index.tsxindex 1ee3df36f262..192eba147ee6 100644--- a/products/conversations/frontend/components/SupportNavBadge/index.tsx+++ b/products/conversations/frontend/components/SupportNavBadge/index.tsx@@ -10,8 +10,13 @@ export interface SupportNavBadgeProps {className?: string}+/** The unread ticket count. It mounts the counter logic, which polls only while Support is on. */+export function useSupportUnreadCount(): number {+ return useValues(supportTicketCounterLogic).unreadCount+}+export function SupportNavBadge({ className }: SupportNavBadgeProps): JSX.Element {- const { unreadCount } = useValues(supportTicketCounterLogic)+ const unreadCount = useSupportUnreadCount()return (<IconWithCount count={unreadCount} showZero={false} className={className}>diff --git a/products/conversations/frontend/scenes/ticket/SupportTicketScene.tsx b/products/conversations/frontend/scenes/ticket/SupportTicketScene.tsxindex 5bc1cea02813..c1c4a42722ef 100644--- a/products/conversations/frontend/scenes/ticket/SupportTicketScene.tsx+++ b/products/conversations/frontend/scenes/ticket/SupportTicketScene.tsx@@ -23,6 +23,7 @@ import { userLogic } from 'scenes/userLogic'import { SceneContent } from '~/layout/scenes/components/SceneContent'import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'+import { useTodayPeopleTitle } from '~/layout/today/todayPeopleRows'import { ProductKey } from '~/queries/schema/schema-general'import { AccessControlLevel, AccessControlResourceType, Breadcrumb } from '~/types'@@ -55,9 +56,9 @@ import { reportTimelineExtras } from './ThreadReports'// (the ticket row carries them through on navigation). Rebuild the list URL from// them so the back arrow returns to the view the user came from rather than the// unfiltered ticket list.-export function ticketListBackTo(searchParams: Record<string, any>): Breadcrumb {+export function ticketListBackTo(searchParams: Record<string, any>, name: string = 'Ticket list'): Breadcrumb {return {- name: 'Ticket list',+ name,path: combineUrl(urls.supportTickets(), searchParams).url,key: 'supportTickets',}@@ -167,6 +168,7 @@ export function SupportTicketScene({ ticketId }: { ticketId: string }): JSX.Elemconst { user } = useValues(userLogic)const { featureFlags } = useValues(featureFlagLogic)+ const ticketsTitle = useTodayPeopleTitle('support')const simplifiedReplies = !!featureFlags[FEATURE_FLAGS.PRODUCT_SUPPORT_SIMPLIFIED_REPLIES]// Widget tickets stay images only until the widget can render file links.const canAttachFiles =@@ -270,8 +272,8 @@ export function SupportTicketScene({ ticketId }: { ticketId: string }): JSX.Elem) : undefined}description=""- resourceType={{ type: 'conversation' }}- forceBackTo={ticketListBackTo(searchParams)}+ resourceType={ticketsTitle?.resourceType ?? { type: 'conversation' }}+ forceBackTo={ticketListBackTo(searchParams, ticketsTitle?.name ?? undefined)}/><LemonModal title="Full email" isOpen={fullEmailMessageId !== null} onClose={closeFullEmail}>{fullEmailContentLoading ? (diff --git a/products/conversations/frontend/scenes/ticket/supportTicketSceneLogic.test.ts b/products/conversations/frontend/scenes/ticket/supportTicketSceneLogic.test.tsindex c667f47e3dfa..a0850c481e07 100644--- a/products/conversations/frontend/scenes/ticket/supportTicketSceneLogic.test.ts+++ b/products/conversations/frontend/scenes/ticket/supportTicketSceneLogic.test.ts@@ -9,6 +9,7 @@ import { lemonToast } from '@posthog/lemon-ui'import { commentsLogic } from 'lib/components/Comments/commentsLogic'import { FEATURE_FLAGS } from 'lib/constants'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'+import { urls } from 'scenes/urls'import { userLogic } from 'scenes/userLogic'import { impersonationNoticeLogic } from '~/layout/navigation/ImpersonationNotice/impersonationNoticeLogic'@@ -163,6 +164,14 @@ describe('supportTicketSceneLogic ai reply feedback', () => {localStorage.removeItem(FEEDBACK_STORAGE_KEY)})+ it('gives the loaded ticket as a People recent', () => {+ expect(logic.values.todayPeopleRecent).toEqual({+ type: 'ticket',+ name: 'Ticket #42',+ href: urls.supportTicketDetail(42),+ })+ })+it('selects the latest AI message', async () => {await expectLogic(logic).toMatchValues({latestAiMessage: expect.objectContaining({ id: 'msg-ai-1', authorType: 'AI' }),diff --git a/products/conversations/frontend/scenes/ticket/supportTicketSceneLogic.ts b/products/conversations/frontend/scenes/ticket/supportTicketSceneLogic.tsindex 86218ae28f88..5564fe8d83f6 100644--- a/products/conversations/frontend/scenes/ticket/supportTicketSceneLogic.ts+++ b/products/conversations/frontend/scenes/ticket/supportTicketSceneLogic.ts@@ -40,6 +40,7 @@ import {ImpersonationTicketContext,impersonationNoticeLogic,} from '~/layout/navigation/ImpersonationNotice/impersonationNoticeLogic'+import { TODAY_PEOPLE_RECENT_KEY, TodayPeopleRecent } from '~/layout/today/todayPeople'import api, { ApiConfig } from '~/lib/api'import { PERSON_DISPLAY_NAME_COLUMN_NAME } from '~/lib/constants'import { CLOUD_HOSTNAMES } from '~/lib/constants'@@ -338,6 +339,7 @@ export interface supportTicketSceneLogicValues {ticketDeleting: booleanticketLoading: booleanticketUpdating: boolean+ todayPeopleRecent: TodayPeopleRecent | nullunsavedTicketChanges: string[]}@@ -595,6 +597,7 @@ export interface supportTicketSceneLogicProps {export interface supportTicketSceneLogicMeta {key: number | string__keaTypeGenInternalSelectorTypes: {+ todayPeopleRecent: (ticket: Ticket | null) => TodayPeopleRecent | nullbreadcrumbs: (id: number | string) => Breadcrumb[]emailReplyBlockedReason: (ticket: Ticket | null,@@ -1058,6 +1061,17 @@ export const supportTicketSceneLogic = kea<supportTicketSceneLogicType>([],}),selectors({+ [TODAY_PEOPLE_RECENT_KEY]: [+ (s) => [s.ticket],+ (ticket: Ticket | null): TodayPeopleRecent | null =>+ ticket?.ticket_number+ ? {+ type: 'ticket',+ name: `Ticket #${ticket.ticket_number}`,+ href: urls.supportTicketDetail(ticket.ticket_number),+ }+ : null,+ ],breadcrumbs: [(_, p) => [p.id],(id: number | string): Breadcrumb[] => {diff --git a/products/conversations/frontend/scenes/tickets/SupportTicketsScene.tsx b/products/conversations/frontend/scenes/tickets/SupportTicketsScene.tsxindex 1bbc98dcecf3..7362c497978e 100644--- a/products/conversations/frontend/scenes/tickets/SupportTicketsScene.tsx+++ b/products/conversations/frontend/scenes/tickets/SupportTicketsScene.tsx@@ -13,6 +13,7 @@ import { urls } from 'scenes/urls'import { SceneContent } from '~/layout/scenes/components/SceneContent'import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'+import { useTodayPeopleTitle } from '~/layout/today/todayPeopleRows'import { ProductKey } from '~/queries/schema/schema-general'import { ComposeTicketButton } from '../../components/ComposeTicket/ComposeTicketButton'@@ -196,15 +197,14 @@ export function SupportTicketsTable({ embedded = false }: SupportTicketsTableProexport function SupportTicketsScene(): JSX.Element {const { aiEnabled } = useValues(supportTicketsSceneLogic)+ const ticketsTitle = useTodayPeopleTitle('support')return (<SceneContent className="pb-4"><SceneTitleSection- name="Support"+ name={ticketsTitle?.name ?? 'Support'}description=""- resourceType={{- type: 'conversation',- }}+ resourceType={ticketsTitle?.resourceType ?? { type: 'conversation' }}actions={<ComposeTicketButton />}/>{/* pinned: survey 01a17c76-69b3-0000-bb24-4adfd734f406 targets #ai-support-feedback-button */}diff --git a/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.ts b/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.tsindex 8d89834b9f82..6595e2f2ace4 100644--- a/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.ts+++ b/products/conversations/frontend/scenes/tickets/supportTicketsSceneLogic.ts@@ -19,11 +19,13 @@ import { lemonToast } from '@posthog/lemon-ui'import api, { ApiConfig } from 'lib/api'import { Sorting } from 'lib/lemon-ui/LemonTable/sorting'+import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'import { accessLevelSatisfied } from 'lib/utils/accessControlUtils'import { objectsEqual } from 'lib/utils/objects'import { Scene } from 'scenes/sceneTypes'import { teamLogic } from 'scenes/teamLogic'+import { todayPeopleRowLabel } from '~/layout/today/todayPeopleRows'import { AccessControlLevel, AccessControlResourceType, Breadcrumb, TeamType } from '~/types'import { assigneeSelectLogic } from '../../components/Assignee'@@ -349,7 +351,7 @@ export interface supportTicketsSceneLogicActions {export interface supportTicketsSceneLogicMeta {key: string__keaTypeGenInternalSelectorTypes: {- breadcrumbs: (activeView: SavedTicketView | null) => Breadcrumb[]+ breadcrumbs: (activeView: SavedTicketView | null, featureFlags: FeatureFlagsSet) => Breadcrumb[]aiEnabled: (currentTeam: TeamType | null | import('~/types').TeamPublicType) => booleanorderBy: (sorting: Sorting | null) => stringselectedTickets: (tickets: Ticket[], selectedTicketIds: string[]) => Ticket[]@@ -597,9 +599,12 @@ export const supportTicketsSceneLogic = kea<supportTicketsSceneLogicType>([}),selectors({breadcrumbs: [- (s) => [s.activeView],- (activeView: SavedTicketView | null): Breadcrumb[] => [- { key: Scene.SupportTickets, name: activeView?.name || 'Ticket list' },+ (s) => [s.activeView, featureFlagLogic.selectors.featureFlags],+ (activeView: SavedTicketView | null, featureFlags: FeatureFlagsSet): Breadcrumb[] => [+ {+ key: Scene.SupportTickets,+ name: activeView?.name || todayPeopleRowLabel(featureFlags, 'support') || 'Ticket list',+ },],],aiEnabled: [diff --git a/products/customer_analytics/frontend/CustomerAnalyticsScene.test.tsx b/products/customer_analytics/frontend/CustomerAnalyticsScene.test.tsxindex 7723426e0755..bfecc184c52c 100644--- a/products/customer_analytics/frontend/CustomerAnalyticsScene.test.tsx+++ b/products/customer_analytics/frontend/CustomerAnalyticsScene.test.tsx@@ -102,6 +102,31 @@ describe('CustomerAnalyticsScene', () => {expect(screen.getByText(label).closest('a')).toHaveAttribute('href', `/project/997${destination}`)})+ it('hides the tab bar in the Today rail and keeps the open tab', () => {+ featureFlagLogic.actions.setFeatureFlags(+ [+ FEATURE_FLAGS.TODAY_RAIL_NAV,+ FEATURE_FLAGS.CUSTOMER_ANALYTICS,+ FEATURE_FLAGS.CUSTOMER_ANALYTICS_CUSTOMER_TASKS,+ ],+ {+ [FEATURE_FLAGS.TODAY_RAIL_NAV]: true,+ [FEATURE_FLAGS.CUSTOMER_ANALYTICS]: true,+ [FEATURE_FLAGS.CUSTOMER_ANALYTICS_CUSTOMER_TASKS]: true,+ }+ )++ render(+ <Provider>+ <CustomerAnalyticsScene />+ </Provider>+ )++ expect(document.querySelector('[data-attr="customer-analytics-tabs"]')).not.toBeInTheDocument()+ expect(screen.queryByRole('tab')).not.toBeInTheDocument()+ expect(document.querySelector('[data-attr="tasks-inbox"]')).toBeInTheDocument()+ })+it('shows the Tasks tab and inbox only when the tasks flag is enabled', () => {featureFlagLogic.actions.setFeatureFlags([FEATURE_FLAGS.CUSTOMER_ANALYTICS, FEATURE_FLAGS.CUSTOMER_ANALYTICS_CUSTOMER_TASKS],diff --git a/products/customer_analytics/frontend/CustomerAnalyticsScene.tsx b/products/customer_analytics/frontend/CustomerAnalyticsScene.tsxindex ae005adb824a..467535f8e4b8 100644--- a/products/customer_analytics/frontend/CustomerAnalyticsScene.tsx+++ b/products/customer_analytics/frontend/CustomerAnalyticsScene.tsx@@ -22,6 +22,7 @@ import { urls } from 'scenes/urls'import { FeaturePreviewSceneGate } from '~/layout/scenes/components/FeaturePreviewSceneGate'import { SceneContent } from '~/layout/scenes/components/SceneContent'import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'+import { useTodayPeopleTitle } from '~/layout/today/todayPeopleRows'import { dataNodeCollectionLogic } from '~/queries/nodes/DataNode/dataNodeCollectionLogic'import { ProductIntentContext, ProductKey } from '~/queries/schema/schema-general'import { AccessControlLevel, AccessControlResourceType } from '~/types'@@ -70,7 +71,7 @@ function CustomerAnalyticsSceneContent(): JSX.Element {const { addProductIntent } = useActions(teamLogic)const { reportCustomerAnalyticsDashboardConfigurationButtonClicked, reportCustomerAnalyticsViewed } =useActions(eventUsageLogic)- const { businessType, activeTab } = useValues(customerAnalyticsSceneLogic)+ const { businessType, activeTab, sceneName, todayPeopleRowKey } = useValues(customerAnalyticsSceneLogic)const { shouldShowGroupsIntroduction } = useValues(groupsAccessLogic)const { featureFlags } = useValues(featureFlagLogic)const { location, searchParams } = useValues(router)@@ -78,6 +79,7 @@ function CustomerAnalyticsSceneContent(): JSX.Element {const { saveChanges, cancelChanges } = useActions(journeyEditorLogic)const { activeJourney } = useValues(customerJourneysLogic)const todayRailNav = useFeatureFlag('TODAY_RAIL_NAV')+ const todayTitle = useTodayPeopleTitle(todayPeopleRowKey)const accessControlDisabledReason = getAccessControlDisabledReason(AccessControlResourceType.CustomerAnalytics,@@ -218,12 +220,16 @@ function CustomerAnalyticsSceneContent(): JSX.Element {})}- const tabsContent =+ // The Today rail's People pane links to every tab, so the shell shows only the open tab's content.+ const activeTabEntry = tabs.find((tab) => tab.key === activeTab)+ const activeTabContent = activeTabEntry && 'content' in activeTabEntry ? activeTabEntry.content : dashboardContent+ const tabBar =tabs.length > 1 ? (<LemonTabs activeKey={activeTab} data-attr="customer-analytics-tabs" tabs={tabs} sceneInset />) : (dashboardContent)+ const tabsContent = todayRailNav ? activeTabContent : tabBarconst isFeatureRequestDetail =activeTab === 'feature_requests' && /\/customer_analytics\/feature-requests\/[^/]+\/?$/.test(location.pathname)@@ -237,18 +243,20 @@ function CustomerAnalyticsSceneContent(): JSX.Element {) : (<><SceneTitleSection- name={activeTab === 'tasks' ? 'Tasks' : sceneConfigurations[Scene.CustomerAnalytics].name}+ name={sceneName}description={activeTab === 'tasks'? 'Work assigned to you across customer accounts.': sceneConfigurations[Scene.CustomerAnalytics].description}- resourceType={{- type: sceneConfigurations[Scene.CustomerAnalytics].iconType || 'default_icon_type',- }}+ resourceType={+ todayTitle?.resourceType ?? {+ type: sceneConfigurations[Scene.CustomerAnalytics].iconType || 'default_icon_type',+ }+ }actions={todayRailNav ? (- <QuillCustomerAnalyticsSceneActions onConfigureClick={onConfigureClick} />+ <QuillCustomerAnalyticsSceneActions />) : (<><FeedbackButton id="customer-analytics-dashboard-feedback-button" />diff --git a/products/customer_analytics/frontend/QuillCustomerAnalyticsSceneActions.tsx b/products/customer_analytics/frontend/QuillCustomerAnalyticsSceneActions.tsxindex 576308680df2..583036e5d388 100644--- a/products/customer_analytics/frontend/QuillCustomerAnalyticsSceneActions.tsx+++ b/products/customer_analytics/frontend/QuillCustomerAnalyticsSceneActions.tsx@@ -1,13 +1,9 @@import { useActions, useValues } from 'kea'-import { IconGear } from '@posthog/icons'import { Button, Text } from '@posthog/quill'-import { Shortcut } from 'lib/components/Shortcuts/Shortcut'-import { keyBinds } from 'lib/components/Shortcuts/shortcuts'import { LinkPrimitive } from 'lib/lemon-ui/Link'import { getAccessControlDisabledReason } from 'lib/utils/accessControlUtils'-import { Scene } from 'scenes/sceneTypes'import { urls } from 'scenes/urls'import { AccessControlLevel, AccessControlResourceType } from '~/types'@@ -20,11 +16,8 @@ import { FeedbackButton } from './components/FeedbackButton'import { TaskDigestButton } from './components/TaskDigest/TaskDigestButton'import { customerAnalyticsSceneLogic } from './customerAnalyticsSceneLogic'-export function QuillCustomerAnalyticsSceneActions({- onConfigureClick,-}: {- onConfigureClick: () => void-}): JSX.Element {+// Under today-rail-nav, Configure is a row in the People pane, so the header has no Configure button.+export function QuillCustomerAnalyticsSceneActions(): JSX.Element {const { activeTab } = useValues(customerAnalyticsSceneLogic)const { isEditMode, stagedNodes, isSaving } = useValues(journeyEditorLogic)const { saveChanges, cancelChanges } = useActions(journeyEditorLogic)@@ -84,34 +77,7 @@ export function QuillCustomerAnalyticsSceneActions({)}<DeleteJourneyButton /></>- ) : (- <Shortcut- name="CustomerAnalyticsSettings"- keybind={[keyBinds.settings]}- intent="Configure customer analytics"- interaction="click"- scope={Scene.CustomerAnalytics}- >- <Button- variant="outline"- render={- <LinkPrimitive- to={- activeTab === 'accounts'- ? `${urls.customerAnalyticsConfiguration()}?tab=customer-analytics-accounts`- : urls.customerAnalyticsConfiguration()- }- />- }- onClick={onConfigureClick}- tooltip="Configure customer analytics"- data-attr="customer-analytics-config"- >- <IconGear />- Configure- </Button>- </Shortcut>- )}+ ) : null}</div>)}diff --git a/products/customer_analytics/frontend/customerAnalyticsSceneLogic.test.ts b/products/customer_analytics/frontend/customerAnalyticsSceneLogic.test.tsindex 2816d2ff74f6..1bd4647511de 100644--- a/products/customer_analytics/frontend/customerAnalyticsSceneLogic.test.ts+++ b/products/customer_analytics/frontend/customerAnalyticsSceneLogic.test.ts@@ -1,6 +1,8 @@import { router } from 'kea-router'import { expectLogic } from 'kea-test-utils'+import { FEATURE_FLAGS } from 'lib/constants'+import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { sceneLogic } from 'scenes/sceneLogic'import { emptySceneParams } from 'scenes/scenes'import { Scene } from 'scenes/sceneTypes'@@ -53,6 +55,20 @@ describe('customerAnalyticsSceneLogic', () => {})})+ describe('page name', () => {+ it.each([+ ['customerAnalyticsDashboard', false, 'Customer analytics'],+ ['customerAnalyticsFeed', false, 'Customer analytics'],+ ['customerAnalyticsDashboard', true, 'Overview'],+ ['customerAnalyticsFeed', true, 'Feed'],+ ])('names the %s breadcrumb when today-rail-nav is %s', (sceneKey, todayRailNav, name) => {+ featureFlagLogic.actions.setFeatureFlags([], { [FEATURE_FLAGS.TODAY_RAIL_NAV]: todayRailNav })+ sceneLogic.actions.setScene(Scene.CustomerAnalytics, sceneKey, emptySceneParams)++ expect(logic.values.breadcrumbs[0].name).toEqual(name)+ })+ })+describe('URL sync', () => {it('activates the Requests tab for its scene key', () => {sceneLogic.actions.setScene(Scene.CustomerAnalytics, 'customerAnalyticsFeatureRequests', emptySceneParams)diff --git a/products/customer_analytics/frontend/customerAnalyticsSceneLogic.ts b/products/customer_analytics/frontend/customerAnalyticsSceneLogic.tsindex f5fe9ffa6dd9..c3b09dd5d395 100644--- a/products/customer_analytics/frontend/customerAnalyticsSceneLogic.ts+++ b/products/customer_analytics/frontend/customerAnalyticsSceneLogic.ts@@ -2,6 +2,7 @@ import { MakeLogicType, actions, connect, kea, path, reducers, selectors } fromimport { router, urlToAction } from 'kea-router'import { FunnelLayout } from 'lib/constants'+import { featureFlagLogic, FeatureFlagsSet } from 'lib/logic/featureFlagLogic'import { trackedActionToUrl } from 'lib/logic/scenes/trackedActionToUrl'import { getDefaultInterval } from 'lib/utils/dateFilters'import { capitalizeFirstLetter, wordPluralize } from 'lib/utils/strings'@@ -9,6 +10,7 @@ import { sceneConfigurations } from 'scenes/scenes'import { Scene } from 'scenes/sceneTypes'import { urls } from 'scenes/urls'+import { TodayPeopleStaticRowKey, todayPeopleRowLabel } from '~/layout/today/todayPeopleRows'import { groupsModel } from '~/models/groupsModel'import {ActionsNode,@@ -110,6 +112,7 @@ export interface customerAnalyticsSceneLogicValues {signupEvent: AnyEntityNode // customerAnalyticsConfigLogicsignupPageviewEvent: AnyEntityNode // customerAnalyticsConfigLogicsubscriptionEvent: AnyEntityNode // customerAnalyticsConfigLogic+ featureFlags: FeatureFlagsSet // featureFlagLogicaggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun // groupsModelgroupTypesRaw: Array<GroupType> // groupsModelgroupsEnabled: boolean // groupsModel@@ -140,12 +143,15 @@ export interface customerAnalyticsSceneLogicValues {mauSeries: AnyEntityNode | nullmineOnly: booleanpaymentSeries: AnyEntityNode | null+ sceneName: string | undefinedselectedGroupType: numbersessionInsights: InsightDefinition[]signupInsights: InsightDefinition[]signupPageviewSeries: AnyEntityNode | nullsignupSeries: AnyEntityNode | nullsubscriptionSeries: AnyEntityNode | null+ todayPeopleRowKey: TodayPeopleStaticRowKey+ todayRailTabName: string | nullwauSeries: AnyEntityNode | null}@@ -176,8 +182,27 @@ export interface customerAnalyticsSceneLogicActions {export interface customerAnalyticsSceneLogicMeta {__keaTypeGenInternalSelectorTypes: {activeTab: (sceneKey: string | null) => ActiveTab+ todayPeopleRowKey: (activeTab: ActiveTab) => TodayPeopleStaticRowKey+ todayRailTabName: (+ featureFlags: FeatureFlagsSet,+ todayPeopleRowKey:+ | 'accounts'+ | 'announcements'+ | 'cohorts'+ | 'configure'+ | 'feature_requests'+ | 'feed'+ | 'journeys'+ | 'notes'+ | 'overview'+ | 'persons'+ | 'support'+ | 'tasks'+ ) => string | null+ sceneName: (todayRailTabName: string | null, activeTab: ActiveTab) => string | undefined+ breadcrumbs: (todayRailTabName: string | null) => Breadcrumb[]customerLabel: (- aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun, // groupsModel+ aggregationLabel: (groupTypeIndex: number | null | undefined, deferToUserWording?: boolean) => Noun,businessType: BusinessType,selectedGroupType: number) => {@@ -293,6 +318,8 @@ export const customerAnalyticsSceneLogic = kea<customerAnalyticsSceneLogicType>(['aggregationLabel', 'groupsEnabled', 'groupTypesRaw'],sceneLogic,['sceneKey'],+ featureFlagLogic,+ ['featureFlags'],],})),actions({@@ -349,12 +376,28 @@ export const customerAnalyticsSceneLogic = kea<customerAnalyticsSceneLogicType>((s) => [s.sceneKey],(sceneKey: string | null): ActiveTab => (sceneKey && SCENE_KEY_TO_TAB[sceneKey]) || 'dashboard',],+ /** The People pane row for the open tab. Under today-rail-nav those rows replace the tabs. */+ todayPeopleRowKey: [+ (s) => [s.activeTab],+ (activeTab: ActiveTab): TodayPeopleStaticRowKey => (activeTab === 'dashboard' ? 'overview' : activeTab),+ ],+ todayRailTabName: [+ (s) => [s.featureFlags, s.todayPeopleRowKey],+ (featureFlags: FeatureFlagsSet, rowKey: TodayPeopleStaticRowKey): string | null =>+ todayPeopleRowLabel(featureFlags, rowKey),+ ],+ sceneName: [+ (s) => [s.todayRailTabName, s.activeTab],+ (todayRailTabName: string | null, activeTab: ActiveTab): string | undefined =>+ todayRailTabName ??+ (activeTab === 'tasks' ? 'Tasks' : sceneConfigurations[Scene.CustomerAnalytics].name),+ ],breadcrumbs: [- () => [],- (): Breadcrumb[] => [+ (s) => [s.todayRailTabName],+ (todayRailTabName: string | null): Breadcrumb[] => [{key: Scene.CustomerAnalytics,- name: sceneConfigurations[Scene.CustomerAnalytics].name,+ name: todayRailTabName ?? sceneConfigurations[Scene.CustomerAnalytics].name,path: urls.customerAnalyticsDashboard(),iconType: sceneConfigurations[Scene.CustomerAnalytics].iconType || 'default_icon_type',},diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/customerAnalyticsAccountSceneLogic.test.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/customerAnalyticsAccountSceneLogic.test.tsindex fbd437d0fe3c..2c6ca466f5c5 100644--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/customerAnalyticsAccountSceneLogic.test.ts+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/customerAnalyticsAccountSceneLogic.test.ts@@ -117,6 +117,11 @@ describe('customerAnalyticsAccountSceneLogic', () => {expect(logic.values.account).toEqual(account)expect(logic.values.accountLoadError).toBeNull()expect(logic.values.breadcrumbs.at(-1)?.name).toBe(account.name)+ expect(logic.values.todayPeopleRecent).toEqual({+ type: 'account',+ name: account.name,+ href: urls.customerAnalyticsAccount(ACCOUNT_ID),+ })})it.each([false, true])(diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/customerAnalyticsAccountSceneLogic.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/customerAnalyticsAccountSceneLogic.tsindex 55ebc7e8a288..b678d22244e8 100644--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/customerAnalyticsAccountSceneLogic.ts+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/customerAnalyticsAccountSceneLogic.ts@@ -28,6 +28,7 @@ import { teamLogic } from 'scenes/teamLogic'import { urls } from 'scenes/urls'import { userLogic } from 'scenes/userLogic'+import { TODAY_PEOPLE_RECENT_KEY, TodayPeopleRecent } from '~/layout/today/todayPeople'import { tagsModel } from '~/models/tagsModel'import { Breadcrumb, UserType } from '~/types'@@ -148,6 +149,7 @@ export interface customerAnalyticsAccountSceneLogicValues {requestedTab: stringshowAccountFormErrors: booleantagsSaving: boolean+ todayPeopleRecent: TodayPeopleRecent | null}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -252,6 +254,7 @@ export interface customerAnalyticsAccountSceneLogicMeta {accountLoadError: unknown,arg: boolean) => boolean+ todayPeopleRecent: (account: AccountApi | null) => TodayPeopleRecent | nullbreadcrumbs: (account: AccountApi | null,user: UserType | null,@@ -447,6 +450,17 @@ export const customerAnalyticsAccountSceneLogic = kea<customerAnalyticsAccountScinvalidRoute: boolean): boolean => invalidRoute || (!account && !accountLoading && isAccountNotFound(accountLoadError)),],+ [TODAY_PEOPLE_RECENT_KEY]: [+ (s) => [s.account],+ (account: AccountApi | null): TodayPeopleRecent | null =>+ account+ ? {+ type: 'account',+ name: account.name ?? 'Account',+ href: urls.customerAnalyticsAccount(account.id),+ }+ : null,+ ],breadcrumbs: [(s) => [s.account, s.user, s.currentTeamId, (_, props) => props.projectId],(diff --git a/products/groups/frontend/logics/groupLogic.test.ts b/products/groups/frontend/logics/groupLogic.test.tsindex 80fe620f82c3..ad8cfc4e1f64 100644--- a/products/groups/frontend/logics/groupLogic.test.ts+++ b/products/groups/frontend/logics/groupLogic.test.ts@@ -1,4 +1,9 @@-import { resolveBackNavigation } from './groupLogic'+import { urls } from 'scenes/urls'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'++import { groupLogic, resolveBackNavigation } from './groupLogic'describe('resolveBackNavigation', () => {it('returns the sanitized internal path and name', () => {@@ -30,3 +35,30 @@ describe('resolveBackNavigation', () => {expect(resolveBackNavigation({ backUrl: '/groups/0/acme' })).toEqual({ url: '/groups/0/acme', name: 'Back' })})})++describe('groupLogic todayPeopleRecent', () => {+ beforeEach(() => {+ useMocks({ get: { '/api/environments/:team_id/groups/find/': { status: 404 } } })+ initKeaTests()+ })++ it('gives the loaded group as a People recent', () => {+ const logic = groupLogic({ groupTypeIndex: 0, groupKey: 'acme' })+ logic.mount()+ expect(logic.values.todayPeopleRecent).toBeNull()++ logic.actions.loadGroupSuccess({+ group_type_index: 0,+ group_key: 'acme',+ group_properties: { name: 'Acme Inc' },+ created_at: '2026-01-01T00:00:00Z',+ notebook: null,+ })++ expect(logic.values.todayPeopleRecent).toEqual({+ type: 'group',+ name: 'Acme Inc',+ href: urls.group('0', 'acme'),+ })+ })+})diff --git a/products/groups/frontend/logics/groupLogic.ts b/products/groups/frontend/logics/groupLogic.tsindex 37bc64bc3ffb..b43e25d9fb52 100644--- a/products/groups/frontend/logics/groupLogic.ts+++ b/products/groups/frontend/logics/groupLogic.ts@@ -14,6 +14,7 @@ import { Scene } from 'scenes/sceneTypes'import { urls } from 'scenes/urls'import { SIDE_PANEL_CONTEXT_KEY, SidePanelSceneContext } from '~/layout/navigation-3000/sidepanel/types'+import { TODAY_PEOPLE_RECENT_KEY, TodayPeopleRecent } from '~/layout/today/todayPeople'import { groupsModel } from '~/models/groupsModel'import { defaultDataTableColumns } from '~/queries/nodes/DataTable/utils'import { isDataTableNode } from '~/queries/schema/node-guards'@@ -115,6 +116,7 @@ export interface groupLogicValues {hasRevenueData: booleanlogicProps: GroupLogicPropssidePanelContext: SidePanelSceneContext | null+ todayPeopleRecent: TodayPeopleRecent | null}// Generated by kea-typegen. Update if you're an agent, ignore if you're human.@@ -236,6 +238,11 @@ export interface groupLogicMeta {groupTypeIndex: number,backNavigation: GroupBackNavigation | null) => Breadcrumb+ todayPeopleRecent: (+ groupTypeIndex: number,+ groupKey: string,+ groupData: Group | null+ ) => TodayPeopleRecent | nullbreadcrumbs: (groupTypeName: string,groupTypeIndex: number,@@ -529,6 +536,17 @@ export const groupLogic = kea<groupLogicType>([}},],+ [TODAY_PEOPLE_RECENT_KEY]: [+ (s, p) => [p.groupTypeIndex, p.groupKey, s.groupData],+ (groupTypeIndex: number, groupKey: string, groupData: Group | null): TodayPeopleRecent | null =>+ groupData+ ? {+ type: 'group',+ name: groupDisplayId(groupKey, groupData.group_properties || {}),+ href: urls.group(String(groupTypeIndex), groupKey),+ }+ : null,+ ],breadcrumbs: [(s, p) => [s.groupTypeName, p.groupTypeIndex, p.groupKey, s.groupData],(diff --git a/products/groups/frontend/pages/Group.tsx b/products/groups/frontend/pages/Group.tsxindex f17a85cd1c14..7ffb96dbeae8 100644--- a/products/groups/frontend/pages/Group.tsx+++ b/products/groups/frontend/pages/Group.tsx@@ -26,6 +26,7 @@ import { urls } from 'scenes/urls'import { SceneContent } from '~/layout/scenes/components/SceneContent'import { SceneDivider } from '~/layout/scenes/components/SceneDivider'import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'+import { useTodayPeopleTitle } from '~/layout/today/todayPeopleRows'import { Query } from '~/queries/Query/Query'import type { ActionFilter } from '~/types'import {@@ -78,6 +79,7 @@ export function Group(): JSX.Element {const { currentTeam } = useValues(teamLogic)const { featureFlags } = useValues(featureFlagLogic)const groupProfileVariant = useFeatureFlagVariantKey(FEATURE_FLAGS.GROUP_PROFILE_EXPERIMENT)+ const groupTitle = useTodayPeopleTitle('group')const isProfileEnabled = groupProfileVariant === 'test'const showProfile = featureFlags[FEATURE_FLAGS.CUSTOMER_ANALYTICS] || isProfileEnabled@@ -91,7 +93,7 @@ export function Group(): JSX.Element {<SceneContent><SceneTitleSectionname={groupDisplayId(groupData.group_key, groupData.group_properties)}- resourceType={{ type: 'group' }}+ resourceType={groupTitle?.resourceType ?? { type: 'group' }}forceBackTo={backTo}actions={<>diff --git a/products/groups/frontend/pages/Groups.tsx b/products/groups/frontend/pages/Groups.tsxindex d1e9c9818981..96f9acfe09e1 100644--- a/products/groups/frontend/pages/Groups.tsx+++ b/products/groups/frontend/pages/Groups.tsx@@ -16,6 +16,7 @@ import { urls } from 'scenes/urls'import { SceneContent } from '~/layout/scenes/components/SceneContent'import { SceneTitleSection } from '~/layout/scenes/components/SceneTitleSection'+import { useTodayPeopleTitle } from '~/layout/today/todayPeopleRows'import { groupsModel } from '~/models/groupsModel'import { Query } from '~/queries/Query/Query'import { ProductKey } from '~/queries/schema/schema-general'@@ -45,6 +46,7 @@ export function GroupsScene(): JSX.Element {const { baseCurrency } = useValues(teamLogic)const hasCustomerAnalyticsEnabled = useFeatureFlag('CUSTOMER_ANALYTICS')const todayRailNav = useFeatureFlag('TODAY_RAIL_NAV')+ const groupTitle = useTodayPeopleTitle('group')if (groupTypeIndex === undefined) {throw new Error('groupTypeIndex is undefined')@@ -80,9 +82,7 @@ export function GroupsScene(): JSX.Element {<SceneTitleSectionname={capitalizeFirstLetter(groupTypeNamePlural)}description={`A catalog of all ${groupTypeNamePlural} for this project`}- resourceType={{- type: 'cohort',- }}+ resourceType={groupTitle?.resourceType ?? { type: 'cohort' }}actions={<><FeedbackButton id="customer-analytics-groups-list-feedback-button" />diff --git a/products/persons/frontend/logics/personsLogic.test.ts b/products/persons/frontend/logics/personsLogic.test.tsindex d1e360438cb8..9b4c75197a92 100644--- a/products/persons/frontend/logics/personsLogic.test.ts+++ b/products/persons/frontend/logics/personsLogic.test.ts@@ -412,6 +412,17 @@ describe('personsLogic', () => {})})+ it('gives the Today rail the person as a recent once the person has loaded, under one URL for each person', () => {+ expect(logic.values.todayPeopleRecent).toBeNull()++ logic.actions.setPerson({ id: 'uuid-1', distinct_ids: ['[email protected]'], properties: {} } as PersonType)+ expect(logic.values.todayPeopleRecent).toEqual({+ type: 'person',+ name: '[email protected]',+ href: '/persons/uuid-1',+ })+ })+describe('setPerson / setPersons reducers', () => {const personA: PersonType = {id: '1',diff --git a/products/persons/frontend/logics/personsLogic.tsx b/products/persons/frontend/logics/personsLogic.tsxindex 3b94a40d8f2a..7f7d91bf57a4 100644--- a/products/persons/frontend/logics/personsLogic.tsx+++ b/products/persons/frontend/logics/personsLogic.tsx@@ -21,6 +21,7 @@ import { teamLogic } from 'scenes/teamLogic'import { urls } from 'scenes/urls'import { SIDE_PANEL_CONTEXT_KEY, SidePanelSceneContext } from '~/layout/navigation-3000/sidepanel/types'+import { TODAY_PEOPLE_RECENT_KEY, TodayPeopleRecent } from '~/layout/today/todayPeople'import { defaultDataTableColumns } from '~/queries/nodes/DataTable/utils'import { DataTableNode, HogQLQuery, HogQLQueryResponse, NodeKind } from '~/queries/schema/schema-general'import {@@ -164,6 +165,7 @@ export interface personsLogicValues {sidePanelContext: SidePanelSceneContextsplitMergeModalShown: booleansurveyResponsesQuery: DataTableNode | null+ todayPeopleRecent: TodayPeopleRecent | nullurlId: any}@@ -326,6 +328,7 @@ export interface personsLogicMeta {},featureFlags: FeatureFlagsSet) => Breadcrumb[]+ todayPeopleRecent: (person: PersonType | null) => TodayPeopleRecent | nullsidePanelContext: (person: PersonType | null) => SidePanelSceneContextexporterProps: (listFilters: PersonListParams, arg: any) => TriggerExportProps[]urlId: (arg: any) => any@@ -624,7 +627,7 @@ export const personsLogic = kea<personsLogicType>([},featureFlags: FeatureFlagsSet): Breadcrumb[] => {- // The Today rail names recent persons from this crumb, and opens them by UUID under `/persons/`.+ // The Today rail opens persons by UUID under `/persons/`.const personPath = featureFlags[FEATURE_FLAGS.TODAY_RAIL_NAV] ? /\/persons?\/.+/ : /\/person\/.+/const showPerson = person && location.pathname.match(personPath)const breadcrumbs: Breadcrumb[] = [@@ -646,6 +649,13 @@ export const personsLogic = kea<personsLogicType>([},],+ [TODAY_PEOPLE_RECENT_KEY]: [+ (s) => [s.person],+ (person: PersonType | null): TodayPeopleRecent | null =>+ person?.id != null+ ? { type: 'person', name: asDisplay(person), href: urls.personByUUID(String(person.id)) }+ : null,+ ],[SIDE_PANEL_CONTEXT_KEY]: [(s) => [s.person],(person: PersonType | null): SidePanelSceneContext => {diff --git a/products/persons/frontend/pages/PersonsScene.tsx b/products/persons/frontend/pages/PersonsScene.tsxindex 5321374c7a56..1a50ab8b08f8 100644--- a/products/persons/frontend/pages/PersonsScene.tsx+++ b/products/persons/frontend/pages/PersonsScene.tsx@@ -38,6 +38,7 @@ export function PersonsScene(): JSX.Element {const { loadConfigs } = useActions(customerProfileConfigLogic({ scope: CustomerProfileScope.PERSON }))const queryUniqueKey = 'persons-query'const sceneMenuBarEnabled = useFeatureFlag('SCENE_MENU_BAR')+ const todayRailNav = useFeatureFlag('TODAY_RAIL_NAV')// A UUID-shaped search that returns nothing is often a session ID typed into the wrong field.// Session IDs aren't part of the persons query, so point the user to where they are searchable.@@ -53,13 +54,17 @@ export function PersonsScene(): JSX.Element {<SceneContent><ActivitySceneTabs activeKey="persons" />- {sceneMenuBarEnabled && (- <SceneMenuBar>- <SceneMenuBarMenu label="File" dataAttr="persons-menubar-file">- <SceneMenuBarFileItems dataAttrKey="persons" />- </SceneMenuBarMenu>- </SceneMenuBar>- )}+ {sceneMenuBarEnabled &&+ (todayRailNav ? (+ // This page has no project tree entry, so it has no File menu. The bar adds Help under the Today layout.+ <SceneMenuBar />+ ) : (+ <SceneMenuBar>+ <SceneMenuBarMenu label="File" dataAttr="persons-menubar-file">+ <SceneMenuBarFileItems dataAttrKey="persons" />+ </SceneMenuBarMenu>+ </SceneMenuBar>+ ))}<SceneTitleSectionname={sceneConfigurations[Scene.Persons].name}