: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
import { MakeLogicType, actions, connect, kea, path, reducers, selectors } from 'kea'
import { FeatureFlagsSet, featureFlagLogic } from 'lib/logic/featureFlagLogic'
import { getProductAccessDisabledReason } from 'lib/utils/accessControlUtils'
import { isFileSystemImportFlagEnabled } from 'lib/utils/fileSystemImportFlags'
import { projectTreeDataLogic } from '~/layout/panel-layout/ProjectTree/projectTreeDataLogic'
import { FileSystemImport } from '~/queries/schema/schema-general'
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[] // projectTreeDataLogic
search: string
toolGroups: ToolGroup[]
tools: FileSystemImport[]
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface toolsLogicActions {
setSearch: (search: string) => {
search: string
}
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface toolsLogicMeta {
__keaTypeGenInternalSelectorTypes: {
tools: (featureFlags: FeatureFlagsSet, groupItems: FileSystemImport[]) => FileSystemImport[]
toolGroups: (tools: FileSystemImport[], search: string) => ToolGroup[]
}
}
export type toolsLogicType = MakeLogicType<toolsLogicValues, toolsLogicActions, Record<string, any>, toolsLogicMeta>
export const toolsLogic = kea<toolsLogicType>([
path(['scenes', 'tools', 'toolsLogic']),
connect(() => ({ values: [featureFlagLogic, ['featureFlags'], projectTreeDataLogic, ['groupItems']] })),
actions({ setSearch: (search: string) => ({ search }) }),
reducers({ search: ['', { setSearch: (_, { search }) => search }] }),
selectors({
tools: [
(s) => [s.featureFlags, s.groupItems],
(featureFlags: FeatureFlagsSet, groupItems: FileSystemImport[]): FileSystemImport[] => {
const seen = new Set<string>()
// 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 ||
!isToolItem(item) ||
seen.has(item.href) ||
!isFileSystemImportFlagEnabled(item, featureFlags) ||
getProductAccessDisabledReason(item)
) {
return false
}
seen.add(item.href)
return true
})
.sort((first, second) => toolLabel(first).localeCompare(toolLabel(second)))
},
],
toolGroups: [
(s) => [s.tools, s.search],
(tools: FileSystemImport[], search: string): ToolGroup[] => groupTools(tools, search),
],
}),
])