: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(search): list sidebar data products under products in search (#122225)
Shy Alter76030d21f544
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 7d609134ec6d..39d7172ef03f 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -701,9 +701,9 @@ snapshots:components-command-k-search--chip-and-value-suggestions--light:hash: v1.k794b7964.e7333bff9cf7731d6fc4de2c3de02126f269c9f18072af98231084282a7c5d65.J458vmekHctug5oj4MC67c2qudoY1nHzt0P9V_3lzx4components-command-k-search--empty--dark:- hash: v1.k794b7964.4484e7d68af11aaef170ca21b18f643a52c0450fcccf7145858f42058f3a7274.o3_BNw21CY4AJQQyiGz6hgboSFv6n16lHhQwWdI6SA4+ hash: v1.k794b7964.711532ac6e726991456a1aa5a65adf56f507b821de5e1a0c1fdfdb346fbd6e50.-PeRL7ixVxVUioP_mIhM-QchAgCbxP020gNMtokg-Xkcomponents-command-k-search--empty--light:- hash: v1.k794b7964.fad5dab496146f2d1b2d91797627e8fb1561aa7ebfa136e797405d6e4ffc0a7f.XWb09o2rM_vyj5XpvqH59nnKZIdGRyV1LuxMzax6oLg+ hash: v1.k794b7964.f4c44beb1177df5a36770418b3141cbc9c26aa1665bf648865efd6eeab65437f.yDDLvsODc11eeiBKHRmSt12Ox8AxQZSgiRfGcd_ZR5ocomponents-command-k-search-notice--close-spellings--dark:hash: v1.k794b7964.ffa192d267350a8866038659a7415aed68505662d35ae38774d58f83d5836c77.mHzLJfwxAGLcu-XeF7aGcByPBoDWki0HcQVfD-vHjoscomponents-command-k-search-notice--close-spellings--light:@@ -2581,21 +2581,21 @@ snapshots:components-sample-data-tag--default--light:hash: v1.k794b7964.8ebad648dbf23b4ccf50c7b2543d02e9429c2f5c67446cee8823fc06fc98a97d.MSu4A4yz_nNpo8sN007sucqXSdbb7pJQExT5Z2ki0Yscomponents-search--default--dark:- hash: v1.k794b7964.e02bbbdf3b5e7c127c50dfd8a8b37f2de2f7f23a2e168b0fd2d13aaeaa44c88e.X7tFtyBFjd0owneYHrHkMXGyTTfUpyv3ZSK4jVhZAPQ+ hash: v1.k794b7964.dca87db2490271ab0f31e1b979c2c750b4f043aa08498e30c5369b1c83f3e850.9IyyaNG3y6r8tfQ_In6KmoBQAu6FlPFJwch9B89Iuaccomponents-search--default--light:- hash: v1.k794b7964.3420591fdb738826c4e0e26f2409e1d03b93e5ae9629ff93e6e688b4d1b162c3.-cabrwpKPTBpJBfmgQtynN4vhxoATGoOZfVsymBWV0U+ hash: v1.k794b7964.10627e8b69503bd6032015f2ad8c2e552e81867fdb62edb4b227db9161714699.3KhOPe07YqESm6ymnYqFsas51lcVitH0LkFikbyS_pIcomponents-search--no-recents--dark:- hash: v1.k794b7964.b168e4ad14397a720a1e45e6b446552fb9ea78e40b25cc2e3074310b52a5dff6.q6X85q0o2uVqkASgia96VyNCZAlzZ2Q2HFISdsFXzw0+ hash: v1.k794b7964.8f8e67ab8165a5bb4aa3d509893f94ba58f7f8035914616cf8bcf7c534e66b26.mnAGjlTGX_zDvUYV4Dk8apN7oSJKHt1N44Kc_8QYNhEcomponents-search--no-recents--light:- hash: v1.k794b7964.ae1ddd9214e27e7567fdc898f5f0e41412f34288a81ed50e90ab28864d76c531.EZU79H9z28tXUACiqIupE2mb5Mv1JNcn-mFDellqV44+ hash: v1.k794b7964.d69ea663238ed0999dcd14571ae277687251aa334630b3633d74c797668259d3.-WbgKzJQ53wPPlS9fSRAPccrJxlr-5O4gnvxaj7wQS8components-search--product-recents-and-starred--dark:- hash: v1.k794b7964.614b22a128f415535fbb21f8a81368d14c3f1bf7ddafdae6629c82726ebbe42a.MTE--SBuwsAWaNIRH67s1jt1RfBZr1Oz9HvG_WVxI8s+ hash: v1.k794b7964.cf516b70563583f8fb7769dbcc5137148c0386e3b94425e0ccb69a56dc79f40a.VFbD1u7M3am4LhA_Vg6qeDRZPpleheJwcpfOsmF9YkAcomponents-search--product-recents-and-starred--light:- hash: v1.k794b7964.45213063c3c767175033b9c3ff72d94df2e3ffc9ffe46398bc78c45c3708f1b5.X_mXo_erMw09YXsaZY6-sc_9vQx8VtriGVHZgr_wJmw+ hash: v1.k794b7964.de38039f5c4dd76a9caf4c523b664147d93a5920443ff6afa6353227e58ef2e6.NsoucGXVlw4tPpndBq9jFa-71CN-nHMr1VhLxOoPNUMcomponents-search--searching--dark:- hash: v1.k794b7964.03acd9350d844642fcd4971fedf6ccd292cd55de90491de1e0e61e3d2f2c6351.d7owNfoNUSyFo1hSaw30YobKmlUwv7-6KTuJ1gmFTdQ+ hash: v1.k794b7964.8c219491666e60b1ad086370c8f852cdf1acfee4535f64982efeb7613c19050e.1gjDWCOin1IZ-0bvNOSsHei1nJpA2_MCOU4otfuRxaMcomponents-search--searching--light:- hash: v1.k794b7964.51550119b35091ec40c82de96dbd0f24321f97c57ff3478d89bea67725e12af9.Nleu2HKxfxKvGQ_3IatPMgra85XmDbPQu1tCIUE5QvI+ hash: v1.k794b7964.9b06546bad6e583e43eed94fcfe5f99d97bbc30754f181095a127a1a16b336ef.ueejxmtIVer_cwBqE1T-UiEguosuhQPFz7AbasCihCgcomponents-sentencelist--full-sentence--dark:hash: v1.k794b7964.7e8e5dd2e09d246cc3668f362f2391fe67618bd1143aa393832297f5dc30e558.yptEWKc5RAUY613Fwd5cQ0VIinMvpdoI6cuKgagAGxkcomponents-sentencelist--full-sentence--light:diff --git a/frontend/src/layout/panel-layout/navbar/tabs/navProductItems.ts b/frontend/src/layout/panel-layout/navbar/tabs/navProductItems.tsindex 719ce90fd4df..23f1fe1cca1f 100644--- a/frontend/src/layout/panel-layout/navbar/tabs/navProductItems.ts+++ b/frontend/src/layout/panel-layout/navbar/tabs/navProductItems.ts@@ -19,6 +19,10 @@ import {// These pages are tabs of Event definitions, so the sidebar lists only that entry for them.const DEFINITIONS_TAB_HREFS = new Set(DEFINITIONS_TABS.filter((tab) => tab.key !== 'events').map((tab) => tab.url))+export function isDefinitionsTabHref(href: string | undefined): boolean {+ return !!href && DEFINITIONS_TAB_HREFS.has(href)+}+// Items in this category sit above Starred and All products, so they are never starred or grouped.export const PINNED_CATEGORY = 'Project'@@ -79,7 +83,7 @@ export function getNavProductItems(featureFlags: FeatureFlagsSet, projectCreated]const destinations = new Map<string, FileSystemImport>()for (const item of items) {- if (!item.href || DEFINITIONS_TAB_HREFS.has(item.href) || !isFileSystemImportFlagEnabled(item, featureFlags)) {+ if (!item.href || isDefinitionsTabHref(item.href) || !isFileSystemImportFlagEnabled(item, featureFlags)) {continue}const existing = destinations.get(item.href)diff --git a/frontend/src/lib/components/CommandKSearch/COMMAND_K_SEARCH_UX.md b/frontend/src/lib/components/CommandKSearch/COMMAND_K_SEARCH_UX.mdindex 91f8746a478b..01535bdde630 100644--- a/frontend/src/lib/components/CommandKSearch/COMMAND_K_SEARCH_UX.md+++ b/frontend/src/lib/components/CommandKSearch/COMMAND_K_SEARCH_UX.md@@ -103,7 +103,7 @@ The input is always in exactly one mode, decided from the token under the cursor### Ranked results-Results for a search with words follow ordered tie-breaking rules: words matched, typos, word proximity, name before folder, exact words, word position, exactness, the person's recent views, then recency. Products rank with the same rules through their name and search keywords, so "recordings" finds Session replay.+Results for a search with words follow ordered tie-breaking rules: words matched, typos, word proximity, name before folder, exact words, word position, exactness, the person's recent views, then recency. Products rank with the same rules through their name and search keywords, so "recordings" finds Session replay. When a name match and a search keyword match tie, the name match ranks first, so "metrics" puts Metrics above Data catalog.- When no result has every word, results use the words that matched. A callout above the results names the dropped word ("No matches for **xyzzy**. Showing results for **report**."). When every match needs a typo, it says "No exact matches for **dashbord**. Showing close spellings." The callout is not selectable.- **Best matches** comes first: the three best results of different types.diff --git a/frontend/src/lib/components/CommandKSearch/commandKRankedResults.test.ts b/frontend/src/lib/components/CommandKSearch/commandKRankedResults.test.tsindex 1f5c0d2bf911..9e0eba26714f 100644--- a/frontend/src/lib/components/CommandKSearch/commandKRankedResults.test.ts+++ b/frontend/src/lib/components/CommandKSearch/commandKRankedResults.test.ts@@ -59,6 +59,20 @@ describe('buildRankedResults', () => {products: [product('Session replay', ['recordings']), product('Surveys')],expected: ['Results: Session replay, Recordings funnel'],},+ {+ name: 'a product leads a tab of another product with the same name, and they do not collapse',+ query: 'playground',+ results: [],+ products: [+ {+ ...product('Business knowledge Playground'),+ displayName: 'Playground',+ parentName: 'Business knowledge',+ },+ product('Playground'),+ ],+ expected: ['Results: Playground, Business knowledge Playground'],+ },{name: 'a product that matches fewer words than the saved objects stays out',query: 'flags billing',diff --git a/frontend/src/lib/components/CommandKSearch/commandKRankedResults.ts b/frontend/src/lib/components/CommandKSearch/commandKRankedResults.tsindex 895ebebbd9fb..bd28ea99ff86 100644--- a/frontend/src/lib/components/CommandKSearch/commandKRankedResults.ts+++ b/frontend/src/lib/components/CommandKSearch/commandKRankedResults.ts@@ -28,7 +28,12 @@ function groupLabel(groupKey: string): string {function rankProducts(products: SearchItem[], query: string): RankedItem[] {return products.flatMap((item) => {- const ranked = rankLocalItem(query, String(item.displayName || item.name), item.searchKeywords)+ const ranked = rankLocalItem(+ query,+ String(item.displayName || item.name),+ item.searchKeywords,+ !!item.parentName+ )return ranked? [{@@ -75,7 +80,7 @@ function collapseSameName(entries: RankedItem[]): CollapsedItem[] {const byName = new Map<string, CollapsedItem>()const collapsed: CollapsedItem[] = []for (const entry of entries) {- const key = `${entry.groupKey}|${normalizedName(entry.item)}`+ const key = `${entry.groupKey}|${entry.item.parentName ?? ''}|${normalizedName(entry.item)}`const existing = byName.get(key)if (existing) {existing.duplicates++diff --git a/frontend/src/lib/components/CommandKSearch/commandKRanking.test.ts b/frontend/src/lib/components/CommandKSearch/commandKRanking.test.tsindex 53685f818e3d..df862a754b12 100644--- a/frontend/src/lib/components/CommandKSearch/commandKRanking.test.ts+++ b/frontend/src/lib/components/CommandKSearch/commandKRanking.test.ts@@ -39,6 +39,14 @@ describe('commandKRanking', () => {expect(rankLocalItem(query, name, aliases)?.matchedAlias).toEqual(alias)})+ test.each([+ { query: 'metrics', other: 'Data catalog', aliases: ['semantic layer', 'metrics'] },+ { query: 'mertics', other: 'Shared metrics', aliases: [] },+ ])('ranks Metrics above $other for $query', ({ query, other, aliases }) => {+ const metrics = rankLocalItem(query, 'Metrics', ['time series'])?.rank ?? []+ expect(compareRanks(metrics, rankLocalItem(query, other, aliases)?.rank ?? [])).toBeLessThan(0)+ })+it('matches a plural query to a singular name without a typo', () => {expect(strictLocalMatches([{ name: 'Survey' }, { name: 'Surveyed users' }], 'surveys')).toEqual([{ name: 'Survey' },diff --git a/frontend/src/lib/components/CommandKSearch/commandKRanking.ts b/frontend/src/lib/components/CommandKSearch/commandKRanking.tsindex ca55cc056316..e9835b33038b 100644--- a/frontend/src/lib/components/CommandKSearch/commandKRanking.ts+++ b/frontend/src/lib/components/CommandKSearch/commandKRanking.ts@@ -101,7 +101,7 @@ function exactness(query: string, name: string, nameWords: string[]): number {return 5}-function rankName(query: string, tokens: string[], name: string): RankKey | null {+function rankName(query: string, tokens: string[], name: string, indirect: number): RankKey | null {const lowerName = name.toLowerCase()const nameWords = searchWords(lowerName)let matched = 0@@ -137,9 +137,9 @@ function rankName(query: string, tokens: string[], name: string): RankKey | nullproximity,matched === tokens.length ? 0 : 1,-exactWords,- 0,+ Math.min(...positions),Math.min(exactness(query, lowerName, nameWords), STARTS_WITH),- 0,+ indirect,-Number.MAX_SAFE_INTEGER,]}@@ -158,19 +158,19 @@ interface LocalRank {matchedAlias: string | null}-export function rankLocalItem(query: string, name: string, aliases: string[] = []): LocalRank | null {+export function rankLocalItem(query: string, name: string, aliases: string[] = [], isTab = false): LocalRank | null {const normalized = query.trim().toLowerCase().replace(/\s+/g, ' ').slice(0, MAX_LOCAL_QUERY_LENGTH)const tokens = searchWords(normalized)if (!tokens.length) {return null}let best: LocalRank | null = null- const byName = rankName(normalized, tokens, name)+ const byName = rankName(normalized, tokens, name, isTab ? 1 : 0)if (byName) {best = { rank: byName, matchedAlias: null }}for (const alias of normalized.length >= MIN_ALIAS_QUERY_LENGTH ? aliases : []) {- const byAlias = rankName(normalized, tokens, alias)+ const byAlias = rankName(normalized, tokens, alias, isTab ? 2 : 1)if (byAlias && (!best || compareRanks(byAlias, best.rank) < 0)) {best = { rank: byAlias, matchedAlias: alias }}diff --git a/frontend/src/lib/components/Search/searchListsLogic.test.ts b/frontend/src/lib/components/Search/searchListsLogic.test.tsindex ddc0aa2c1900..45a815368fab 100644--- a/frontend/src/lib/components/Search/searchListsLogic.test.ts+++ b/frontend/src/lib/components/Search/searchListsLogic.test.ts@@ -35,6 +35,13 @@ describe('searchListsLogic', () => {expect(logic.values.productsItems.some((item) => item.id === 'product-Data warehouse')).toBe(visible)})+ it('lists each product destination once', () => {+ const hrefs = logic.values.productsItems.filter((item) => item.category === 'tools').map((item) => item.href)++ expect(hrefs.filter((href) => href === urls.endpoints())).toHaveLength(1)+ expect(new Set(hrefs).size).toBe(hrefs.length)+ })+it.each(['support', 'tickets', 'contact support', 'help'])('finds Your tickets when searching "%s"', (query) => {const matches = filterSearchItems(logic.values.miscItems, query)diff --git a/frontend/src/lib/components/Search/searchListsLogic.tsx b/frontend/src/lib/components/Search/searchListsLogic.tsxindex 9d493813e8be..a8f4193d6002 100644--- a/frontend/src/lib/components/Search/searchListsLogic.tsx+++ b/frontend/src/lib/components/Search/searchListsLogic.tsx@@ -27,6 +27,7 @@ import { terminalDockLogic } from 'scenes/terminal/terminalDockLogic'import { urls } from 'scenes/urls'import { userLogic } from 'scenes/userLogic'+import { isDefinitionsTabHref } from '~/layout/panel-layout/navbar/tabs/navProductItems'import { getDefaultTreePersons } from '~/layout/panel-layout/ProjectTree/defaultTree'import { projectTreeDataLogic } from '~/layout/panel-layout/ProjectTree/projectTreeDataLogic'import { recentItemsModel } from '~/models/recentItemsModel'@@ -45,6 +46,10 @@ const isEnabledByFlag = (flag: string | undefined, featureFlags: FeatureFlagsSetconst displayNameOf = (item: SearchItem): string => item.displayName || item.name+const CATEGORY_SEARCH_KEYWORDS: Record<string, string[]> = {+ CDP: ['data pipelines', 'data pipeline', 'pipeline'],+}+const toSearchTabItems = (parents: SearchItem[],sources: FileSystemImport[],@@ -254,9 +259,13 @@ export const searchListsLogic = kea<searchListsLogicType>([user: null | import('~/types').UserType,sceneLogViewsByRef: Record<string, string>): SearchItem[] => {- const allProducts = getTreeItemsProducts()+ const allProducts = [+ ...getTreeItemsProducts(),+ ...getTreeItemsMetadata().filter((item) => !isDefinitionsTabHref(item.href)),+ ]+ const seenHrefs = new Set<string>()const filteredProducts = allProducts.filter((product) => {- if (!product.href) {+ if (!product.href || seenHrefs.has(product.href)) {return false}if (!isDev && !user?.is_staff && product.category === 'Unreleased') {@@ -265,6 +274,7 @@ export const searchListsLogic = kea<searchListsLogicType>([if (!isFileSystemImportFlagEnabled(product, featureFlags)) {return false}+ seenHrefs.add(product.href)return true})@@ -276,7 +286,10 @@ export const searchListsLogic = kea<searchListsLogicType>([productCategory: product.category || null,href: product.href || PLACEHOLDER_HREF,itemType: product.iconType || product.type || null,- searchKeywords: product.searchKeywords,+ searchKeywords: [+ ...(product.category ? (CATEGORY_SEARCH_KEYWORDS[product.category] ?? []) : []),+ ...(product.searchKeywords ?? []),+ ],lastViewedAt: product.sceneKey ? (sceneLogViewsByRef[product.sceneKey] ?? null) : null,disabledReason: getProductAccessDisabledReason(product),record: {@@ -314,7 +327,7 @@ export const searchListsLogic = kea<searchListsLogicType>([user: null | import('~/types').UserType,sceneLogViewsByRef: Record<string, string>): SearchItem[] => {- const allMetadata = getTreeItemsMetadata()+ const allMetadata = getTreeItemsMetadata().filter((item) => isDefinitionsTabHref(item.href))const filteredMetadata = allMetadata.filter((item) => {if (!isDev && !user?.is_staff && item.category === 'Unreleased') {return false@@ -325,10 +338,6 @@ export const searchListsLogic = kea<searchListsLogicType>([return true})- const categorySearchKeywords: Record<string, string[]> = {- CDP: ['data pipelines', 'data pipeline', 'pipeline'],- }-const items: SearchItem[] = filteredMetadata.map((item) => ({id: `data-management-${item.path}`,name: item.path,@@ -337,10 +346,7 @@ export const searchListsLogic = kea<searchListsLogicType>([productCategory: item.category || null,href: item.href || PLACEHOLDER_HREF,itemType: item.iconType || item.type || null,- searchKeywords: [- ...(item.category ? (categorySearchKeywords[item.category] ?? []) : []),- ...(item.searchKeywords ?? []),- ],+ searchKeywords: item.searchKeywords,lastViewedAt: item.sceneKey ? (sceneLogViewsByRef[item.sceneKey] ?? null) : null,disabledReason: getProductAccessDisabledReason(item),record: {diff --git a/frontend/src/lib/components/Search/searchLogic.test.ts b/frontend/src/lib/components/Search/searchLogic.test.tsindex 4122bd177698..8b554df33280 100644--- a/frontend/src/lib/components/Search/searchLogic.test.ts+++ b/frontend/src/lib/components/Search/searchLogic.test.ts@@ -110,9 +110,9 @@ describe('searchLogic', () => {})it.each([- ['materialized views', 'dataManagementItems', 'Models'],- ['data modeling', 'dataManagementItems', 'Models'],- ['batch exports', 'dataManagementItems', 'Destinations Batch exports'],+ ['materialized views', 'productsItems', 'Models'],+ ['data modeling', 'productsItems', 'Models'],+ ['batch exports', 'productsItems', 'Destinations Batch exports'],['insights', 'productsItems', 'Product analytics'],['semantic layer', 'productsItems', 'Data catalog'],['Semantic Layer', 'productsItems', 'Data catalog'],