: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(customer-analytics): open account details on name click (#68661)
Sean Mallia3cc105275bf7
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex e0c8c6ea12b4..7fe44b99201b 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -4969,9 +4969,9 @@ snapshots:scenes-app-batchexports--runs-with-data--light:hash: v1.k794b7964.4c1646577dc53efffd814b1a2e723f9da6b10d3641e979f48c5d0447859e2348.fkHuUw1l_9c3rJKSi467jx-6Nv81nNp-PjeRmsgU7l0scenes-app-customer-analytics-accounts--default--dark:- hash: v1.k794b7964.c208ae9e334d2f3dc220f35ceb269b124a054acef5e342fdbc583e026f05d52f.vE6mY_JxSO2tMmTZ8TbCRnXZW8qRN8fNdsmT0zXP5VU+ hash: v1.k794b7964.c9c370b05fbbd44a9e387412dba111b38e4ba97fdc6c59e01a42ff3adb5492ef.XjoStLPNP7yOd4GOuEQsqwJ16Q1nxxxq4bKJ_fmfaicscenes-app-customer-analytics-accounts--default--light:- hash: v1.k794b7964.12bd6621a42884928ca2d187e70e676a79f2edbad2f09a1f4cc42140d7cce6c1.S2kYUTzb6Rv3AVPOA8YWSrs-GLXK_MUNH4Gpib6dwcA+ hash: v1.k794b7964.a8d7c019f2dc54de0dbc718203ff8198e8a21b6ad9825bcba03d18fb3bfc72d6.KKOhq4Q5XQMplujdgO1GALvINjHnWlL2KUNSocSlQe8scenes-app-customer-analytics-accounts--empty--dark:hash: v1.k794b7964.892b7da6722a32bd8383152a945e4bbc30eefebf1b9daa79d615e55a969e1a52._oCcXCKvTuiGNNd4h0WZ2YoMvWXtHmgHCxHmljYucH0scenes-app-customer-analytics-accounts--empty--light:diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.mdindex 0f5df72127dd..08d71a79418c 100644--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md@@ -51,7 +51,7 @@ AccountsTabContent ── binds dataNodeLogic(ACCOUNTS_HOGQL_DATA_NODE_KEY, acc`accountsLogic.hogqlQuery` builds a `DataTableNode` wrapping an `AccountsQuery` for the list rows (`select`, plus optional `search`, `tagNames`, `allRolesUnassigned`, `assignedToUserIds`, `filterExpression`, `orderBy`). The overview-tile `metrics` are **not** on this query — `accountsLogic.metricsQuery` is a separate metrics-only `AccountsQuery` (`metrics` set, no `select`; `null` when there are no tiles) that the backend runner answers with its own aggregation query, so the tiles load without blocking the rows. Both queries share filters via `applyAccountFilters`. The backend runner (`accounts_query_runner`) returns **rows as arrays** aligned to `visibleColumnNames`, and tile aggregations in `metricsResults`. `assignedToUserIds` is the "assigned to" filter — a list of user ids the runner expands into `csm IN ids OR account_executive IN ids` (the single user-facing role filter; there are no separate per-role CSM/AE/owner filters). The `allRolesUnassigned` flag (the "Unassigned only" option, surfaced inside the "Assigned to" picker — mutually exclusive with picking people via the cascade in `accountsLogic` listeners) restricts to accounts with no csm/AE/owner. The "My accounts" checkbox is a client-side shortcut: `accountsLogic` resolves it to `[currentUserId]` (from `userLogic`) before the query is sent, so the backend only ever receives explicit ids and a shared URL resolves to the same accounts for every viewer. Two cell shapes matter:-- **`name` column** (mandatory, `ACCOUNTS_NAME_COLUMN`) — emitted as `tuple(name, external_id, id)`, read as `{ name, external_id, id }`. This is the row's identity: `id` (the account PK) drives expansion/scroll/role updates; `external_id` is the copy-able group key. `getNameCell()` in `AccountsHogQLTable.tsx` is the canonical accessor; never assume a column index.+- **`name` column** (mandatory, `ACCOUNTS_NAME_COLUMN`) — emitted as `tuple(name, external_id, id)`, read as `{ name, external_id, id }`. This is the row's identity: `id` (the account PK) drives expansion/scroll/role updates; `external_id` is the copy-able group key. `getNameCell()` in `AccountsHogQLTable.tsx` is the canonical accessor; never assume a column index. In `NameCell` the name renders as the prominent (`font-semibold`) primary label: a plain click opens the account details inline (toggles the row's expansion via `accountsExpansionLogic`, firing `AccountOpened` on open), while the `<Link>` href points at `urls.customerAnalyticsAccount(id)` so cmd/ctrl-click opens the account's deep-link page in a new tab. The `external_id` sits beneath it as de-emphasized (`text-xs text-muted`) copy-to-clipboard text.- **role columns** (`csm`, `account_executive`, `account_owner`) — emitted as `tuple(id, email)`, rendered with `MemberSelect`. Sorting these uses `tupleElement(col, 2)` (email) so visual order matches.Default columns (`ACCOUNTS_HOGQL_DEFAULT_SELECT`): `name`, `tag_names`, `notebook_count`, `csm`, `account_executive`, `account_owner`. The name column is force-kept (`ensureNameColumn`) — removing it breaks identity, scroll, and role edits. Extra columns come from account properties, lazy/virtual-table joins under `system.accounts`, data-warehouse joins, freeform SQL, or **custom properties** — all assembled by `buildAccountColumnGroups`.@@ -166,6 +166,7 @@ We track user actions on the Accounts list with `posthog.capture()`. Conventions| `customer analytics accounts searched` | `accountsLogic` `setSearchInput` listener (post-debounce) | `query_length`, `has_query`, `active_filter_count` || `customer analytics accounts refreshed` | `accountsLogic` `refresh` | `has_search`, `active_filter_count`, `sort_column` || `customer analytics accounts sorted` | `accountsLogic` `toggleSort` | `column`, `direction` (`asc` \| `desc` \| `cleared`) |+| `customer analytics accounts account opened` | `AccountsHogQLTable.tsx` `NameCell` account-name `<Link>` `onClick` (only when the row expands, not when it collapses) | _(none — the row's `id` is customer PII-adjacent and kept out)_ || ~~`customer analytics accounts columns saved`~~ | _Deprecated — no longer emitted. Column changes are now saved as part of a view (see view events below)._ | _n/a_ || `customer analytics accounts overview tiles edited` | `accountsOverviewTilesLogic` editor close (diffed vs open snapshot, only when changed) | `tiles_added`, `tiles_removed`, `tiles_updated`, `reordered`, `tile_count_before`, `tile_count_after` || `customer analytics accounts overview tiles localstorage read` | `accountsOverviewTilesLogic` `afterMount` (only when a legacy custom value exists) | `tile_count` — **tombstone**: a legacy localStorage tiles value was read; once this stops firing, no browser still carries one and the read path can be removed |diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsHogQLTable.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsHogQLTable.tsxindex 1505604a19db..b521de241714 100644--- a/products/customer_analytics/frontend/components/Accounts/AccountsHogQLTable.tsx+++ b/products/customer_analytics/frontend/components/Accounts/AccountsHogQLTable.tsx@@ -1,4 +1,5 @@import { useActions, useValues } from 'kea'+import posthog from 'posthog-js'import { useMemo } from 'react'import { IconCheck, IconX } from '@posthog/icons'@@ -11,6 +12,8 @@ import { ObjectTags } from 'lib/components/ObjectTags/ObjectTags'import { TZLabel } from 'lib/components/TZLabel'import { LemonTableColumns } from 'lib/lemon-ui/LemonTable'import { SortingIndicator } from 'lib/lemon-ui/LemonTable/sorting'+import { Link } from 'lib/lemon-ui/Link'+import { urls } from 'scenes/urls'import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'import { DataTable } from '~/queries/nodes/DataTable/DataTable'@@ -25,6 +28,7 @@ import { AccountNotebooksExpansion } from './AccountNotebooksExpansion'import { ACCOUNTS_NAME_COLUMN, accountsColumnConfigLogic } from './accountsColumnConfigLogic'import { accountsExpansionLogic } from './accountsExpansionLogic'import { AccountRoleKey, accountsLogic } from './accountsLogic'+import { AccountsEvents } from './constants'type AccountAssignment = { id: number; email: string } | null@@ -85,17 +89,44 @@ function tupleToAssignment(value: unknown): AccountAssignment {function NameCell({ record }: { record: unknown }): JSX.Element {const { visibleColumnNames } = useValues(accountsColumnConfigLogic)+ const { isAccountExpanded } = useValues(accountsExpansionLogic)+ const { toggleAccountExpanded } = useActions(accountsExpansionLogic)const cell = getNameCell(record, visibleColumnNames)const name = cell?.name ?? ''const externalId = cell?.external_id ?? ''+ const accountId = cell?.idreturn (- <div className="flex flex-col min-w-40" data-account-id={cell?.id}>- <span className="font-medium">{name}</span>+ <div className="flex flex-col min-w-40" data-account-id={accountId}>+ {accountId ? (+ <Link+ // Plain click opens the account details inline (keeping the list mounted); the href+ // stays so a modifier-click (cmd/ctrl/shift) opens the account's deep-link page in a new tab/window.+ to={urls.customerAnalyticsAccount(accountId)}+ className="font-semibold"+ onClick={(event) => {+ if (event.metaKey || event.ctrlKey || event.shiftKey) {+ return+ }+ event.preventDefault()+ event.stopPropagation()+ if (!isAccountExpanded(accountId)) {+ posthog.capture(AccountsEvents.AccountOpened)+ }+ toggleAccountExpanded(accountId)+ }}+ >+ {name}+ </Link>+ ) : (+ <span className="font-semibold">{name}</span>+ )}{externalId ? (<CopyToClipboardInlineexplicitValue={externalId}iconStyle={{ color: 'var(--color-accent)' }}+ iconSize="xsmall"description="account ID"+ className="text-xs text-muted">{externalId}</CopyToClipboardInline>diff --git a/products/customer_analytics/frontend/components/Accounts/constants.ts b/products/customer_analytics/frontend/components/Accounts/constants.tsindex cebd171f17e8..58efa8eda596 100644--- a/products/customer_analytics/frontend/components/Accounts/constants.ts+++ b/products/customer_analytics/frontend/components/Accounts/constants.ts@@ -32,6 +32,7 @@ export const AccountsEvents = {Searched: 'customer analytics accounts searched',Refreshed: 'customer analytics accounts refreshed',Sorted: 'customer analytics accounts sorted',+ AccountOpened: 'customer analytics accounts account opened',ColumnsSaved: 'customer analytics accounts columns saved',OverviewTilesEdited: 'customer analytics accounts overview tiles edited',OverviewTilesLocalStorageRead: 'customer analytics accounts overview tiles localstorage read',