: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
feat(data-table): show column-aware sample rows in empty tables (#128933)
Thomas Obermüllere0e28b7b78dc
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex b3f9a4b81c6d..cb664cc311f0 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -8766,6 +8766,18 @@ snapshots:hash: v1.k794b7964.b16b4ed1913fbe3942aa6282cbd4e3a166fbbdf32fc4e53cef7adf97f00d2336.P9x17WzBdvzIy3lZSVhWTY6Kz2lNjMWlvMWiJ-Qx9d0queries-datatable-harnesscolumn--arbitrary-query-result--light:hash: v1.k794b7964.3875aa4d2826a34a035d8da68aa05734d412af03ac6f14fd1bd2a7807985167d.a5nSly5FdcZENmGcfyFRPvOZcAc79U1Ha5KZhIGU8fE+ queries-datatable-sample-data--default-columns--dark:+ hash: v1.k794b7964.8188bc1334f666144075f3e62be13df62c6d1ffdc0603d55f02e324c88b570b3.ce8ory-CJamgcjIMR5eITaNx2GadEYUDoNJrz5LIDJg+ queries-datatable-sample-data--default-columns--light:+ hash: v1.k794b7964.4f6d55eff8e08597eaca39b7c7b95293d19c23b1c9a5753282157676ef147395.XFF0r9DBkYkAMxKimNWdKSuU_sTVYVkBAaBOvEzIZfY+ queries-datatable-sample-data--persons--dark:+ hash: v1.k794b7964.ae2da422740de5fd57f4edd3810cc1115c9ec3ce549b64def6f79dd5d80ae0c0.fOt9Madj8vttP-303TwdTDUny5Bwj3PeF8hVRv5C7C0+ queries-datatable-sample-data--persons--light:+ hash: v1.k794b7964.2a1ed669c6e7928666745de570f60f5ee78b7fd3cbbde3d3540f78593f2a58da.uivo-hVl_SCGgBqMFSe4Yu9hPH3b767gPlZPYs_OCr0+ queries-datatable-sample-data--with-custom-column--dark:+ hash: v1.k794b7964.d7051aeccb2010d44cea0705b69aeed8143777329f7415d53190a293634f5df5.I3y5shNKX2o5XmLeiyrtGcK4Q7dydAGKybsFBgCXf94+ queries-datatable-sample-data--with-custom-column--light:+ hash: v1.k794b7964.2973df921e21a53d1c25e7ff86fcb50ce8d3ca48ef78e031576d9b27eb68265b.2IB6-FqJdm6RNmFQxmWqvBnEn7-UamMpA_tnd5s62Gsqueries-webvitals--web-vitals--dark:hash: v1.k794b7964.2ae778a0c5fdba3c69dfcbd3e9589c3c3d9cc2f0fef2eefd304c565be7e9a7c9.hH71byl33sIAdRCgaPk1lDOev0qooW1xhv0AL_yrIvgqueries-webvitals--web-vitals--light:diff --git a/frontend/src/queries/nodes/DataTable/DataTable.tsx b/frontend/src/queries/nodes/DataTable/DataTable.tsxindex 19709d7a102c..2c8125fc1c27 100644--- a/frontend/src/queries/nodes/DataTable/DataTable.tsx+++ b/frontend/src/queries/nodes/DataTable/DataTable.tsx@@ -8,6 +8,7 @@ import { PreAggregatedBadge } from 'lib/components/PreAggregatedBadge'import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'import { TaxonomicPopover } from 'lib/components/TaxonomicPopover/TaxonomicPopover'import ViewRecordingButton, { RecordingPlayerType } from 'lib/components/ViewRecordingButton/ViewRecordingButton'+import { dayjs } from 'lib/dayjs'import { useFeatureFlag } from 'lib/hooks/useFeatureFlag'import { LemonButton } from 'lib/lemon-ui/LemonButton'import { LemonDivider } from 'lib/lemon-ui/LemonDivider'@@ -24,6 +25,7 @@ import { Reload } from '~/queries/nodes/DataNode/Reload'import { SupportTracesFilters } from '~/queries/nodes/DataNode/SupportTracesFilters'import { TestAccountFilters } from '~/queries/nodes/DataNode/TestAccountFilters'import { BackToSource } from '~/queries/nodes/DataTable/BackToSource'+import { buildSampleTable } from '~/queries/nodes/DataTable/buildSampleTable'import { ColumnConfigurator } from '~/queries/nodes/DataTable/ColumnConfigurator/ColumnConfigurator'import { DataTableCount } from '~/queries/nodes/DataTable/DataTableCount'import { DataTableExport } from '~/queries/nodes/DataTable/DataTableExport'@@ -287,6 +289,15 @@ export function DataTable({}),[allColumns, contextColumns])+ const sampleRowsSource = context?.dataTableSampleRows+ const hasRows = !!dataTableRows?.length+ const sampleTable = useMemo(+ () =>+ sampleRowsSource && !hasRows+ ? buildSampleTable(sampleRowsSource, columnsInLemonTable, query, context, dayjs())+ : undefined,+ [sampleRowsSource, hasRows, columnsInLemonTable, query, context]+ )const orderByForKey = useCallback((key: string): string => {const rawSelect = sourceFeatures.has(QueryFeature.selectAndOrderByColumns)@@ -1151,6 +1162,7 @@ export function DataTable({detail={context?.emptyStateDetail}icon={context?.emptyStateIcon}sampleDataVariant="table"+ sampleTable={sampleTable}insightProps={insightProps}/>)diff --git a/frontend/src/queries/nodes/DataTable/DataTableSampleData.stories.tsx b/frontend/src/queries/nodes/DataTable/DataTableSampleData.stories.tsxnew file mode 100644index 000000000000..87db367852ae--- /dev/null+++ b/frontend/src/queries/nodes/DataTable/DataTableSampleData.stories.tsx@@ -0,0 +1,111 @@+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'++import type { Meta, StoryObj } from '@storybook/react'++import { SAMPLE_EVENTS_SOURCE } from 'scenes/activity/explore/sampleEventRows'++import { mswDecorator } from '~/mocks/browser'+import { defaultDataTableColumns, getDefaultDataTablePersonColumns } from '~/queries/nodes/DataTable/utils'+import { Query } from '~/queries/Query/Query'+import { DataTableNode, NodeKind } from '~/queries/schema/schema-general'+import { QueryContext } from '~/queries/types'++import { SAMPLE_PERSONS_SOURCE } from 'products/persons/frontend/samplePersonRows'++const TEAM_WITHOUT_EVENTS = { ...MOCK_DEFAULT_TEAM, ingested_event: false }++function eventsTable(select: string[]): DataTableNode {+ return {+ kind: NodeKind.DataTableNode,+ source: { kind: NodeKind.EventsQuery, select, after: '-24h' },+ }+}++function WideAndNarrow({ query }: { query: DataTableNode }): JSX.Element {+ const context: QueryContext = {+ dataTableSampleRows: query.source.kind === NodeKind.ActorsQuery ? SAMPLE_PERSONS_SOURCE : SAMPLE_EVENTS_SOURCE,+ }+ return (+ <div className="flex flex-col gap-6">+ <div className="w-240">+ <Query query={query} context={context} />+ </div>+ {/* The width of a scene with the side panel open in a 1280px window */}+ <div className="w-130">+ <Query query={query} context={context} />+ </div>+ </div>+ )+}++type Story = StoryObj<{ query: DataTableNode }>+const meta: Meta<{ query: DataTableNode }> = {+ title: 'Queries/DataTable/Sample data',+ parameters: {+ layout: 'padded',+ mockDate: '2026-10-23T12:00:00Z',+ testOptions: {+ waitForSelector: '[data-attr$="-table-sample-data"]',+ },+ },+ decorators: [+ mswDecorator({+ get: {+ '/api/projects/:team_id/tasks/': { count: 0, results: [] },+ },+ post: {+ '/api/environments/:team_id/query/:query_kind/': { results: [], hasMore: false },+ },+ }),+ ],+ // teamLogic reads the team from the app context, not the API. `beforeEach` runs before Kea mounts it.+ beforeEach: () => {+ const appContext = window.POSTHOG_APP_CONTEXT+ const originalTeam = appContext?.current_team+ if (appContext) {+ appContext.current_team = TEAM_WITHOUT_EVENTS+ }+ return () => {+ if (appContext) {+ appContext.current_team = originalTeam ?? null+ }+ }+ },+ render: ({ query }) => <WideAndNarrow query={query} />,+}+export default meta++export const DefaultColumns: Story = {+ args: { query: eventsTable(defaultDataTableColumns(NodeKind.EventsQuery)) },+}++const DEFAULT_EVENT_COLUMNS = defaultDataTableColumns(NodeKind.EventsQuery)++// The custom column goes before the card's column cap, so the card shows its skeleton bar+export const WithCustomColumn: Story = {+ args: {+ query: eventsTable([+ ...DEFAULT_EVENT_COLUMNS.slice(0, 2),+ 'properties.$browser_version',+ ...DEFAULT_EVENT_COLUMNS.slice(2),+ ]),+ },+}++export const Persons: Story = {+ args: {+ query: {+ kind: NodeKind.DataTableNode,+ source: {+ kind: NodeKind.ActorsQuery,+ select: [+ ...getDefaultDataTablePersonColumns(true),+ 'properties.$initial_utm_campaign',+ 'person.$delete',+ ],+ },+ full: true,+ showCount: true,+ },+ },+}diff --git a/frontend/src/queries/nodes/DataTable/buildSampleTable.test.tsx b/frontend/src/queries/nodes/DataTable/buildSampleTable.test.tsxnew file mode 100644index 000000000000..cf0198e18d9f--- /dev/null+++ b/frontend/src/queries/nodes/DataTable/buildSampleTable.test.tsx@@ -0,0 +1,82 @@+import { render } from '@testing-library/react'+import { Provider } from 'kea'+import type { ReactNode } from 'react'++import { dayjs } from 'lib/dayjs'++import { setLatestVersionsOnQuery } from '~/queries/schema/query-versions'+import { DataTableNode, NodeKind } from '~/queries/schema/schema-general'+import { initKeaTests } from '~/test/init'++import { buildSampleTable } from './buildSampleTable'+import { type SampleRowsSource, samplePlaceholderColumn } from './sampleRows'++const NOW = dayjs('2026-10-23T12:00:00.000Z')++function eventsTable(select: string[], hiddenColumns?: string[]): DataTableNode {+ return setLatestVersionsOnQuery({+ kind: NodeKind.DataTableNode,+ source: { kind: NodeKind.EventsQuery, select },+ hiddenColumns,+ }) as DataTableNode+}++function sampleSource({+ values = {},+ excludedColumns = [],+}: {+ values?: Record<string, unknown>+ excludedColumns?: string[]+}): SampleRowsSource {+ return {+ buildRows: (columns) => [+ { result: columns.map((column) => (column in values ? values[column] : samplePlaceholderColumn)) },+ ],+ dataAttr: 'test-table-sample-data',+ excludedColumns,+ }+}++function cellText(cell: ReactNode): string | null {+ return render(<Provider>{cell}</Provider>).container.textContent+}++describe('buildSampleTable', () => {+ beforeEach(() => initKeaTests())++ it.each([+ ['the * column', ['*', 'a', 'b', 'c', 'd', 'e'], [], []],+ ['a hidden column', ['a', 'hidden', 'b', 'c', 'd', 'e'], ['hidden'], []],+ ['an excluded column', ['a', 'excluded', 'b', 'c', 'd', 'e'], [], ['excluded']],+ ])('removes %s before it caps the columns', (_, columns, hiddenColumns, excludedColumns) => {+ const table = buildSampleTable(+ sampleSource({ excludedColumns }),+ columns,+ eventsTable(columns, hiddenColumns),+ undefined,+ NOW+ )++ expect(table.header).toEqual(['a', 'b', 'c', 'd'])+ })++ it('renders each value with its own column when a column before it is removed', () => {+ const columns = ['*', 'event', 'properties.$browser']+ const source = sampleSource({ values: { event: '$pageview', 'properties.$browser': 'Chrome' } })++ const table = buildSampleTable(source, columns, eventsTable(columns), undefined, NOW)++ expect(table.rows[0].map(cellText)).toEqual(['Pageview', 'Chrome'])+ })++ it('leaves only placeholder cells empty, so a real null still renders', () => {+ const columns = ['event', 'distinct_id']+ const source = sampleSource({ values: { event: samplePlaceholderColumn, distinct_id: null } })++ const table = buildSampleTable(source, columns, eventsTable(columns), undefined, NOW)++ const [placeholderCell, nullCell] = table.rows[0]+ expect(placeholderCell).toBeNull()+ expect(cellText(nullCell)).toBe('—')+ })+})diff --git a/frontend/src/queries/nodes/DataTable/buildSampleTable.ts b/frontend/src/queries/nodes/DataTable/buildSampleTable.tsnew file mode 100644index 000000000000..22455c5e7256--- /dev/null+++ b/frontend/src/queries/nodes/DataTable/buildSampleTable.ts@@ -0,0 +1,48 @@+import type { Dayjs } from 'lib/dayjs'+import type { SampleTableContent } from 'scenes/insights/EmptyStates/SampleDataState'++import { renderColumn } from '~/queries/nodes/DataTable/renderColumn'+import { renderColumnMeta } from '~/queries/nodes/DataTable/renderColumnMeta'+import { type SampleRowsSource, samplePlaceholderColumn } from '~/queries/nodes/DataTable/sampleRows'+import type { DataTableNode } from '~/queries/schema/schema-general'+import type { QueryContext } from '~/queries/types'++// The sample card is narrow, so it shows only the first columns of the table+const SAMPLE_TABLE_MAX_COLUMNS = 4++export function buildSampleTable(+ source: SampleRowsSource,+ columns: string[],+ query: DataTableNode,+ context: QueryContext<DataTableNode> | undefined,+ now: Dayjs+): SampleTableContent {+ const shownColumns = columns+ .filter(+ (column) =>+ column !== '*' && !query.hiddenColumns?.includes(column) && !source.excludedColumns.includes(column)+ )+ .slice(0, SAMPLE_TABLE_MAX_COLUMNS)+ const rows = source.buildRows(shownColumns, now)++ return {+ dataAttr: source.dataAttr,+ header: shownColumns.map((column) => renderColumnMeta(column, query, context).title ?? column),+ rows: rows.map(({ result }, rowIndex) =>+ result.map((value, columnIndex) =>+ value === samplePlaceholderColumn+ ? null+ : renderColumn(+ shownColumns[columnIndex],+ value,+ result,+ rowIndex,+ rows.length,+ query,+ undefined,+ context+ )+ )+ ),+ }+}diff --git a/frontend/src/queries/nodes/DataTable/sampleRows.ts b/frontend/src/queries/nodes/DataTable/sampleRows.tsnew file mode 100644index 000000000000..6f2e63647e9b--- /dev/null+++ b/frontend/src/queries/nodes/DataTable/sampleRows.ts@@ -0,0 +1,64 @@+import type { Dayjs } from 'lib/dayjs'++import type { DataTableRow } from '~/queries/nodes/DataTable/dataTableLogic'+import { removeExpressionComment } from '~/queries/nodes/DataTable/utils'++/** Fills a cell whose column has no invented value, so the sample card shows a skeleton bar. */+export const samplePlaceholderColumn = Symbol('sample placeholder')++export type SampleRow = DataTableRow & { result: unknown[] }++export interface SampleRowsSource {+ /** One row per invented record, one value per column in `columns`. */+ buildRows: (columns: string[], now: Dayjs) => SampleRow[]+ dataAttr: string+ /** Columns the sample card never shows, for example ones whose actions would act on invented records. */+ excludedColumns: string[]+}++export interface SampleIds {+ distinctId: string+ personId: string+ eventId: string+}++/** The IDs are obviously invented, so nothing can resolve them to a real person or event. */+export function sampleIds(index: number): SampleIds {+ const suffix = String(index + 1).padStart(12, '0')+ return {+ distinctId: `sample-distinct-id-${index + 1}`,+ personId: `00000000-0000-4000-8000-${suffix}`,+ eventId: `00000000-0000-4000-9000-${suffix}`,+ }+}++export function samplePersonDisplayName(+ email: string,+ ids: SampleIds+): { display_name: string; distinct_id: string; id: string } {+ return { display_name: email, distinct_id: ids.distinctId, id: ids.personId }+}++/** The value of a `properties.<key>` column, or `samplePlaceholderColumn` when the sample has no such property. */+export function samplePropertyValue(key: string, properties: Record<string, unknown>): unknown {+ if (key.startsWith('properties.')) {+ const propertyKey = key.slice('properties.'.length)+ if (Object.hasOwn(properties, propertyKey)) {+ return properties[propertyKey]+ }+ }+ return samplePlaceholderColumn+}++/** `valueFor` gets the column without its `-- comment` suffix. */+export function buildSampleRows<T>(+ samples: T[],+ columns: string[],+ valueFor: (key: string, sample: T, ids: SampleIds) => unknown+): SampleRow[] {+ const keys = columns.map(removeExpressionComment)+ return samples.map((sample, index) => {+ const ids = sampleIds(index)+ return { result: keys.map((key) => valueFor(key, sample, ids)) }+ })+}diff --git a/frontend/src/queries/types.ts b/frontend/src/queries/types.tsindex 8adc640f1dce..5c916d77b6eb 100644--- a/frontend/src/queries/types.ts+++ b/frontend/src/queries/types.ts@@ -16,6 +16,7 @@ import { InsightLogicProps, TrendResult } from '~/types'import { ColumnFeature } from './nodes/DataTable/DataTable'import { DataTableRow } from './nodes/DataTable/dataTableLogic'+import { SampleRowsSource } from './nodes/DataTable/sampleRows'import { BIVisualizationNode } from './schema/schema-business-intelligence'/** Pass custom metadata to queries. Used for e.g. custom columns in the DataTable. */@@ -42,6 +43,11 @@ export interface QueryContext<Q extends QuerySchema = QuerySchema> {emptyStateDetail?: string | JSX.ElementemptyStateIcon?: JSX.ElementrenderEmptyStateAsSkeleton?: boolean+ /**+ * Fills the sample-data card of an empty data table with invented values for the table's columns, before+ * the project ingests its first event. Without it, the card shows its own made-up rows.+ */+ dataTableSampleRows?: SampleRowsSourcerowProps?: (record: unknown) => Omit<HTMLProps<HTMLTableRowElement>, 'key'>/*** Displayed in insight tooltip's "Click to view {groupTypeLabel}".diff --git a/frontend/src/scenes/activity/explore/EventsScene.tsx b/frontend/src/scenes/activity/explore/EventsScene.tsxindex 9d4c1a0e9987..91b5ba7cd532 100644--- a/frontend/src/scenes/activity/explore/EventsScene.tsx+++ b/frontend/src/scenes/activity/explore/EventsScene.tsx@@ -20,6 +20,7 @@ import { useAttachedContext } from 'products/posthog_ai/frontend/api/logics'import { buildExploreAgentContext } from '../activityAgentContext'import { eventsSceneLogic } from './eventsSceneLogic'+import { SAMPLE_EVENTS_SOURCE } from './sampleEventRows'export function EventsScene(): JSX.Element {const { query, flagCallsNote } = useValues(eventsSceneLogic())@@ -64,6 +65,7 @@ export function EventsScene(): JSX.Element {dataTableMaxPaginationLimit: 200,// A live-data explorer over captured events, so it keeps the hidden ones selectable.includeHiddenEvents: true,+ dataTableSampleRows: SAMPLE_EVENTS_SOURCE,}}/></SceneContent>diff --git a/frontend/src/scenes/activity/explore/sampleEventRows.test.ts b/frontend/src/scenes/activity/explore/sampleEventRows.test.tsnew file mode 100644index 000000000000..bcd8c00d720a--- /dev/null+++ b/frontend/src/scenes/activity/explore/sampleEventRows.test.ts@@ -0,0 +1,37 @@+import { dayjs } from 'lib/dayjs'++import { samplePlaceholderColumn } from '~/queries/nodes/DataTable/sampleRows'++import { buildSampleEventRows } from './sampleEventRows'++const NOW = dayjs('2026-10-23T12:00:00.000Z')+const URL_COLUMN = 'coalesce(properties.$current_url, properties.$screen_name) -- Url / Screen'++describe('buildSampleEventRows', () => {+ it('puts each value in the position of its column, whatever the column order', () => {+ const rows = buildSampleEventRows(+ ['timestamp', 'properties.$browser_version', 'event', 'person_display_name -- Person', URL_COLUMN],+ NOW+ )++ expect(rows[0].result).toEqual([+ '2026-10-23T11:59:00.000Z',+ samplePlaceholderColumn,+ '$pageview',+ expect.objectContaining({ display_name: '[email protected]' }),+ 'https://example.com/pricing',+ ])+ })++ it.each([+ ['count()', samplePlaceholderColumn],+ ['properties.$lib', 'posthog-ios'],+ ['properties.constructor', samplePlaceholderColumn],+ [URL_COLUMN, 'HomeScreen'],+ ['person', expect.objectContaining({ properties: { email: '[email protected]' } })],+ ])('fills the %s column of a mobile row', (column, expected) => {+ const mobileRow = buildSampleEventRows([column], NOW)[2]++ expect(mobileRow.result).toEqual([expected])+ })+})diff --git a/frontend/src/scenes/activity/explore/sampleEventRows.ts b/frontend/src/scenes/activity/explore/sampleEventRows.tsnew file mode 100644index 000000000000..867af44ae7a9--- /dev/null+++ b/frontend/src/scenes/activity/explore/sampleEventRows.ts@@ -0,0 +1,106 @@+import type { Dayjs } from 'lib/dayjs'++import {+ type SampleIds,+ type SampleRow,+ type SampleRowsSource,+ buildSampleRows,+ samplePersonDisplayName,+ samplePropertyValue,+} from '~/queries/nodes/DataTable/sampleRows'++interface SampleEvent {+ event: string+ email: string+ properties: Record<string, string | null>+ minutesAgo: number+}++const WEB = { $lib: 'web', $browser: 'Chrome', $os: 'Mac OS X' }++const SAMPLE_EVENTS: SampleEvent[] = [+ {+ event: '$pageview',+ email: '[email protected]',+ properties: { ...WEB, $current_url: 'https://example.com/pricing', $pathname: '/pricing', $screen_name: null },+ minutesAgo: 1,+ },+ {+ event: 'user signed up',+ email: '[email protected]',+ properties: { ...WEB, $current_url: 'https://example.com/signup', $pathname: '/signup', $screen_name: null },+ minutesAgo: 3,+ },+ {+ event: '$screen',+ email: '[email protected]',+ properties: {+ $lib: 'posthog-ios',+ $os: 'iOS',+ $browser: null,+ $current_url: null,+ $pathname: null,+ $screen_name: 'HomeScreen',+ },+ minutesAgo: 6,+ },+ {+ event: 'purchase completed',+ email: '[email protected]',+ properties: {+ $lib: 'posthog-node',+ $os: null,+ $browser: null,+ $current_url: null,+ $pathname: null,+ $screen_name: null,+ },+ minutesAgo: 12,+ },+]++const URL_OR_SCREEN_COLUMN = 'coalesce(properties.$current_url, properties.$screen_name)'++function sampleValue(key: string, sample: SampleEvent, ids: SampleIds, now: Dayjs): unknown {+ const timestamp = now.subtract(sample.minutesAgo, 'minute').toISOString()++ if (key === '*') {+ return {+ uuid: ids.eventId,+ event: sample.event,+ distinct_id: ids.distinctId,+ properties: sample.properties,+ timestamp,+ }+ }+ if (key === 'event') {+ return sample.event+ }+ if (key === 'timestamp') {+ return timestamp+ }+ if (key === 'distinct_id') {+ return ids.distinctId+ }+ if (key === 'person_display_name') {+ return samplePersonDisplayName(sample.email, ids)+ }+ if (key === 'person') {+ return { uuid: ids.personId, distinct_id: ids.distinctId, properties: { email: sample.email } }+ }+ if (key === URL_OR_SCREEN_COLUMN) {+ return sample.properties.$current_url ?? sample.properties.$screen_name+ }+ return samplePropertyValue(key, sample.properties)+}++export function buildSampleEventRows(columns: string[], now: Dayjs): SampleRow[] {+ return buildSampleRows(SAMPLE_EVENTS, columns, (key, sample, ids) => sampleValue(key, sample, ids, now))+}++export const SAMPLE_EVENTS_SOURCE: SampleRowsSource = {+ buildRows: buildSampleEventRows,+ // pinned: the data-attr value is an autocapture selector, so renaming it breaks dashboards+ dataAttr: 'events-table-sample-data',+ excludedColumns: [],+}diff --git a/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsx b/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsxindex 0b6e88883a56..703939d97e86 100644--- a/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsx+++ b/frontend/src/scenes/insights/EmptyStates/EmptyStates.tsx@@ -60,7 +60,7 @@ import { funnelDataLogic } from 'products/product_analytics/frontend/insights/fuimport { insightDataLogic } from '../insightDataLogic'import { insightVizDataLogic } from '../insightVizDataLogic'import { InsightErrorLayout } from './InsightErrorLayout'-import { SampleDataState, SampleDataVariant } from './SampleDataState'+import { SampleDataState, SampleDataVariant, type SampleTableContent } from './SampleDataState'import { sampleDataStateLogic } from './sampleDataStateLogic'const HedgehogConstruction2 = pngHoggie(construction2Png)@@ -78,6 +78,7 @@ export function InsightEmptyState({detail,icon: iconProp,sampleDataVariant,+ sampleTable,insightProps,}: {heading?: string@@ -89,6 +90,7 @@ export function InsightEmptyState({* `null` to opt this call site out entirely.*/sampleDataVariant?: SampleDataVariant | null+ sampleTable?: SampleTableContentinsightProps?: Pick<InsightLogicProps, 'dashboardId' | 'dashboardItemId'>}): JSX.Element {const { shouldShowSampleData } = useValues(sampleDataStateLogic)@@ -115,7 +117,7 @@ export function InsightEmptyState({})if (showingSampleData) {- return <SampleDataState variant={sampleDataVariant ?? 'line'} />+ return <SampleDataState variant={sampleDataVariant ?? 'line'} table={sampleTable} />}heading = heading ?? 'There are no matching events for this query'diff --git a/frontend/src/scenes/insights/EmptyStates/SampleDataState.tsx b/frontend/src/scenes/insights/EmptyStates/SampleDataState.tsxindex 3f62e9b797cc..dcaacf8bd246 100644--- a/frontend/src/scenes/insights/EmptyStates/SampleDataState.tsx+++ b/frontend/src/scenes/insights/EmptyStates/SampleDataState.tsx@@ -79,41 +79,64 @@ function SampleNumber({ animate }: { animate: boolean }): JSX.Element {)}-function SampleTable(): JSX.Element {+/** Sample values for a table the card shows in place of its own made-up rows. */+export interface SampleTableContent {+ header: ReactNode[]+ /** One cell per header column. A `null` cell shows a skeleton bar. */+ rows: ReactNode[][]+ dataAttr?: string+}++function SampleTable({ table }: { table?: SampleTableContent }): JSX.Element {return (- <div className="w-full max-w-120 self-center m-4 rounded border overflow-hidden text-secondary">+ <div+ className="w-full max-w-120 self-center m-4 rounded border overflow-hidden text-secondary"+ data-attr={table?.dataAttr}+ // The cells can hold links and popovers for invented records, so `inert` keeps them away+ // from the pointer, the keyboard and assistive tech. React 18 types lack the attribute.+ {...(table ? { inert: '' } : {})}+ ><div className="flex items-center gap-3 px-3 py-2 bg-surface-secondary text-xs font-semibold">- {TABLE_HEADER.map((label, cellIndex) => (- <div key={cellIndex} className={clsx('flex-1', cellIndex > 0 && 'text-right')}>+ {(table?.header ?? TABLE_HEADER).map((label, cellIndex) => (+ <div+ key={cellIndex}+ className={clsx('flex-1', table ? 'min-w-0 truncate' : cellIndex > 0 && 'text-right')}+ >{label}</div>))}</div>- {TABLE_ROWS.map((cells, index) => (+ {(table?.rows ?? TABLE_ROWS).map((cells, index) => (<divkey={index}className="SampleDataState__row flex items-center gap-3 px-3 py-2 border-t text-sm"// eslint-disable-next-line react/forbid-dom-propsstyle={{ animationDelay: `${index * 110}ms` }}>- {cells.map((value, cellIndex) => (- <div- key={cellIndex}- className={clsx(- 'flex-1',- cellIndex === 0 ? 'flex items-center gap-2' : 'text-right tabular-nums'- )}- >- {cellIndex === 0 ? (- <>- <div className="SampleDataState__row-cell h-3 w-3 shrink-0 rounded-full" />- <span className="truncate">{value}</span>- </>- ) : (- value- )}- </div>- ))}+ {table+ ? cells.map((value, cellIndex) => (+ <div key={cellIndex} className="flex-1 min-w-0 truncate">+ {value ?? <div className="SampleDataState__row-cell w-16 max-w-full" />}+ </div>+ ))+ : cells.map((value, cellIndex) => (+ <div+ key={cellIndex}+ className={clsx(+ 'flex-1',+ cellIndex === 0 ? 'flex items-center gap-2' : 'text-right tabular-nums'+ )}+ >+ {cellIndex === 0 ? (+ <>+ <div className="SampleDataState__row-cell h-3 w-3 shrink-0 rounded-full" />+ <span className="truncate">{value}</span>+ </>+ ) : (+ value+ )}+ </div>+ ))}</div>))}</div>@@ -143,9 +166,11 @@ function SampleChart({ variant }: { variant: Exclude<SampleDataVariant, 'number'/** Obviously-fake placeholder chart shown instead of an empty state before a project has ingested any events. */export function SampleDataState({variant = 'line',+ table,children,}: {variant?: SampleDataVariant+ table?: SampleTableContentchildren?: ReactNode}): JSX.Element {const { setupStatus, setupStatusLoading } = useValues(setupWizardStatusLogic)@@ -221,7 +246,7 @@ export function SampleDataState({(variant === 'number' ? (<SampleNumber animate={!isStatic} />) : variant === 'table' ? (- <SampleTable />+ <SampleTable table={table} />) : (<SampleChart variant={variant} />))}diff --git a/products/persons/frontend/pages/PersonsScene.tsx b/products/persons/frontend/pages/PersonsScene.tsxindex c0ca27732906..5321374c7a56 100644--- a/products/persons/frontend/pages/PersonsScene.tsx+++ b/products/persons/frontend/pages/PersonsScene.tsx@@ -23,6 +23,7 @@ import { PersonDisplayNameNudgeBanner } from 'products/customer_analytics/fronteimport { customerProfileConfigLogic } from 'products/customer_analytics/frontend/customerProfileConfigLogic'import { personsSceneLogic } from '../logics/personsSceneLogic'+import { SAMPLE_PERSONS_SOURCE } from '../samplePersonRows'export const scene: SceneExport = {component: PersonsScene,@@ -81,6 +82,7 @@ export function PersonsScene(): JSX.Element {setQuery={setQuery}context={{refresh: 'blocking',+ dataTableSampleRows: SAMPLE_PERSONS_SOURCE,emptyStateHeading:currentTeam?.ingested_event && searchLooksLikeSessionId? 'Looking for a session?'diff --git a/products/persons/frontend/samplePersonRows.test.ts b/products/persons/frontend/samplePersonRows.test.tsnew file mode 100644index 000000000000..7e88cc3d9e34--- /dev/null+++ b/products/persons/frontend/samplePersonRows.test.ts@@ -0,0 +1,33 @@+import { dayjs } from 'lib/dayjs'++import { samplePlaceholderColumn } from '~/queries/nodes/DataTable/sampleRows'++import { buildSamplePersonRows } from './samplePersonRows'++const NOW = dayjs('2026-10-23T12:00:00.000Z')++describe('buildSamplePersonRows', () => {+ it('puts each value in the position of its column, whatever the column order', () => {+ const rows = buildSamplePersonRows(+ ['last_seen_at', 'properties.$initial_utm_campaign', 'id', 'person_display_name -- Person', 'created_at'],+ NOW+ )++ expect(rows[0].result).toEqual([+ '2026-10-23T11:59:00.000Z',+ samplePlaceholderColumn,+ '00000000-0000-4000-8000-000000000001',+ expect.objectContaining({ display_name: '[email protected]' }),+ '2026-10-21T12:00:00.000Z',+ ])+ })++ it.each([+ ['properties.email', '[email protected]'],+ ['person', expect.objectContaining({ distinct_ids: ['sample-distinct-id-3'] })],+ ])('fills the %s column', (column, expected) => {+ const thirdRow = buildSamplePersonRows([column], NOW)[2]++ expect(thirdRow.result).toEqual([expected])+ })+})diff --git a/products/persons/frontend/samplePersonRows.ts b/products/persons/frontend/samplePersonRows.tsnew file mode 100644index 000000000000..7fe5bc47b307--- /dev/null+++ b/products/persons/frontend/samplePersonRows.ts@@ -0,0 +1,76 @@+import type { Dayjs } from 'lib/dayjs'++import {+ type SampleIds,+ type SampleRow,+ type SampleRowsSource,+ buildSampleRows,+ samplePersonDisplayName,+ samplePropertyValue,+} from '~/queries/nodes/DataTable/sampleRows'++interface SamplePerson {+ email: string+ properties: Record<string, string>+ daysSinceCreated: number+ minutesSinceSeen: number+}++const SAMPLE_PERSONS: SamplePerson[] = [+ {+ email: '[email protected]',+ properties: { name: 'Alice', $geoip_country_code: 'US', $browser: 'Chrome', $os: 'Mac OS X' },+ daysSinceCreated: 2,+ minutesSinceSeen: 1,+ },+ {+ email: '[email protected]',+ properties: { name: 'Bob', $geoip_country_code: 'GB', $browser: 'Firefox', $os: 'Windows' },+ daysSinceCreated: 5,+ minutesSinceSeen: 3,+ },+ {+ email: '[email protected]',+ properties: { name: 'Carol', $geoip_country_code: 'DE', $browser: 'Mobile Safari', $os: 'iOS' },+ daysSinceCreated: 9,+ minutesSinceSeen: 6,+ },+ {+ email: '[email protected]',+ properties: { name: 'Dave', $geoip_country_code: 'FR', $browser: 'Chrome', $os: 'Linux' },+ daysSinceCreated: 14,+ minutesSinceSeen: 12,+ },+]++function sampleValue(key: string, sample: SamplePerson, ids: SampleIds, now: Dayjs): unknown {+ const properties = { email: sample.email, ...sample.properties }++ if (key === 'person_display_name') {+ return samplePersonDisplayName(sample.email, ids)+ }+ if (key === 'person') {+ return { id: ids.personId, distinct_ids: [ids.distinctId], properties }+ }+ if (key === 'id') {+ return ids.personId+ }+ if (key === 'created_at') {+ return now.subtract(sample.daysSinceCreated, 'day').toISOString()+ }+ if (key === 'last_seen_at') {+ return now.subtract(sample.minutesSinceSeen, 'minute').toISOString()+ }+ return samplePropertyValue(key, properties)+}++export function buildSamplePersonRows(columns: string[], now: Dayjs): SampleRow[] {+ return buildSampleRows(SAMPLE_PERSONS, columns, (key, sample, ids) => sampleValue(key, sample, ids, now))+}++export const SAMPLE_PERSONS_SOURCE: SampleRowsSource = {+ buildRows: buildSamplePersonRows,+ // pinned: the data-attr value is an autocapture selector, so renaming it breaks dashboards+ dataAttr: 'persons-table-sample-data',+ excludedColumns: ['person.$delete'],+}