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(customer-analytics): default accounts to all assignment statuses (#95311)

Arthur Moreira de Deusf8be1e7a490d
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index 952e03f88684..2a7b88e77768 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6277,45 +6277,45 @@ snapshots:
scenes-app-customer-analytics-account-detail--narrow--light:
hash: v1.k794b7964.5a6763d49a273274f686f1517da9d2ba4af64b5be6897a9886addc04f429c209.JZ6O0iGKO-5AKZyg0XnVZ8JoOZ2-Jg4i9E746aSUm2I
scenes-app-customer-analytics-accounts--default--dark:
- hash: v1.k794b7964.dbaff4c177f276bb47e0587c5f66195cec454a062fa87a2c506ad1cbc5d04a40.3YhGb7YnUDZDgX333J4grk5qzIg-8A1qMdTDxUiTLec
+ hash: v1.k794b7964.97f0ca87971b15063d49547b9dcd6ac408805eeeba4818861c79efe4a00546bb.Beg7zqqVXErdSTxwwKNImW-swYpMUtoQYSdy1HMF6vw
scenes-app-customer-analytics-accounts--default--light:
- hash: v1.k794b7964.c9ec4f78a9fa7101e014af8c25168fb12ea7f9c6f9ff9c1f7023c2500a1b17c8.FOaZdKiATjm-L6s6qpyNzZlKcVNr35awJg9y53N9v4g
+ hash: v1.k794b7964.49e00fd16d847577e31f63f3fe3b52106ea3413984de498d94dee9fb4191dfab.Pyp8xV0Zulz2LZPD8BYBY2pYF8MiL_RUeyB95taWBAg
scenes-app-customer-analytics-accounts--empty--dark:
- hash: v1.k794b7964.476e882b10a17c95583186080ee4278caccc81741c79dd5e00b9bbf978034137.PJGrQRo3GFGiE8PPimhZtLGF8JUXA_neVBrZ631auLM
+ hash: v1.k794b7964.8bbfbb085c8371d1acc371ebb7486f5a1830933fd43ccc69c4616c03b405c49b.S-o-UavAzV6HKT4M9ngxzog4L8V2gjmO7hFD-IurEiM
scenes-app-customer-analytics-accounts--empty--light:
- hash: v1.k794b7964.b5b8140f271f4e6da493124f472b38ae6f136fe20e2b58661869fe05c6cf7464.9E-nJaqW5RSGIeB7bwdTn2AJMsfhaQzFKdcRLkPswoc
+ hash: v1.k794b7964.2eae93b6c127e4d0067f328ee14b00febf2251ce1ea115823bda5c91c5d25d20.pprP1-oCTqN-0lKKKkrtrefqO6-JTmpeXBUr6uVnqBU
scenes-app-customer-analytics-accounts--feature-gate-off--dark:
hash: v1.k794b7964.4b8d5226ee154debdf333ff93d65a90ca766bcb25951e1baf36affb8b84b548d.dWZSHssPc83RkHVE-JPJA562bJR7MUim2yfqhjfNE50
scenes-app-customer-analytics-accounts--feature-gate-off--light:
hash: v1.k794b7964.e8b91bf6a0dd1b5d31064f4cbb94e9791e999c210831c455a498d0c7cc7e6bbb.IkZPJrJz33sKS8zzKwoy8V3s0GvmKpe5EGYTCIljhLs
scenes-app-customer-analytics-accounts--row-expanded-conversations--dark:
- hash: v1.k794b7964.28471d9337f14b772cfe89b267cd6e8ee0af6d9c056829cdbed4f6002ceb0f69.-Ag1Nr1iECryl7-Y6awXl0Vko7ApVJUAiZxpD6gE9S8
+ hash: v1.k794b7964.85d2156f037fbbef7b7bfd3a53243f586a1422255364fc20bb2fdf62833edf9e.UF17aYyH5Y3WjTM7h8mCURAt98oED9XQfhG1rEUzKOA
scenes-app-customer-analytics-accounts--row-expanded-conversations--light:
- hash: v1.k794b7964.4a269ddfd195a52ee4e4ee900d9b33ca23ca417119e9a981727c3d555b84c0ad.0seDk14GuoEOGh25pb7azihedQf5P4ykGyBY2aFkR_M
+ hash: v1.k794b7964.01ce8914a73199cd0cfd692b1dd35434f9be454be0f4903bb475bb8c271c84a8.T8R4tZv9tCGQa516kPRRLI8G0r5jL73o4HmrH2D7yoU
scenes-app-customer-analytics-accounts--row-expanded-empty--dark:
- hash: v1.k794b7964.e26fa4e54eab3ae9089c88549743a71d5647a2b1a9ea59329670f65736f7c3e3.D83ROyLmN1qnXFrUnHwIxmI43D1Wx1ng3YFP0xGGIG0
+ hash: v1.k794b7964.01f884cde35ce4f59e9629d063c25f7f55fe3f45e4be94fd9b176e80044a3692.cQ1evUe7hRE6uWypbH4hz-DgGoOf3ZvuZfrAaSI7wws
scenes-app-customer-analytics-accounts--row-expanded-empty--light:
- hash: v1.k794b7964.d0c7cf851a7d0d02b354b9dbb0415a3520f5fa441687b0f6c22ec0dd540fff2c.KrxRllCdcGjUwupry7nEYDFjvQ1a4EirAq2nJpid3f0
+ hash: v1.k794b7964.4d3eb646bfc9fa9e2bfeca3c11c76014b1db431d4a47c42051ca250a78f36ea9.aN76eWjyfARC_7vbAdOaNwxiym8WhKu8zoHv7YY0DrU
scenes-app-customer-analytics-accounts--row-expanded-feature-requests--dark:
- hash: v1.k794b7964.5763aba8a69cfabd27fa35d9c257f9b34ef0ec0c5fc9ea0fb04f8f24b6fb99fb.vE84W00tlPWei24OhvFK9QMol-BYY3a88jkXlRmyfc0
+ hash: v1.k794b7964.700dd4b2db8d70887eb28b5f9f3249ed76a43eb285eee7cc44ad943b97dd2d62.VJaag8tyrF8wroT7lWR5RCcD_9O4FMtuqGHlsdYln8g
scenes-app-customer-analytics-accounts--row-expanded-feature-requests--light:
- hash: v1.k794b7964.64a789d465c72848d4636af9b8285621b0c6d52773fcf807f2acda2fac8564ad.LOlyA-ERhmFyj_kuJ6O5ytfReKYFaf6i2kSPL7SrFTU
+ hash: v1.k794b7964.f8f5f387b10f139ebd7d7d973fe357f09f627a0fadbde73d8cbf4d9c039ceb46.VAJxkZjd8iprsEbDq27oGm6IIjjt1Gkh8e-0mCw-S3I
scenes-app-customer-analytics-accounts--row-expanded-links-disabled--dark:
- hash: v1.k794b7964.98273ded9eab6ee15a348dee6d75024d6a43c3454d735d5498c3bd7407c301a1.n4AeBhdPn7iCbsutgSjml8OwwKGVRHGRQ3pjsVnOFL0
+ hash: v1.k794b7964.454674320a381f066455658873231ecef115a1f8ebd4fb28336dab458f16d5b3.dCE35U2jbl9_Wz4om921P9iXVi9gjq_itULyXutuIwE
scenes-app-customer-analytics-accounts--row-expanded-links-disabled--light:
- hash: v1.k794b7964.1c005ce13c47e11cacadf35f6b53d3873e02605672edc4aa56956f46586209b8.-QGC5z3_B--rJpbLNrUZB9cM8znB8wW8FsJpdVyUsfE
+ hash: v1.k794b7964.1ded4377e2c911433fe7c7cad58d9dc5ca25048b64d3fef64eb6758928bf6d9c.q52r6GX2EJc91KSFF7Tc_KoBT8ALu5hG2_4q0tfRbAA
scenes-app-customer-analytics-accounts--row-expanded-usage-not-found--dark:
- hash: v1.k794b7964.f445ec51405294a7e1fe387bd0954c9499b912f9f9f5675bd54af7d3f42e1bc0.6ryzyVK3ajRA3clhtKz-GlFhv14tJcG6RU-ioWKP1_Q
+ hash: v1.k794b7964.cd65fe4409d235612246e32bb0b30f22ec975993eb6961226f27dc30b146325f.3_5MdMYqgV49hODxv9hGK75sPv79z53eK4QqaekUqoo
scenes-app-customer-analytics-accounts--row-expanded-usage-not-found--light:
- hash: v1.k794b7964.0b205d5623ec4ae0bc4fb606845322bcc18beeaf7b6f0954dbf5670ac972e56d.q83dxrVG2zLbR6T4bop2VlZxrqqz6dxdLcWLvQk_fQk
+ hash: v1.k794b7964.0728c102b2d5e41ec26196cb25534e6556fae0bf3d98b28cf322862edc8ea13f.W61cjs7VG1TyyqFFK9t4C1jkBdvtdlk6nP6PH7sqRO8
scenes-app-customer-analytics-accounts--row-expanded-with-note--dark:
- hash: v1.k794b7964.e4c9a4f5fa70c9d812972d49a61b3364d782c4a7993b28802d46063a11e01906.qAeMvIE_-M57FFA0T97nilxqOt1Li5_5hblANFeh9nU
+ hash: v1.k794b7964.73f6224f2a2fe465845423f5851a4d6095de3bf76f475cd34a74d2a5af9fa69e.pBn0jp3FJZY-7b2j_ceh-dErIGGbxkRDJWrq4kVzDts
scenes-app-customer-analytics-accounts--row-expanded-with-note--light:
- hash: v1.k794b7964.ae995eb9195d6badc128fe351cc31528f9730ea03c8c61a85098134f46e3bcf4.vl18MUmsu2699D97TPUISdp-Xl9Yi5Lmut2suQEYRDg
+ hash: v1.k794b7964.84c3a7d780275f21ac26f7b7819acf934376ffede731f98591cb8276b822a784.g8o45FmYlFxr_OaZvURXrLvjZpD00diTHcp8x4A6Tfg
scenes-app-customer-analytics-dashboard--b-2-b-mode-with-groups-enabled--dark:
- hash: v1.k794b7964.cf03f6a65f846aec287042028193b834c567f01226d2e91f6389df5af935530d.bXzRv9MkU0nXN-4tvGbenagVaJuhFr86goke8HVYFJY
+ hash: v1.k794b7964.676001075ee700388d9cdd0c7ec45430e7fc40c5b7aedbb7e26efe0e01ccee30.9lZ1hXCdIHbJEf7RqEWimEYspfWdC8UsIE8LKrK6c7c
scenes-app-customer-analytics-dashboard--b-2-b-mode-with-groups-enabled--light:
- hash: v1.k794b7964.4ee0185302dbca8e82bf55b9ce41d3fbbd357be595f39e1601be9714a46df5b6.4tdIruQOTdOTFWzHYxNCfm24rxaY9YscJG-pT2fk12w
+ hash: v1.k794b7964.43dc0afd3727996fc4e52810da9f7d50740c33b5b276b0aa7cd04a9afb471616.A_tOvmQbs-iR3mUPbRiNUDmQeYmBmFmBtLGRAA19vf0
scenes-app-customer-analytics-dashboard--b-2-b-mode-without-groups--dark:
hash: v1.k794b7964.fba00c329afe3f32d762b5ca68fd34ec029f644f5b0e9e1122589fa00bf39147.ZgZqcfIjl8qUUZ2865YzQ12RBt0Om97q2dsg9dxUYDY
scenes-app-customer-analytics-dashboard--b-2-b-mode-without-groups--light:
diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
index 5f02ea043bf6..f028a79c071e 100644
--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md
+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
@@ -20,7 +20,7 @@ The scene renders `AccountsTabContent`, which binds **two** keyed `dataNodeLogic
AccountsTabContent ── binds dataNodeLogic(ACCOUNTS_TABLE_DATA_NODE_KEY, accountsLogic.accountsQuerySource) [list rows]
└─ binds dataNodeLogic(ACCOUNTS_METRICS_DATA_NODE_KEY, accountsLogic.metricsQuery) [overview tiles, metrics-only]
├── AccountsMaxTools registers the `open_account` Max contextual tool → accountsLogic.openAccount
-├── AccountsTabFilters two rows: (1) search + Refresh; (2) tags / "assigned to" (incl. unassigned-only) /
+├── AccountsTabFilters two rows: (1) search + Refresh; (2) tags / "assigned to" (assignment-status picker) /
│ "my accounts" / native-field, relationship, and custom-property filters on the left,
│ AccountsOverviewTilesButton + AccountsColumnConfigurator on the right
├── AccountsOverviewTiles metric tiles across the filtered set
@@ -42,7 +42,7 @@ AccountsTabContent ── binds dataNodeLogic(ACCOUNTS_TABLE_DATA_NODE_KEY, acc
| Logic | Owns |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `accountsLogic` | The hub. Search (debounced), tag / assigned-to/unassigned / native-field / relationship / custom-property filters, sort, inline role and custom-property assignment, typed Postgres list and metrics queries, shareable URL-hash view state, and `openAccount` (the Max entry point). Canonical and warehouse-backed property values are read-only. Workflow-backed properties stay editable, but a future workflow run overwrites a manual value. `accountsTableQueryPlan` translates live, saved-view, and URL-restored state into typed references. `connect`s column-config, overview-tiles, and expansion logics. |
+| `accountsLogic` | The hub. Search (debounced), tag / assignment-status (the canonical `assignmentStatus`: `all` \| `assigned` \| `unassigned`, default `all`) + assigned-to / native-field / relationship / custom-property filters, sort, inline role and custom-property assignment, typed Postgres list and metrics queries, shareable URL-hash view state, and `openAccount` (the Max entry point). Canonical and warehouse-backed property values are read-only. Workflow-backed properties stay editable, but a future workflow run overwrites a manual value. `accountsTableQueryPlan` translates live, saved-view, and URL-restored state into typed references. `connect`s column-config, overview-tiles, and expansion logics. |
| `accountsViewsLogic` | Saved-views lifecycle (list/create/update/delete/select) and browser-persisted column widths. Connects to `accountsLogic`, `accountsColumnConfigLogic`, and `accountsOverviewTilesLogic`; is the single owner of reading and writing the `ColumnConfiguration` rows for this area. |
| `accountsColumnConfigLogic` | Selected columns (`selectColumns` / `visibleColumnNames`), Postgres-backed column-picker groups, the per-team saved column config (`columnConfigurations` API), and custom-property definitions. It seeds `propertyDefinitionsModel` so the filter UI resolves per-type operator sets. Warehouse-backed columns and SQL expressions are not offered. |
| `accountsExpansionLogic` | Which rows are expanded (`expandedAccountIds`) and the active tab per account (`activeTabByAccount`). Pure state — no DOM, no data fetching. |
@@ -74,6 +74,14 @@ The list query, account search endpoint, and agent entity search share both path
Ignored accounts (`ignored_at IS NOT NULL`) are excluded from list rows and overview metrics by default. A direct account route sets `includeIgnored` as well as `includeChurned`, so an ignored account still opens by id. `ignored_at` is a selectable account field, but the Accounts UI does not write it.
+**Assignment filter (`assignmentStatus`).**
+A single canonical state on `accountsLogic` — `AssignmentStatus = 'all' | 'assigned' | 'unassigned'`, default `all` — drives the assigned/unassigned choice, so the status and the assigned-to user list can never describe contradictory sets.
+The "assigned to" dropdown shows three mutually exclusive checkboxes at the top, in order: **Unassigned only** (`unassigned`), **Assigned to anyone** (`assigned`), **All assignment statuses** (`all`, the default), plus the member picker below.
+`accountsTableQuery.ts` maps each status to a query filter: `all` omits the assignment filter entirely (both assigned and unassigned show), `assigned` emits `{ kind: 'assigned' }`, and `unassigned` emits `{ kind: 'unassigned' }`.
+Selecting users or checking "My accounts" narrows the assigned status to those user ids (`{ kind: 'assigned_to' }`) — both force the status to `assigned`; leaving the assigned status clears the user list.
+Legacy compatibility: a saved view or shared link created before this field defaulted to assigned-only, so any persisted filters object with no `assignmentStatus` resolves to `assigned` (an old `unassigned: true` resolves to `unassigned`) — they never silently broaden to `all`.
+New saved views always store `assignmentStatus`; in the URL hash the default `all` is only written once another filter is present (so a pure-default view keeps an empty hash), and an empty hash restores as `all`.
+
Overview tiles run as a separate metrics-only `AccountsTableQuery` (`metrics` set and `columns: []`; `null` when there are no tiles or while definitions are loading). Count, sum, average, minimum, maximum, median, scaling, and threshold counts execute in Postgres. The "My accounts" checkbox resolves to the current user's explicit ID before either query is built, so shared URLs remain viewer-independent. Two cell shapes matter:
- **`name` column** (mandatory, `ACCOUNTS_NAME_COLUMN`) — read directly from the keyed row's `id`, `name`, `externalId`, and `logoDomain`. This is the row's identity: `id` (the account PK) drives expansion, scroll, and role updates; `externalId` is the copyable group key. `getNameCell()` in `AccountsTable.tsx` is the canonical accessor. `AccountNameCell.tsx` owns the shared name, deep link, and copyable external ID presentation. `AccountsTableNameCell.tsx` owns list selection behavior. The Accounts list passes `logoDomain`, which adds `AccountLogo`. Other account tables omit the logo and use normal deep-link navigation.
@@ -207,7 +215,7 @@ The Notes tab is server-paginated, searchable, and sortable (all via `accountNot
## Shareable view state
-`accountsLogic` mirrors the full view (search, tags, unassigned, assigned-to, native-field and custom-property filters, sort, columns, tile filter) into the URL hash `#view=...` via `actionToUrl`/`urlToAction`, so a copied URL reproduces the exact list. Column widths stay in browser-local preferences instead of the URL because they are display preferences. Only non-default values are serialized. The "assigned to" filter persists as concrete `assignedTo` ids (not a `mine` flag), so a link shared with a colleague resolves to the **same** accounts for them as for the sharer; the legacy `mine: true` hash is still read and resolved to the current user's id for backward compatibility. A shared link's `columns` win over the per-user saved column config (`accountsColumnConfigLogic` enforces this when its async saved-config load resolves by checking the live URL).
+`accountsLogic` mirrors the full view (search, tags, assignment status, assigned-to, native-field and custom-property filters, sort, columns, tile filter) into the URL hash `#view=...` via `actionToUrl`/`urlToAction`, so a copied URL reproduces the exact list. Column widths stay in browser-local preferences instead of the URL because they are display preferences. Only non-default values are serialized. The "assigned to" filter persists as concrete `assignedTo` ids (not a `mine` flag), so a link shared with a colleague resolves to the **same** accounts for them as for the sharer; the legacy `mine: true` hash is still read and resolved to the current user's id for backward compatibility. A shared link's `columns` win over the per-user saved column config (`accountsColumnConfigLogic` enforces this when its async saved-config load resolves by checking the live URL).
### Deep-link to one account (path route)
@@ -247,7 +255,7 @@ Views are persisted as `ColumnConfiguration` rows under `context_key = 'customer
- `columns` ← `selectColumns` (column names in order)
- `order_by` ← sort, stored as `["<column> <ASC|DESC>"]` using the logical column name, then translated into a typed sort reference at query-build time
-- `filters` ← search text, tags, unassigned toggle, assigned-to filter, tile filter, custom-property filters (JSON; custom-property filters key by definition **id**, so they survive renames)
+- `filters` ← search text, tags, assignment status (`assignmentStatus`, always stored so a new `all` view is distinct from a legacy field-less view that restores as assigned-only), assigned-to filter, tile filter, custom-property filters (JSON; custom-property filters key by definition **id**, so they survive renames)
- `properties` ← `{ tiles }` — overview tile configuration (a `properties` field added to the `ColumnConfiguration` model)
**Visibility** is `private` or `shared`; only the creator can edit or delete a view (enforced by the backend viewset).
@@ -314,59 +322,59 @@ We track user actions on the Accounts list with `posthog.capture()`. Conventions
- Event names: `customer analytics accounts <verb> <object>` — lowercase, spaces. Property keys are `snake_case`.
- **Reference event names via the `AccountsEvents` const in `constants.ts`** — never pass a raw string to `posthog.capture`. A typo'd literal silently forks a new event in PostHog and breaks reporting with no error. When adding an event, add it to `AccountsEvents` and to the table below.
- Fire events in the **kea logic listeners** (where the action and its values live), not in components. Only fire from a component when no action exists for the interaction (the expanded-row links/notes).
-- **Filters use a dedicated `reportFilterChange` action.** The raw filter setters (`setTagsFilter`, `setAssignedToFilter`, …) are also dispatched by URL sync (shared view links) and by cross-filter cascades (checking "unassigned only" clears the assigned-to filter, and vice versa), so capturing in their listeners would log phantom events. The filter controls dispatch `reportFilterChange(filterType)` on genuine interaction only; its listener reads the post-change state and captures. Add new filters the same way.
+- **Filters use a dedicated `reportFilterChange` action.** The raw filter setters (`setTagsFilter`, `setAssignedToFilter`, …) are also dispatched by URL sync (shared view links) and by cross-filter cascades (selecting users forces the `assigned` status, and leaving that status clears the user list), so capturing in their listeners would log phantom events. The filter controls dispatch `reportFilterChange(filterType)` on genuine interaction only; its listener reads the post-change state and captures. Add new filters the same way.
- Use the **effective/debounced** action where one exists (e.g. capture in the `setSearchInput` listener after its debounce) so events don't fire per keystroke.
- PII: log internal team members by `user_id` only (never email); never log raw search text, link URLs, or notebook titles.
### Tracked events
-| Event | Fires from | Properties |
-| -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `customer analytics accounts list viewed` | `accountsLogic` `afterMount` | _(none — funnel anchor; account count and saved-config aren't loaded at mount)_ |
-| `customer analytics accounts filter changed` | `accountsLogic` `reportFilterChange` listener (dispatched by the filter controls) | `filter_type` (`tag` \| `unassigned_only` \| `my_accounts` \| `assigned_to` \| `custom_property`), `value`, `is_cleared`, `active_filter_count`; for `tag` also `tag_count`; for `assigned_to` also `role_count`; for `custom_property` only `filter_count` + `is_cleared` (no `value` — property values can carry customer data) |
-| `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 column resized` | `accountsViewsLogic` `reportColumnResize` after a header drag | _(none — column names can contain customer property names)_ |
-| `customer analytics accounts account opened` | `AccountsTableNameCell.tsx` account-name `<Link>` `onClick` (only when the row expands in the legacy experience) | _(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 |
-| `customer analytics accounts view saved` | `accountsViewsLogic` `submitNewViewForm` listener (success) | `visibility` (`private` \| `shared`) |
-| `customer analytics accounts view updated` | `accountsViewsLogic` `updateViewSuccess` listener | _(none)_ |
-| `customer analytics accounts view selected` | `accountsViewsLogic` `applyView` listener | `visibility` |
-| `customer analytics accounts view deleted` | `accountsViewsLogic` `deleteViewSuccess` listener | _(none)_ |
-| `customer analytics account role assigned` | `accountsLogic` `updateAccountRole` | `role` (`csm` \| `account_executive` \| `account_owner` for the seeded definitions, else the definition name), `is_assigned`, `assigned_user_id`, `source` (`list_row` from `accountsLogic.updateAccountRole` \| `relationships_tab` from `accountRelationshipsLogic` assign/end) |
-| `customer analytics accounts relationship deleted` | `accountRelationshipsLogic` `deleteRelationship` listener (after the DELETE succeeds) | _(none - count only; relationship and account identifiers stay out)_ |
-| `customer analytics account tags updated` | `accountsLogic` `updateAccountTags` listener (after the debounced PATCH succeeds; dispatched by the tags cell editor) | `tag_count` (tag names kept out — they can name customers) |
-| `customer analytics account custom property updated` | `accountsLogic` `updateAccountCustomProperty` listener (after the custom-property-values write succeeds) | `display_type`, `workflow_reference` (property name and value stay out because they can contain customer data) |
-| `customer analytics account link clicked` | `AccountNotebooksExpansion.tsx` useful-link `onClick` (incl. the "Copy link to account" row, `link_key: 'copy-account-link'`) | `link_key`, `has_destination` |
-| `customer analytics account note clicked` | `AccountNotebooksExpansion.tsx` note `<Link>` `onClick` | `notebook_short_id` |
-| `customer analytics accounts note created` | `accountNotebooksLogic` `createNoteSuccess` listener | `notebook_short_id` |
-| `customer analytics accounts notes searched` | `accountNotebooksLogic` `setSearchTerm` listener (post-debounce) | `has_query`, `query_length` (no raw text) |
-| `customer analytics accounts notes sorted` | `accountNotebooksLogic` `setSorting` listener | `column` (`created_at` \| `created_by` \| null), `direction` (`asc` \| `desc` \| `cleared`) |
-| `customer analytics account tab viewed` | `accountsExpansionLogic` `setActiveTab` listener (genuine tab clicks only; programmatic `openAccountTab` navigation does not fire it) | `tab` (`notes` \| `users` \| `relationships` \| `usage` \| `spend` \| `opportunities` \| `summaries` \| `support_tickets` \| `email_threads` \| `meetings` \| `event_stream`) |
-| `customer analytics account usage series toggled` | `accountBillingLogic` `toggleHiddenSeriesKey` listener (dispatched by the `AccountBillingSeriesToggle` chips) | `kind` (`usage` \| `spend`), `is_hidden` (the post-click state), `series_count` (no series label / no PII) |
-| `customer analytics account usage series bulk toggled` | `accountBillingLogic` `setAllSeriesHidden` listener (dispatched by the Select all / Clear all buttons in `AccountBillingSeriesToggle`) | `kind` (`usage` \| `spend`), `is_hidden` (`true` when hiding all, `false` when showing all), `series_count` (no series label / no PII) |
-| `customer analytics account related user clicked` | `AccountRelatedUsersExpansion.tsx` user `<Link>` `onClick` | _(none — customer end-user PII kept out)_ |
-| `customer analytics account related user admin opened` | `AccountRelatedUsersExpansion.tsx` staff-only "Impersonate" button | `region` (`US` \| `EU`; user ID kept out) |
-| `customer analytics account opportunity clicked` | `AccountOpportunitiesExpansion.tsx` opportunity name `<Link>` `onClick` | _(none — CRM record id/url kept out)_ |
-| `customer analytics account summary cadence changed` | `accountSummariesLogic` `setCadence` listener (after the PATCH succeeds) | `cadence` (`daily` \| `weekly` \| `monthly` \| `off`) |
-| `customer analytics account summary expanded` | `accountSummariesLogic` `toggleSummaryExpanded` listener (only when the toggle opens a summary, not on collapse) | _(none — summary content/period is customer data and kept out)_ |
-| `customer analytics account summaries page changed` | `accountSummariesLogic` `loadSummariesPage` listener (only dispatched by the pagination controls) | `page` |
-| `customer analytics account support ticket clicked` | `AccountSupportTicketsExpansion.tsx` ticket `<Link>` `onClick` | _(none — ticket number/customer content kept out)_ |
-| `customer analytics account meeting matching saved` | `accountMeetingsLogic` `saveMatching` listener (after the PATCH succeeds) | `domain_count`, `email_count` (no raw domains/emails — customer PII kept out) |
-| `customer analytics account meetings searched` | `accountMeetingsLogic` `setSearchTerm` listener (post-debounce) | `has_query`, `query_length` (no raw text) |
-| `customer analytics account meeting attendee clicked` | `AccountMeetingsExpansion.tsx` attendee `<Link>` `onClick` (person links only) | _(none — attendee email/person id is customer PII and kept out)_ |
-| `customer analytics account gong call opened` | `AccountMeetingsExpansion.tsx` "Open in Gong" button | _(none; meeting and Gong identifiers stay out)_ |
-| `customer analytics account event stream toggled` | `eventStreamLogic` (`../EventStream/`) `setAccountMembership` listener — the "Include in event stream" toggle in the expanded row's Event stream tab | `account_id`, `included`, `member_count` |
-| `customer analytics event stream config saved` | `eventStreamLogic` `saveEventStreamSuccess` listener — the Save button in the Event stream settings section | `enabled`, `event_count`, `has_slack_channel`, `member_count` |
-| `customer analytics event stream test message sent` | `eventStreamLogic` `sendTestMessageSuccess` listener — the "Send test message" button in the Event stream settings section | `event_count`, `member_count` |
-| `customer analytics notes tab viewed` | `accountNotesLogic` (`../AccountNotes/`) `afterMount` — the top-level Notes tab, not the per-account expansion | _(none — funnel anchor)_ |
-| `customer analytics notes tab searched` | `accountNotesLogic` `setSearch` listener (post-debounce) | `has_query`, `query_length` (no raw text) |
-| `customer analytics notes tab filtered` | `accountNotesLogic` `reportFilterChange` listener (dispatched by the filter controls only, so the "My notes"/"My accounts" cascade doesn't double-fire) | `filter_type` (`created_by` \| `account` \| `my_notes` \| `my_accounts`), `is_cleared`; for `created_by` also `user_count`; for `my_notes`/`my_accounts` also `value` (no account id/name logged) |
-| `customer analytics notes tab note clicked` | `AccountNotesTabContent.tsx` note title `<Link>` `onClick` (opens side panel) | `notebook_short_id` |
-| `customer analytics notes tab account clicked` | `AccountNotesTabContent.tsx` account `<Link>` `onClick` | `account_id` |
+| Event | Fires from | Properties |
+| -------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| `customer analytics accounts list viewed` | `accountsLogic` `afterMount` | _(none — funnel anchor; account count and saved-config aren't loaded at mount)_ |
+| `customer analytics accounts filter changed` | `accountsLogic` `reportFilterChange` listener (dispatched by the filter controls) | `filter_type` (`tag` \| `assignment_status` \| `my_accounts` \| `assigned_to` \| `custom_property`), `value`, `is_cleared`, `active_filter_count`; for `tag` also `tag_count`; for `assignment_status` `value` is the status (`all` \| `assigned` \| `unassigned`) and `is_cleared` is `value === 'all'`; for `assigned_to` also `role_count`; for `custom_property` only `filter_count` + `is_cleared` (no `value` — property values can carry customer data) |
+| `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 column resized` | `accountsViewsLogic` `reportColumnResize` after a header drag | _(none — column names can contain customer property names)_ |
+| `customer analytics accounts account opened` | `AccountsTableNameCell.tsx` account-name `<Link>` `onClick` (only when the row expands in the legacy experience) | _(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 |
+| `customer analytics accounts view saved` | `accountsViewsLogic` `submitNewViewForm` listener (success) | `visibility` (`private` \| `shared`) |
+| `customer analytics accounts view updated` | `accountsViewsLogic` `updateViewSuccess` listener | _(none)_ |
+| `customer analytics accounts view selected` | `accountsViewsLogic` `applyView` listener | `visibility` |
+| `customer analytics accounts view deleted` | `accountsViewsLogic` `deleteViewSuccess` listener | _(none)_ |
+| `customer analytics account role assigned` | `accountsLogic` `updateAccountRole` | `role` (`csm` \| `account_executive` \| `account_owner` for the seeded definitions, else the definition name), `is_assigned`, `assigned_user_id`, `source` (`list_row` from `accountsLogic.updateAccountRole` \| `relationships_tab` from `accountRelationshipsLogic` assign/end) |
+| `customer analytics accounts relationship deleted` | `accountRelationshipsLogic` `deleteRelationship` listener (after the DELETE succeeds) | _(none - count only; relationship and account identifiers stay out)_ |
+| `customer analytics account tags updated` | `accountsLogic` `updateAccountTags` listener (after the debounced PATCH succeeds; dispatched by the tags cell editor) | `tag_count` (tag names kept out — they can name customers) |
+| `customer analytics account custom property updated` | `accountsLogic` `updateAccountCustomProperty` listener (after the custom-property-values write succeeds) | `display_type`, `workflow_reference` (property name and value stay out because they can contain customer data) |
+| `customer analytics account link clicked` | `AccountNotebooksExpansion.tsx` useful-link `onClick` (incl. the "Copy link to account" row, `link_key: 'copy-account-link'`) | `link_key`, `has_destination` |
+| `customer analytics account note clicked` | `AccountNotebooksExpansion.tsx` note `<Link>` `onClick` | `notebook_short_id` |
+| `customer analytics accounts note created` | `accountNotebooksLogic` `createNoteSuccess` listener | `notebook_short_id` |
+| `customer analytics accounts notes searched` | `accountNotebooksLogic` `setSearchTerm` listener (post-debounce) | `has_query`, `query_length` (no raw text) |
+| `customer analytics accounts notes sorted` | `accountNotebooksLogic` `setSorting` listener | `column` (`created_at` \| `created_by` \| null), `direction` (`asc` \| `desc` \| `cleared`) |
+| `customer analytics account tab viewed` | `accountsExpansionLogic` `setActiveTab` listener (genuine tab clicks only; programmatic `openAccountTab` navigation does not fire it) | `tab` (`notes` \| `users` \| `relationships` \| `usage` \| `spend` \| `opportunities` \| `summaries` \| `support_tickets` \| `email_threads` \| `meetings` \| `event_stream`) |
+| `customer analytics account usage series toggled` | `accountBillingLogic` `toggleHiddenSeriesKey` listener (dispatched by the `AccountBillingSeriesToggle` chips) | `kind` (`usage` \| `spend`), `is_hidden` (the post-click state), `series_count` (no series label / no PII) |
+| `customer analytics account usage series bulk toggled` | `accountBillingLogic` `setAllSeriesHidden` listener (dispatched by the Select all / Clear all buttons in `AccountBillingSeriesToggle`) | `kind` (`usage` \| `spend`), `is_hidden` (`true` when hiding all, `false` when showing all), `series_count` (no series label / no PII) |
+| `customer analytics account related user clicked` | `AccountRelatedUsersExpansion.tsx` user `<Link>` `onClick` | _(none — customer end-user PII kept out)_ |
+| `customer analytics account related user admin opened` | `AccountRelatedUsersExpansion.tsx` staff-only "Impersonate" button | `region` (`US` \| `EU`; user ID kept out) |
+| `customer analytics account opportunity clicked` | `AccountOpportunitiesExpansion.tsx` opportunity name `<Link>` `onClick` | _(none — CRM record id/url kept out)_ |
+| `customer analytics account summary cadence changed` | `accountSummariesLogic` `setCadence` listener (after the PATCH succeeds) | `cadence` (`daily` \| `weekly` \| `monthly` \| `off`) |
+| `customer analytics account summary expanded` | `accountSummariesLogic` `toggleSummaryExpanded` listener (only when the toggle opens a summary, not on collapse) | _(none — summary content/period is customer data and kept out)_ |
+| `customer analytics account summaries page changed` | `accountSummariesLogic` `loadSummariesPage` listener (only dispatched by the pagination controls) | `page` |
+| `customer analytics account support ticket clicked` | `AccountSupportTicketsExpansion.tsx` ticket `<Link>` `onClick` | _(none — ticket number/customer content kept out)_ |
+| `customer analytics account meeting matching saved` | `accountMeetingsLogic` `saveMatching` listener (after the PATCH succeeds) | `domain_count`, `email_count` (no raw domains/emails — customer PII kept out) |
+| `customer analytics account meetings searched` | `accountMeetingsLogic` `setSearchTerm` listener (post-debounce) | `has_query`, `query_length` (no raw text) |
+| `customer analytics account meeting attendee clicked` | `AccountMeetingsExpansion.tsx` attendee `<Link>` `onClick` (person links only) | _(none — attendee email/person id is customer PII and kept out)_ |
+| `customer analytics account gong call opened` | `AccountMeetingsExpansion.tsx` "Open in Gong" button | _(none; meeting and Gong identifiers stay out)_ |
+| `customer analytics account event stream toggled` | `eventStreamLogic` (`../EventStream/`) `setAccountMembership` listener — the "Include in event stream" toggle in the expanded row's Event stream tab | `account_id`, `included`, `member_count` |
+| `customer analytics event stream config saved` | `eventStreamLogic` `saveEventStreamSuccess` listener — the Save button in the Event stream settings section | `enabled`, `event_count`, `has_slack_channel`, `member_count` |
+| `customer analytics event stream test message sent` | `eventStreamLogic` `sendTestMessageSuccess` listener — the "Send test message" button in the Event stream settings section | `event_count`, `member_count` |
+| `customer analytics notes tab viewed` | `accountNotesLogic` (`../AccountNotes/`) `afterMount` — the top-level Notes tab, not the per-account expansion | _(none — funnel anchor)_ |
+| `customer analytics notes tab searched` | `accountNotesLogic` `setSearch` listener (post-debounce) | `has_query`, `query_length` (no raw text) |
+| `customer analytics notes tab filtered` | `accountNotesLogic` `reportFilterChange` listener (dispatched by the filter controls only, so the "My notes"/"My accounts" cascade doesn't double-fire) | `filter_type` (`created_by` \| `account` \| `my_notes` \| `my_accounts`), `is_cleared`; for `created_by` also `user_count`; for `my_notes`/`my_accounts` also `value` (no account id/name logged) |
+| `customer analytics notes tab note clicked` | `AccountNotesTabContent.tsx` note title `<Link>` `onClick` (opens side panel) | `notebook_short_id` |
+| `customer analytics notes tab account clicked` | `AccountNotesTabContent.tsx` account `<Link>` `onClick` | `account_id` |
> **Keep this table up to date.** Whenever you add, rename, or remove a `posthog.capture()` event in the Accounts area — or change its properties — update this table in the same change. An agent reading this file should be able to trust it as the source of truth for what the Accounts list reports.
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsx
index 32cc214f422e..b01b19e7bae8 100644
--- a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsx
+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsx
@@ -114,7 +114,31 @@ describe('AccountsTabFilters', () => {
it('renders the "Assigned to" picker with its default label', () => {
renderFilters()
- expect(screen.getByText('Assigned to anyone')).toBeInTheDocument()
+ // Default shows every account regardless of assignment.
+ expect(screen.getByText('All accounts')).toBeInTheDocument()
+ })
+
+ it('the assignment dropdown offers the three mutually exclusive statuses', () => {
+ renderFilters()
+
+ fireEvent.click(screen.getByText('All accounts'))
+
+ const labels = ['Unassigned only', 'Assigned to anyone', 'All assignment statuses']
+ for (const label of labels) {
+ expect(screen.getByText(label)).toBeInTheDocument()
+ }
+ })
+
+ it.each([
+ ['Unassigned only', 'unassigned'],
+ ['Assigned to anyone', 'assigned'],
+ ])('selecting "%s" sets the canonical assignment status', (label, status) => {
+ renderFilters()
+
+ fireEvent.click(screen.getByText('All accounts'))
+ fireEvent.click(screen.getByText(label))
+
+ expect(logic.values.assignmentStatus).toBe(status)
})
// Regression: the picker must summarize a URL-restored filter from the id count
@@ -125,14 +149,14 @@ describe('AccountsTabFilters', () => {
renderFilters()
expect(screen.getByText('Assigned to 2 people')).toBeInTheDocument()
- expect(screen.queryByText('Assigned to anyone')).not.toBeInTheDocument()
+ expect(screen.queryByText('All accounts')).not.toBeInTheDocument()
})
- it('labels the assigned-to picker "Unassigned" when unassigned-only is active', () => {
- logic.actions.setAllRolesUnassigned(true)
+ it('labels the assigned-to picker "Unassigned only" when that status is active', () => {
+ logic.actions.setAssignmentStatus('unassigned')
renderFilters()
- expect(screen.getByText('Unassigned')).toBeInTheDocument()
- expect(screen.queryByText('Assigned to anyone')).not.toBeInTheDocument()
+ expect(screen.getByText('Unassigned only')).toBeInTheDocument()
+ expect(screen.queryByText('All accounts')).not.toBeInTheDocument()
})
})
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx
index 3fae26e150a2..80c2a4fd4ebf 100644
--- a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx
+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx
@@ -21,7 +21,7 @@ import type { AnyPropertyFilter } from '~/types'
import { AccountRelationshipOperatorValueSelect } from './AccountRelationshipOperatorValueSelect'
import { accountsColumnConfigLogic } from './accountsColumnConfigLogic'
import { AccountsColumnConfigurator } from './AccountsColumnConfigurator'
-import { accountsLogic, RoleFilterValue } from './accountsLogic'
+import { accountsLogic, AssignmentStatus, RoleFilterValue } from './accountsLogic'
import { AccountsOverviewTilesButton } from './AccountsOverviewTilesButton'
import {
ACCOUNT_FIELD_TAXONOMIC_OPTIONS,
@@ -33,13 +33,13 @@ import {
import { AccountsViewSelector } from './AccountsViewSelector'
export function AccountsTabFilters(): JSX.Element {
- const { searchInput, tagsFilter, allRolesUnassigned, assignedToCurrentUser, assignedToFilter, accountFilters } =
+ const { searchInput, tagsFilter, assignmentStatus, assignedToCurrentUser, assignedToFilter, accountFilters } =
useValues(accountsLogic)
const { responseLoading: accountsLoading } = useValues(dataNodeLogic)
const {
setSearchInput,
setTagsFilter,
- setAllRolesUnassigned,
+ setAssignmentStatus,
setAssignedToCurrentUser,
setAssignedToFilter,
updateAccountFilters,
@@ -123,10 +123,10 @@ export function AccountsTabFilters(): JSX.Element {
setAssignedToFilter(value)
reportFilterChange('assigned_to')
}}
- unassignedOnly={allRolesUnassigned}
- onUnassignedOnlyChange={(value) => {
- setAllRolesUnassigned(value)
- reportFilterChange('unassigned_only')
+ status={assignmentStatus}
+ onStatusChange={(status) => {
+ setAssignmentStatus(status)
+ reportFilterChange('assignment_status')
}}
/>
@@ -179,22 +179,26 @@ export function AccountsTabFilters(): JSX.Element {
function AssignedToPicker({
value,
onChange,
- unassignedOnly,
- onUnassignedOnlyChange,
+ status,
+ onStatusChange,
}: {
value: RoleFilterValue
onChange: (value: RoleFilterValue) => void
- unassignedOnly: boolean
- onUnassignedOnlyChange: (value: boolean) => void
+ status: AssignmentStatus
+ onStatusChange: (status: AssignmentStatus) => void
}): JSX.Element {
- const buttonLabel = unassignedOnly
- ? 'Unassigned'
- : value.length === 0
- ? 'Assigned to anyone'
- : value.length === 1
- ? 'Assigned to 1 person'
- : `Assigned to ${value.length} people`
- const hasFilter = unassignedOnly || value.length > 0
+ const buttonLabel =
+ status === 'unassigned'
+ ? 'Unassigned only'
+ : status === 'all'
+ ? 'All accounts'
+ : value.length === 0
+ ? 'Assigned to anyone'
+ : value.length === 1
+ ? 'Assigned to 1 person'
+ : `Assigned to ${value.length} people`
+ // `all` is the default, so anything else is an active choice worth a clear button.
+ const hasFilter = status !== 'all'
return (
<div className="flex gap-1 items-center" data-attr="accounts-assigned-to-filter">
<LemonDropdown
@@ -202,11 +206,23 @@ function AssignedToPicker({
overlay={
<div className="p-2 min-w-64 flex flex-col gap-2">
<LemonCheckbox
- checked={unassignedOnly}
- onChange={onUnassignedOnlyChange}
+ checked={status === 'unassigned'}
+ onChange={(checked) => checked && onStatusChange('unassigned')}
label="Unassigned only"
data-attr="accounts-unassigned-filter"
/>
+ <LemonCheckbox
+ checked={status === 'assigned'}
+ onChange={(checked) => checked && onStatusChange('assigned')}
+ label="Assigned to anyone"
+ data-attr="accounts-assigned-filter"
+ />
+ <LemonCheckbox
+ checked={status === 'all'}
+ onChange={(checked) => checked && onStatusChange('all')}
+ label="All assignment statuses"
+ data-attr="accounts-all-assignment-filter"
+ />
<LemonDivider className="my-0" />
<MemberSelectMultiple
idKey="id"
@@ -225,15 +241,8 @@ function AssignedToPicker({
type="secondary"
size="small"
icon={<IconX />}
- onClick={() => {
- if (unassignedOnly) {
- onUnassignedOnlyChange(false)
- }
- if (value.length > 0) {
- onChange([])
- }
- }}
- tooltip="Clear assigned-to filter"
+ onClick={() => onStatusChange('all')}
+ tooltip="Clear assignment filter"
/>
)}
</div>
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts
index 42c1f6d4df4d..55646c7890ab 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts
@@ -187,10 +187,15 @@ describe('accountsLogic', () => {
it('starts with empty filters', () => {
expect(logic.values.searchQuery).toBe('')
expect(logic.values.tagsFilter).toEqual([])
- expect(logic.values.allRolesUnassigned).toBe(false)
+ expect(logic.values.assignmentStatus).toBe('all')
expect(logic.values.assignedToFilter).toEqual([])
})
+ it('defaults to showing all accounts, omitting the assignment filter', () => {
+ const filters = logic.values.accountsQuerySource?.filters ?? []
+ expect(filters.some((filter) => filter.kind === 'assigned' || filter.kind === 'unassigned')).toBe(false)
+ })
+
it('runs the list and overview through typed Postgres queries', () => {
const source = logic.values.accountsQuerySource as AccountsTableQuery
expect(source.kind).toBe('AccountsTableQuery')
@@ -356,9 +361,22 @@ describe('accountsLogic', () => {
expect(logic.values.metricsQuery?.columns).toEqual([])
})
- it('setAllRolesUnassigned toggles the flag', () => {
- logic.actions.setAllRolesUnassigned(true)
- expect(logic.values.allRolesUnassigned).toBe(true)
+ it('setAssignmentStatus drives the canonical status and its query filter', () => {
+ logic.actions.setAssignmentStatus('unassigned')
+ expect(logic.values.assignmentStatus).toBe('unassigned')
+ expect(logic.values.accountsQuerySource?.filters).toContainEqual({ kind: 'unassigned' })
+
+ logic.actions.setAssignmentStatus('assigned')
+ expect(logic.values.assignmentStatus).toBe('assigned')
+ expect(logic.values.accountsQuerySource?.filters).toContainEqual({ kind: 'assigned' })
+
+ logic.actions.setAssignmentStatus('all')
+ expect(logic.values.assignmentStatus).toBe('all')
+ expect(
+ (logic.values.accountsQuerySource?.filters ?? []).some(
+ (filter) => filter.kind === 'assigned' || filter.kind === 'unassigned'
+ )
+ ).toBe(false)
})
describe('assignedTo filter and "my accounts" shortcut', () => {
@@ -409,21 +427,21 @@ describe('accountsLogic', () => {
expect(logic.values.activeFilterCount).toBe(1)
})
- it('enabling it clears the unassigned flag', async () => {
- logic.actions.setAllRolesUnassigned(true)
+ it('selecting users forces the assigned status', async () => {
+ logic.actions.setAssignmentStatus('unassigned')
logic.actions.setAssignedToFilter([7])
await expectLogic(logic).toFinishAllListeners()
expect(logic.values.assignedToFilter).toEqual([7])
- expect(logic.values.allRolesUnassigned).toBe(false)
+ expect(logic.values.assignmentStatus).toBe('assigned')
})
- it('enabling the unassigned flag clears the assigned-to filter', async () => {
+ it('leaving the assigned status clears the assigned-to filter', async () => {
logic.actions.setAssignedToFilter([7])
- logic.actions.setAllRolesUnassigned(true)
+ logic.actions.setAssignmentStatus('unassigned')
await expectLogic(logic).toFinishAllListeners()
- expect(logic.values.allRolesUnassigned).toBe(true)
+ expect(logic.values.assignmentStatus).toBe('unassigned')
expect(logic.values.assignedToFilter).toEqual([])
})
@@ -431,7 +449,10 @@ describe('accountsLogic', () => {
await expectLogic(logic, () => {
logic.actions.setAssignedToCurrentUser(true)
}).toFinishAllListeners()
- expect(router.values.hashParams.view).toEqual({ assignedTo: [CURRENT_USER_ID] })
+ expect(router.values.hashParams.view).toEqual({
+ assignmentStatus: 'assigned',
+ assignedTo: [CURRENT_USER_ID],
+ })
})
it('restores the assigned-to filter from the view hash, independent of the viewer', async () => {
@@ -632,12 +653,32 @@ describe('accountsLogic', () => {
expect(router.values.hashParams.view).toEqual({
search: 'acme',
tags: ['enterprise'],
+ assignmentStatus: 'assigned',
assignedTo: [7],
sort: { column: 'name', direction: 'desc' },
tileFilter: TILE_FILTER,
})
})
+ it('marks an explicit status in the hash while other filters are present', async () => {
+ await expectLogic(logic, () => {
+ logic.actions.setTagsFilter(['enterprise'])
+ logic.actions.setAssignmentStatus('all')
+ }).toFinishAllListeners()
+
+ // A legacy hash with no status field restores as assigned-only, so a non-default
+ // hash must carry `all` explicitly rather than being mistaken for legacy.
+ expect(router.values.hashParams.view).toEqual({ tags: ['enterprise'], assignmentStatus: 'all' })
+ })
+
+ it('reads a legacy hash without a status field as assigned-only', async () => {
+ router.actions.push(urls.customerAnalyticsAccounts(), {}, { view: { tags: ['enterprise'] } })
+ await expectLogic(logic).toFinishAllListeners()
+
+ expect(logic.values.assignmentStatus).toBe('assigned')
+ expect(logic.values.accountsQuerySource?.filters).toContainEqual({ kind: 'assigned' })
+ })
+
it('keeps the hash empty for the default view', async () => {
await expectLogic(logic, () => {
logic.actions.setTagsFilter(['enterprise'])
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts
index 5ea628b40b14..0a298e06d4a1 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts
@@ -63,7 +63,7 @@ import {
isAccountsTableRow,
supportedAccountFilters,
} from './accountsTableQuery'
-import { normalizeRoleFilter } from './accountsViewState'
+import { type AssignmentStatus, isAssignmentStatus, normalizeRoleFilter } from './accountsViewState'
import { AccountsEvents } from './constants'
export const SEARCH_DEBOUNCE_MS = 300
@@ -101,7 +101,9 @@ function clearSortIfColumnRemoved(values: SortLikeValues, actions: SortLikeActio
export type RoleFilterValue = number[]
-export type AccountFilterType = 'tag' | 'unassigned_only' | 'my_accounts' | 'assigned_to'
+export type { AssignmentStatus }
+
+export type AccountFilterType = 'tag' | 'assignment_status' | 'my_accounts' | 'assigned_to'
// `column` matches the visible column name (alias-stripped) so any selected
// column can drive the sort.
@@ -133,6 +135,10 @@ function accountsPathToWriteBackTo(accountIdFilter: string | null): string {
export interface AccountsViewUrlState {
search?: string
tags?: string[]
+ /** The canonical assignment status. Absent on legacy links, which resolve to
+ * assigned-only so they never silently broaden. */
+ assignmentStatus?: AssignmentStatus
+ /** @deprecated Legacy unassigned-only flag; still read for old shared links. Never written. */
unassigned?: boolean
/** Concrete user ids for the "Assigned to" / "My accounts" filter — explicit
* (not viewer-relative) so a shared link resolves identically for everyone. */
@@ -172,9 +178,9 @@ export interface accountsLogicValues {
accountsTableQueryPlan: AccountsTableQueryPlan
accountsTableQueryPlanInput: BuildAccountsTableQueryPlanInput
activeFilterCount: number
- allRolesUnassigned: boolean
assignedToCurrentUser: boolean
assignedToFilter: RoleFilterValue
+ assignmentStatus: AssignmentStatus
awaitingSavedView: boolean
canSortClientSide: boolean
currentUserId: number | null
@@ -395,15 +401,15 @@ export interface accountsLogicActions {
setAccountIdFilter: (accountId: string | null) => {
accountId: string | null
}
- setAllRolesUnassigned: (value: boolean) => {
- value: boolean
- }
setAssignedToCurrentUser: (value: boolean) => {
value: boolean
}
setAssignedToFilter: (value: RoleFilterValue) => {
value: RoleFilterValue
}
+ setAssignmentStatus: (status: AssignmentStatus) => {
+ status: AssignmentStatus
+ }
setAwaitingSavedView: (awaiting: boolean) => {
awaiting: boolean
}
@@ -496,14 +502,13 @@ export interface accountsLogicMeta {
activeFilterCount: (
searchQuery: string,
tagsFilter: string[],
- allRolesUnassigned: boolean,
- assignedToFilter: RoleFilterValue,
+ assignmentStatus: AssignmentStatus,
accountFilters: AccountFilter[]
) => number
viewUrlState: (
searchQuery: string,
tagsFilter: string[],
- allRolesUnassigned: boolean,
+ assignmentStatus: AssignmentStatus,
assignedToFilter: RoleFilterValue,
sortOrder: AccountSortOrder,
selectColumns: string[],
@@ -523,7 +528,7 @@ export interface accountsLogicMeta {
visibleColumnNames: string[],
searchQuery: string,
tagsFilter: string[],
- allRolesUnassigned: boolean,
+ assignmentStatus: AssignmentStatus,
assignedToFilter: RoleFilterValue,
accountIdFilter: string | null,
tileFilter: TileFilter | null,
@@ -624,7 +629,7 @@ export const accountsLogic = kea<accountsLogicType>([
setTagsFilter: (tags: string[]) => ({ tags }),
setAccountFilters: (filters: AccountFilter[]) => ({ filters }),
updateAccountFilters: (filters: AccountFilter[]) => ({ filters }),
- setAllRolesUnassigned: (value: boolean) => ({ value }),
+ setAssignmentStatus: (status: AssignmentStatus) => ({ status }),
setAssignedToFilter: (value: RoleFilterValue) => ({ value }),
// Shortcut for the "My accounts" checkbox — resolves to the current
// user's id and routes through setAssignedToFilter.
@@ -705,10 +710,10 @@ export const accountsLogic = kea<accountsLogicType>([
setAccountFilters: (_, { filters }) => filters,
},
],
- allRolesUnassigned: [
- false,
+ assignmentStatus: [
+ 'all' as AssignmentStatus,
{
- setAllRolesUnassigned: (_, { value }) => value,
+ setAssignmentStatus: (_, { status }) => status,
},
],
assignedToFilter: [
@@ -859,19 +864,19 @@ export const accountsLogic = kea<accountsLogicType>([
!!savingTags[accountId],
],
activeFilterCount: [
- (s) => [s.searchQuery, s.tagsFilter, s.allRolesUnassigned, s.assignedToFilter, s.accountFilters],
+ (s) => [s.searchQuery, s.tagsFilter, s.assignmentStatus, s.accountFilters],
(
searchQuery: string,
tagsFilter: string[],
- allRolesUnassigned: boolean,
- assignedToFilter: RoleFilterValue,
+ assignmentStatus: AssignmentStatus,
accountFilters: AccountFilter[]
): number =>
[
!!searchQuery.trim(),
tagsFilter.length > 0,
- allRolesUnassigned,
- assignedToFilter.length > 0,
+ // `all` is the default, so any other status (including assigned-to
+ // narrowing, which forces `assigned`) is one active filter.
+ assignmentStatus !== 'all',
accountFilters.length > 0,
].filter(Boolean).length,
],
@@ -879,7 +884,7 @@ export const accountsLogic = kea<accountsLogicType>([
(s) => [
s.searchQuery,
s.tagsFilter,
- s.allRolesUnassigned,
+ s.assignmentStatus,
s.assignedToFilter,
s.sortOrder,
s.selectColumns,
@@ -891,7 +896,7 @@ export const accountsLogic = kea<accountsLogicType>([
(
searchQuery: string,
tagsFilter: string[],
- allRolesUnassigned: boolean,
+ assignmentStatus: AssignmentStatus,
assignedToFilter: RoleFilterValue,
sortOrder: AccountSortOrder,
selectColumns: string[],
@@ -908,11 +913,13 @@ export const accountsLogic = kea<accountsLogicType>([
if (tagsFilter.length > 0) {
state.tags = tagsFilter
}
- if (allRolesUnassigned) {
- state.unassigned = true
- }
- if (assignedToFilter.length > 0) {
- state.assignedTo = assignedToFilter
+ if (assignmentStatus === 'unassigned') {
+ state.assignmentStatus = 'unassigned'
+ } else if (assignmentStatus === 'assigned') {
+ state.assignmentStatus = 'assigned'
+ if (assignedToFilter.length > 0) {
+ state.assignedTo = assignedToFilter
+ }
}
if (sortOrder) {
state.sort = sortOrder
@@ -929,6 +936,12 @@ export const accountsLogic = kea<accountsLogicType>([
if (accountFilters.length > 0) {
state.customProperties = accountFilters
}
+ // The default `all` status is omitted so a pure-default view keeps an empty
+ // hash. But a legacy hash without the field reads as assigned-only, so once
+ // any other filter is present we mark `all` explicitly to avoid that mislabel.
+ if (assignmentStatus === 'all' && Object.keys(state).length > 0) {
+ state.assignmentStatus = 'all'
+ }
return state
},
],
@@ -956,7 +969,7 @@ export const accountsLogic = kea<accountsLogicType>([
s.visibleColumnNames,
s.searchQuery,
s.tagsFilter,
- s.allRolesUnassigned,
+ s.assignmentStatus,
s.assignedToFilter,
s.accountIdFilter,
s.tileFilter,
@@ -972,7 +985,7 @@ export const accountsLogic = kea<accountsLogicType>([
visibleColumnNames: string[],
searchQuery: string,
tagsFilter: string[],
- allRolesUnassigned: boolean,
+ assignmentStatus: AssignmentStatus,
assignedToFilter: RoleFilterValue,
accountIdFilter: string | null,
tileFilter: TileFilter | null,
@@ -987,7 +1000,7 @@ export const accountsLogic = kea<accountsLogicType>([
visibleColumnNames,
searchQuery,
tagsFilter,
- allRolesUnassigned,
+ assignmentStatus,
assignedToFilter,
accountIdFilter,
tileFilter,
@@ -1158,9 +1171,9 @@ export const accountsLogic = kea<accountsLogicType>([
properties.tag_count = values.tagsFilter.length
properties.is_cleared = values.tagsFilter.length === 0
break
- case 'unassigned_only':
- properties.value = values.allRolesUnassigned
- properties.is_cleared = !values.allRolesUnassigned
+ case 'assignment_status':
+ properties.value = values.assignmentStatus
+ properties.is_cleared = values.assignmentStatus === 'all'
break
case 'my_accounts':
properties.value = values.assignedToCurrentUser
@@ -1174,8 +1187,11 @@ export const accountsLogic = kea<accountsLogicType>([
}
posthog.capture(AccountsEvents.FilterChanged, properties)
},
- setAllRolesUnassigned: ({ value }) => {
- if (value && values.assignedToFilter.length > 0) {
+ // The assigned-to narrowing only applies within the assigned status, so leaving
+ // that status clears any selected users. This keeps the canonical status and the
+ // user filter from ever describing contradictory sets.
+ setAssignmentStatus: ({ status }) => {
+ if (status !== 'assigned' && values.assignedToFilter.length > 0) {
actions.setAssignedToFilter([])
}
},
@@ -1185,11 +1201,10 @@ export const accountsLogic = kea<accountsLogicType>([
setAssignedToCurrentUser: ({ value }) => {
actions.setAssignedToFilter(value && values.currentUserId !== null ? [values.currentUserId] : [])
},
- // "Assigned to" (an account's CSM or AE is one of these users) clears the
- // unassigned flag — the two are a genuine contradiction.
+ // Selecting users narrows assigned accounts, so it forces the assigned status.
setAssignedToFilter: ({ value }) => {
- if (value.length > 0 && values.allRolesUnassigned) {
- actions.setAllRolesUnassigned(false)
+ if (value.length > 0 && values.assignmentStatus !== 'assigned') {
+ actions.setAssignmentStatus('assigned')
}
// Keep the shared "mine only" toggle in step with the assigned-to filter
// (set via the "My accounts" shortcut or the assigned-to picker) so
@@ -1206,7 +1221,7 @@ export const accountsLogic = kea<accountsLogicType>([
values.mineOnly &&
values.currentUserId !== null &&
!values.assignedToFilter.length &&
- !values.allRolesUnassigned
+ values.assignmentStatus !== 'unassigned'
) {
actions.setAssignedToFilter([values.currentUserId])
}
@@ -1365,8 +1380,8 @@ export const accountsLogic = kea<accountsLogicType>([
if (values.tagsFilter.length > 0) {
actions.setTagsFilter([])
}
- if (values.allRolesUnassigned) {
- actions.setAllRolesUnassigned(false)
+ if (values.assignmentStatus !== 'all') {
+ actions.setAssignmentStatus('all')
}
if (values.assignedToFilter.length > 0) {
actions.setAssignedToFilter([])
@@ -1424,7 +1439,7 @@ export const accountsLogic = kea<accountsLogicType>([
setSearchQuery: toUrl,
setTagsFilter: toUrl,
setAccountFilters: toUrl,
- setAllRolesUnassigned: toUrl,
+ setAssignmentStatus: toUrl,
setAssignedToFilter: toUrl,
setSortOrder: toUrl,
setSelectColumns: toUrl,
@@ -1471,9 +1486,20 @@ export const accountsLogic = kea<accountsLogicType>([
actions.setAccountFilters(customProperties)
}
- const unassigned = view.unassigned ?? false
- if (unassigned !== values.allRolesUnassigned) {
- actions.setAllRolesUnassigned(unassigned)
+ // Resolve the canonical status: an explicit field wins; a legacy hash with any
+ // key but no field is assigned-only (never broadens); an empty hash is the pure
+ // default and shows all.
+ const explicitStatus = isAssignmentStatus(view.assignmentStatus) ? view.assignmentStatus : undefined
+ const hasViewKeys = Object.keys(view).length > 0
+ const nextStatus: AssignmentStatus = explicitStatus
+ ? explicitStatus
+ : hasViewKeys
+ ? view.unassigned
+ ? 'unassigned'
+ : 'assigned'
+ : 'all'
+ if (nextStatus !== values.assignmentStatus) {
+ actions.setAssignmentStatus(nextStatus)
}
const assignedTo = normalizeRoleFilter(view.assignedTo)
@@ -1481,11 +1507,16 @@ export const accountsLogic = kea<accountsLogicType>([
// resolve it to the opener's own id so old shared links still work.
const legacyMine =
!assignedTo.length && view.mine && values.currentUserId !== null ? [values.currentUserId] : []
- // With no explicit assignment in the hash (e.g. arriving via the tab
- // link), fall back to the shared "mine only" toggle so the choice made
- // on the Notes tab carries over.
+ // With no assignment intent in the hash at all (no status, no assignedTo, no
+ // mine — e.g. arriving via the tab link), fall back to the shared "mine only"
+ // toggle so the choice made on the Notes tab carries over. An explicit status
+ // always wins over that toggle.
const sharedMine =
- !assignedTo.length && !view.mine && values.mineOnly && values.currentUserId !== null
+ explicitStatus === undefined &&
+ !assignedTo.length &&
+ !view.mine &&
+ values.mineOnly &&
+ values.currentUserId !== null
? [values.currentUserId]
: []
// The persisted "my accounts" intent can't be resolved until the user id is
@@ -1493,7 +1524,11 @@ export const accountsLogic = kea<accountsLogicType>([
// writing an empty one, which would cascade to setMineOnly(false) and clobber the
// preference) and let the loadUserSuccess listener apply it once the user resolves.
const mineRestorePending =
- !assignedTo.length && !view.mine && values.mineOnly && values.currentUserId === null
+ explicitStatus === undefined &&
+ !assignedTo.length &&
+ !view.mine &&
+ values.mineOnly &&
+ values.currentUserId === null
const nextAssignedTo = assignedTo.length ? assignedTo : legacyMine.length ? legacyMine : sharedMine
if (!mineRestorePending && !objectsEqual(nextAssignedTo, values.assignedToFilter)) {
actions.setAssignedToFilter(nextAssignedTo)
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.test.ts
index 126697625c8d..def8661ab712 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.test.ts
@@ -71,7 +71,7 @@ function queryInput(overrides: Partial<BuildAccountsTableQueryPlanInput> = {}):
visibleColumnNames: ['name', 'tag_names', 'notebook_count', 'csm'],
searchQuery: '',
tagsFilter: [],
- allRolesUnassigned: false,
+ assignmentStatus: 'all',
assignedToFilter: [],
accountIdFilter: null,
tileFilter: null,
@@ -93,6 +93,7 @@ describe('accountsTableQuery', () => {
queryInput({
searchQuery: ' acme ',
tagsFilter: ['enterprise'],
+ assignmentStatus: 'assigned',
assignedToFilter: [7, 9],
accountFilters: [relationshipFilter(), customFilter()],
sortOrder: { column: 'csm', direction: 'desc' },
@@ -147,7 +148,6 @@ describe('accountsTableQuery', () => {
)
expect(plan.query.filters).toEqual([
- { kind: 'assigned' },
{
kind: 'account_field',
field: AccountsTableAccountField.IgnoredAt,
@@ -176,13 +176,29 @@ describe('accountsTableQuery', () => {
})
)
- expect(plan.query.filters).toEqual([{ kind: 'assigned' }])
+ expect(plan.query.filters).toEqual([])
})
- it('filters the default account list to accounts assigned to someone', () => {
- const plan = buildAccountsTableQueryPlan(queryInput())
+ it.each([
+ ['all', undefined],
+ ['assigned', { kind: 'assigned' }],
+ ['unassigned', { kind: 'unassigned' }],
+ ] as const)('maps the %s assignment status to its query filter', (assignmentStatus, expected) => {
+ const plan = buildAccountsTableQueryPlan(queryInput({ assignmentStatus }))
+
+ expect(plan.query.filters).toEqual(expected ? [expected] : [])
+ })
+
+ it('narrows the assigned status to specific users when any are selected', () => {
+ const plan = buildAccountsTableQueryPlan(queryInput({ assignmentStatus: 'assigned', assignedToFilter: [7] }))
+
+ expect(plan.query.filters).toEqual([{ kind: 'assigned_to', userIds: [7] }])
+ })
+
+ it('ignores selected users outside the assigned status', () => {
+ const plan = buildAccountsTableQueryPlan(queryInput({ assignmentStatus: 'all', assignedToFilter: [7] }))
- expect(plan.query.filters).toEqual([{ kind: 'assigned' }])
+ expect(plan.query.filters).toEqual([])
})
it('translates saved custom-property history display configuration', () => {
@@ -216,7 +232,7 @@ describe('accountsTableQuery', () => {
accountIdFilter: RELATIONSHIP_ID,
searchQuery: 'ignored',
tagsFilter: ['ignored'],
- allRolesUnassigned: true,
+ assignmentStatus: 'unassigned',
})
)
@@ -253,7 +269,6 @@ describe('accountsTableQuery', () => {
)
expect(plan.query.filters).toEqual([
- { kind: 'assigned' },
{
kind: 'custom_property',
definitionId: CUSTOM_PROPERTY_ID,
@@ -279,7 +294,6 @@ describe('accountsTableQuery', () => {
)
expect(plan.query.filters).toEqual([
- { kind: 'assigned' },
{
kind: 'custom_property',
definitionId: CUSTOM_PROPERTY_ID,
@@ -309,7 +323,7 @@ describe('accountsTableQuery', () => {
})
)
- expect(plan.query.filters).toEqual([{ kind: 'assigned' }])
+ expect(plan.query.filters).toEqual([])
})
it('keeps contains filters for link properties', () => {
@@ -322,7 +336,6 @@ describe('accountsTableQuery', () => {
)
expect(plan.query.filters).toEqual([
- { kind: 'assigned' },
{
kind: 'custom_property',
definitionId: CUSTOM_PROPERTY_ID,
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.ts b/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.ts
index c881d3645901..7fdd9c5410c1 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.ts
@@ -40,6 +40,7 @@ import {
isAccountPropertyFilter,
isAccountRelationshipFilter,
} from './accountsPropertyFilters'
+import type { AssignmentStatus } from './accountsViewState'
const RELATIONSHIP_COLUMN_REGEX = /^accounts\.relationships\.values\.`([0-9a-fA-F-]+)` AS [A-Za-z_][\w]*$/
const CUSTOM_PROPERTY_COLUMN_REGEX = /^accounts\.custom_properties\.values\.`([0-9a-fA-F-]+)` AS [A-Za-z_][\w]*$/
@@ -115,7 +116,7 @@ export interface BuildAccountsTableQueryPlanInput {
visibleColumnNames: string[]
searchQuery: string
tagsFilter: string[]
- allRolesUnassigned: boolean
+ assignmentStatus: AssignmentStatus
assignedToFilter: RoleFilterValue
accountIdFilter: string | null
tileFilter: TileFilter | null
@@ -305,12 +306,20 @@ function queryFilters(input: BuildAccountsTableQueryPlanInput): AccountsTableFil
if (input.tagsFilter.length > 0) {
filters.push({ kind: 'tags', tagNames: input.tagsFilter } satisfies AccountsTableTagsFilter)
}
- if (input.allRolesUnassigned) {
+ // `all` omits the assignment filter entirely so both assigned and unassigned accounts
+ // show. `assigned` narrows to assigned accounts, further restricted to specific users
+ // when any are selected.
+ if (input.assignmentStatus === 'unassigned') {
filters.push({ kind: 'unassigned' } satisfies AccountsTableUnassignedFilter)
- } else if (input.assignedToFilter.length > 0) {
- filters.push({ kind: 'assigned_to', userIds: input.assignedToFilter } satisfies AccountsTableAssignedToFilter)
- } else {
- filters.push({ kind: 'assigned' } satisfies AccountsTableAssignedFilter)
+ } else if (input.assignmentStatus === 'assigned') {
+ if (input.assignedToFilter.length > 0) {
+ filters.push({
+ kind: 'assigned_to',
+ userIds: input.assignedToFilter,
+ } satisfies AccountsTableAssignedToFilter)
+ } else {
+ filters.push({ kind: 'assigned' } satisfies AccountsTableAssignedFilter)
+ }
}
for (const filter of input.accountFilters) {
const translatedFilter = isAccountPropertyFilter(filter)
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsViewState.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsViewState.test.ts
index 6139c9cb10da..fe31754cd1e9 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsViewState.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsViewState.test.ts
@@ -56,9 +56,9 @@ describe('serializeAccountsView / deserializeAccountsView', () => {
sortOrder: { column: 'csm' as const, direction: 'desc' as const },
filters: {
search: 'acme',
- tags: ['enterprise'],
- unassigned: false,
+ assignmentStatus: 'assigned',
assignedTo: [1, 2, 3],
+ tags: ['enterprise'],
tileFilter: {
tileId: 't1',
filter: {
@@ -97,33 +97,35 @@ describe('serializeAccountsView / deserializeAccountsView', () => {
expect(deserializeAccountsView(payload)).toEqual(state)
})
- it('omits empty filters and serializes no sort', () => {
+ it('omits empty filters but always stores the assignment status', () => {
const payload = serializeAccountsView({
columns: [...ACCOUNTS_DEFAULT_COLUMNS],
sortOrder: null,
filters: {
search: '',
- tags: [],
- unassigned: false,
+ assignmentStatus: 'all',
assignedTo: [],
+ tags: [],
tileFilter: null,
customProperties: [],
},
tiles: [...DEFAULT_TILES],
columnDisplay: {},
})
- expect(payload.filters).toEqual({})
+ // The status is stored even for the `all` default so reopening the view can't be
+ // mistaken for a legacy view (no field), which restores as assigned-only.
+ expect(payload.filters).toEqual({ assignmentStatus: 'all' })
expect(payload.order_by).toEqual([])
expect(payload.properties).toEqual({ tiles: DEFAULT_TILES })
})
- it('treats a legacy columns-only row (filters [], no properties) as defaults', () => {
+ it('reads a legacy row with no assignment field as assigned-only', () => {
const state = deserializeAccountsView({ columns: ['name'], order_by: null, filters: [], properties: {} })
expect(state.filters).toEqual({
search: '',
- tags: [],
- unassigned: false,
+ assignmentStatus: 'assigned',
assignedTo: [],
+ tags: [],
tileFilter: null,
customProperties: [],
})
@@ -132,6 +134,18 @@ describe('serializeAccountsView / deserializeAccountsView', () => {
expect(state.columnDisplay).toEqual({})
})
+ it('reads a legacy unassigned-only row as the unassigned status', () => {
+ const state = deserializeAccountsView({ columns: ['name'], order_by: null, filters: { unassigned: true } })
+ expect(state.filters.assignmentStatus).toEqual('unassigned')
+ })
+
+ it('keeps an explicit stored status distinct from a legacy default', () => {
+ expect(deserializeAccountsView({ filters: { assignmentStatus: 'all' } }).filters.assignmentStatus).toEqual(
+ 'all'
+ )
+ expect(deserializeAccountsView({ filters: {} }).filters.assignmentStatus).toEqual('assigned')
+ })
+
it('falls back to default columns when a row has none', () => {
const state = deserializeAccountsView({ columns: [], order_by: [], filters: {}, properties: {} })
expect(state.columns).toEqual(ACCOUNTS_DEFAULT_COLUMNS)
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsViewState.ts b/products/customer_analytics/frontend/components/Accounts/accountsViewState.ts
index 8ca65194aac5..8f20148a4f8e 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsViewState.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsViewState.ts
@@ -6,15 +6,43 @@ import type { AccountsOverviewTile, TileFilter } from './accountsOverviewTilesLo
import type { AccountFilter } from './accountsPropertyFilters'
import { DEFAULT_TILES } from './constants'
+// The single canonical assignment filter state. `all` shows every account (assigned
+// and unassigned) and omits the assignment query filter; `assigned` narrows to accounts
+// with an active assignment (optionally to specific users); `unassigned` shows only
+// accounts with no assignment.
+export type AssignmentStatus = 'all' | 'assigned' | 'unassigned'
+
+export const ASSIGNMENT_STATUS_VALUES: readonly AssignmentStatus[] = ['all', 'assigned', 'unassigned']
+
+export function isAssignmentStatus(value: unknown): value is AssignmentStatus {
+ return typeof value === 'string' && (ASSIGNMENT_STATUS_VALUES as readonly string[]).includes(value)
+}
+
export interface AccountsViewFilters {
search: string
- tags: string[]
- unassigned: boolean
+ assignmentStatus: AssignmentStatus
assignedTo: RoleFilterValue
+ tags: string[]
tileFilter: TileFilter | null
customProperties: AccountFilter[]
}
+// A raw persisted filter object may predate `assignmentStatus` and carry only the legacy
+// `unassigned` boolean. Read both so restoring an old view can resolve a status.
+interface AccountsViewFiltersRaw extends Partial<AccountsViewFilters> {
+ /** @deprecated Legacy field, superseded by `assignmentStatus`. Read for back-compat. */
+ unassigned?: boolean
+}
+
+// A saved view or shared link created before `assignmentStatus` existed defaulted to
+// assigned-only. Resolve legacy filters to that status so they never silently broaden.
+function assignmentStatusFromRaw(raw: AccountsViewFiltersRaw): AssignmentStatus {
+ if (isAssignmentStatus(raw.assignmentStatus)) {
+ return raw.assignmentStatus
+ }
+ return raw.unassigned ? 'unassigned' : 'assigned'
+}
+
export interface AccountsViewProperties {
tiles?: AccountsOverviewTile[]
column_display?: AccountColumnDisplayState
@@ -72,10 +100,10 @@ export function serializeAccountsView(state: AccountsViewState): AccountsViewPay
if (state.filters.tags.length > 0) {
filters.tags = state.filters.tags
}
- if (state.filters.unassigned) {
- filters.unassigned = true
- }
- if (state.filters.assignedTo.length > 0) {
+ // Always store the status so a new "all" view is distinct from a legacy view with no
+ // field (which restores as assigned-only). Assigned-to only narrows the assigned status.
+ filters.assignmentStatus = state.filters.assignmentStatus
+ if (state.filters.assignmentStatus === 'assigned' && state.filters.assignedTo.length > 0) {
filters.assignedTo = state.filters.assignedTo
}
if (state.filters.tileFilter) {
@@ -98,9 +126,7 @@ export function serializeAccountsView(state: AccountsViewState): AccountsViewPay
export function deserializeAccountsView(view: Partial<ColumnConfigurationApi>): AccountsViewState {
// The backend normalizes empty filters to `[]`; treat any non-object as empty.
- const rawFilters = (
- view.filters && !Array.isArray(view.filters) ? view.filters : {}
- ) as Partial<AccountsViewFilters>
+ const rawFilters = (view.filters && !Array.isArray(view.filters) ? view.filters : {}) as AccountsViewFiltersRaw
const rawProperties = (
view.properties && typeof view.properties === 'object' ? view.properties : {}
) as AccountsViewProperties
@@ -110,9 +136,9 @@ export function deserializeAccountsView(view: Partial<ColumnConfigurationApi>):
sortOrder: orderByToSortOrder(view.order_by),
filters: {
search: rawFilters.search ?? '',
- tags: rawFilters.tags ?? [],
- unassigned: rawFilters.unassigned ?? false,
+ assignmentStatus: assignmentStatusFromRaw(rawFilters),
assignedTo: normalizeRoleFilter(rawFilters.assignedTo),
+ tags: rawFilters.tags ?? [],
tileFilter: rawFilters.tileFilter ?? null,
customProperties: Array.isArray(rawFilters.customProperties) ? rawFilters.customProperties : [],
},
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts
index 1e597fbb586f..304c20246c47 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.test.ts
@@ -115,7 +115,7 @@ describe('accountsViewsLogic', () => {
filters: {
search: 'acme',
tags: ['enterprise'],
- unassigned: false,
+ assignmentStatus: 'assigned',
assignedTo: [1, 2, 3],
tileFilter: {
tileId: 't1',
@@ -133,7 +133,7 @@ describe('accountsViewsLogic', () => {
expect(accountsColumnConfigLogic.values.selectColumns).toEqual(['name', 'csm'])
expect(accountsLogic.values.searchQuery).toEqual('acme')
expect(accountsLogic.values.tagsFilter).toEqual(['enterprise'])
- expect(accountsLogic.values.allRolesUnassigned).toBe(false)
+ expect(accountsLogic.values.assignmentStatus).toBe('assigned')
expect(accountsLogic.values.assignedToFilter).toEqual([1, 2, 3])
expect(accountsLogic.values.sortOrder).toEqual({ column: 'csm', direction: 'desc' })
expect(accountsOverviewTilesLogic.values.tiles).toEqual([
@@ -174,6 +174,19 @@ describe('accountsViewsLogic', () => {
])
})
+ it('applies a legacy saved view (no assignment field) as assigned-only', async () => {
+ useMocks({ get: { '/api/environments/:team_id/column_configurations/': { count: 0, results: [] } } })
+ mountAll()
+ // A view saved before the status field existed must not silently broaden to all.
+ await expectLogic(logic, () =>
+ logic.actions.applyView(buildView({ columns: ['name'], filters: { search: 'acme' } }))
+ ).toFinishAllListeners()
+
+ expect(accountsLogic.values.assignmentStatus).toBe('assigned')
+ const source = accountsLogic.values.accountsQuerySource as AccountsTableQuery
+ expect(source.filters).toContainEqual({ kind: 'assigned' })
+ })
+
it('keeps column widths when the selected view changes', async () => {
useMocks({ get: { '/api/environments/:team_id/column_configurations/': { count: 0, results: [] } } })
mountAll()
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.ts
index 1e41998a74d7..b25a5263cc85 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.ts
@@ -18,7 +18,7 @@ import type { UserType } from '../../../../../frontend/src/types'
import { ACCOUNTS_COLUMN_CONFIG_KEY, accountsColumnConfigLogic } from './accountsColumnConfigLogic'
import type { AccountColumnDisplayState } from './accountsColumnConfigLogic'
import { accountsLogic } from './accountsLogic'
-import type { AccountSortOrder, RoleFilterValue } from './accountsLogic'
+import type { AccountSortOrder, AssignmentStatus, RoleFilterValue } from './accountsLogic'
import { accountsOverviewTilesLogic } from './accountsOverviewTilesLogic'
import type { AccountsOverviewTile, TileFilter } from './accountsOverviewTilesLogic'
import type { AccountFilter } from './accountsPropertyFilters'
@@ -38,8 +38,8 @@ export interface accountsViewsLogicValues {
columnDisplay: AccountColumnDisplayState // accountsColumnConfigLogic
selectColumns: string[] // accountsColumnConfigLogic
accountFilters: AccountFilter[] // accountsLogic
- allRolesUnassigned: boolean // accountsLogic
assignedToFilter: RoleFilterValue // accountsLogic
+ assignmentStatus: AssignmentStatus // accountsLogic
searchQuery: string // accountsLogic
sortOrder: AccountSortOrder // accountsLogic
tagsFilter: string[] // accountsLogic
@@ -122,12 +122,12 @@ export interface accountsViewsLogicActions {
setAccountFilters: (filters: AccountFilter[]) => {
filters: AccountFilter[]
} // accountsLogic
- setAllRolesUnassigned: (value: boolean) => {
- value: boolean
- } // accountsLogic
setAssignedToFilter: (value: RoleFilterValue) => {
value: RoleFilterValue
} // accountsLogic
+ setAssignmentStatus: (status: AssignmentStatus) => {
+ status: AssignmentStatus
+ } // accountsLogic
setAwaitingSavedView: (awaiting: boolean) => {
awaiting: boolean
} // accountsLogic
@@ -366,7 +366,7 @@ export interface accountsViewsLogicMeta {
selectColumns: string[],
searchQuery: string,
tagsFilter: string[],
- allRolesUnassigned: boolean,
+ assignmentStatus: AssignmentStatus,
assignedToFilter: RoleFilterValue,
sortOrder: AccountSortOrder,
tileFilter: TileFilter | null,
@@ -398,7 +398,7 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
accountsColumnConfigLogic,
['selectColumns', 'columnDisplay'],
accountsLogic,
- ['searchQuery', 'tagsFilter', 'allRolesUnassigned', 'assignedToFilter', 'sortOrder', 'accountFilters'],
+ ['searchQuery', 'tagsFilter', 'assignmentStatus', 'assignedToFilter', 'sortOrder', 'accountFilters'],
accountsOverviewTilesLogic,
['tiles', 'tileFilter'],
],
@@ -409,7 +409,7 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
[
'setSearchQuery',
'setTagsFilter',
- 'setAllRolesUnassigned',
+ 'setAssignmentStatus',
'setAssignedToFilter',
'setSortOrder',
'setAccountFilters',
@@ -515,7 +515,7 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
s.selectColumns,
s.searchQuery,
s.tagsFilter,
- s.allRolesUnassigned,
+ s.assignmentStatus,
s.assignedToFilter,
s.sortOrder,
s.tileFilter,
@@ -527,7 +527,7 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
selectColumns: string[],
searchQuery: string,
tagsFilter: string[],
- allRolesUnassigned: boolean,
+ assignmentStatus: AssignmentStatus,
assignedToFilter: import('./accountsLogic').RoleFilterValue,
sortOrder: import('./accountsLogic').AccountSortOrder,
tileFilter: null | import('./accountsOverviewTilesLogic').TileFilter,
@@ -539,9 +539,9 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
sortOrder,
filters: {
search: searchQuery,
- tags: tagsFilter,
- unassigned: allRolesUnassigned,
+ assignmentStatus,
assignedTo: assignedToFilter,
+ tags: tagsFilter,
tileFilter,
customProperties: accountFilters,
},
@@ -615,10 +615,11 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
actions.setColumnDisplayConfig(state.columnDisplay)
actions.setSearchQuery(state.filters.search)
actions.setTagsFilter(state.filters.tags)
- // accountsLogic cross-clears the assigned-to filter vs "unassigned only", so set the
- // unassigned flag first so the assigned-to filter below isn't wiped by that cross-listener.
- actions.setAllRolesUnassigned(state.filters.unassigned)
- actions.setAssignedToFilter(state.filters.assignedTo)
+ // accountsLogic cross-clears the assigned-to filter when the status is not
+ // `assigned`, so set the status first, then restore the users (only meaningful
+ // within the assigned status) so they aren't wiped by that cross-listener.
+ actions.setAssignmentStatus(state.filters.assignmentStatus)
+ actions.setAssignedToFilter(state.filters.assignmentStatus === 'assigned' ? state.filters.assignedTo : [])
actions.setAccountFilters(state.filters.customProperties)
actions.setSortOrder(state.sortOrder)
actions.setTiles(state.tiles)