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.

fix(customer-analytics): preserve account table row memoization (#98169)

Paul D'Ambraf3d0f233b502
diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
index 2b6edba6f2b5..5192d769780d 100644
--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md
+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
@@ -25,6 +25,7 @@ AccountsTabContent ── binds dataNodeLogic(ACCOUNTS_TABLE_DATA_NODE_KEY, acc
│ AccountsOverviewTilesButton + AccountsColumnConfigurator on the right
├── AccountsOverviewTiles metric tiles across the filtered set
└── AccountsTable the DataTable; keyed row renderers; controlled row expansion
+ └── passes a memoized DataTable context, so unrelated state updates keep memoized table rows intact
└── AccountNotebooksExpansion expanded row: sidebar (Useful links + active-relationships summary) + LemonTabs(Notes/Users/Relationships/Feature requests/Usage/Spend/Opportunities/Conversations/Meetings/Event stream)
├── (notes) paginated/searchable/sortable LemonTable + "New note" button (accountNotebooksLogic, keyed by accountId)
├── (users) AccountRelatedUsersExpansion (accountRelatedUsersLogic, keyed by externalId; staff get a compact, region-aware admin link)
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsTable.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTable.tsx
index 7dd7eed800d0..71eb4e720f10 100644
--- a/products/customer_analytics/frontend/components/Accounts/AccountsTable.tsx
+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTable.tsx
@@ -61,6 +61,9 @@ const COLUMN_WIDTHS = {
relationship: '220px',
} as const
+// Filters are owned by accountsLogic; column/sort changes from the DataTable are ignored on purpose.
+const ignoreDataTableQueryChange = (): void => {}
+
function useGetCell(): (record: unknown, column: string) => unknown {
const { accountsTableQueryPlan } = useValues(accountsLogic)
return (record, column) =>
@@ -898,6 +901,19 @@ export function AccountsTable(): JSX.Element {
const contextColumns = useContextColumns()
const expandable = useExpandable()
const accountSceneEnabled = !!featureFlags[FEATURE_FLAGS.CUSTOMER_ANALYTICS_ACCOUNT_SCENE]
+ const dataTableContext = useMemo<QueryContext<DataTableNode>>(
+ () => ({
+ columns: contextColumns,
+ tableLayout: 'fixed',
+ tableStyle: Object.keys(columnWidths).length > 0 ? { width: 'max-content' } : undefined,
+ expandable,
+ dataTableRowsTransformer: sortedRowsTransformer,
+ dataNodeLogicKey: ACCOUNTS_TABLE_DATA_NODE_KEY,
+ emptyStateHeading: 'There are no matching accounts for this query',
+ emptyStateDetail: 'Try adjusting the filters or refreshing',
+ }),
+ [contextColumns, columnWidths, expandable, sortedRowsTransformer]
+ )
// A null source means the query is still waiting on the relationship
// definitions — same skeleton as the initial fetch, not an empty table.
if ((responseLoading || !accountsQuerySource) && !response) {
@@ -908,19 +924,8 @@ export function AccountsTable(): JSX.Element {
<DataTable
uniqueKey="customer-analytics-accounts-table"
query={accountsDataTableQuery}
- setQuery={() => {
- // Filters are owned by accountsLogic; column/sort changes from the DataTable are ignored on purpose.
- }}
- context={{
- columns: contextColumns,
- tableLayout: 'fixed',
- tableStyle: Object.keys(columnWidths).length > 0 ? { width: 'max-content' } : undefined,
- expandable,
- dataTableRowsTransformer: sortedRowsTransformer,
- dataNodeLogicKey: ACCOUNTS_TABLE_DATA_NODE_KEY,
- emptyStateHeading: 'There are no matching accounts for this query',
- emptyStateDetail: 'Try adjusting the filters or refreshing',
- }}
+ setQuery={ignoreDataTableQueryChange}
+ context={dataTableContext}
readOnly
/>
</div>