: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 type { XYPosition } from '@xyflow/react'
import { MakeLogicType, actions, reducers, afterMount, connect, kea, key, path, props } from 'kea'
import { databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'
import { materializationJobsLogic } from 'scenes/data-warehouse/saved_queries/materializationJobsLogic'
import type {
DatabaseSchemaDataWarehouseTable,
DatabaseSchemaTable,
DatabaseSchemaViewTable,
HogQLMetadataResponse,
} from '../../../../queries/schema/schema-general'
import { sqlEditorLogic } from '../sqlEditorLogic'
export interface InfoTabLogicProps {
tabId: string
viewId?: string
skipLineage?: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface infoTabLogicValues {
dataWarehouseTablesMap: Record<string, DatabaseSchemaDataWarehouseTable | DatabaseSchemaViewTable> // databaseTableListLogic
posthogTablesMap: Record<string, DatabaseSchemaTable> // databaseTableListLogic
metadata: HogQLMetadataResponse | null // sqlEditorLogic
activeSection: 'lineage' | 'materialization' | 'quality'
lineageNodePositions: Record<string, XYPosition>
lineageVisited: boolean
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface infoTabLogicActions {
loadUpstream: (modelId: string) => {
modelId: string
} // sqlEditorLogic
lineageNodeDragStopped: (
nodeId: string,
position: XYPosition
) => {
nodeId: string
position: XYPosition
}
resetLineageNodePositions: () => {
value: true
}
setActiveSection: (section: 'lineage' | 'materialization' | 'quality') => {
section: 'lineage' | 'materialization' | 'quality'
}
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
export interface infoTabLogicMeta {
key: string
}
export type infoTabLogicType = MakeLogicType<
infoTabLogicValues,
infoTabLogicActions,
InfoTabLogicProps,
infoTabLogicMeta
>
export const infoTabLogic = kea<infoTabLogicType>([
path(['data-warehouse', 'editor', 'sidebar', 'infoTabLogic']),
props({} as InfoTabLogicProps),
key((props) => `${props.tabId}-${props.viewId ?? 'new'}`),
connect((props: InfoTabLogicProps) => ({
values: [
sqlEditorLogic({ tabId: props.tabId }),
['metadata'],
databaseTableListLogic,
['posthogTablesMap', 'dataWarehouseTablesMap'],
],
actions: [sqlEditorLogic({ tabId: props.tabId }), ['loadUpstream']],
logic: props.viewId ? [materializationJobsLogic({ viewId: props.viewId })] : [],
})),
actions({
setActiveSection: (section: 'materialization' | 'lineage' | 'quality') => ({ section }),
lineageNodeDragStopped: (nodeId: string, position: XYPosition) => ({ nodeId, position }),
resetLineageNodePositions: true,
}),
reducers({
lineageNodePositions: [
{} as Record<string, XYPosition>,
{
lineageNodeDragStopped: (positions, { nodeId, position }) => ({ ...positions, [nodeId]: position }),
resetLineageNodePositions: () => ({}),
},
],
lineageVisited: [false, { setActiveSection: (visited, { section }) => visited || section === 'lineage' }],
activeSection: [
'materialization' as 'materialization' | 'lineage' | 'quality',
{ setActiveSection: (_, { section }) => section },
],
}),
afterMount(({ actions, props }) => {
if (props.viewId && !props.skipLineage) {
actions.loadUpstream(props.viewId)
}
}),
])