: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
refactor(customer-analytics): Remove redundant account role filters (#63801)
Arthur Moreira de Deus3e2a6b715ee8
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex e1cf10276163..526fca1d882f 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -4475,13 +4475,13 @@ snapshots:scenes-app-batchexports--runs-with-data--light:hash: v1.k794b7964.144b41b97a76df864203804f6bf0b956998d6f0e6e4d81c4102c52dadce11813.DeXap8kCLxs-8UrwnfoTk5PIbkan4hrzxPCfyN_htMEscenes-app-customer-analytics-accounts--default--dark:- hash: v1.k794b7964.2d4fb8c374e2995fe8dcd196a365881710b6af22a0b9c2c70710b3cc1bed8eb2.96Xx2DJB6NG4b9N0J-fEsBLxgbYI2TWTdlo4CwZPEVg+ hash: v1.k794b7964.8dee1c5495b4bf2b8946bf107f6fcad200632a9905ade27510486535a737a959.oMs-LHry1y5jQeEQPYtZ9NuBX57GjqdVYQo9MDJnVPoscenes-app-customer-analytics-accounts--default--light:- hash: v1.k794b7964.d78be4615c5ddafa7376704b215ebefd4d58a8e1b24603347212f3c14f4e06ba.K4frA5u_W62G7d511pwXgXiPgcS6Ja45IXbHv8lMOT4+ hash: v1.k794b7964.d3d5aff5a454a0d12d1caf042138b4fec9bccc22eb0864cf8ea02fe731ec9b11.a1mKciSBMLACivrzuv10n85UzU5tL9ddUx-I9jQs3h8scenes-app-customer-analytics-accounts--empty--dark:- hash: v1.k794b7964.1664f952be582a86b8afb9cc695dd4d332b18aedbd963f91e23e01490140f771.FISvQ9Ymsjkt3xJ1CpAmESHzEmt4t3iVBe5luBKyNGU+ hash: v1.k794b7964.fd876018908374ed70f6b33223582ba628934a217720b10ac1c9bd964442d7d3.hI1w37iscAvSQJPoZcvZKabIbk13bp4ausw1azme4EIscenes-app-customer-analytics-accounts--empty--light:- hash: v1.k794b7964.ce312c4142788e7fb8516bf31d360eab0d5df20b603d9ee855b4fcff0b27fee3.e8nTVdSI2d5Wu7W0giB9bYN47DCFgYGLyxq_9leuNLw+ hash: v1.k794b7964.1384b7f44d0a9ed38859992a8d91bdbaf3d02da24fed766b2c359d41c6e1bc88.0IxTKv58B9NMAIM__pVqQaHW_UbWBbJLH4oRGNpccrgscenes-app-customer-analytics-accounts--feature-gate-off--dark:hash: v1.k794b7964.7750bce37ad591ab773135ad1a9b8738ac790727774c03d3aa7b5abbfc42fab0.KbXf74dR5pSVh6Wc8mSjrNGqL8LbTcsMl78W7WVvTXUscenes-app-customer-analytics-accounts--feature-gate-off--light:@@ -4491,17 +4491,17 @@ snapshots:scenes-app-customer-analytics-accounts--row-expanded-empty--light:hash: v1.k794b7964.904bd5b939f99d43408ae3a8a814a3c299bd57bf13a0fd1d98ff6033fd66e343.K1Z16ICEF6-O9kIej8kGnYyarloq2oZH5rdtmx-8Hu0scenes-app-customer-analytics-accounts--row-expanded-links-disabled--dark:- hash: v1.k794b7964.9b18ad0a8cbe107cc03f82a4fd248ad31b951987a64f347aaf9a5e4ff4263f44.XB-umE74AEB4_9bUMCOhcvMXwShZL5OtLy1dwgec9bc+ hash: v1.k794b7964.0d01e116e4a6c7f48c2463d03e458a537de5b7ed170bcd6eaa53132e5401b003.SXbtak_1nqvrKhJF0zbIF4qEW9NFrjrd6VcoQphZ2Z0scenes-app-customer-analytics-accounts--row-expanded-links-disabled--light:- hash: v1.k794b7964.182d3d5e83e0eadd483d7294e94a990895edd7dbdd467e4180f1520dfcb3290c.LoRDMlmPuUagvXvOr4stvShG9-5GuDCK5MpR1S8Jbrc+ hash: v1.k794b7964.2719242d07a4035afb1207ecc9f5bc17023128269e105416dbef7fa89532b0df.PS57UkTp6HZQve4AaLvscsJRv6Do48TkGsQC3YDtFqcscenes-app-customer-analytics-accounts--row-expanded-usage-not-found--dark:- hash: v1.k794b7964.eba558ef304111974792b634bfe75c19aae4a86e2edc37dd6797b9c1830d8f27._lCVn78wbVioIgfhyGOcm-BSV9mcwEIe207dPM3fG6Q+ hash: v1.k794b7964.db2b85da4ffdfb9b336ce25618d52fa2b83e385d794ac7e15ee208ee5180cbe5.OUqstg6jUmYhZrvHuH5p4__83sjVTVpWFFA6HA0_ODcscenes-app-customer-analytics-accounts--row-expanded-usage-not-found--light:- hash: v1.k794b7964.cbb11987b4cd1ba8dd9e8bca4c3db8045008ab42b84530e53963e7a8b268b566.B8yb2ysrOlCwYdPiXW1B5t1p_Lx1tVz0hT87w2PQfr4+ hash: v1.k794b7964.a764885f8e150d90b1e5377d48cd3b27c0662375b868efa15e7151eb9cc65c96.K1zizRw3mEP8dLm7dR2Exm6BBSx4y2rcbiVvu1roBcsscenes-app-customer-analytics-accounts--row-expanded-usage-populated--dark:- hash: v1.k794b7964.7b361d8434af412d51759866d0707a4de3a5b780c675488bf989ec3b637cdbaf.5av0Uc5JwMOyBT9EoCWnSy-F7fXll3NEIF2VduZoV_M+ hash: v1.k794b7964.f6e3297d03ce70c9f476a3f4a439023e9165f0b807da04cbaea31bdd4e7131fc.5UhghJQ945WUBU_G21NKnnFtNXpl02vNHgHGKUmuF3wscenes-app-customer-analytics-accounts--row-expanded-usage-populated--light:- hash: v1.k794b7964.15485ed4d97f6e62a78f4117109d28bce2853b7c8d46807bad3baffb7cb34183.GCGEjmwlM6b9aAvleOYdoCSAnlth8nU9NcmlNCYUV8Q+ hash: v1.k794b7964.3c9bf682041aaec51eee49033716cc5b02bd868faaf1a4212610fcbc7de774be.__A7U7lquAbOTTIY-zgPd7uYibm3hEug52PnXcet8H0scenes-app-customer-analytics-accounts--row-expanded-with-note--dark:hash: v1.k794b7964.3c9ce002ecb9931c56ef82618cc1625ee847a7f8df2a35c490006e4b356e6fb5.bK3yVZfb-U4TUMJHKvLemkMdqx6YNKdkFC2lnrWBgYgscenes-app-customer-analytics-accounts--row-expanded-with-note--light:diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex eaf630b1a500..18e8abe82883 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -21,20 +21,6 @@"AccountsQuery": {"additionalProperties": false,"properties": {- "accountExecutive": {- "description": "Match accounts whose account executive is any of these user ids (OR semantics).",- "items": {- "$ref": "#/definitions/integer"- },- "type": "array"- },- "accountOwner": {- "description": "Match accounts whose account owner is any of these user ids (OR semantics).",- "items": {- "$ref": "#/definitions/integer"- },- "type": "array"- },"allRolesUnassigned": {"type": "boolean"},@@ -45,13 +31,6 @@},"type": "array"},- "csm": {- "description": "Match accounts whose CSM is any of these user ids (OR semantics).",- "items": {- "$ref": "#/definitions/integer"- },- "type": "array"- },"filterExpression": {"$ref": "#/definitions/HogQLExpression","description": "Optional HogQL boolean expression AND-ed into the WHERE clause. Used by the overview tile click-to-filter affordance."diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex e4045132e1cb..d05dca5b1e4b 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -2328,12 +2328,6 @@ export interface AccountsQuery extends DataNode<AccountsQueryResponse> {metrics?: HogQLExpression[]search?: stringtagNames?: string[]- /** Match accounts whose CSM is any of these user ids (OR semantics). */- csm?: integer[]- /** Match accounts whose account executive is any of these user ids (OR semantics). */- accountExecutive?: integer[]- /** Match accounts whose account owner is any of these user ids (OR semantics). */- accountOwner?: integer[]/** Match accounts where any of these user ids is the CSM or the account executive (OR over both roles). Drives the "My accounts" shortcut (the current user's id) and the shareable "Assigned to" filter — the ids are explicit so a shared URL resolves identically for every viewer. */assignedToUserIds?: integer[]allRolesUnassigned?: booleandiff --git a/posthog/schema.py b/posthog/schema.pyindex 2a48d3195340..53ba1d2bf98e 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -20582,14 +20582,6 @@ class AccountsQuery(BaseModel):model_config = ConfigDict(extra="forbid",)- accountExecutive: list[int] | None = Field(- default=None,- description=("Match accounts whose account executive is any of these user ids (OR semantics)."),- )- accountOwner: list[int] | None = Field(- default=None,- description=("Match accounts whose account owner is any of these user ids (OR semantics)."),- )allRolesUnassigned: bool | None = NoneassignedToUserIds: list[int] | None = Field(default=None,@@ -20600,10 +20592,6 @@ class AccountsQuery(BaseModel):" explicit so a shared URL resolves identically for every viewer."),)- csm: list[int] | None = Field(- default=None,- description="Match accounts whose CSM is any of these user ids (OR semantics).",- )filterExpression: str | None = Field(default=None,description=(diff --git a/products/customer_analytics/backend/hogql_queries/accounts_query_runner.py b/products/customer_analytics/backend/hogql_queries/accounts_query_runner.pyindex 8197ca897644..22d67ac5a83b 100644--- a/products/customer_analytics/backend/hogql_queries/accounts_query_runner.py+++ b/products/customer_analytics/backend/hogql_queries/accounts_query_runner.py@@ -26,11 +26,10 @@ def _normalize_order_clause(raw: str) -> str:return stripped-ROLE_FIELDS = {- "csm": "csm",- "accountExecutive": "account_executive",- "accountOwner": "account_owner",-}+# Account-properties JSON keys for the three assignable roles. The+# `allRolesUnassigned` filter ("Unassigned only") requires every one of these to+# be empty.+ROLE_JSON_KEYS = ("csm", "account_executive", "account_owner")# Roles that count as "assigned" for the `assignedToUserIds` filter — an account# is assigned to a user if they are its CSM or account executive.@@ -114,14 +113,8 @@ class AccountsQueryRunner(AnalyticsQueryRunner[AccountsQueryResponse]):if self.query.tagNames:where_exprs.append(self._tag_filter_expr(self.query.tagNames))- for query_field, json_key in ROLE_FIELDS.items():- role_value = getattr(self.query, query_field, None)- role_expr = self._role_filter_expr(json_key, role_value)- if role_expr is not None:- where_exprs.append(role_expr)-if self.query.allRolesUnassigned:- for json_key in ROLE_FIELDS.values():+ for json_key in ROLE_JSON_KEYS:where_exprs.append(self._role_id_isnull(json_key))if self.query.assignedToUserIds:@@ -200,10 +193,9 @@ class AccountsQueryRunner(AnalyticsQueryRunner[AccountsQueryResponse]):)def _assigned_to_users_expr(self, user_ids: list[int]) -> ast.Expr:- # OR over the CSM/AE roles, reusing the same IN-list shape as the- # per-role filters: an account is "assigned to" a user if they hold- # either role. Explicit ids (not the requester) so a shared URL filtered- # by "my accounts" resolves to the same accounts for every viewer.+ # OR over the CSM/AE roles: an account is "assigned to" a user if they+ # hold either role. Explicit ids (not the requester) so a shared URL+ # filtered by "my accounts" resolves to the same accounts for every viewer.role_exprs: list[ast.Expr] = []for json_key in ASSIGNED_ROLE_KEYS:role_expr = self._role_filter_expr(json_key, user_ids)diff --git a/products/customer_analytics/backend/hogql_queries/test/test_accounts_query_runner.py b/products/customer_analytics/backend/hogql_queries/test/test_accounts_query_runner.pyindex 6e8427644484..e4fa85598b6f 100644--- a/products/customer_analytics/backend/hogql_queries/test/test_accounts_query_runner.py+++ b/products/customer_analytics/backend/hogql_queries/test/test_accounts_query_runner.py@@ -140,31 +140,6 @@ class TestAccountsQueryRunner(ClickhouseTestMixin, NonAtomicBaseTest):self.assertEqual(self._ids(tagNames=["billing"]), [str(local_account.id)])- def test_csm_filter_by_id(self):- match = create_account(team_id=self.team.id, name="Has CSM", _properties={"csm": {"id": 7, "email": "[email protected]"}})- create_account(team_id=self.team.id, name="Other CSM", _properties={"csm": {"id": 9, "email": "[email protected]"}})- self.assertEqual(self._ids(csm=[7]), [str(match.id)])-- def test_csm_filter_matches_any_of_multiple_ids(self):- seven = create_account(team_id=self.team.id, name="Seven", _properties={"csm": {"id": 7, "email": "[email protected]"}})- nine = create_account(team_id=self.team.id, name="Nine", _properties={"csm": {"id": 9, "email": "[email protected]"}})- create_account(team_id=self.team.id, name="Eleven", _properties={"csm": {"id": 11, "email": "[email protected]"}})- self.assertEqual(set(self._ids(csm=[7, 9])), {str(seven.id), str(nine.id)})-- def test_account_executive_filter_by_id(self):- match = create_account(- team_id=self.team.id, name="A", _properties={"account_executive": {"id": 7, "email": "[email protected]"}}- )- create_account(team_id=self.team.id, name="B")- self.assertEqual(self._ids(accountExecutive=[7]), [str(match.id)])-- def test_account_owner_filter_by_id(self):- match = create_account(- team_id=self.team.id, name="A", _properties={"account_owner": {"id": 7, "email": "[email protected]"}}- )- create_account(team_id=self.team.id, name="B")- self.assertEqual(self._ids(accountOwner=[7]), [str(match.id)])-@parameterized.expand([("absent_keys", {"_properties": {}}),@@ -176,7 +151,7 @@ class TestAccountsQueryRunner(ClickhouseTestMixin, NonAtomicBaseTest):unassigned = create_account(team_id=self.team.id, name="Unassigned", **unassigned_kwargs)self.assertEqual(self._ids(allRolesUnassigned=True), [str(unassigned.id)])- def test_combined_role_and_tags(self):+ def test_combined_assigned_to_and_tags(self):enterprise_tag = Tag.objects.create(name="enterprise", team=self.team)startup_tag = Tag.objects.create(name="startup", team=self.team)@@ -186,16 +161,10 @@ class TestAccountsQueryRunner(ClickhouseTestMixin, NonAtomicBaseTest):wrong_tag = create_account(team_id=self.team.id, name="B", _properties={"csm": {"id": 7, "email": "[email protected]"}})wrong_tag.tagged_items.create(tag=startup_tag)- wrong_csm = create_account(team_id=self.team.id, name="C", _properties={"csm": {"id": 8, "email": "[email protected]"}})- wrong_csm.tagged_items.create(tag=enterprise_tag)-- self.assertEqual(self._ids(csm=[7], tagNames=["enterprise"]), [str(match.id)])+ wrong_user = create_account(team_id=self.team.id, name="C", _properties={"csm": {"id": 8, "email": "[email protected]"}})+ wrong_user.tagged_items.create(tag=enterprise_tag)- def test_role_filter_respects_team_isolation(self):- other_team = Team.objects.create(organization=self.organization)- create_account(team_id=other_team.id, name="Theirs", _properties={"csm": {"id": 7, "email": "[email protected]"}})- mine = create_account(team_id=self.team.id, name="Mine", _properties={"csm": {"id": 7, "email": "[email protected]"}})- self.assertEqual(self._ids(csm=[7]), [str(mine.id)])+ self.assertEqual(self._ids(assignedToUserIds=[7], tagNames=["enterprise"]), [str(match.id)])@parameterized.expand([@@ -456,9 +425,9 @@ class TestAccountsQueryRunner(ClickhouseTestMixin, NonAtomicBaseTest):def test_set_tags_on_object_helper_matches(self):# Mirror existing API test setup that uses set_tags_on_object.- account = create_account(team_id=self.team.id, name="A", _properties={"csm": {"id": 7, "email": "[email protected]"}})+ account = create_account(team_id=self.team.id, name="A")set_tags_on_object(["enterprise"], account)- self.assertEqual(self._ids(csm=[7], tagNames=["enterprise"]), [str(account.id)])+ self.assertEqual(self._ids(tagNames=["enterprise"]), [str(account.id)])def test_custom_select_uses_only_requested_columns(self):create_account(team_id=self.team.id, name="A")diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.mdindex aa6ffb785e41..9dc1223875b0 100644--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md@@ -19,8 +19,8 @@ The scene renders `AccountsTabContent`, which binds one `dataNodeLogic` (key `AC```textAccountsTabContent ── binds dataNodeLogic(ACCOUNTS_HOGQL_DATA_NODE_KEY, accountsLogic.hogqlQuery.source)├── AccountsMaxTools registers the `open_account` Max contextual tool → accountsLogic.openAccount-├── AccountsTabFilters search / tags / role filters / "my accounts" / "unassigned only"-├── AccountsOverviewTilesButton + AccountsColumnConfigurator+├── AccountsTabFilters two rows: (1) search + Refresh; (2) tags / "assigned to" (incl. unassigned-only) /+│ "my accounts" on the left, AccountsOverviewTilesButton + AccountsColumnConfigurator on the right├── AccountsOverviewTiles metric tiles across the filtered set└── AccountsHogQLTable the DataTable; per-column renderers; controlled row expansion└── AccountNotebooksExpansion expanded row: Useful links + LemonTabs(Notes/Users/Usage)@@ -31,20 +31,20 @@ AccountsTabContent ── binds dataNodeLogic(ACCOUNTS_HOGQL_DATA_NODE_KEY, acc### Logics and what each owns-| Logic | Owns |-| ---------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |-| `accountsLogic` | The hub. Search (debounced), tag/role filters, sort, inline role assignment, the `hogqlQuery` selector, shareable URL-hash view state, and `openAccount` (the Max entry point). `connect`s column-config, overview-tiles, and expansion logics. |-| `accountsColumnConfigLogic` | Selected columns (`selectColumns` / `visibleColumnNames`), the column-picker groups built from the DB schema + data-warehouse joins, and the per-team saved column config (`columnConfigurations` API). |-| `accountsExpansionLogic` | Which rows are expanded (`expandedAccountIds`) and the active tab per account (`activeTabByAccount`). Pure state — no DOM, no data fetching. |-| `accountsOverviewTilesLogic` | The overview metric tiles (persisted per team); feeds `metrics` into the query. |-| `accountNotebooksLogic` | Notes/notebooks linked to one account (keyed by `accountId`). |-| `accountRelatedUsersLogic` | Group members / related users for one account (keyed by `externalId`). |-| `accountBillingLogic` | Billing/usage data behind the Usage tab. |-| `accountLinksLogic` | The "Useful links" sidebar for one account (keyed by `accountId`). |+| Logic | Owns |+| ---------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| `accountsLogic` | The hub. Search (debounced), tag and assigned-to/unassigned filters, sort, inline role assignment, the `hogqlQuery` selector, shareable URL-hash view state, and `openAccount` (the Max entry point). `connect`s column-config, overview-tiles, and expansion logics. |+| `accountsColumnConfigLogic` | Selected columns (`selectColumns` / `visibleColumnNames`), the column-picker groups built from the DB schema + data-warehouse joins, and the per-team saved column config (`columnConfigurations` API). |+| `accountsExpansionLogic` | Which rows are expanded (`expandedAccountIds`) and the active tab per account (`activeTabByAccount`). Pure state — no DOM, no data fetching. |+| `accountsOverviewTilesLogic` | The overview metric tiles (persisted per team); feeds `metrics` into the query. |+| `accountNotebooksLogic` | Notes/notebooks linked to one account (keyed by `accountId`). |+| `accountRelatedUsersLogic` | Group members / related users for one account (keyed by `externalId`). |+| `accountBillingLogic` | Billing/usage data behind the Usage tab. |+| `accountLinksLogic` | The "Useful links" sidebar for one account (keyed by `accountId`). |## Data & query model-`accountsLogic.hogqlQuery` builds a `DataTableNode` wrapping an `AccountsQuery` (`select`, plus optional `search`, `tagNames`, role filters, `allRolesUnassigned`, `assignedToUserIds`, `filterExpression`, `metrics`, `orderBy`). The backend runner (`accounts_query_runner`) returns **rows as arrays** aligned to `visibleColumnNames`. `assignedToUserIds` is the "assigned to" filter — a list of user ids the runner expands into `csm IN ids OR account_executive IN ids`. 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:+`accountsLogic.hogqlQuery` builds a `DataTableNode` wrapping an `AccountsQuery` (`select`, plus optional `search`, `tagNames`, `allRolesUnassigned`, `assignedToUserIds`, `filterExpression`, `metrics`, `orderBy`). The backend runner (`accounts_query_runner`) returns **rows as arrays** aligned to `visibleColumnNames`. `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.- **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.@@ -61,7 +61,7 @@ The Usage tab renders an existing saved billing-usage insight — **point users## Shareable view state-`accountsLogic` mirrors the full view (search, tags, roles, unassigned, assigned-to, sort, columns, tile filter) into the URL hash `#view=...` via `actionToUrl`/`urlToAction`, so a copied URL reproduces the exact list. 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, unassigned, assigned-to, sort, columns, tile filter) into the URL hash `#view=...` via `actionToUrl`/`urlToAction`, so a copied URL reproduces the exact list. 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).## Max / agent integration@@ -97,26 +97,26 @@ 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`, `setCsmFilter`, …) are also dispatched by URL sync (shared view links) and by cross-filter cascades (checking "unassigned only" clears the role filters), 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 (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.- 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` \| `csm` \| `account_executive` \| `account_owner` \| `unassigned_only` \| `my_accounts`), `value`, `is_cleared`, `active_filter_count`; for `tag` also `tag_count` |-| `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 columns saved` | `accountsColumnConfigLogic` `saveColumns` (success, only when changed) | `column_count`, `columns`, `added_count`, `removed_count`, `reordered` |-| `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 account role assigned` | `accountsLogic` `updateAccountRole` | `role` (`csm` \| `account_executive` \| `account_owner`), `is_assigned`, `assigned_user_id`, `source` (always `list_row` today) |-| `customer analytics account link clicked` | `AccountNotebooksExpansion.tsx` useful-link `onClick` | `link_key`, `has_destination` |-| `customer analytics account note clicked` | `AccountNotebooksExpansion.tsx` note `<Link>` `onClick` | `notebook_short_id` |-| `customer analytics account tab viewed` | `accountsExpansionLogic` `setActiveTab` listener (genuine tab clicks only; programmatic `openAccountTab` navigation does not fire it) | `tab` (`notes` \| `users` \| `usage`) |-| `customer analytics account related user clicked` | `AccountRelatedUsersExpansion.tsx` user `<Link>` `onClick` | _(none — customer end-user PII kept out)_ |+| 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`), `value`, `is_cleared`, `active_filter_count`; for `tag` also `tag_count`; for `assigned_to` also `role_count` |+| `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 columns saved` | `accountsColumnConfigLogic` `saveColumns` (success, only when changed) | `column_count`, `columns`, `added_count`, `removed_count`, `reordered` |+| `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 account role assigned` | `accountsLogic` `updateAccountRole` | `role` (`csm` \| `account_executive` \| `account_owner`), `is_assigned`, `assigned_user_id`, `source` (always `list_row` today) |+| `customer analytics account link clicked` | `AccountNotebooksExpansion.tsx` useful-link `onClick` | `link_key`, `has_destination` |+| `customer analytics account note clicked` | `AccountNotebooksExpansion.tsx` note `<Link>` `onClick` | `notebook_short_id` |+| `customer analytics account tab viewed` | `accountsExpansionLogic` `setActiveTab` listener (genuine tab clicks only; programmatic `openAccountTab` navigation does not fire it) | `tab` (`notes` \| `users` \| `usage`) |+| `customer analytics account related user clicked` | `AccountRelatedUsersExpansion.tsx` user `<Link>` `onClick` | _(none — customer end-user PII kept out)_ |> **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/AccountsTabContent.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTabContent.tsxindex 400a48933ed2..7b3d2ae967f8 100644--- a/products/customer_analytics/frontend/components/Accounts/AccountsTabContent.tsx+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTabContent.tsx@@ -3,12 +3,10 @@ import { BindLogic, useValues } from 'kea'import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'import { ACCOUNTS_HOGQL_DATA_NODE_KEY } from '../../constants'-import { AccountsColumnConfigurator } from './AccountsColumnConfigurator'import { AccountsHogQLTable } from './AccountsHogQLTable'import { accountsLogic } from './accountsLogic'import { AccountsMaxTools } from './AccountsMaxTools'import { AccountsOverviewTiles } from './AccountsOverviewTiles'-import { AccountsOverviewTilesButton } from './AccountsOverviewTilesButton'import { AccountsTabFilters } from './AccountsTabFilters'export function AccountsTabContent(): JSX.Element {@@ -25,10 +23,6 @@ export function AccountsTabContent(): JSX.Element {<div className="flex flex-col gap-3"><AccountsMaxTools /><AccountsTabFilters />- <div className="flex justify-end gap-2">- <AccountsOverviewTilesButton />- <AccountsColumnConfigurator />- </div><AccountsOverviewTiles /><AccountsHogQLTable /></div>diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsxindex 461b4d5219ef..559f341dd694 100644--- a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsx+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsx@@ -48,30 +48,6 @@ describe('AccountsTabFilters', () => {)}- // Regression: the role pickers used to resolve the selected member's name from the- // lazily-loaded org members list, so a filter restored from the URL showed "Any CSM"- // until the dropdown was opened — the list was filtered but the control looked empty.- it('reflects a restored role filter without the members list being loaded', () => {- logic.actions.setCsmFilter([42])- renderFilters()-- expect(screen.getByText('1 CSM')).toBeInTheDocument()- expect(screen.queryByText('Any CSM')).not.toBeInTheDocument()- })-- it('summarizes multiple selected members as a count', () => {- logic.actions.setAccountExecutiveFilter([1, 2, 3])- renderFilters()-- expect(screen.getByText('3 AEs')).toBeInTheDocument()- })-- it('shows the default label when no role is selected', () => {- renderFilters()-- expect(screen.getByText('Any Owner')).toBeInTheDocument()- })-function myAccountsCheckbox(): HTMLInputElement {return screen.getByText('My accounts').closest('.LemonCheckbox')!.querySelector('input')!}@@ -107,10 +83,22 @@ describe('AccountsTabFilters', () => {expect(screen.getByText('Assigned to anyone')).toBeInTheDocument()})+ // Regression: the picker must summarize a URL-restored filter from the id count+ // alone, without waiting on the lazily-loaded org members list — otherwise the+ // control looks empty (the default label) until the dropdown is opened.it('reflects a restored assigned-to filter as a count', () => {logic.actions.setAssignedToFilter([1, 2])renderFilters()expect(screen.getByText('Assigned to 2 people')).toBeInTheDocument()+ expect(screen.queryByText('Assigned to anyone')).not.toBeInTheDocument()+ })++ it('labels the assigned-to picker "Unassigned" when unassigned-only is active', () => {+ logic.actions.setAllRolesUnassigned(true)+ renderFilters()++ expect(screen.getByText('Unassigned')).toBeInTheDocument()+ expect(screen.queryByText('Assigned to anyone')).not.toBeInTheDocument()})})diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsxindex 88d20ec8c2eb..5fbe670a8346 100644--- a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx@@ -1,26 +1,27 @@import { useActions, useValues } from 'kea'import { IconChevronDown, IconRefresh, IconX } from '@posthog/icons'-import { LemonButton, LemonCheckbox, LemonDropdown, LemonInput, LemonInputSelect } from '@posthog/lemon-ui'+import {+ LemonButton,+ LemonCheckbox,+ LemonDivider,+ LemonDropdown,+ LemonInput,+ LemonInputSelect,+} from '@posthog/lemon-ui'import { MemberSelectMultiple } from 'lib/components/MemberSelectMultiple'import { tagsModel } from '~/models/tagsModel'import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'+import { AccountsColumnConfigurator } from './AccountsColumnConfigurator'import { accountsLogic, RoleFilterValue } from './accountsLogic'+import { AccountsOverviewTilesButton } from './AccountsOverviewTilesButton'export function AccountsTabFilters(): JSX.Element {- const {- searchInput,- tagsFilter,- allRolesUnassigned,- assignedToCurrentUser,- assignedToFilter,- csmFilter,- accountExecutiveFilter,- accountOwnerFilter,- } = useValues(accountsLogic)+ const { searchInput, tagsFilter, allRolesUnassigned, assignedToCurrentUser, assignedToFilter } =+ useValues(accountsLogic)const { responseLoading: accountsLoading } = useValues(dataNodeLogic)const {setSearchInput,@@ -28,9 +29,6 @@ export function AccountsTabFilters(): JSX.Element {setAllRolesUnassigned,setAssignedToCurrentUser,setAssignedToFilter,- setCsmFilter,- setAccountExecutiveFilter,- setAccountOwnerFilter,refresh,reportFilterChange,} = useActions(accountsLogic)@@ -40,118 +38,17 @@ export function AccountsTabFilters(): JSX.Element {tagsFilter.length === 0 ? 'All tags' : tagsFilter.length === 1 ? tagsFilter[0] : `${tagsFilter.length} tags`return (- <div className="flex flex-wrap gap-3 items-center">- <LemonInput- type="search"- placeholder="Search by name or ID..."- value={searchInput}- onChange={setSearchInput}- size="small"- className="min-w-64"- data-attr="accounts-search"- />- <LemonDropdown- closeOnClickInside={false}- overlay={- <div className="p-2 min-w-64">- <LemonInputSelect- mode="multiple"- allowCustomValues- value={tagsFilter}- options={(tagsAvailable || []).map((t: string) => ({ key: t, label: t }))}- onChange={(tags) => {- setTagsFilter(tags)- reportFilterChange('tag')- }}- placeholder="Select or type tags..."- data-attr="accounts-tags-filter"- />- </div>- }- >- <LemonButton type="secondary" size="small" sideIcon={<IconChevronDown />}>- {tagsButtonLabel}- </LemonButton>- </LemonDropdown>- {tagsFilter.length > 0 && (- <LemonButton- type="secondary"+ <div className="flex flex-col gap-2">+ <div className="flex flex-wrap gap-2 items-center justify-between">+ <LemonInput+ type="search"+ placeholder="Search by name or ID..."+ value={searchInput}+ onChange={setSearchInput}size="small"- icon={<IconX />}- onClick={() => {- setTagsFilter([])- reportFilterChange('tag')- }}- tooltip="Clear tag filter"+ className="min-w-64"+ data-attr="accounts-search"/>- )}-- <RolePicker- label="CSM"- value={csmFilter}- onChange={(value) => {- setCsmFilter(value)- reportFilterChange('csm')- }}- dataAttr="accounts-csm-filter"- />- <RolePicker- label="AE"- value={accountExecutiveFilter}- onChange={(value) => {- setAccountExecutiveFilter(value)- reportFilterChange('account_executive')- }}- dataAttr="accounts-ae-filter"- />- <RolePicker- label="Owner"- value={accountOwnerFilter}- onChange={(value) => {- setAccountOwnerFilter(value)- reportFilterChange('account_owner')- }}- dataAttr="accounts-owner-filter"- />- <RolePicker- label="Assigned to"- value={assignedToFilter}- onChange={(value) => {- setAssignedToFilter(value)- reportFilterChange('assigned_to')- }}- dataAttr="accounts-assigned-to-filter"- formatButtonLabel={(count) =>- count === 0- ? 'Assigned to anyone'- : count === 1- ? 'Assigned to 1 person'- : `Assigned to ${count} people`- }- />- <LemonCheckbox- checked={assignedToCurrentUser}- onChange={(value) => {- setAssignedToCurrentUser(value)- reportFilterChange('my_accounts')- }}- label="My accounts"- info="Shortcut for Assigned to: you — accounts where you are the CSM or account executive"- disabledReason={accountsLoading ? 'Loading…' : undefined}- data-attr="accounts-my-accounts-filter"- />- <LemonCheckbox- checked={allRolesUnassigned}- onChange={(value) => {- setAllRolesUnassigned(value)- reportFilterChange('unassigned_only')- }}- label="Unassigned only"- disabledReason={accountsLoading ? 'Loading…' : undefined}- data-attr="accounts-unassigned-filter"- />-- <div className="ml-auto"><LemonButtontype="secondary"icon={<IconRefresh />}@@ -164,36 +61,110 @@ export function AccountsTabFilters(): JSX.Element {Refresh</LemonButton></div>+ <div className="flex flex-wrap gap-2 items-center justify-between">+ <div className="flex flex-wrap gap-2 items-center">+ <LemonDropdown+ closeOnClickInside={false}+ overlay={+ <div className="p-2 min-w-64">+ <LemonInputSelect+ mode="multiple"+ allowCustomValues+ value={tagsFilter}+ options={(tagsAvailable || []).map((t: string) => ({ key: t, label: t }))}+ onChange={(tags) => {+ setTagsFilter(tags)+ reportFilterChange('tag')+ }}+ placeholder="Select or type tags..."+ data-attr="accounts-tags-filter"+ />+ </div>+ }+ >+ <LemonButton type="secondary" size="small" sideIcon={<IconChevronDown />}>+ {tagsButtonLabel}+ </LemonButton>+ </LemonDropdown>+ {tagsFilter.length > 0 && (+ <LemonButton+ type="secondary"+ size="small"+ icon={<IconX />}+ onClick={() => {+ setTagsFilter([])+ reportFilterChange('tag')+ }}+ tooltip="Clear tag filter"+ />+ )}++ <AssignedToPicker+ value={assignedToFilter}+ onChange={(value) => {+ setAssignedToFilter(value)+ reportFilterChange('assigned_to')+ }}+ unassignedOnly={allRolesUnassigned}+ onUnassignedOnlyChange={(value) => {+ setAllRolesUnassigned(value)+ reportFilterChange('unassigned_only')+ }}+ />++ <LemonCheckbox+ checked={assignedToCurrentUser}+ onChange={(value) => {+ setAssignedToCurrentUser(value)+ reportFilterChange('my_accounts')+ }}+ label="My accounts"+ info="Shortcut for Assigned to: you — accounts where you are the CSM or account executive"+ disabledReason={accountsLoading ? 'Loading…' : undefined}+ data-attr="accounts-my-accounts-filter"+ />+ </div>+ <div className="flex flex-wrap gap-2 items-center">+ <AccountsOverviewTilesButton />+ <AccountsColumnConfigurator />+ </div>+ </div></div>)}-function RolePicker({- label,+function AssignedToPicker({value,onChange,- dataAttr,- formatButtonLabel,+ unassignedOnly,+ onUnassignedOnlyChange,}: {- label: stringvalue: RoleFilterValueonChange: (value: RoleFilterValue) => void- dataAttr: string- formatButtonLabel?: (count: number) => string+ unassignedOnly: boolean+ onUnassignedOnlyChange: (value: boolean) => void}): JSX.Element {- const buttonLabel = formatButtonLabel- ? formatButtonLabel(value.length)+ const buttonLabel = unassignedOnly+ ? 'Unassigned': value.length === 0- ? `Any ${label}`+ ? 'Assigned to anyone': value.length === 1- ? `1 ${label}`- : `${value.length} ${label}s`+ ? 'Assigned to 1 person'+ : `Assigned to ${value.length} people`+ const hasFilter = unassignedOnly || value.length > 0return (- <div className="flex gap-1 items-center" data-attr={dataAttr}>+ <div className="flex gap-1 items-center" data-attr="accounts-assigned-to-filter"><LemonDropdowncloseOnClickInside={false}overlay={- <div className="p-2 min-w-64">+ <div className="p-2 min-w-64 flex flex-col gap-2">+ <LemonCheckbox+ checked={unassignedOnly}+ onChange={onUnassignedOnlyChange}+ label="Unassigned only"+ data-attr="accounts-unassigned-filter"+ />+ <LemonDivider className="my-0" /><MemberSelectMultipleidKey="id"value={value}@@ -206,13 +177,20 @@ function RolePicker({{buttonLabel}</LemonButton></LemonDropdown>- {value.length > 0 && (+ {hasFilter && (<LemonButtontype="secondary"size="small"icon={<IconX />}- onClick={() => onChange([])}- tooltip={`Clear ${label} filter`}+ onClick={() => {+ if (unassignedOnly) {+ onUnassignedOnlyChange(false)+ }+ if (value.length > 0) {+ onChange([])+ }+ }}+ tooltip="Clear assigned-to filter"/>)}</div>diff --git a/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.tsindex 2b79754a1d62..8876c266375e 100644--- a/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts+++ b/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts@@ -76,9 +76,7 @@ describe('accountsLogic', () => {expect(logic.values.searchQuery).toBe('')expect(logic.values.tagsFilter).toEqual([])expect(logic.values.allRolesUnassigned).toBe(false)- expect(logic.values.csmFilter).toEqual([])- expect(logic.values.accountExecutiveFilter).toEqual([])- expect(logic.values.accountOwnerFilter).toEqual([])+ expect(logic.values.assignedToFilter).toEqual([])})it('setTagsFilter updates the reducer', () => {@@ -108,37 +106,6 @@ describe('accountsLogic', () => {expect(logic.values.allRolesUnassigned).toBe(true)})- it('setCsmFilter accepts a list of user ids and clears with an empty list', () => {- logic.actions.setCsmFilter([42])- expect(logic.values.csmFilter).toEqual([42])- logic.actions.setCsmFilter([42, 43])- expect(logic.values.csmFilter).toEqual([42, 43])- logic.actions.setCsmFilter([])- expect(logic.values.csmFilter).toEqual([])- })-- it('setting a role filter clears the all_roles_unassigned flag', async () => {- logic.actions.setAllRolesUnassigned(true)- logic.actions.setCsmFilter([7])- await expectLogic(logic).toFinishAllListeners()-- expect(logic.values.allRolesUnassigned).toBe(false)- expect(logic.values.csmFilter).toEqual([7])- })-- it('enabling all_roles_unassigned clears any active role filters', async () => {- logic.actions.setCsmFilter([7])- logic.actions.setAccountExecutiveFilter([9])- logic.actions.setAccountOwnerFilter([11])- logic.actions.setAllRolesUnassigned(true)- await expectLogic(logic).toFinishAllListeners()-- expect(logic.values.allRolesUnassigned).toBe(true)- expect(logic.values.csmFilter).toEqual([])- expect(logic.values.accountExecutiveFilter).toEqual([])- expect(logic.values.accountOwnerFilter).toEqual([])- })-describe('assignedTo filter and "my accounts" shortcut', () => {const CURRENT_USER_ID = 42@@ -196,19 +163,6 @@ describe('accountsLogic', () => {expect(logic.values.allRolesUnassigned).toBe(false)})- it('enabling it clears the CSM and AE pickers but keeps the owner filter', async () => {- logic.actions.setCsmFilter([7])- logic.actions.setAccountExecutiveFilter([8])- logic.actions.setAccountOwnerFilter([9])- logic.actions.setAssignedToFilter([CURRENT_USER_ID])- await expectLogic(logic).toFinishAllListeners()-- expect(logic.values.assignedToFilter).toEqual([CURRENT_USER_ID])- expect(logic.values.csmFilter).toEqual([])- expect(logic.values.accountExecutiveFilter).toEqual([])- expect(logic.values.accountOwnerFilter).toEqual([9])- })-it('enabling the unassigned flag clears the assigned-to filter', async () => {logic.actions.setAssignedToFilter([7])logic.actions.setAllRolesUnassigned(true)@@ -218,33 +172,6 @@ describe('accountsLogic', () => {expect(logic.values.assignedToFilter).toEqual([])})- it('selecting a CSM clears the assigned-to filter', async () => {- logic.actions.setAssignedToFilter([CURRENT_USER_ID])- logic.actions.setCsmFilter([7])- await expectLogic(logic).toFinishAllListeners()-- expect(logic.values.csmFilter).toEqual([7])- expect(logic.values.assignedToFilter).toEqual([])- })-- it('selecting an AE clears the assigned-to filter', async () => {- logic.actions.setAssignedToFilter([CURRENT_USER_ID])- logic.actions.setAccountExecutiveFilter([8])- await expectLogic(logic).toFinishAllListeners()-- expect(logic.values.accountExecutiveFilter).toEqual([8])- expect(logic.values.assignedToFilter).toEqual([])- })-- it('selecting an owner leaves the assigned-to filter intact', async () => {- logic.actions.setAssignedToFilter([CURRENT_USER_ID])- logic.actions.setAccountOwnerFilter([9])- await expectLogic(logic).toFinishAllListeners()-- expect(logic.values.accountOwnerFilter).toEqual([9])- expect(logic.values.assignedToFilter).toEqual([CURRENT_USER_ID])- })-it('persists concrete ids in the view hash (shareable, not viewer-relative)', async () => {await expectLogic(logic, () => {logic.actions.setAssignedToCurrentUser(true)@@ -364,7 +291,7 @@ describe('accountsLogic', () => {await expectLogic(logic, () => {logic.actions.setSearchQuery('acme')logic.actions.setTagsFilter(['enterprise'])- logic.actions.setCsmFilter([7])+ logic.actions.setAssignedToFilter([7])logic.actions.setSortOrder({ column: 'name', direction: 'desc' })logic.actions.setTileFilter({ tileId: 'tile-1', expression: 'count() > 5' })}).toFinishAllListeners()@@ -372,7 +299,7 @@ describe('accountsLogic', () => {expect(router.values.hashParams.view).toEqual({search: 'acme',tags: ['enterprise'],- csm: [7],+ assignedTo: [7],sort: { column: 'name', direction: 'desc' },tileFilter: { tileId: 'tile-1', expression: 'count() > 5' },})@@ -393,25 +320,25 @@ describe('accountsLogic', () => {urls.customerAnalyticsAccounts(),{},{- view: { search: 'beta', csm: [7], sort: { column: 'name', direction: 'desc' }, tileFilter },+ view: { search: 'beta', assignedTo: [7], sort: { column: 'name', direction: 'desc' }, tileFilter },})await expectLogic(logic).toFinishAllListeners()expect(logic.values.searchQuery).toBe('beta')expect(logic.values.searchInput).toBe('beta')- expect(logic.values.csmFilter).toEqual([7])+ expect(logic.values.assignedToFilter).toEqual([7])expect(logic.values.sortOrder).toEqual({ column: 'name', direction: 'desc' })expect(logic.values.tileFilter).toEqual(tileFilter)})- it('coerces a legacy single-number role id from an old shared URL into an array', async () => {- // URLs shared before the filters became multi-select stored e.g. `csm: 7`.- router.actions.push(urls.customerAnalyticsAccounts(), {}, { view: { csm: 7, accountExecutive: 9 } })+ it('coerces a malformed scalar assignedTo from the view hash into an array', async () => {+ // normalizeRoleFilter defends the array-shaped filter against a stray+ // scalar in the hash (hand-edited or stale link) so .length/.map stay safe.+ router.actions.push(urls.customerAnalyticsAccounts(), {}, { view: { assignedTo: 7 } })await expectLogic(logic).toFinishAllListeners()- expect(logic.values.csmFilter).toEqual([7])- expect(logic.values.accountExecutiveFilter).toEqual([9])+ expect(logic.values.assignedToFilter).toEqual([7])})it('restores columns and shields them from a late saved column config', async () => {diff --git a/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountsLogic.tsindex 14d990fa17bc..da6f21de1882 100644--- a/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts+++ b/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts@@ -73,14 +73,7 @@ function normalizeRoleFilter(value: unknown): RoleFilterValue {export type AccountRoleKey = 'csm' | 'account_executive' | 'account_owner'-export type AccountFilterType =- | 'tag'- | 'csm'- | 'account_executive'- | 'account_owner'- | 'unassigned_only'- | 'my_accounts'- | 'assigned_to'+export type AccountFilterType = 'tag' | 'unassigned_only' | 'my_accounts' | 'assigned_to'// `column` matches the visible column name (alias-stripped) so any selected// column can drive the sort.@@ -127,9 +120,6 @@ export interface AccountsViewUrlState {/** @deprecated Legacy viewer-relative flag; still read so old shared links* resolve to the opener's own id. Never written. */mine?: boolean- csm?: number[]- accountExecutive?: number[]- accountOwner?: number[]sort?: NonNullable<AccountSortOrder>columns?: string[]tileFilter?: TileFilter@@ -166,9 +156,6 @@ export const accountsLogic = kea<accountsLogicType>([// Shortcut for the "My accounts" checkbox — resolves to the current// user's id and routes through setAssignedToFilter.setAssignedToCurrentUser: (value: boolean) => ({ value }),- setCsmFilter: (value: RoleFilterValue) => ({ value }),- setAccountExecutiveFilter: (value: RoleFilterValue) => ({ value }),- setAccountOwnerFilter: (value: RoleFilterValue) => ({ value }),setSortOrder: (sortOrder: AccountSortOrder) => ({ sortOrder }),toggleSort: (column: AccountSortableColumn) => ({ column }),refresh: true,@@ -223,24 +210,6 @@ export const accountsLogic = kea<accountsLogicType>([setAssignedToFilter: (_, { value }) => value,},],- csmFilter: [- [] as RoleFilterValue,- {- setCsmFilter: (_, { value }) => value,- },- ],- accountExecutiveFilter: [- [] as RoleFilterValue,- {- setAccountExecutiveFilter: (_, { value }) => value,- },- ],- accountOwnerFilter: [- [] as RoleFilterValue,- {- setAccountOwnerFilter: (_, { value }) => value,- },- ],sortOrder: [null as AccountSortOrder,{@@ -285,33 +254,16 @@ export const accountsLogic = kea<accountsLogicType>([!!savingRoles[savingRoleKey(accountId, role)],],activeFilterCount: [- (s) => [- s.searchQuery,- s.tagsFilter,- s.csmFilter,- s.accountExecutiveFilter,- s.accountOwnerFilter,- s.allRolesUnassigned,- s.assignedToFilter,- ],+ (s) => [s.searchQuery, s.tagsFilter, s.allRolesUnassigned, s.assignedToFilter],(searchQuery: string,tagsFilter: string[],- csmFilter: RoleFilterValue,- accountExecutiveFilter: RoleFilterValue,- accountOwnerFilter: RoleFilterValue,allRolesUnassigned: boolean,assignedToFilter: RoleFilterValue): number =>- [- !!searchQuery.trim(),- tagsFilter.length > 0,- csmFilter.length > 0,- accountExecutiveFilter.length > 0,- accountOwnerFilter.length > 0,- allRolesUnassigned,- assignedToFilter.length > 0,- ].filter(Boolean).length,+ [!!searchQuery.trim(), tagsFilter.length > 0, allRolesUnassigned, assignedToFilter.length > 0].filter(+ Boolean+ ).length,],viewUrlState: [(s) => [@@ -319,9 +271,6 @@ export const accountsLogic = kea<accountsLogicType>([s.tagsFilter,s.allRolesUnassigned,s.assignedToFilter,- s.csmFilter,- s.accountExecutiveFilter,- s.accountOwnerFilter,s.sortOrder,s.selectColumns,s.tileFilter,@@ -331,9 +280,6 @@ export const accountsLogic = kea<accountsLogicType>([tagsFilter: string[],allRolesUnassigned: boolean,assignedToFilter: RoleFilterValue,- csmFilter: RoleFilterValue,- accountExecutiveFilter: RoleFilterValue,- accountOwnerFilter: RoleFilterValue,sortOrder: AccountSortOrder,selectColumns: string[],tileFilter: TileFilter | null@@ -352,15 +298,6 @@ export const accountsLogic = kea<accountsLogicType>([if (assignedToFilter.length > 0) {state.assignedTo = assignedToFilter}- if (csmFilter.length > 0) {- state.csm = csmFilter- }- if (accountExecutiveFilter.length > 0) {- state.accountExecutive = accountExecutiveFilter- }- if (accountOwnerFilter.length > 0) {- state.accountOwner = accountOwnerFilter- }if (sortOrder) {state.sort = sortOrder}@@ -379,9 +316,6 @@ export const accountsLogic = kea<accountsLogicType>([s.tagsFilter,s.allRolesUnassigned,s.assignedToFilter,- s.csmFilter,- s.accountExecutiveFilter,- s.accountOwnerFilter,s.tileFilter,s.overviewMetrics,s.sortOrder,@@ -392,9 +326,6 @@ export const accountsLogic = kea<accountsLogicType>([tagsFilter: string[],allRolesUnassigned: boolean,assignedToFilter: RoleFilterValue,- csmFilter: RoleFilterValue,- accountExecutiveFilter: RoleFilterValue,- accountOwnerFilter: RoleFilterValue,tileFilter: TileFilter | null,overviewMetrics: string[],sortOrder: AccountSortOrder,@@ -421,15 +352,6 @@ export const accountsLogic = kea<accountsLogicType>([if (assignedToFilter.length > 0) {source.assignedToUserIds = assignedToFilter}- if (csmFilter.length > 0) {- source.csm = csmFilter- }- if (accountExecutiveFilter.length > 0) {- source.accountExecutive = accountExecutiveFilter- }- if (accountOwnerFilter.length > 0) {- source.accountOwner = accountOwnerFilter- }if (tileFilter) {source.filterExpression = tileFilter.expression}@@ -472,21 +394,6 @@ export const accountsLogic = kea<accountsLogicType>([properties.tag_count = values.tagsFilter.lengthproperties.is_cleared = values.tagsFilter.length === 0break- case 'csm':- properties.value = values.csmFilter- properties.role_count = values.csmFilter.length- properties.is_cleared = values.csmFilter.length === 0- break- case 'account_executive':- properties.value = values.accountExecutiveFilter- properties.role_count = values.accountExecutiveFilter.length- properties.is_cleared = values.accountExecutiveFilter.length === 0- break- case 'account_owner':- properties.value = values.accountOwnerFilter- properties.role_count = values.accountOwnerFilter.length- properties.is_cleared = values.accountOwnerFilter.length === 0- breakcase 'unassigned_only':properties.value = values.allRolesUnassignedproperties.is_cleared = !values.allRolesUnassigned@@ -504,19 +411,8 @@ export const accountsLogic = kea<accountsLogicType>([posthog.capture(AccountsEvents.FilterChanged, properties)},setAllRolesUnassigned: ({ value }) => {- if (value) {- if (values.assignedToFilter.length > 0) {- actions.setAssignedToFilter([])- }- if (values.csmFilter.length > 0) {- actions.setCsmFilter([])- }- if (values.accountExecutiveFilter.length > 0) {- actions.setAccountExecutiveFilter([])- }- if (values.accountOwnerFilter.length > 0) {- actions.setAccountOwnerFilter([])- }+ if (value && values.assignedToFilter.length > 0) {+ actions.setAssignedToFilter([])}},// "My accounts" is a shortcut: filter by the current user's own id. The@@ -526,43 +422,8 @@ export const accountsLogic = kea<accountsLogicType>([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 (a genuine contradiction) and the CSM/AE pickers- // (ANDing an OR-over-both-roles shortcut with an explicit single-role- // pick is more confusing than useful). The owner picker stays orthogonal.+ // unassigned flag — the two are a genuine contradiction.setAssignedToFilter: ({ value }) => {- if (value.length > 0) {- if (values.allRolesUnassigned) {- actions.setAllRolesUnassigned(false)- }- if (values.csmFilter.length > 0) {- actions.setCsmFilter([])- }- if (values.accountExecutiveFilter.length > 0) {- actions.setAccountExecutiveFilter([])- }- }- },- setCsmFilter: ({ value }) => {- if (value.length > 0) {- if (values.allRolesUnassigned) {- actions.setAllRolesUnassigned(false)- }- if (values.assignedToFilter.length > 0) {- actions.setAssignedToFilter([])- }- }- },- setAccountExecutiveFilter: ({ value }) => {- if (value.length > 0) {- if (values.allRolesUnassigned) {- actions.setAllRolesUnassigned(false)- }- if (values.assignedToFilter.length > 0) {- actions.setAssignedToFilter([])- }- }- },- setAccountOwnerFilter: ({ value }) => {if (value.length > 0 && values.allRolesUnassigned) {actions.setAllRolesUnassigned(false)}@@ -650,15 +511,6 @@ export const accountsLogic = kea<accountsLogicType>([if (values.assignedToFilter.length > 0) {actions.setAssignedToFilter([])}- if (values.csmFilter.length > 0) {- actions.setCsmFilter([])- }- if (values.accountExecutiveFilter.length > 0) {- actions.setAccountExecutiveFilter([])- }- if (values.accountOwnerFilter.length > 0) {- actions.setAccountOwnerFilter([])- }const term = externalId || nameif (term) {actions.setSearchQuery(term)@@ -707,9 +559,6 @@ export const accountsLogic = kea<accountsLogicType>([setTagsFilter: toUrl,setAllRolesUnassigned: toUrl,setAssignedToFilter: toUrl,- setCsmFilter: toUrl,- setAccountExecutiveFilter: toUrl,- setAccountOwnerFilter: toUrl,setSortOrder: toUrl,setSelectColumns: toUrl,selectColumn: toUrl,@@ -749,21 +598,6 @@ export const accountsLogic = kea<accountsLogicType>([actions.setAssignedToFilter(nextAssignedTo)}- const csm = normalizeRoleFilter(view.csm)- if (!objectsEqual(csm, values.csmFilter)) {- actions.setCsmFilter(csm)- }-- const accountExecutive = normalizeRoleFilter(view.accountExecutive)- if (!objectsEqual(accountExecutive, values.accountExecutiveFilter)) {- actions.setAccountExecutiveFilter(accountExecutive)- }-- const accountOwner = normalizeRoleFilter(view.accountOwner)- if (!objectsEqual(accountOwner, values.accountOwnerFilter)) {- actions.setAccountOwnerFilter(accountOwner)- }-const sort = view.sort ?? nullif (!objectsEqual(sort, values.sortOrder)) {actions.setSortOrder(sort)diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex c0283ba273cb..39f07be15af3 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -7211,15 +7211,9 @@ export interface AccountsQueryResponseApi {}export interface AccountsQueryApi {- /** Match accounts whose account executive is any of these user ids (OR semantics). */- accountExecutive?: number[] | null- /** Match accounts whose account owner is any of these user ids (OR semantics). */- accountOwner?: number[] | nullallRolesUnassigned?: boolean | null/** Match accounts where any of these user ids is the CSM or the account executive (OR over both roles). Drives the "My accounts" shortcut (the current user's id) and the shareable "Assigned to" filter — the ids are explicit so a shared URL resolves identically for every viewer. */assignedToUserIds?: number[] | null- /** Match accounts whose CSM is any of these user ids (OR semantics). */- csm?: number[] | null/** Optional HogQL boolean expression AND-ed into the WHERE clause. Used by the overview tile click-to-filter affordance. */filterExpression?: string | nullkind?: 'AccountsQuery'diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.tsindex c087a0bc81e6..a2cf370fcc7c 100644--- a/products/product_analytics/frontend/generated/api.schemas.ts+++ b/products/product_analytics/frontend/generated/api.schemas.ts@@ -6724,15 +6724,9 @@ export interface AccountsQueryResponseApi {}export interface AccountsQueryApi {- /** Match accounts whose account executive is any of these user ids (OR semantics). */- accountExecutive?: number[] | null- /** Match accounts whose account owner is any of these user ids (OR semantics). */- accountOwner?: number[] | nullallRolesUnassigned?: boolean | null/** Match accounts where any of these user ids is the CSM or the account executive (OR over both roles). Drives the "My accounts" shortcut (the current user's id) and the shareable "Assigned to" filter — the ids are explicit so a shared URL resolves identically for every viewer. */assignedToUserIds?: number[] | null- /** Match accounts whose CSM is any of these user ids (OR semantics). */- csm?: number[] | null/** Optional HogQL boolean expression AND-ed into the WHERE clause. Used by the overview tile click-to-filter affordance. */filterExpression?: string | nullkind?: 'AccountsQuery'diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 0e240c261b99..d47789fe0433 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -509,15 +509,9 @@ export namespace Schemas {}export interface AccountsQuery {- /** Match accounts whose account executive is any of these user ids (OR semantics). */- accountExecutive?: number[] | null;- /** Match accounts whose account owner is any of these user ids (OR semantics). */- accountOwner?: number[] | null;allRolesUnassigned?: boolean | null;/** Match accounts where any of these user ids is the CSM or the account executive (OR over both roles). Drives the "My accounts" shortcut (the current user's id) and the shareable "Assigned to" filter — the ids are explicit so a shared URL resolves identically for every viewer. */assignedToUserIds?: number[] | null;- /** Match accounts whose CSM is any of these user ids (OR semantics). */- csm?: number[] | null;/** Optional HogQL boolean expression AND-ed into the WHERE clause. Used by the overview tile click-to-filter affordance. */filterExpression?: string | null;kind?: 'AccountsQuery';