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.

2.4 KB
Raw Blame
import { TZLabel } from 'lib/components/TZLabel'
import { LemonTable, LemonTableColumns } from 'lib/lemon-ui/LemonTable'

import type { HealthIssue } from '../types'
import { getErrorLabelForMaterializedView } from '../utils/materializedViewErrors'
import { issueActionsColumn, severityColumn } from './healthTableColumns'

export function DataModelingHealthTable({
    issues,
    onSnooze,
    onDismiss,
    onUndismiss,
}: {
    issues: HealthIssue[]
    onSnooze: (id: string, duration: string) => void
    onDismiss: (id: string) => void
    onUndismiss: (id: string) => void
}): JSX.Element {
    const columns: LemonTableColumns<HealthIssue> = [
        {
            title: 'View',
            key: 'view',
            render: function Render(_, issue: HealthIssue) {
                const { pipeline_name } = issue.payload
                return <span className="font-medium">{pipeline_name ?? 'Unknown view'}</span>
            },
        },
        {
            title: 'Error',
            key: 'error',
            render: function Render(_, issue: HealthIssue) {
                const { error } = issue.payload
                if (!error) {
                    return <span className="text-muted">—</span>
                }
                const errorHelp = getErrorLabelForMaterializedView(error)
                return (
                    <div className="py-1">
                        <div className="text-xs text-secondary whitespace-pre-wrap break-words">{error}</div>
                        {errorHelp && <div className="text-xs text-muted mt-1">{errorHelp}</div>}
                    </div>
                )
            },
        },
        severityColumn(),
        {
            title: 'Last seen',
            key: 'last_seen',
            width: 140,
            align: 'right',
            render: function Render(_, issue: HealthIssue) {
                return <TZLabel time={issue.created_at} />
            },
            sorter: (a, b) => new Date(a.created_at).getTime() - new Date(b.created_at).getTime(),
        },
        issueActionsColumn(onSnooze, onDismiss, onUndismiss),
    ]

    return (
        <LemonTable
            dataSource={issues}
            columns={columns}
            embedded
            size="small"
            defaultSorting={{
                columnKey: 'last_seen',
                order: -1,
            }}
            noSortingCancellation
            rowClassName="group"
        />
    )
}