: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(library): open each product's own list page from the library sidebar (#112199)
Peter Kirkhamcb300897dc24
diff --git a/frontend/src/layout/today/TodayLibrarySidebar.tsx b/frontend/src/layout/today/TodayLibrarySidebar.tsxindex 22bb57743f70..ffc842d92d58 100644--- a/frontend/src/layout/today/TodayLibrarySidebar.tsx+++ b/frontend/src/layout/today/TodayLibrarySidebar.tsx@@ -8,7 +8,7 @@ import { Text } from '@posthog/quill'import { removeProjectIdIfPresent } from 'lib/utils/kea-router'import { LibraryCreateButton } from 'scenes/library/LibraryCreateButton'import { libraryLogic } from 'scenes/library/libraryLogic'-import { libraryTypeForPath } from 'scenes/library/libraryUtils'+import { libraryListHref, libraryTypeForPath } from 'scenes/library/libraryUtils'import { urls } from 'scenes/urls'import { iconForType } from '~/layout/panel-layout/ProjectTree/defaultTree'@@ -60,7 +60,7 @@ export function TodayLibrarySidebar(): JSX.Element {value={`type:${type.value}`}label={type.pluralLabel}icon={iconForType(type.value as FileSystemIconType)}- to={urls.library(type.value)}+ to={libraryListHref(type.value) ?? urls.library(type.value)}active={path === urls.library(type.value) || objectPageType === type.value}action={<LibraryCreateButton objectType={type.value} />}dataAttr="today-library-type"diff --git a/frontend/src/products.tsx b/frontend/src/products.tsxindex 459226ce5b85..97d8193f76a7 100644--- a/frontend/src/products.tsx+++ b/frontend/src/products.tsx@@ -1794,6 +1794,7 @@ export const fileSystemTypes = {action: {name: 'Action',href: (ref: string) => urls.action(ref),+ listHref: () => urls.actions(),filterKey: 'action',iconType: 'action' as FileSystemIconType,iconColor: ['var(--color-product-actions-light)', 'var(--color-product-actions-dark)'] as FileSystemIconColor,@@ -1803,6 +1804,7 @@ export const fileSystemTypes = {iconType: 'cohort' as FileSystemIconType,iconColor: ['var(--color-product-cohorts-light)', 'var(--color-product-cohorts-dark)'] as FileSystemIconColor,href: (ref: string) => urls.cohort(ref),+ listHref: () => urls.cohorts(),filterKey: 'cohort',},dashboard: {@@ -1816,6 +1818,7 @@ export const fileSystemTypes = {name: 'Early access feature',iconType: 'early_access_feature' as FileSystemIconType,href: (ref: string) => urls.earlyAccessFeature(ref),+ listHref: () => urls.earlyAccessFeatures(),iconColor: ['var(--color-product-early-access-features-light)','var(--color-product-early-access-features-dark)',@@ -1833,6 +1836,7 @@ export const fileSystemTypes = {name: 'Experiment',iconType: 'experiment',href: (ref: string) => urls.experiment(ref),+ listHref: () => urls.experiments(),iconColor: ['var(--color-product-experiments-light)'],filterKey: 'experiment',},@@ -1840,6 +1844,7 @@ export const fileSystemTypes = {name: 'Feature flag',iconType: 'feature_flag',href: (ref: string) => urls.featureFlag(ref),+ listHref: () => urls.featureFlags(),iconColor: ['var(--color-product-feature-flags-light)'],filterKey: 'feature_flag',},@@ -1847,6 +1852,7 @@ export const fileSystemTypes = {name: 'Insight',iconType: 'product_analytics',href: (ref: string) => urls.insightView(ref as InsightShortId),+ listHref: () => urls.savedInsights(),iconColor: ['var(--color-product-product-analytics-light)'],filterKey: 'insight',},@@ -1860,6 +1866,7 @@ export const fileSystemTypes = {name: 'Product tour',iconType: 'product_tour',href: (ref: string) => urls.productTour(ref),+ listHref: () => urls.productTours(),iconColor: ['var(--color-product-product-tours-light)', 'var(--color-product-product-tours-dark)'],filterKey: 'product_tour',},@@ -1867,6 +1874,7 @@ export const fileSystemTypes = {name: 'Replay playlist',iconType: 'session_replay',href: (ref: string) => urls.replayPlaylist(ref),+ listHref: () => urls.replay(ReplayTabs.Playlists),iconColor: ['var(--color-product-session-replay-light)', 'var(--color-product-session-replay-dark)'],filterKey: 'session_recording_playlist',},@@ -1874,6 +1882,7 @@ export const fileSystemTypes = {name: 'Survey',iconType: 'survey',href: (ref: string) => urls.survey(ref),+ listHref: () => urls.surveys(),iconColor: ['var(--color-product-surveys-light)'],filterKey: 'survey',},@@ -1890,6 +1899,7 @@ export const fileSystemTypes = {iconType: 'workflows',iconColor: ['var(--color-product-workflows-light)'] as FileSystemIconColor,href: (ref: string) => urls.workflow(ref, 'workflow'),+ listHref: () => urls.workflows(),filterKey: 'workflows',},}diff --git a/frontend/src/scenes/library/libraryLogic.ts b/frontend/src/scenes/library/libraryLogic.tsindex 084fd94ef479..c2f08eb79d04 100644--- a/frontend/src/scenes/library/libraryLogic.ts+++ b/frontend/src/scenes/library/libraryLogic.ts@@ -10,7 +10,14 @@ import { urls } from 'scenes/urls'import { fileSystemTypes, getTreeItemsNew } from '~/products'import { FileSystemEntry, FileSystemImport } from '~/queries/schema/schema-general'-import { LibraryObjectType, baseObjectType, isLibraryEntry, isLibraryType, sortLibraryTypes } from './libraryUtils'+import {+ LibraryObjectType,+ baseObjectType,+ isLibraryEntry,+ isLibraryType,+ libraryListHref,+ sortLibraryTypes,+} from './libraryUtils'export const LIBRARY_PAGE_SIZE = 50// "All objects" drops tool and view entries after each page loads, so it reads ahead until a page has@@ -233,6 +240,11 @@ export const libraryLogic = kea<libraryLogicType>([router.actions.replace(urls.views())return}+ const listHref = objectType ? libraryListHref(objectType) : null+ if (listHref) {+ router.actions.replace(listHref)+ return+ }if (objectType !== values.objectType || !cache.loaded) {cache.loaded = trueactions.setObjectType(objectType)diff --git a/frontend/src/scenes/library/libraryUtils.test.ts b/frontend/src/scenes/library/libraryUtils.test.tsindex 313c37865d45..5fb6270a0ca7 100644--- a/frontend/src/scenes/library/libraryUtils.test.ts+++ b/frontend/src/scenes/library/libraryUtils.test.ts@@ -1,4 +1,10 @@-import { isLibraryType, libraryObjectHref, libraryObjectName, libraryTypeForPath } from './libraryUtils'+import {+ isLibraryType,+ libraryListHref,+ libraryObjectHref,+ libraryObjectName,+ libraryTypeForPath,+} from './libraryUtils'describe('libraryUtils', () => {test.each([@@ -40,4 +46,18 @@ describe('libraryUtils', () => {])('finds the object type of %s', (path, type) => {expect(libraryTypeForPath(path)).toBe(type)})++ test.each([+ ['feature_flag', '/feature_flags'],+ ['insight', '/insights'],+ ['cohort', '/cohorts'],+ ['session_recording_playlist', '/replay/playlists'],+ ['not_a_type', null],+ ])('opens the list page of %s', (type, href) => {+ const listHref = libraryListHref(type)+ expect(listHref).toBe(href)+ if (listHref) {+ expect(libraryTypeForPath(listHref)).toBe(type)+ }+ })})diff --git a/frontend/src/scenes/library/libraryUtils.ts b/frontend/src/scenes/library/libraryUtils.tsindex cfd8df825a73..dda8a2d38613 100644--- a/frontend/src/scenes/library/libraryUtils.ts+++ b/frontend/src/scenes/library/libraryUtils.ts@@ -2,6 +2,7 @@ import { routes } from 'scenes/scenes'import { fileSystemTypes, getTreeItemsMetadata, getTreeItemsProducts } from '~/products'import { FileSystemEntry } 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.export const TOOL_FILE_SYSTEM_TYPES = new Set(['endpoints', 'task'])@@ -44,6 +45,14 @@ export function libraryObjectHref(entry: Pick<FileSystemEntry, 'href' | 'type' |return entry.ref && definition ? definition.href(entry.ref) : null}+/** The product's own list page for a type, if its manifest registers one. */+export function libraryListHref(type: string): string | null {+ const definition = Object.hasOwn(fileSystemTypes, type)+ ? (fileSystemTypes[type as keyof typeof fileSystemTypes] as FileSystemType)+ : null+ return definition?.listHref?.() ?? null+}+const REF_PLACEHOLDER = 'LIBRARY_REF'function routeSegments(route: string): string[] {@@ -84,8 +93,9 @@ export function libraryTypeForPath(path: string): string | null {scenes.set(scene, type)}}- for (const [type, definition] of Object.entries(fileSystemTypes)) {- addPage(type, definition.href(REF_PLACEHOLDER))+ for (const [type, definition] of Object.entries(fileSystemTypes) as [string, FileSystemType][]) {+ addPage(type, definition.href?.(REF_PLACEHOLDER))+ addPage(type, definition.listHref?.())}for (const item of [...getTreeItemsProducts(), ...getTreeItemsMetadata()]) {const type = baseObjectType(item.type) || item.iconType || ''diff --git a/frontend/src/scenes/project-homepage/today/Today.stories.tsx b/frontend/src/scenes/project-homepage/today/Today.stories.tsxindex 3814660190c1..21c0ad971ccf 100644--- a/frontend/src/scenes/project-homepage/today/Today.stories.tsx+++ b/frontend/src/scenes/project-homepage/today/Today.stories.tsx@@ -901,7 +901,7 @@ export const LibraryAllObjects: Story = {}export const LibraryFeatureFlags: Story = {- parameters: { pageUrl: urls.library('feature_flag') },+ parameters: { pageUrl: urls.featureFlags() },}export const ToolsPane: Story = {diff --git a/frontend/src/types.ts b/frontend/src/types.tsindex 3abc7c3ca2ef..47ad306a5804 100644--- a/frontend/src/types.ts+++ b/frontend/src/types.ts@@ -7765,6 +7765,8 @@ export type FileSystemIconColor = [string] | [string, string]export interface FileSystemType {href?: (ref: string) => string+ // The product's own list page, which Library opens for this type instead of its generic table+ listHref?: () => string// Visual name of the productname: string// Flag to determine if the product is enableddiff --git a/products/actions/manifest.tsx b/products/actions/manifest.tsxindex 80ef0553d2d0..588e186cbf6f 100644--- a/products/actions/manifest.tsx+++ b/products/actions/manifest.tsx@@ -50,6 +50,7 @@ export const manifest: ProductManifest = {action: {name: 'Action',href: (ref: string) => urls.action(ref),+ listHref: () => urls.actions(),filterKey: 'action',iconType: 'action' as FileSystemIconType,iconColor: [diff --git a/products/cohorts/manifest.tsx b/products/cohorts/manifest.tsxindex 82e046116803..2caecd51b4ea 100644--- a/products/cohorts/manifest.tsx+++ b/products/cohorts/manifest.tsx@@ -33,6 +33,7 @@ export const manifest: ProductManifest = {'var(--color-product-cohorts-dark)',] as FileSystemIconColor,href: (ref: string) => urls.cohort(ref),+ listHref: () => urls.cohorts(),filterKey: 'cohort',},},diff --git a/products/early_access_features/manifest.tsx b/products/early_access_features/manifest.tsxindex c45b4d35ec16..7224dca09b53 100644--- a/products/early_access_features/manifest.tsx+++ b/products/early_access_features/manifest.tsx@@ -39,6 +39,7 @@ export const manifest: ProductManifest = {name: 'Early access feature',iconType: 'early_access_feature' as FileSystemIconType,href: (ref: string) => urls.earlyAccessFeature(ref),+ listHref: () => urls.earlyAccessFeatures(),iconColor: ['var(--color-product-early-access-features-light)','var(--color-product-early-access-features-dark)',diff --git a/products/experiments/manifest.tsx b/products/experiments/manifest.tsxindex 36df51dee2be..dfb31cd2e607 100644--- a/products/experiments/manifest.tsx+++ b/products/experiments/manifest.tsx@@ -52,6 +52,7 @@ export const manifest: ProductManifest = {name: 'Experiment',iconType: 'experiment',href: (ref: string) => urls.experiment(ref),+ listHref: () => urls.experiments(),iconColor: ['var(--color-product-experiments-light)'],filterKey: 'experiment',},diff --git a/products/feature_flags/manifest.tsx b/products/feature_flags/manifest.tsxindex a500e1312da0..2bb03349c9e7 100644--- a/products/feature_flags/manifest.tsx+++ b/products/feature_flags/manifest.tsx@@ -62,6 +62,7 @@ export const manifest: ProductManifest = {name: 'Feature flag',iconType: 'feature_flag',href: (ref: string) => urls.featureFlag(ref),+ listHref: () => urls.featureFlags(),iconColor: ['var(--color-product-feature-flags-light)'],filterKey: 'feature_flag',},diff --git a/products/product_analytics/manifest.tsx b/products/product_analytics/manifest.tsxindex 18cae8b460ff..5f44e04dee63 100644--- a/products/product_analytics/manifest.tsx+++ b/products/product_analytics/manifest.tsx@@ -101,6 +101,7 @@ export const manifest: ProductManifest = {name: 'Insight',iconType: 'product_analytics',href: (ref: string) => urls.insightView(ref as InsightShortId),+ listHref: () => urls.savedInsights(),iconColor: ['var(--color-product-product-analytics-light)'],filterKey: 'insight',},diff --git a/products/product_tours/manifest.tsx b/products/product_tours/manifest.tsxindex 90be3d33849b..656e0040b913 100644--- a/products/product_tours/manifest.tsx+++ b/products/product_tours/manifest.tsx@@ -15,6 +15,7 @@ export const manifest: ProductManifest = {name: 'Product tour',iconType: 'product_tour',href: (ref: string) => urls.productTour(ref),+ listHref: () => urls.productTours(),iconColor: ['var(--color-product-product-tours-light)', 'var(--color-product-product-tours-dark)'],filterKey: 'product_tour',},diff --git a/products/replay/manifest.tsx b/products/replay/manifest.tsxindex ebc07e705bc3..5deb9eff603b 100644--- a/products/replay/manifest.tsx+++ b/products/replay/manifest.tsx@@ -42,6 +42,7 @@ export const manifest: ProductManifest = {name: 'Replay playlist',iconType: 'session_replay',href: (ref: string) => urls.replayPlaylist(ref),+ listHref: () => urls.replay(ReplayTabs.Playlists),iconColor: ['var(--color-product-session-replay-light)', 'var(--color-product-session-replay-dark)'],filterKey: 'session_recording_playlist',},diff --git a/products/surveys/manifest.tsx b/products/surveys/manifest.tsxindex 175bdd55ce74..5c67d522bf87 100644--- a/products/surveys/manifest.tsx+++ b/products/surveys/manifest.tsx@@ -20,6 +20,7 @@ export const manifest: ProductManifest = {name: 'Survey',iconType: 'survey',href: (ref: string) => urls.survey(ref),+ listHref: () => urls.surveys(),iconColor: ['var(--color-product-surveys-light)'],filterKey: 'survey',},diff --git a/products/workflows/manifest.tsx b/products/workflows/manifest.tsxindex 0ad994cf1874..ba99ee32aab5 100644--- a/products/workflows/manifest.tsx+++ b/products/workflows/manifest.tsx@@ -85,6 +85,7 @@ export const manifest: ProductManifest = {iconType: 'workflows',iconColor: ['var(--color-product-workflows-light)'] as FileSystemIconColor,href: (ref: string) => urls.workflow(ref, 'workflow'),+ listHref: () => urls.workflows(),filterKey: 'workflows',},},