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(marketing-analytics): add shared breakdown table ui (#105161)

Javier Bahamondes8d1d66fa4201
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 3da6664e4987..d52a0e14ab7a 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -5476,6 +5476,30 @@ snapshots:
hash: v1.k794b7964.fda088b86665fa1e7f42ac158d9c5acf12b2afc030a90ad385d3d0fe16170d46.WqmQ9-wSSHQj0J-kUbJKkFI8DhDljOP6queW3e6jxDQ
marketing-analytics-customer-acquisition-cards--unconfigured--light:
hash: v1.k794b7964.40240d162f715f3da0d8363e08797fb8a9c131852a5d6356c892424e25dfa35c.yeHaH7ecKHVh7IOwmerxuVPzSGclQrUDBwWnoPV0rmw
+ marketing-analytics-dashboard-breakdown-table--empty--dark:
+ hash: v1.k794b7964.595e55eba52af8b27ddecd40dd1b59d636bcbae1ee0dc5d78be62dd3b892d981.IyZb58wgD9xEUOLcWOt5PP2o4wps9Oh7Sb6S1SfQKvE
+ marketing-analytics-dashboard-breakdown-table--empty--light:
+ hash: v1.k794b7964.60b8c75933454013c8d7539b3007c7caa6f0441f1dc23e3c334f7a5872187557.dxJ3aGIlzFEUyl7-pqdaOYuXFUdOXkNZTClmZbEJmaQ
+ marketing-analytics-dashboard-breakdown-table--error--dark:
+ hash: v1.k794b7964.eebc6e004f1842c2083110bc236d68d1bd02922262ecdd4616b834253c196c34.4CgdirQZGwGdbeZVm-0x2AV5qAMzKN6JzihBkSvcm3g
+ marketing-analytics-dashboard-breakdown-table--error--light:
+ hash: v1.k794b7964.be182f1ad0321aca7ecad66bf6542b1cb293dbb1feac6846e1a6d1cbec2c43bc.psYi72UaaE2V8n2EEl_eLM5trQb558iM-K9KiO_W6cY
+ marketing-analytics-dashboard-breakdown-table--interactive--dark:
+ hash: v1.k794b7964.26101b571687a3e276320f8614905e37e974878b8c97394bbcab3529071ed94b.g9JC1Dl369GaW2Smmnfhs0lE_r7QNMa-kQyhDtUyXpA
+ marketing-analytics-dashboard-breakdown-table--interactive--light:
+ hash: v1.k794b7964.48a01e6ed781d8cb4a8304fde452a48881a684635940aff184f4d368373991bc.MdNlqtUcdUAzW3cJznYE1DhoGbkhpYo9eBQFciZaNuc
+ marketing-analytics-dashboard-breakdown-table--loading--dark:
+ hash: v1.k794b7964.3ed4d155c3d1dc42a922ca9245738dd964be8ea64de45e8277098f8b8a72d6fb.LQIl_ubh4uCgp4CNTSJqZW7eLRntIFpgDPuQgIuJ6Pg
+ marketing-analytics-dashboard-breakdown-table--loading--light:
+ hash: v1.k794b7964.0452833de0d3a8ced6b8b1f792998f7f352c15398053ad67a9643459b62fae0f.8key9ACTC3rCKFjmq2LRfZKSDBh1q_TwwZU70LP_VX8
+ marketing-analytics-dashboard-breakdown-table--narrow--dark:
+ hash: v1.k794b7964.3146e200a27a61ff64e9e1ea91f195d5d1aae75bc431d368f4ff0c575db062bd.NwGD71k9q_I_ai9lpQUbnUTYOdX4-4-M7r1N_6zWc3o
+ marketing-analytics-dashboard-breakdown-table--narrow--light:
+ hash: v1.k794b7964.1b4e76ab2e17352db7d12e0437368b7991143c5ce31fd14c329d5ef07a2f27f7.Rw-g3rHkdH6cYXDCkLOpCgVXOwCuzZc6W1Lp670paaQ
+ marketing-analytics-dashboard-breakdown-table--narrow-comparison--dark:
+ hash: v1.k794b7964.31e41069d269db8708235ebe4532f1d192bbaa665684020f6fdb4027aa8acd46.ZUY6P6E0RJdx4a7g6MNz26VSupyhqYn89k6oTj8xmEM
+ marketing-analytics-dashboard-breakdown-table--narrow-comparison--light:
+ hash: v1.k794b7964.aeb0d17c3166922193e00df2ff2b294a46046f5f0dafb448eb378b03f45de07a.6g_f5vb1BIZzlbnBa0ii0axbN9XzPruR7CZfbKiDGK4
marketing-analytics-dashboard-metric-cards--interactive--dark:
hash: v1.k794b7964.4c13e857435c2bee42eea33c6f86ab2d46f0d3c1c9d997f32bcdc57cf1e7dafc.J9JahhAU6VQmtGCK8icH17WJvkELlNa7DkbabJ2wtRU
marketing-analytics-dashboard-metric-cards--interactive--light:
diff --git a/products/marketing_analytics/frontend/dashboard/tables/ChangeValueCell.tsx b/products/marketing_analytics/frontend/dashboard/tables/ChangeValueCell.tsx
index 45381318f95d..97c42a0c3b80 100644
--- a/products/marketing_analytics/frontend/dashboard/tables/ChangeValueCell.tsx
+++ b/products/marketing_analytics/frontend/dashboard/tables/ChangeValueCell.tsx
@@ -48,7 +48,7 @@ export function ChangeValueCell({
: getColorVar('danger')
const body = (
- <span className="inline-flex items-center justify-end gap-1.5 tabular-nums">
+ <span className="inline-flex max-w-full flex-wrap items-center justify-end gap-1.5 tabular-nums">
<span>{current}</span>
{difference !== null && (
// eslint-disable-next-line react/forbid-dom-props
diff --git a/products/marketing_analytics/frontend/dashboard/tables/MarketingBreakdownTable.stories.tsx b/products/marketing_analytics/frontend/dashboard/tables/MarketingBreakdownTable.stories.tsx
new file mode 100644
index 000000000000..fd8e563cd516
--- /dev/null
+++ b/products/marketing_analytics/frontend/dashboard/tables/MarketingBreakdownTable.stories.tsx
@@ -0,0 +1,34 @@
+import { Meta, StoryObj } from '@storybook/react'
+
+import { TablePreview } from './TablePreview'
+
+const meta: Meta<typeof TablePreview> = {
+ title: 'Marketing Analytics/Dashboard/Breakdown table',
+ component: TablePreview,
+}
+export default meta
+type Story = StoryObj<typeof meta>
+
+export const Interactive: Story = {}
+export const Loading: Story = {
+ parameters: { testOptions: { waitForLoadersToDisappear: false } },
+ args: { initialState: 'loading' },
+}
+export const Empty: Story = { args: { initialState: 'empty' } }
+export const Error: Story = { args: { initialState: 'error' } }
+export const Narrow: Story = {
+ parameters: Loading.parameters,
+ args: Loading.args,
+ decorators: [
+ (Story) => (
+ <div className="w-[32.5rem] max-w-full">
+ {/* A 520 px scene models the space beside an open side panel. */}
+ <Story />
+ </div>
+ ),
+ ],
+}
+export const NarrowComparison: Story = {
+ args: { initiallyCompare: true },
+ decorators: Narrow.decorators,
+}
diff --git a/products/marketing_analytics/frontend/dashboard/tables/MarketingBreakdownTable.tsx b/products/marketing_analytics/frontend/dashboard/tables/MarketingBreakdownTable.tsx
new file mode 100644
index 000000000000..8089595a7f51
--- /dev/null
+++ b/products/marketing_analytics/frontend/dashboard/tables/MarketingBreakdownTable.tsx
@@ -0,0 +1,180 @@
+import { useActions, useValues } from 'kea'
+import { useId } from 'react'
+
+import { LemonBanner, LemonButton, LemonTable, LemonTableColumn } from '@posthog/lemon-ui'
+
+import { TileId } from 'scenes/web-analytics/common'
+import { displayBreakdownValue } from 'scenes/web-analytics/tabs/marketing-analytics/frontend/logic/marketingBreakdown'
+import { WebTileHeader, WebTileHeaderProps } from 'scenes/web-analytics/WebTileHeader'
+
+import { CurrencyCode } from '~/queries/schema/schema-general'
+
+import { BreakdownTableColumn, compareByCurrent } from './breakdownTableColumn'
+import { buildExportMenuItems, buildExportRows } from './breakdownTableExport'
+import { ChangeValueCell } from './ChangeValueCell'
+import { marketingBreakdownTableLogic } from './marketingBreakdownTableLogic'
+
+export interface MarketingBreakdownTableProps<Row extends object> {
+ tileId: TileId
+ titlePrefix: string
+ breakdownLabel: string
+ titleDropdown?: WebTileHeaderProps['titleDropdown']
+ rows: Row[]
+ rowKey: (row: Row) => string
+ breakdownValue: (row: Row) => string
+ columns: BreakdownTableColumn<Row>[]
+ defaultSortKey: string
+ compare: boolean
+ currency: CurrencyCode
+ loading: boolean
+ error: boolean
+ onRetry: () => void
+ emptyState: string
+ footnote?: React.ReactNode
+ exportFilename: string
+ focusedBreakdownValue?: string | null
+ onFocusBreakdown?: (value: string) => void
+}
+
+export function MarketingBreakdownTable<Row extends object>({
+ tileId,
+ titlePrefix,
+ breakdownLabel,
+ titleDropdown,
+ rows,
+ rowKey,
+ breakdownValue,
+ columns,
+ defaultSortKey,
+ compare,
+ currency,
+ loading,
+ error,
+ onRetry,
+ emptyState,
+ footnote,
+ exportFilename,
+ focusedBreakdownValue,
+ onFocusBreakdown,
+}: MarketingBreakdownTableProps<Row>): JSX.Element {
+ const tableKey = useId()
+ const logic = marketingBreakdownTableLogic({ tableKey, defaultSortKey })
+ const { sorting } = useValues(logic)
+ const { setSorting } = useActions(logic)
+ const tableColumns: LemonTableColumn<Row, keyof Row | undefined>[] = [
+ {
+ title: breakdownLabel,
+ key: 'breakdown_value',
+ render: (_, row) => {
+ const value = breakdownValue(row)
+ const label = displayBreakdownValue(value, breakdownLabel)
+ return onFocusBreakdown ? (
+ <LemonButton
+ size="xsmall"
+ onClick={() => onFocusBreakdown(value)}
+ tooltip="Focus this line in the chart"
+ aria-label={`Focus ${label} in the chart`}
+ data-attr="marketing-breakdown-focus"
+ className="max-w-full"
+ >
+ <span className="truncate" title={label}>
+ {label}
+ </span>
+ </LemonButton>
+ ) : (
+ <span className="block truncate" title={label}>
+ {label}
+ </span>
+ )
+ },
+ },
+ ...columns.map(
+ (column): LemonTableColumn<Row, keyof Row | undefined> => ({
+ title: (
+ <span className="whitespace-normal wrap-anywhere">
+ <span className="hidden @min-[40rem]:inline">{column.title}</span>
+ <span className="@min-[40rem]:hidden">
+ {column.shortTitle?.replaceAll('/', '/\u200b') ?? column.title}
+ </span>
+ </span>
+ ),
+ key: column.key,
+ align: 'right',
+ tooltip: column.tooltip,
+ sorter: compareByCurrent(column, sorting?.order ?? -1),
+ render: (_, row) => (
+ <ChangeValueCell
+ value={column.value(row)}
+ compare={compare}
+ kind={column.kind}
+ reverseColors={column.reverseColors}
+ neutral={column.neutral}
+ tooltipContent={column.tooltipContent?.(row)}
+ currency={currency}
+ />
+ ),
+ })
+ ),
+ ]
+
+ return (
+ <div className="@container border rounded bg-surface-primary flex flex-col">
+ <WebTileHeader
+ tileId={tileId}
+ titlePrefix={titlePrefix}
+ title={breakdownLabel}
+ titleDropdown={titleDropdown}
+ overflowMenuItems={buildExportMenuItems(
+ () =>
+ buildExportRows({
+ columns,
+ rows,
+ breakdownLabel,
+ breakdownValue: (row) => displayBreakdownValue(breakdownValue(row), breakdownLabel),
+ compare,
+ sorting,
+ }),
+ exportFilename,
+ !loading && !error && rows.length > 0
+ )}
+ />
+ {error && !loading ? (
+ <div className="p-3">
+ <LemonBanner
+ type="error"
+ action={{
+ children: 'Retry',
+ onClick: onRetry,
+ 'data-attr': 'marketing-breakdown-table-retry',
+ }}
+ >
+ Couldn't load this table. Try again.
+ </LemonBanner>
+ </div>
+ ) : (
+ <div className="max-h-[36rem] overflow-auto">
+ {/* Cap long breakdowns so later dashboard sections stay within reach. */}
+ <LemonTable
+ className="@max-[40rem]:[&_th_svg]:hidden @max-[40rem]:[&_.sorting-indicator]:hidden"
+ embedded
+ tableLayout="fixed"
+ size="small"
+ firstColumnSticky
+ useURLForSorting={false}
+ columns={tableColumns}
+ dataSource={loading ? [] : rows}
+ loading={loading}
+ loadingSkeletonRows={5}
+ rowKey={rowKey}
+ sorting={sorting}
+ onSort={setSorting}
+ emptyState={emptyState}
+ // The sticky first column paints its own background, so a row class alone leaves it unhighlighted.
+ rowStatus={(row) => (focusedBreakdownValue === breakdownValue(row) ? 'highlighted' : null)}
+ />
+ </div>
+ )}
+ {footnote && <div className="text-secondary text-xs px-3 pb-3">{footnote}</div>}
+ </div>
+ )
+}
diff --git a/products/marketing_analytics/frontend/dashboard/tables/TablePreview.tsx b/products/marketing_analytics/frontend/dashboard/tables/TablePreview.tsx
new file mode 100644
index 000000000000..afad6b701f8b
--- /dev/null
+++ b/products/marketing_analytics/frontend/dashboard/tables/TablePreview.tsx
@@ -0,0 +1,103 @@
+import { useActions, useValues } from 'kea'
+import { useId } from 'react'
+
+import { LemonButton, LemonSwitch } from '@posthog/lemon-ui'
+
+import { BREAKDOWN_OTHER_STRING_LABEL } from 'scenes/insights/utils'
+import { TileId } from 'scenes/web-analytics/common'
+
+import { CurrencyCode } from '~/queries/schema/schema-general'
+
+import { MarketingBreakdownTable } from './MarketingBreakdownTable'
+import { TablePreviewState, tablePreviewLogic } from './tablePreviewLogic'
+import {
+ BOUNCE_RATE_COLUMN,
+ PAGES_PER_SESSION_COLUMN,
+ SESSIONS_COLUMN,
+ SESSION_DURATION_COLUMN,
+} from './webStatsColumns'
+import { WebStatsRow } from './webStatsRows'
+
+const rows: WebStatsRow[] = [
+ {
+ breakdownValue: 'Direct',
+ sessions: [120, 100],
+ views: [240, 180],
+ session_duration: [90, 60],
+ bounce_rate: [0.3, 0.4],
+ },
+ {
+ breakdownValue: 'Paid search',
+ sessions: [80, 100],
+ views: [160, 200],
+ session_duration: [45, 60],
+ bounce_rate: [0.4, 0.3],
+ },
+ {
+ breakdownValue: 'Email',
+ sessions: [20, 10],
+ views: [60, 20],
+ session_duration: [120, 90],
+ bounce_rate: [0.2, 0.25],
+ },
+ { breakdownValue: '', sessions: [0, null], views: [0, null], session_duration: [0, null], bounce_rate: [0, null] },
+ { breakdownValue: BREAKDOWN_OTHER_STRING_LABEL, sessions: [5, 4], views: [10, 8], bounce_rate: [0.5, 0.5] },
+]
+
+export function TablePreview({
+ initialState = 'loaded',
+ initiallyCompare = false,
+}: {
+ initialState?: TablePreviewState
+ initiallyCompare?: boolean
+}): JSX.Element {
+ const previewKey = useId()
+ const logic = tablePreviewLogic({ previewKey, initialState, initiallyCompare })
+ const { state, compare, focusedValue } = useValues(logic)
+ const { setState, setCompare, setFocusedValue } = useActions(logic)
+
+ return (
+ <div className="flex flex-col gap-4">
+ <MarketingBreakdownTable
+ tileId={TileId.MARKETING}
+ titlePrefix="Engagement by"
+ breakdownLabel="Channel"
+ rows={state === 'empty' ? [] : rows}
+ rowKey={(row) => row.breakdownValue}
+ breakdownValue={(row) => row.breakdownValue}
+ columns={[SESSIONS_COLUMN, SESSION_DURATION_COLUMN, BOUNCE_RATE_COLUMN, PAGES_PER_SESSION_COLUMN]}
+ defaultSortKey="sessions"
+ compare={compare}
+ currency={CurrencyCode.USD}
+ loading={state === 'loading'}
+ error={state === 'error'}
+ onRetry={() => setState('loading')}
+ emptyState="No sessions in this date range. Try a wider date range."
+ footnote="Grouped by session entry. Visitors can appear in more than one row."
+ exportFilename="marketing-engagement"
+ focusedBreakdownValue={focusedValue}
+ onFocusBreakdown={setFocusedValue}
+ />
+ <div className="flex flex-wrap items-center gap-2">
+ <LemonButton data-attr="marketing-breakdown-story-show-loading" onClick={() => setState('loading')}>
+ Show loading
+ </LemonButton>
+ <LemonButton data-attr="marketing-breakdown-story-show-data" onClick={() => setState('loaded')}>
+ Show data
+ </LemonButton>
+ <LemonButton data-attr="marketing-breakdown-story-show-empty" onClick={() => setState('empty')}>
+ Show empty
+ </LemonButton>
+ <LemonButton data-attr="marketing-breakdown-story-show-error" onClick={() => setState('error')}>
+ Show error
+ </LemonButton>
+ <LemonSwitch
+ data-attr="marketing-breakdown-story-compare"
+ checked={compare}
+ onChange={setCompare}
+ label="Compare"
+ />
+ </div>
+ </div>
+ )
+}
diff --git a/products/marketing_analytics/frontend/dashboard/tables/breakdownTableExport.test.ts b/products/marketing_analytics/frontend/dashboard/tables/breakdownTableExport.test.ts
index 8ac9950da36a..f9c71429b661 100644
--- a/products/marketing_analytics/frontend/dashboard/tables/breakdownTableExport.test.ts
+++ b/products/marketing_analytics/frontend/dashboard/tables/breakdownTableExport.test.ts
@@ -46,6 +46,26 @@ describe('buildExportRows', () => {
)
})
+ it.each([
+ [{ columnKey: 'visitors', order: 1 }, ['Direct', 'Email', 'Organic']],
+ [{ columnKey: 'visitors', order: -1 }, ['Email', 'Direct', 'Organic']],
+ [null, ['Organic', 'Direct', 'Email']],
+ [{ columnKey: 'unavailable', order: 1 }, ['Organic', 'Direct', 'Email']],
+ ] as const)('exports the visible row order for sorting=%j without changing input rows', (sorting, expected) => {
+ const input = [rows[2], rows[1], rows[0]]
+ const exported = buildExportRows({
+ columns: [VISITORS_COLUMN],
+ rows: input,
+ breakdownLabel: 'Channel',
+ breakdownValue: (row) => row.breakdownValue,
+ compare: false,
+ sorting,
+ })
+
+ expect(exported.slice(1).map((row) => row[0])).toEqual(expected)
+ expect(input.map((row) => row.breakdownValue)).toEqual(['Organic', 'Direct', 'Email'])
+ })
+
it.each([
['Copy as CSV', 'Channel,Visitors\r\nEmail,0'],
['Copy for Excel', 'Channel\tVisitors\r\nEmail\t0'],
diff --git a/products/marketing_analytics/frontend/dashboard/tables/breakdownTableExport.ts b/products/marketing_analytics/frontend/dashboard/tables/breakdownTableExport.ts
index 6e5b77db490c..9a90699f2614 100644
--- a/products/marketing_analytics/frontend/dashboard/tables/breakdownTableExport.ts
+++ b/products/marketing_analytics/frontend/dashboard/tables/breakdownTableExport.ts
@@ -1,11 +1,12 @@
import { LemonMenuItem } from '@posthog/lemon-ui'
+import type { Sorting } from 'lib/lemon-ui/LemonTable/sorting'
import { downloadTableDataAsCsv } from 'scenes/web-analytics/webAnalyticsExportUtils'
import { copyTableData } from '~/queries/nodes/InsightViz/exportAdapters'
import { ExporterFormat } from '~/types'
-import type { BreakdownTableColumn } from './breakdownTableColumn'
+import { BreakdownTableColumn, compareByCurrent } from './breakdownTableColumn'
export interface ExportRowsOptions<Row> {
columns: BreakdownTableColumn<Row>[]
@@ -13,6 +14,7 @@ export interface ExportRowsOptions<Row> {
breakdownLabel: string
breakdownValue: (row: Row) => string
compare: boolean
+ sorting?: Sorting | null
}
/** Rows as `string[][]` with the header first, which is the shape the shared export helpers take. */
@@ -22,6 +24,7 @@ export function buildExportRows<Row>({
breakdownLabel,
breakdownValue,
compare,
+ sorting,
}: ExportRowsOptions<Row>): string[][] {
if (!rows.length) {
return []
@@ -37,7 +40,14 @@ export function buildExportRows<Row>({
),
]
- const body = rows.map((row) => [
+ const sortColumn = sorting && columns.find((column) => column.key === sorting.columnKey)
+ let sortedRows = rows
+ if (sortColumn && sorting) {
+ const sorter = compareByCurrent(sortColumn, sorting.order)
+ sortedRows = rows.slice().sort((a, b) => sorting.order * sorter(a, b))
+ }
+
+ const body = sortedRows.map((row) => [
breakdownValue(row),
...columns.flatMap((column) => {
const value = column.value(row)
diff --git a/products/marketing_analytics/frontend/dashboard/tables/marketingBreakdownTableLogic.test.ts b/products/marketing_analytics/frontend/dashboard/tables/marketingBreakdownTableLogic.test.ts
new file mode 100644
index 000000000000..eddd27e7f123
--- /dev/null
+++ b/products/marketing_analytics/frontend/dashboard/tables/marketingBreakdownTableLogic.test.ts
@@ -0,0 +1,26 @@
+import { resetContext } from 'kea'
+
+import { marketingBreakdownTableLogic } from './marketingBreakdownTableLogic'
+
+describe('marketingBreakdownTableLogic', () => {
+ it('keeps sorting and cancellation independent for tables with the same default metric', () => {
+ resetContext()
+ const engagement = marketingBreakdownTableLogic({ tableKey: 'engagement', defaultSortKey: 'sessions' })
+ const acquisition = marketingBreakdownTableLogic({ tableKey: 'acquisition', defaultSortKey: 'sessions' })
+ const unmountEngagement = engagement.mount()
+ const unmountAcquisition = acquisition.mount()
+
+ try {
+ engagement.actions.setSorting({ columnKey: 'bounce_rate', order: 1 })
+ expect(engagement.values.sorting).toEqual({ columnKey: 'bounce_rate', order: 1 })
+ expect(acquisition.values.sorting).toEqual({ columnKey: 'sessions', order: -1 })
+
+ engagement.actions.setSorting(null)
+ expect(engagement.values.sorting).toBeNull()
+ expect(acquisition.values.sorting).toEqual({ columnKey: 'sessions', order: -1 })
+ } finally {
+ unmountEngagement()
+ unmountAcquisition()
+ }
+ })
+})
diff --git a/products/marketing_analytics/frontend/dashboard/tables/marketingBreakdownTableLogic.ts b/products/marketing_analytics/frontend/dashboard/tables/marketingBreakdownTableLogic.ts
new file mode 100644
index 000000000000..8a4dc5322c0b
--- /dev/null
+++ b/products/marketing_analytics/frontend/dashboard/tables/marketingBreakdownTableLogic.ts
@@ -0,0 +1,54 @@
+import { LogicWrapper, MakeLogicType, actions, kea, key, path, props, reducers } from 'kea'
+
+import type { Sorting } from 'lib/lemon-ui/LemonTable/sorting'
+
+export interface MarketingBreakdownTableLogicProps {
+ tableKey: string
+ defaultSortKey: string
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface marketingBreakdownTableLogicValues {
+ sorting: Sorting | null
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface marketingBreakdownTableLogicActions {
+ setSorting: (sorting: Sorting | null) => {
+ sorting: Sorting | null
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface marketingBreakdownTableLogicMeta {
+ key: string
+}
+
+export type marketingBreakdownTableLogicType = MakeLogicType<
+ marketingBreakdownTableLogicValues,
+ marketingBreakdownTableLogicActions,
+ MarketingBreakdownTableLogicProps,
+ marketingBreakdownTableLogicMeta
+>
+
+export const marketingBreakdownTableLogic: LogicWrapper<marketingBreakdownTableLogicType> =
+ kea<marketingBreakdownTableLogicType>([
+ props({} as MarketingBreakdownTableLogicProps),
+ key((props) => props.tableKey),
+ path((key) => [
+ 'products',
+ 'marketing_analytics',
+ 'frontend',
+ 'dashboard',
+ 'tables',
+ 'marketingBreakdownTableLogic',
+ key,
+ ]),
+ actions({ setSorting: (sorting: Sorting | null) => ({ sorting }) }),
+ reducers(({ props }) => ({
+ sorting: [
+ { columnKey: props.defaultSortKey, order: -1 } as Sorting | null,
+ { setSorting: (_, { sorting }) => sorting },
+ ],
+ })),
+ ])
diff --git a/products/marketing_analytics/frontend/dashboard/tables/tablePreviewLogic.ts b/products/marketing_analytics/frontend/dashboard/tables/tablePreviewLogic.ts
new file mode 100644
index 000000000000..5aeeb6f3dc7a
--- /dev/null
+++ b/products/marketing_analytics/frontend/dashboard/tables/tablePreviewLogic.ts
@@ -0,0 +1,57 @@
+import { LogicWrapper, MakeLogicType, actions, kea, key, path, props, reducers } from 'kea'
+
+export type TablePreviewState = 'loaded' | 'loading' | 'empty' | 'error'
+
+export interface TablePreviewLogicProps {
+ previewKey: string
+ initialState: TablePreviewState
+ initiallyCompare: boolean
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface tablePreviewLogicValues {
+ compare: boolean
+ focusedValue: string | null
+ state: TablePreviewState
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface tablePreviewLogicActions {
+ setCompare: (compare: boolean) => {
+ compare: boolean
+ }
+ setFocusedValue: (focusedValue: string) => {
+ focusedValue: string
+ }
+ setState: (state: TablePreviewState) => {
+ state: TablePreviewState
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface tablePreviewLogicMeta {
+ key: string
+}
+
+export type tablePreviewLogicType = MakeLogicType<
+ tablePreviewLogicValues,
+ tablePreviewLogicActions,
+ TablePreviewLogicProps,
+ tablePreviewLogicMeta
+>
+
+export const tablePreviewLogic: LogicWrapper<tablePreviewLogicType> = kea<tablePreviewLogicType>([
+ props({} as TablePreviewLogicProps),
+ key((props) => props.previewKey),
+ path((key) => ['products', 'marketing_analytics', 'frontend', 'dashboard', 'tables', 'tablePreviewLogic', key]),
+ actions({
+ setState: (state: TablePreviewState) => ({ state }),
+ setCompare: (compare: boolean) => ({ compare }),
+ setFocusedValue: (focusedValue: string) => ({ focusedValue }),
+ }),
+ reducers(({ props }) => ({
+ state: [props.initialState, { setState: (_, { state }) => state }],
+ compare: [props.initiallyCompare, { setCompare: (_, { compare }) => compare }],
+ focusedValue: [null as string | null, { setFocusedValue: (_, { focusedValue }) => focusedValue }],
+ })),
+])