: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, afterMount, kea, key, path, props, reducers, selectors } from 'kea'
import { loaders } from 'kea-loaders'
import api from 'lib/api'
import { DataModelingEdge, DataModelingNode } from '~/types'
export interface EndpointLineageLogicProps {
savedQueryId: string
}
export interface EndpointLineageGraph {
nodes: DataModelingNode[]
edges: DataModelingEdge[]
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface endpointLineageLogicValues {
currentNodeId: string | undefined
lineage: EndpointLineageGraph | null
lineageFailed: boolean
lineageLoading: boolean
lineageMissing: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface endpointLineageLogicActions {
loadLineage: () => any
loadLineageFailure: (
error: string,
errorObject?: any
) => {
error: string
errorObject?: any
}
loadLineageSuccess: (
lineage: {
edges: DataModelingEdge[]
nodes: DataModelingNode[]
},
payload?: any
) => {
lineage: {
edges: DataModelingEdge[]
nodes: DataModelingNode[]
}
payload?: any
}
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface endpointLineageLogicMeta {
key: string
__keaTypeGenInternalSelectorTypes: {
currentNodeId: (lineage: EndpointLineageGraph | null, savedQueryId: string) => string | undefined
}
}
export type endpointLineageLogicType = MakeLogicType<
endpointLineageLogicValues,
endpointLineageLogicActions,
EndpointLineageLogicProps,
endpointLineageLogicMeta
>
export const endpointLineageLogic = kea<endpointLineageLogicType>([
path((savedQueryId) => ['products', 'endpoints', 'frontend', 'endpointLineageLogic', savedQueryId]),
props({} as EndpointLineageLogicProps),
key((props) => props.savedQueryId),
loaders(({ props }) => ({
lineage: {
__default: null as EndpointLineageGraph | null,
loadLineage: async () => await api.dataModelingNodes.lineage({ savedQueryId: props.savedQueryId }),
},
})),
reducers({
lineageMissing: [
false,
{
loadLineage: () => false,
loadLineageSuccess: () => false,
// The backing model has no lineage node yet, which is not a failure the user can retry away.
loadLineageFailure: (_, { errorObject }) => errorObject?.status === 404,
},
],
lineageFailed: [
false,
{
loadLineage: () => false,
loadLineageSuccess: () => false,
loadLineageFailure: (_, { errorObject }) => errorObject?.status !== 404,
},
],
}),
selectors({
currentNodeId: [
(s, p) => [s.lineage, p.savedQueryId],
(lineage: EndpointLineageGraph | null, savedQueryId: string): string | undefined =>
lineage?.nodes.find((node) => node.saved_query_id === savedQueryId)?.id,
],
}),
afterMount(({ actions }) => {
actions.loadLineage()
}),
])