: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
fix(today): restore missing pages in the products list (#113742)
Adam Leithccf24233bf6e
diff --git a/frontend/src/layout/today/TodayProductsSidebar.tsx b/frontend/src/layout/today/TodayProductsSidebar.tsxindex f6e213d01cdb..52b0b4fc8dd3 100644--- a/frontend/src/layout/today/TodayProductsSidebar.tsx+++ b/frontend/src/layout/today/TodayProductsSidebar.tsx@@ -8,7 +8,7 @@ import { removeProjectIdIfPresent } from 'lib/utils/kea-router'import { LibraryCreateButton } from 'scenes/library/LibraryCreateButton'import { libraryLogic } from 'scenes/library/libraryLogic'import { libraryListHref, libraryTypeForPath } from 'scenes/library/libraryUtils'-import { toolHrefForPath, toolLabel } from 'scenes/tools/toolsUtils'+import { libraryRowProductLabels, toolHrefForPath, toolLabel } from 'scenes/tools/toolsUtils'import { urls } from 'scenes/urls'import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'@@ -31,7 +31,9 @@ export function TodayProductsSidebar(): JSX.Element {const objectPageType = libraryTypeForPath(path)const showAllObjects = matchesPaneQuery('All objects', search)- const libraryTypes = objectTypes.filter((type) => matchesPaneQuery(type.pluralLabel, search))+ const libraryTypes = objectTypes.filter((type) =>+ [type.pluralLabel, ...libraryRowProductLabels(type.value)].some((label) => matchesPaneQuery(label, search))+ )const showLibrary = showAllObjects || libraryTypes.length > 0const recentSection = recentTools.length ? { key: 'recent', label: 'Recently viewed', tools: recentTools } : nullconst categorySections = toolGroups.map((group) => ({@@ -97,7 +99,11 @@ export function TodayProductsSidebar(): JSX.Element {label={type.pluralLabel}icon={iconForType(type.value as FileSystemIconType)}to={libraryListHref(type.value) ?? urls.library(type.value)}- active={path === urls.library(type.value) || objectPageType === type.value}+ // A product page can share a scene with a Library list. The product's own row then takes the highlight.+ active={+ path === urls.library(type.value) ||+ (objectPageType === type.value && !activeHref)+ }action={<LibraryCreateButton objectType={type.value} />}dataAttr="today-library-type"/>diff --git a/frontend/src/layout/today/todayShellLogic.test.ts b/frontend/src/layout/today/todayShellLogic.test.tsindex 17d0a6b3321f..46a23519077e 100644--- a/frontend/src/layout/today/todayShellLogic.test.ts+++ b/frontend/src/layout/today/todayShellLogic.test.ts@@ -3,7 +3,13 @@ import { router } from 'kea-router'import { FEATURE_FLAGS } from 'lib/constants'import { featureFlagLogic } from 'lib/logic/featureFlagLogic'import { removeProjectIdIfPresent } from 'lib/utils/kea-router'-import { toolHrefForPath } from 'scenes/tools/toolsUtils'+import {+ getToolSourceItems,+ isToolItem,+ libraryRowProductLabels,+ toolHrefForPath,+ toolLabel,+} from 'scenes/tools/toolsUtils'import { initKeaTests } from '~/test/init'@@ -32,6 +38,10 @@ describe('todayShellLogic', () => {['/project/1/canvases/new', 'views'],['/project/1/notebooks/abc', 'views'],['/project/1/dashboard/12', 'views'],+ ['/project/1/notebooks', 'products'],+ ['/project/1/dashboard', 'products'],+ ['/project/1/persons', 'products'],+ ['/project/1/activity/events', 'products'],['/project/1/airplane', null],['/project/1/homework', null],])('puts %s under %s', (pathname, pane) => {@@ -48,6 +58,25 @@ describe('todayShellLogic', () => {expect(toolHrefForPath(path, tools)).toBe(href)})+ test.each([+ ['Notebooks', true],+ ['Dashboards', true],+ ['Session replay', true],+ ['Persons', true],+ ['Activity', true],+ ['SQL editor', true],+ ['Feature flags', false],+ ['Product analytics', false],+ ['Cohorts', false],+ ])('gives %s its own row in the Products list: %s', (label, ownRow) => {+ const rows = getToolSourceItems().filter(isToolItem).map(toolLabel)+ expect(rows.includes(label)).toBe(ownRow)+ })++ it('finds the Insights row with a search for the Product analytics name', () => {+ expect(libraryRowProductLabels('insight')).toContain('Product analytics')+ })+test.each([['home', '/home'],['spaces', '/ai'],diff --git a/frontend/src/layout/today/todayShellLogic.ts b/frontend/src/layout/today/todayShellLogic.tsindex aacac38b9cb2..990391c1fe59 100644--- a/frontend/src/layout/today/todayShellLogic.ts+++ b/frontend/src/layout/today/todayShellLogic.ts@@ -78,11 +78,12 @@ export function railPaneForPath(pathname: string): TodayRailPane | null {if (isUnder(path, '/ai') || isUnder(path, '/spaces')) {return 'spaces'}+ // Each notebook and dashboard is a view, but their list pages are rows in the Products list.if (isUnder(path, urls.views()) ||isUnder(path, '/canvases') ||- isUnder(path, urls.notebooks()) ||- isUnder(path, urls.dashboards())+ path.startsWith(`${urls.notebooks()}/`) ||+ path.startsWith(`${urls.dashboards()}/`)) {return 'views'}diff --git a/frontend/src/scenes/library/libraryUtils.ts b/frontend/src/scenes/library/libraryUtils.tsindex 4cf4e16f1cc5..92dd23a6fe4e 100644--- a/frontend/src/scenes/library/libraryUtils.ts+++ b/frontend/src/scenes/library/libraryUtils.ts@@ -1,7 +1,7 @@import { routes } from 'scenes/scenes'import { fileSystemTypes, getTreeItemsMetadata, getTreeItemsProducts } from '~/products'-import { FileSystemEntry } from '~/queries/schema/schema-general'+import { FileSystemEntry, FileSystemImport } from '~/queries/schema/schema-general'import { FileSystemType } from '~/types'// These file system types are working pages rather than saved objects, so they belong to Tools.@@ -24,6 +24,11 @@ export function baseObjectType(type: string | undefined): string {return type?.split('/')[0] ?? ''}+/** The file system type of a product page, from its type or, when it has none, its icon. */+export function productObjectType(item: Pick<FileSystemImport, 'type' | 'iconType'>): string {+ return baseObjectType(item.type) || item.iconType || ''+}+/** Whether a file system type shows in Library, rather than in Tools or Views. */export function isLibraryType(type: string): boolean {return !TOOL_FILE_SYSTEM_TYPES.has(type) && !VIEW_FILE_SYSTEM_TYPES.has(type)@@ -53,6 +58,12 @@ export function libraryListHref(type: string): string | null {return definition?.listHref?.() ?? null}+/** Whether a Library type row opens this product's page, so the product needs no row of its own. */+export function libraryRowOpensProduct(item: Pick<FileSystemImport, 'type' | 'iconType' | 'href'>): boolean {+ const type = productObjectType(item)+ return !!item.href && isLibraryType(type) && libraryListHref(type) === item.href+}+const REF_PLACEHOLDER = 'LIBRARY_REF'function routeSegments(route: string): string[] {@@ -98,7 +109,7 @@ export function libraryTypeForPath(path: string): string | null {addPage(type, definition.listHref?.())}for (const item of [...getTreeItemsProducts(), ...getTreeItemsMetadata()]) {- const type = baseObjectType(item.type) || item.iconType || ''+ const type = productObjectType(item)if (Object.hasOwn(fileSystemTypes, type)) {addPage(type, item.href)}diff --git a/frontend/src/scenes/tools/toolsLogic.ts b/frontend/src/scenes/tools/toolsLogic.tsindex bf9b5e005e92..cc51f239a45e 100644--- a/frontend/src/scenes/tools/toolsLogic.ts+++ b/frontend/src/scenes/tools/toolsLogic.ts@@ -3,14 +3,15 @@ import { MakeLogicType, actions, connect, kea, path, reducers, selectors } fromimport { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'import { getProductAccessDisabledReason } from 'lib/utils/accessControlUtils'-import { getTreeItemsMetadata, getTreeItemsProducts } from '~/products'+import { projectTreeDataLogic } from '~/layout/panel-layout/ProjectTree/projectTreeDataLogic'import { FileSystemImport } from '~/queries/schema/schema-general'-import { ToolGroup, groupTools, isToolItem, toolLabel } from './toolsUtils'+import { ToolGroup, getToolSourceItems, groupTools, isToolItem, toolLabel } from './toolsUtils'// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface toolsLogicValues {featureFlags: FeatureFlagsSet // featureFlagLogic+ groupItems: FileSystemImport[] // projectTreeDataLogicsearch: stringtoolGroups: ToolGroup[]tools: FileSystemImport[]@@ -26,7 +27,7 @@ export interface toolsLogicActions {// Generated by kea-typegen. Update if you're an agent, ignore if you're human.export interface toolsLogicMeta {__keaTypeGenInternalSelectorTypes: {- tools: (featureFlags: FeatureFlagsSet) => FileSystemImport[]+ tools: (featureFlags: FeatureFlagsSet, groupItems: FileSystemImport[]) => FileSystemImport[]toolGroups: (tools: FileSystemImport[], search: string) => ToolGroup[]}}@@ -35,15 +36,17 @@ export type toolsLogicType = MakeLogicType<toolsLogicValues, toolsLogicActions,export const toolsLogic = kea<toolsLogicType>([path(['scenes', 'tools', 'toolsLogic']),- connect(() => ({ values: [featureFlagLogic, ['featureFlags']] })),+ connect(() => ({ values: [featureFlagLogic, ['featureFlags'], projectTreeDataLogic, ['groupItems']] })),actions({ setSearch: (search: string) => ({ search }) }),reducers({ search: ['', { setSearch: (_, { search }) => search }] }),selectors({tools: [- (s) => [s.featureFlags],- (featureFlags: FeatureFlagsSet): FileSystemImport[] => {+ (s) => [s.featureFlags, s.groupItems],+ (featureFlags: FeatureFlagsSet, groupItems: FileSystemImport[]): FileSystemImport[] => {const seen = new Set<string>()- return [...getTreeItemsProducts(), ...getTreeItemsMetadata()]+ // Saved group views are shortcuts to filtered pages, so only the group type pages join the list.+ const groupPages = groupItems.filter((item) => !item.shortcut)+ return [...getToolSourceItems(), ...groupPages].filter((item) => {if (!item.href ||diff --git a/frontend/src/scenes/tools/toolsUtils.ts b/frontend/src/scenes/tools/toolsUtils.tsindex 2c55499755b2..b603cacc7628 100644--- a/frontend/src/scenes/tools/toolsUtils.ts+++ b/frontend/src/scenes/tools/toolsUtils.ts@@ -1,7 +1,10 @@-import { TOOL_FILE_SYSTEM_TYPES } from 'scenes/library/libraryUtils'+import { libraryRowOpensProduct, productObjectType } from 'scenes/library/libraryUtils'+import { urls } from 'scenes/urls'-import { fileSystemTypes, getTreeItemsMetadata, getTreeItemsProducts } from '~/products'-import { FileSystemImport } from '~/queries/schema/schema-general'+import { getDefaultTreePersons } from '~/layout/panel-layout/ProjectTree/defaultTree'+import { getTreeItemsMetadata, getTreeItemsProducts } from '~/products'+import { FileSystemImport, ProductItemCategory } from '~/queries/schema/schema-general'+import { ActivityTab } from '~/types'export interface ToolGroup {category: string@@ -12,6 +15,22 @@ export interface ToolGroup {const PINNED_TOOL_ICONS = ['sql_editor']export const PINNED_TOOLS_CATEGORY = 'Workspace'+/** The static pages the Products list can show. The current nav links Persons, Cohorts and Activity outside its product list. */+export function getToolSourceItems(): FileSystemImport[] {+ return [+ ...getTreeItemsProducts(),+ ...getTreeItemsMetadata(),+ ...getDefaultTreePersons(),+ {+ path: 'Activity',+ category: ProductItemCategory.ANALYTICS,+ iconType: 'activity',+ href: urls.activity(ActivityTab.ExploreEvents),+ sceneKey: 'Activity',+ },+ ]+}+export function toolLabel(tool: FileSystemImport): string {return tool.displayLabel || tool.path}@@ -25,15 +44,30 @@ export function toolMatchesSearch(tool: FileSystemImport, search: string): boolereturn !query || `${toolLabel(tool)} ${toolCategory(tool)}`.toLowerCase().includes(query)}-// Saved object types live in Library, except the ones that are working pages.export function isToolItem(item: FileSystemImport): boolean {- const type = item.type?.split('/')[0] || item.iconType || ''- return !!item.href && !(type in fileSystemTypes && !TOOL_FILE_SYSTEM_TYPES.has(type))+ return !!item.href && !libraryRowOpensProduct(item)+}++let productLabelsByLibraryType: Map<string, string[]> | null = null++/** The names of the products a Library type row opens, so a search for "Product analytics" finds Insights. */+export function libraryRowProductLabels(type: string): string[] {+ if (!productLabelsByLibraryType) {+ const labels = new Map<string, string[]>()+ for (const item of getToolSourceItems()) {+ if (libraryRowOpensProduct(item)) {+ const itemType = productObjectType(item)+ labels.set(itemType, [...(labels.get(itemType) ?? []), toolLabel(item)])+ }+ }+ productLabelsByLibraryType = labels+ }+ return productLabelsByLibraryType.get(type) ?? []}export function toolHrefForPath(path: string,- tools: Pick<FileSystemImport, 'href'>[] = [...getTreeItemsProducts(), ...getTreeItemsMetadata()].filter(isToolItem)+ tools: Pick<FileSystemImport, 'href'>[] = getToolSourceItems().filter(isToolItem)): string | null {let match: { href: string; toolPath: string } | null = nullfor (const { href } of tools) {