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.

feat(data-quality): tighten the data quality overview states (#101047)

Thiago Salvatore3c79cfe30d99
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 55c28b7feff0..2921f329f377 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -5805,21 +5805,21 @@ snapshots:
products-data-modeling-views-list--actions--light:
hash: v1.k794b7964.72724e994dcffa8f4d3914d5e9f87d9c6ad7ddfe0ffd28a02897129354ba956d.Vu7BhdcTI1yxaNzfgaW9gFoiBIScbrYMw9RN8FmP1ms
products-data-quality-overview--default--dark:
- hash: v1.k794b7964.1d8602147e022dc66f365cd1adaecea883b58c9882959151f69e2b1e174854e1.v4WuLvd2kNBF9E9wu-ga73LWO0E7T_hWA4ipRR_nq50
+ hash: v1.k794b7964.a76c0a0a52b4899bbc284267a9401f161027073107f64241a1ca6212c8402eb7.kxBvgToQcotkJw5a6_uClxdSsJmvHxdoWx4dT0DPMf8
products-data-quality-overview--default--light:
- hash: v1.k794b7964.b6c5da27b88a2c579ec3c2c176e8c9ffe613c6429810232a1315e79b80cec4ac.fyT6ugM02IBcH2t_JLB9iqu1AiRX4dDE6-YAmaSEfNc
+ hash: v1.k794b7964.d4e4a007fd8dc6bd071ec34b6414daf84c56d8af2fe843df224d623b308c136d.-qoPd7IS8jzPQhS3wsQ6pOVtumNQ-1HTOTw8wwPucTk
products-data-quality-overview--empty--dark:
- hash: v1.k794b7964.521afa3781f830cc7711e3afaca83cca31428780c9750b62f525ddbf32b4b7e1.l64ODysehFkdsQhCfzbQyGvfMtP7yYauTO27XfoOZTE
+ hash: v1.k794b7964.aef914cdb03e217fe4640aacf8eed4a798f9ef6a9ff1152d424fb839492d3c5a.bQxhnZ1IkgLapO0PLUeTbSbwnfTfgD0GBumWdOq6tsI
products-data-quality-overview--empty--light:
- hash: v1.k794b7964.fae8647ae4c1f915ac9fce2f917588fb725b798eeb922ff7a4761ac7e7d64962.wGwZ5yL_avhnizzxPNWndWUjytnujaC4C3cX8C6Fk8s
+ hash: v1.k794b7964.ae20a8bb7ab523520b39769efb5ba3f209316062d304b7dbda14b1a0118aa59f.DK2jH1rE0O7c3IdFpyI1sWIUU-rjQyh9nWc1VoZD9Gw
products-data-quality-overview--narrow--dark:
hash: v1.k794b7964.ab1dc8d009d28798ed92bac7897cae61a541492a713b7c3e0aae8d30b20cbb70.1RHkf5iF7pgMZru0VsuyYFr54yToqY8wWqkfgKt95O4
products-data-quality-overview--narrow--light:
hash: v1.k794b7964.874828133fdc4247f4ba0e6485094636e490e90cbb265c0c519f9f8ba2168a2a.d7PqHHUzicKzzWuqBJUz6pLOJf44hkf_19dL5k6x4wA
products-data-quality-overview--narrow-empty--dark:
- hash: v1.k794b7964.ef813fd10215bab43b653620d7ff3dcf56d3fb16bab81c0409b67786bcc359a1.eJz8r_4_6j-DVZnnbuL6nTucLWqDnZKwiFq7DE4gvb0
+ hash: v1.k794b7964.1cd9a844cb246b38b4bbd177c34ec9db60c45fdae6a9e46c9246952165a9070f.Sr2NAphdaoOfPI0lR2OL0dhVkr5noiBifnDNr5lQQkk
products-data-quality-overview--narrow-empty--light:
- hash: v1.k794b7964.81260019eb44052bb76fe97fe8debcc7f15ecb6b3a8dcef2422cc19ed8d5acd3.THqGZDG1xTBrwV_Gc404fpGHMABzSYAnm9uCflx5WEo
+ hash: v1.k794b7964.59ccc48cc2c5362a03766b0467145a11574abe2978dc286acd07c3e0249505d1.kkv6y918MpirjkSJIgEzyx2vOKbIaweiEm0zBJ75R4g
products-mcp-analytics-routingbar--all-variants--dark:
hash: v1.k794b7964.769a69526cf676447319f587f24ed0d2670a137098867f8d3ee87ebda3415a70.3FGS0pbxxcrZUSto8SNCNHEkxaFXH6T8shqpdg5zzlQ
products-mcp-analytics-routingbar--all-variants--light:
diff --git a/products/data_quality/frontend/overview/DataQualityEmptyState.tsx b/products/data_quality/frontend/overview/DataQualityEmptyState.tsx
new file mode 100644
index 000000000000..d01c2d9aa4b9
--- /dev/null
+++ b/products/data_quality/frontend/overview/DataQualityEmptyState.tsx
@@ -0,0 +1,71 @@
+import * as scientistPng from '@posthog/brand/hoggies/png/scientist'
+import { LemonButton, LemonTag } from '@posthog/lemon-ui'
+
+import { pngHoggie } from 'lib/brand/hoggies'
+
+import { CHECK_STATUS_TAG_TYPES } from '../checksConstants'
+
+const HedgehogScientist = pngHoggie(scientistPng)
+
+const SETUP_STEPS = [
+ 'Pick a table, view, or metric.',
+ 'Choose what to assert: not null, unique, accepted values, relationships, row count, freshness, or your own SQL.',
+ 'See failing checks here and on the page of the model they test.',
+]
+
+const EXAMPLE_CHECKS = [
+ { name: 'order_id is never null', status: 'failed', detail: '12 failing rows' },
+ { name: 'orders arrive daily', status: 'passed', detail: 'Ran 2 hours ago' },
+]
+
+export function DataQualityEmptyState({ onAddCheck }: { onAddCheck: () => void }): JSX.Element {
+ return (
+ <div
+ data-attr="data-quality-overview-empty-state"
+ className="border rounded p-6 flex flex-col @min-[48rem]/main-content:flex-row gap-6 items-start"
+ >
+ <div className="flex-1 min-w-0 flex flex-col gap-4">
+ <div className="flex items-start gap-4">
+ <HedgehogScientist className="w-24 shrink-0" />
+ <div className="min-w-0">
+ <h2 className="mb-1 text-xl leading-tight">No checks yet</h2>
+ <p className="mb-0 text-secondary">
+ A check tests one thing about your data and runs after each sync or materialization. It
+ tells you when the data stops looking right, before someone reads a dashboard built on it.
+ </p>
+ </div>
+ </div>
+ <ol className="mb-0 list-decimal pl-5 flex flex-col gap-2 text-secondary">
+ {SETUP_STEPS.map((step) => (
+ <li key={step}>{step}</li>
+ ))}
+ </ol>
+ <div>
+ <LemonButton
+ type="primary"
+ size="small"
+ onClick={onAddCheck}
+ data-attr="data-quality-overview-first-check"
+ >
+ Add your first check
+ </LemonButton>
+ </div>
+ </div>
+ <div className="w-full @min-[48rem]/main-content:w-80 shrink-0 rounded border bg-surface-secondary">
+ <div className="flex items-baseline gap-2 px-3 py-2 border-b">
+ <span className="font-semibold truncate">orders</span>
+ <span className="text-xs text-tertiary">Example</span>
+ </div>
+ <div className="divide-y">
+ {EXAMPLE_CHECKS.map((check) => (
+ <div key={check.name} className="flex flex-wrap items-center gap-2 px-3 py-2 text-sm">
+ <span className="flex-1 min-w-0 truncate">{check.name}</span>
+ <LemonTag type={CHECK_STATUS_TAG_TYPES[check.status]}>{check.status}</LemonTag>
+ <span className="text-tertiary">{check.detail}</span>
+ </div>
+ ))}
+ </div>
+ </div>
+ </div>
+ )
+}
diff --git a/products/data_quality/frontend/overview/DataQualityOverview.test.tsx b/products/data_quality/frontend/overview/DataQualityOverview.test.tsx
index 4f6c8cca6d71..9d5f2b852d6f 100644
--- a/products/data_quality/frontend/overview/DataQualityOverview.test.tsx
+++ b/products/data_quality/frontend/overview/DataQualityOverview.test.tsx
@@ -1,4 +1,4 @@
-import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'
+import { cleanup, fireEvent, render, screen, waitFor, within } from '@testing-library/react'
import { databaseTableListLogic } from 'scenes/data-management/database/databaseTableListLogic'
@@ -198,6 +198,7 @@ describe('DataQualityOverview', () => {
await waitFor(() => expect(runSubjectButtons()).toHaveLength(1))
const disclosure = queryAll('[data-attr="data-quality-subject-disclosure"]')[0]
+ expect(within(disclosure.parentElement!).getByText('Failing')).toBeTruthy()
// Suffix match: the rendered href carries the /project/:id prefix, so an exact match on the
// path would find nothing and the assertion below would pass on a null link.
const link = document.querySelector('a[href$="/models/node-1/tests"]')
@@ -225,6 +226,8 @@ describe('DataQualityOverview', () => {
expect(document.querySelector('[data-attr="data-quality-overview-new-check"]')).not.toBeNull()
expect(document.querySelector('[data-attr="data-quality-overview-browse"]')).toBeNull()
expect(document.querySelector('[data-attr="data-quality-overview-empty-state"] img')).not.toBeNull()
+ expect(screen.queryByPlaceholderText('Search checks')).toBeNull()
+ expect(document.querySelector('[data-attr="data-quality-overview-run-all"]')).toBeNull()
fireEvent.click(document.querySelector('[data-attr="data-quality-overview-first-check"]')!)
diff --git a/products/data_quality/frontend/overview/DataQualityOverview.tsx b/products/data_quality/frontend/overview/DataQualityOverview.tsx
index fe0fede42255..ad4bea02eeb0 100644
--- a/products/data_quality/frontend/overview/DataQualityOverview.tsx
+++ b/products/data_quality/frontend/overview/DataQualityOverview.tsx
@@ -1,6 +1,5 @@
import { BindLogic, useActions, useValues } from 'kea'
-import * as scientistPng from '@posthog/brand/hoggies/png/scientist'
import { IconChevronRight, IconEllipsis } from '@posthog/icons'
import {
LemonBanner,
@@ -9,21 +8,28 @@ import {
LemonInput,
LemonMenu,
LemonSegmentedButton,
+ LemonSkeleton,
LemonTable,
LemonTag,
Link,
Spinner,
} from '@posthog/lemon-ui'
-import { pngHoggie } from 'lib/brand/hoggies'
import { TZLabel } from 'lib/components/TZLabel'
import { CheckEditorModal } from '../CheckEditorModal'
import { CheckRunsTable } from '../CheckRunsTable'
-import { HEALTH_TAG_TYPES, SUBJECT_TYPE_TAGS, checkDisplayName, checkTypeLabel } from '../checksConstants'
+import {
+ HEALTH_LABELS,
+ HEALTH_TAG_TYPES,
+ SUBJECT_TYPE_TAGS,
+ checkDisplayName,
+ checkTypeLabel,
+} from '../checksConstants'
import { CheckStatusCell } from '../CheckStatusCell'
import { DataQualityCheckEditorLogicProps, dataQualityCheckEditorLogic } from '../dataQualityCheckEditorLogic'
import type { DataQualityOverviewCheckApi } from '../generated/api.schemas'
+import { DataQualityEmptyState } from './DataQualityEmptyState'
import { DataQualityGateToggle } from './DataQualityGateToggle'
import {
NEW_CHECK_ACTION_ID,
@@ -42,8 +48,6 @@ const STATUS_FILTERS: { value: OverviewStatusFilter; label: string }[] = [
{ value: 'never_run', label: 'Not run yet' },
]
-const HedgehogScientist = pngHoggie(scientistPng)
-
function focusFirstAvailable(elementIds: string[]): void {
// Runs after the removed row has left the DOM, so the first id that still resolves wins.
window.requestAnimationFrame(() => {
@@ -100,9 +104,28 @@ export function DataQualityOverview(): JSX.Element {
const runningAll = (startingRun || isRunning) && runTarget?.kind === 'all'
const anyRunActive = startingRun || isRunning
+ const newCheckButton = (
+ <LemonButton
+ id={NEW_CHECK_ACTION_ID}
+ type="primary"
+ size="small"
+ onClick={addCheck}
+ data-attr="data-quality-overview-new-check"
+ >
+ New check
+ </LemonButton>
+ )
if (!snapshotLoaded && overviewLoading) {
- return <LemonTable dataSource={[]} loading columns={[{ title: 'Check', key: 'name' }]} />
+ return (
+ <div className="flex flex-col gap-3">
+ <div className="flex flex-wrap items-center gap-2">
+ <LemonSkeleton className="h-8 w-64 max-w-full" />
+ <LemonSkeleton className="h-8 w-48" />
+ </div>
+ <LemonSkeleton.Row repeat={3} fade />
+ </div>
+ )
}
if (!snapshotLoaded && overviewError) {
@@ -116,51 +139,41 @@ export function DataQualityOverview(): JSX.Element {
return (
<BindLogic logic={dataQualityCheckEditorLogic} props={editorProps}>
<div className="flex flex-col gap-3">
- <div className="flex flex-wrap items-center gap-2">
- <div className="flex flex-wrap items-center gap-2 grow basis-full @2xl/main-content:basis-0">
- <LemonInput
- type="search"
- size="small"
- placeholder="Search checks"
- value={filters.search}
- onChange={(search) => setFilters({ search })}
- className="flex-1 min-w-40 max-w-64"
- />
- <LemonSegmentedButton
- size="small"
- value={filters.status}
- onChange={(status) => setFilters({ status })}
- options={STATUS_FILTERS}
- />
- </div>
- <div className="flex flex-wrap items-center gap-2 ml-auto">
- <LemonButton
- type="secondary"
- size="small"
- onClick={() => runChecks({ kind: 'all' })}
- loading={runningAll}
- disabledReason={
- checks.length === 0
- ? 'There are no checks to run'
- : anyRunActive && !runningAll
- ? 'Checks are already running'
- : undefined
- }
- data-attr="data-quality-overview-run-all"
- >
- Run all checks
- </LemonButton>
- <LemonButton
- id={NEW_CHECK_ACTION_ID}
- type="primary"
- size="small"
- onClick={addCheck}
- data-attr="data-quality-overview-new-check"
- >
- New check
- </LemonButton>
+ {checks.length === 0 ? (
+ <div className="flex justify-end">{newCheckButton}</div>
+ ) : (
+ <div className="flex flex-wrap items-center gap-2">
+ <div className="flex flex-wrap items-center gap-2 grow basis-full @2xl/main-content:basis-0">
+ <LemonInput
+ type="search"
+ size="small"
+ placeholder="Search checks"
+ value={filters.search}
+ onChange={(search) => setFilters({ search })}
+ className="flex-1 min-w-40 max-w-64"
+ />
+ <LemonSegmentedButton
+ size="small"
+ value={filters.status}
+ onChange={(status) => setFilters({ status })}
+ options={STATUS_FILTERS}
+ />
+ </div>
+ <div className="flex flex-wrap items-center gap-2 ml-auto">
+ <LemonButton
+ type="secondary"
+ size="small"
+ onClick={() => runChecks({ kind: 'all' })}
+ loading={runningAll}
+ disabledReason={anyRunActive && !runningAll ? 'Checks are already running' : undefined}
+ data-attr="data-quality-overview-run-all"
+ >
+ Run all checks
+ </LemonButton>
+ {newCheckButton}
+ </div>
</div>
- </div>
+ )}
<div className="flex flex-wrap items-center gap-x-4 gap-y-2 empty:hidden">
{overviewSummary && <p className="mb-0 text-secondary flex-1 min-w-0">{overviewSummary}</p>}
@@ -189,7 +202,7 @@ export function DataQualityOverview(): JSX.Element {
)}
{checks.length === 0 ? (
- <NoChecksYet onAddCheck={addCheck} />
+ <DataQualityEmptyState onAddCheck={addCheck} />
) : subjectGroups.length === 0 ? (
<div className="flex items-center gap-2">
<span className="text-secondary">No checks match these filters.</span>
@@ -212,24 +225,6 @@ export function DataQualityOverview(): JSX.Element {
)
}
-function NoChecksYet({ onAddCheck }: { onAddCheck: () => void }): JSX.Element {
- return (
- <div
- data-attr="data-quality-overview-empty-state"
- className="border rounded px-4 py-8 flex flex-col items-center text-center mx-auto"
- >
- <HedgehogScientist width="128" height="128" className="mb-4" />
- <h2 className="text-xl leading-tight">No checks yet</h2>
- <p className="mb-4 text-sm text-balance text-tertiary">
- Create a check to spot issues in your data before they affect your analysis.
- </p>
- <LemonButton type="primary" size="small" onClick={onAddCheck} data-attr="data-quality-overview-first-check">
- Add your first check
- </LemonButton>
- </div>
- )
-}
-
function SubjectSection({ group }: { group: SubjectGroup }): JSX.Element {
const { expandedSubjectKeys, startingRun, isRunning, runningSubjectKey, runTarget, runError, pollTimedOut } =
useValues(dataQualityOverviewLogic)
@@ -264,15 +259,17 @@ function SubjectSection({ group }: { group: SubjectGroup }): JSX.Element {
<Link
to={group.detailUrl}
target="_blank"
- className="font-semibold"
+ className="font-semibold truncate max-w-full"
tooltip={`Open ${group.subjectName} in a new tab`}
>
{group.subjectName}
</Link>
) : (
- <span className="font-semibold">{group.subjectName}</span>
+ <span className="font-semibold truncate max-w-full">{group.subjectName}</span>
)}
- <LemonTag type={HEALTH_TAG_TYPES[group.health] ?? 'default'}>{group.health}</LemonTag>
+ <LemonTag type={HEALTH_TAG_TYPES[group.health] ?? 'default'}>
+ {HEALTH_LABELS[group.health] ?? group.health}
+ </LemonTag>
{subjectType && <LemonTag type={subjectType.type}>{subjectType.label}</LemonTag>}
<span className="text-secondary text-sm">
{group.checksFailing > 0
@@ -297,9 +294,6 @@ function SubjectSection({ group }: { group: SubjectGroup }): JSX.Element {
</LemonButton>
</div>
- {scopedToThisSubject && running && (
- <p className="px-2 pb-2 mb-0 text-secondary text-sm">Running checks...</p>
- )}
{scopedToThisSubject && pollTimedOut && (
<div className="px-2 pb-2">
<LemonBanner type="warning" action={{ children: 'Refresh', onClick: loadOverview }}>