Skip to content

: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.

fix(search): resolve icons for blank-typed starred items (#66963)

Paul D'Ambra2c31daa8edca
diff --git a/frontend/src/lib/components/Search/searchLogic.tsx b/frontend/src/lib/components/Search/searchLogic.tsx
index b7b6d2d76e4e..1b19bed6293d 100644
--- a/frontend/src/lib/components/Search/searchLogic.tsx
+++ b/frontend/src/lib/components/Search/searchLogic.tsx
@@ -29,6 +29,7 @@ import { filterSearchItems } from './utils'
let cachedProductIconColorByType: Map<string, FileSystemIconColor> | null = null
let cachedProductDisplayLabelByPath: Map<string, string> | null = null
+let cachedProductIconTypeByPath: Map<string, string> | null = null
const getProductIconColorByType = (): Map<string, FileSystemIconColor> => {
if (cachedProductIconColorByType === null) {
@@ -55,6 +56,19 @@ const getProductDisplayLabelByPath = (): Map<string, string> => {
return cachedProductDisplayLabelByPath
}
+const getProductIconTypeByPath = (): Map<string, string> => {
+ if (cachedProductIconTypeByPath === null) {
+ cachedProductIconTypeByPath = new Map()
+ for (const product of getTreeItemsProducts()) {
+ const iconType = product.type || product.iconType
+ if (iconType) {
+ cachedProductIconTypeByPath.set(product.path, iconType)
+ }
+ }
+ }
+ return cachedProductIconTypeByPath
+}
+
const fileSystemEntryToSearchItem = (
item: FileSystemEntry,
overrides: { id: string; category: string; searchKeywords?: string[] }
@@ -62,13 +76,17 @@ const fileSystemEntryToSearchItem = (
const name = splitPath(item.path).pop()
const itemName = name ? unescapePath(name) : item.path
const displayName = getProductDisplayLabelByPath().get(itemName)
- const productIconColor = item.type ? getProductIconColorByType().get(item.type) : undefined
+ // Older starred shortcuts (e.g. Logs, Web analytics) were saved with a blank (empty-string)
+ // type because their product only defines `iconType`. The `||` (not `??`) is deliberate: an
+ // empty string must fall through to the product registry, keyed by name, so the icon resolves.
+ const itemType = item.type || getProductIconTypeByPath().get(itemName) || null
+ const productIconColor = itemType ? getProductIconColorByType().get(itemType) : undefined
return {
name: itemName,
displayName,
href: item.href || '#',
lastViewedAt: item.last_viewed_at ?? null,
- itemType: item.type ?? null,
+ itemType,
record: { ...item, iconColor: productIconColor },
...overrides,
}