:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(customer-analytics): multi-select CSM/AE/owner account filters (#62241)
Arthur Moreira de Deus29cf5d6db83d
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.jsonindex 729a6d745a61..f72be3620c12 100644--- a/frontend/src/queries/schema.json+++ b/frontend/src/queries/schema.json@@ -22,16 +22,28 @@"additionalProperties": false,"properties": {"accountExecutive": {- "$ref": "#/definitions/AccountsRoleAssignmentFilter"+ "description": "Match accounts whose account executive is any of these user ids (OR semantics).",+ "items": {+ "$ref": "#/definitions/integer"+ },+ "type": "array"},"accountOwner": {- "$ref": "#/definitions/AccountsRoleAssignmentFilter"+ "description": "Match accounts whose account owner is any of these user ids (OR semantics).",+ "items": {+ "$ref": "#/definitions/integer"+ },+ "type": "array"},"allRolesUnassigned": {"type": "boolean"},"csm": {- "$ref": "#/definitions/AccountsRoleAssignmentFilter"+ "description": "Match accounts whose CSM is any of these user ids (OR semantics).",+ "items": {+ "$ref": "#/definitions/integer"+ },+ "type": "array"},"filterExpression": {"$ref": "#/definitions/HogQLExpression",@@ -175,17 +187,6 @@"required": ["columns", "hogql", "kind", "limit", "offset", "results", "types"],"type": "object"},- "AccountsRoleAssignmentFilter": {- "anyOf": [- {- "$ref": "#/definitions/integer"- },- {- "const": "unassigned",- "type": "string"- }- ]- },"ActionConversionGoal": {"additionalProperties": false,"properties": {diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.tsindex 112f48fe4115..c2abba30281b 100644--- a/frontend/src/queries/schema/schema-general.ts+++ b/frontend/src/queries/schema/schema-general.ts@@ -2300,8 +2300,6 @@ export interface AccountsQueryResponse extends AnalyticsQueryResponseBase {metricsResults?: (number | null)[]}-export type AccountsRoleAssignmentFilter = integer | 'unassigned'-export interface AccountsQuery extends DataNode<AccountsQueryResponse> {kind: NodeKind.AccountsQueryselect?: HogQLExpression[]@@ -2309,9 +2307,12 @@ export interface AccountsQuery extends DataNode<AccountsQueryResponse> {metrics?: HogQLExpression[]search?: stringtagNames?: string[]- csm?: AccountsRoleAssignmentFilter- accountExecutive?: AccountsRoleAssignmentFilter- accountOwner?: AccountsRoleAssignmentFilter+ /** 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[]allRolesUnassigned?: boolean/** Optional HogQL boolean expression AND-ed into the WHERE clause. Used by the overview tile click-to-filter affordance. */filterExpression?: HogQLExpressiondiff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex ee0ccec0e49b..4ad8d3b8fc60 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -2471,6 +2471,9 @@ importers:'@testing-library/dom':specifier: '*'version: 9.3.4+ '@testing-library/react':+ specifier: '*'+ version: 14.3.1(@types/[email protected])([email protected]([email protected]))([email protected])'@testing-library/user-event':specifier: '*'version: 14.6.1(@testing-library/[email protected])diff --git a/posthog/schema.py b/posthog/schema.pyindex 321987d6d6e6..c5a171c6eebc 100644--- a/posthog/schema.py+++ b/posthog/schema.py@@ -22810,10 +22810,19 @@ class AccountsQuery(BaseModel):model_config = ConfigDict(extra="forbid",)- accountExecutive: str | int | None = None- accountOwner: str | int | None = None+ 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 = None- csm: str | int | None = None+ 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 6d4b4052fc1b..e254fa5529a6 100644--- a/products/customer_analytics/backend/hogql_queries/accounts_query_runner.py+++ b/products/customer_analytics/backend/hogql_queries/accounts_query_runner.py@@ -164,19 +164,25 @@ class AccountsQueryRunner(AnalyticsQueryRunner[AccountsQueryResponse]):return parse_expr("id IN {subquery}", {"subquery": subquery})def _role_filter_expr(self, json_key: str, value: object) -> ast.Expr | None:- if value is None:+ if not value:return None- if value == "unassigned":- return self._role_id_isnull(json_key)- try:- user_id = int(value) # type: ignore[call-overload]- except (TypeError, ValueError):+ raw_values = value if isinstance(value, list) else [value]+ user_ids: list[int] = []+ for raw in raw_values:+ if isinstance(raw, int):+ user_ids.append(raw)+ elif isinstance(raw, str):+ try:+ user_ids.append(int(raw))+ except ValueError:+ continue+ if not user_ids:return Nonereturn parse_expr(- "JSONExtract(properties, {role_key}, 'id', 'Nullable(Int64)') = {user_id}",+ "JSONExtract(properties, {role_key}, 'id', 'Nullable(Int64)') IN {user_ids}",{"role_key": ast.Constant(value=json_key),- "user_id": ast.Constant(value=user_id),+ "user_ids": ast.Constant(value=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 41fa66e7f086..f402cb61bf49 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@@ -143,32 +143,27 @@ class TestAccountsQueryRunner(ClickhouseTestMixin, NonAtomicBaseTest):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)])+ self.assertEqual(self._ids(csm=[7]), [str(match.id)])- @parameterized.expand(- [- ("absent_keys", {"_properties": {}}),- ("null_valued_keys", {"properties": {}}),- ]- )- def test_csm_unassigned_matches_missing_and_null(self, _name, unassigned_kwargs):- create_account(team_id=self.team.id, name="Assigned", properties={"csm": {"id": 7, "email": "[email protected]"}})- unassigned = create_account(team_id=self.team.id, name="Unassigned", **unassigned_kwargs)- self.assertEqual(self._ids(csm="unassigned"), [str(unassigned.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)])+ 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)])+ self.assertEqual(self._ids(accountOwner=[7]), [str(match.id)])@parameterized.expand([@@ -194,13 +189,13 @@ class TestAccountsQueryRunner(ClickhouseTestMixin, NonAtomicBaseTest):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)])+ self.assertEqual(self._ids(csm=[7], tagNames=["enterprise"]), [str(match.id)])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(csm=[7]), [str(mine.id)])def test_ordering_by_name_asc(self):banana = create_account(team_id=self.team.id, name="Banana")@@ -365,7 +360,7 @@ class TestAccountsQueryRunner(ClickhouseTestMixin, NonAtomicBaseTest):# 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]"}})set_tags_on_object(["enterprise"], account)- self.assertEqual(self._ids(csm=7, tagNames=["enterprise"]), [str(account.id)])+ self.assertEqual(self._ids(csm=[7], 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/AccountsTabFilters.test.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsxnew file mode 100644index 000000000000..8153bf7d5307--- /dev/null+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.test.tsx@@ -0,0 +1,71 @@+import '@testing-library/jest-dom'++import { cleanup, render, screen } from '@testing-library/react'+import { BindLogic, Provider } from 'kea'++import { useMocks } from '~/mocks/jest'+import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'+import { initKeaTests } from '~/test/init'++import { ACCOUNTS_HOGQL_DATA_NODE_KEY } from '../../constants'+import { accountsLogic } from './accountsLogic'+import { AccountsTabFilters } from './AccountsTabFilters'++describe('AccountsTabFilters', () => {+ let logic: ReturnType<typeof accountsLogic.build>++ beforeEach(() => {+ useMocks({+ get: {+ '/api/organizations/:organization_id/members/': () => [200, { results: [] }],+ '/api/projects/:team_id/tags': () => [200, []],+ '/api/environments/:team_id/column_configurations': () => [200, { results: [] }],+ },+ })+ initKeaTests()+ logic = accountsLogic()+ logic.mount()+ })++ afterEach(() => {+ logic.unmount()+ cleanup()+ })++ function renderFilters(): void {+ render(+ <Provider>+ <BindLogic+ logic={dataNodeLogic}+ props={{ key: ACCOUNTS_HOGQL_DATA_NODE_KEY, query: {}, autoLoad: false }}+ >+ <AccountsTabFilters />+ </BindLogic>+ </Provider>+ )+ }++ // 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()+ })+})diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsxindex 1a1ebf87d88e..f8c9dbb18ac3 100644--- a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx@@ -3,7 +3,7 @@ import { useActions, useValues } from 'kea'import { IconChevronDown, IconRefresh, IconX } from '@posthog/icons'import { LemonButton, LemonCheckbox, LemonDropdown, LemonInput, LemonInputSelect } from '@posthog/lemon-ui'-import { MemberSelect } from 'lib/components/MemberSelect'+import { MemberSelectMultiple } from 'lib/components/MemberSelectMultiple'import { tagsModel } from '~/models/tagsModel'import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'@@ -142,15 +142,35 @@ function RolePicker({onChange: (value: RoleFilterValue) => voiddataAttr: string}): JSX.Element {+ const buttonLabel =+ value.length === 0 ? `Any ${label}` : value.length === 1 ? `1 ${label}` : `${value.length} ${label}s`return (- <div data-attr={dataAttr}>- <MemberSelect- size="small"- type="secondary"- defaultLabel={`Any ${label}`}- value={value}- onChange={(user) => onChange(user ? user.id : null)}- />+ <div className="flex gap-1 items-center" data-attr={dataAttr}>+ <LemonDropdown+ closeOnClickInside={false}+ overlay={+ <div className="p-2 min-w-64">+ <MemberSelectMultiple+ idKey="id"+ value={value}+ onChange={(users) => onChange(users.map((user) => user.id))}+ />+ </div>+ }+ >+ <LemonButton type="secondary" size="small" sideIcon={<IconChevronDown />}>+ {buttonLabel}+ </LemonButton>+ </LemonDropdown>+ {value.length > 0 && (+ <LemonButton+ type="secondary"+ size="small"+ icon={<IconX />}+ onClick={() => onChange([])}+ tooltip={`Clear ${label} filter`}+ />+ )}</div>)}diff --git a/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.tsindex 4c9f70fc792f..c0abcaecf33b 100644--- a/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts+++ b/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts@@ -75,9 +75,9 @@ describe('accountsLogic', () => {expect(logic.values.searchQuery).toBe('')expect(logic.values.tagsFilter).toEqual([])expect(logic.values.allRolesUnassigned).toBe(false)- expect(logic.values.csmFilter).toBeNull()- expect(logic.values.accountExecutiveFilter).toBeNull()- expect(logic.values.accountOwnerFilter).toBeNull()+ expect(logic.values.csmFilter).toEqual([])+ expect(logic.values.accountExecutiveFilter).toEqual([])+ expect(logic.values.accountOwnerFilter).toEqual([])})it('setTagsFilter updates the reducer', () => {@@ -107,33 +107,35 @@ describe('accountsLogic', () => {expect(logic.values.allRolesUnassigned).toBe(true)})- it('setCsmFilter accepts a user id and null', () => {- logic.actions.setCsmFilter(42)- expect(logic.values.csmFilter).toBe(42)- logic.actions.setCsmFilter(null)- expect(logic.values.csmFilter).toBeNull()+ 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)+ logic.actions.setCsmFilter([7])await expectLogic(logic).toFinishAllListeners()expect(logic.values.allRolesUnassigned).toBe(false)- expect(logic.values.csmFilter).toBe(7)+ 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.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).toBeNull()- expect(logic.values.accountExecutiveFilter).toBeNull()- expect(logic.values.accountOwnerFilter).toBeNull()+ expect(logic.values.csmFilter).toEqual([])+ expect(logic.values.accountExecutiveFilter).toEqual([])+ expect(logic.values.accountOwnerFilter).toEqual([])})describe('sortOrder', () => {@@ -228,7 +230,7 @@ describe('accountsLogic', () => {await expectLogic(logic, () => {logic.actions.setSearchQuery('acme')logic.actions.setTagsFilter(['enterprise'])- logic.actions.setCsmFilter(7)+ logic.actions.setCsmFilter([7])logic.actions.setSortOrder({ column: 'name', direction: 'desc' })logic.actions.setTileFilter({ tileId: 'tile-1', expression: 'count() > 5' })}).toFinishAllListeners()@@ -236,7 +238,7 @@ describe('accountsLogic', () => {expect(router.values.hashParams.view).toEqual({search: 'acme',tags: ['enterprise'],- csm: 7,+ csm: [7],sort: { column: 'name', direction: 'desc' },tileFilter: { tileId: 'tile-1', expression: 'count() > 5' },})@@ -257,18 +259,27 @@ describe('accountsLogic', () => {urls.customerAnalyticsAccounts(),{},{- view: { search: 'beta', csm: 7, sort: { column: 'name', direction: 'desc' }, tileFilter },+ view: { search: 'beta', csm: [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).toBe(7)+ expect(logic.values.csmFilter).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 } })+ await expectLogic(logic).toFinishAllListeners()++ expect(logic.values.csmFilter).toEqual([7])+ expect(logic.values.accountExecutiveFilter).toEqual([9])+ })+it('restores columns and shields them from a late saved column config', async () => {router.actions.push(urls.customerAnalyticsAccounts(),diff --git a/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountsLogic.tsindex 2d63d87ae4b5..b5c3a28640f6 100644--- a/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts+++ b/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts@@ -47,7 +47,18 @@ function clearSortIfColumnRemoved(values: SortLikeValues, actions: SortLikeActio}}-export type RoleFilterValue = number | null+export type RoleFilterValue = number[]++// Shared URLs persisted a single role id (e.g. `csm: 7`) before the filters+// became multi-select. Coerce any scalar (or malformed value) from the view+// hash into a `number[]` so restoring a legacy link can't poison the array+// (a stray number breaks the `.length`/`.map` the filters now rely on).+function normalizeRoleFilter(value: unknown): RoleFilterValue {+ if (Array.isArray(value)) {+ return value.filter((entry): entry is number => typeof entry === 'number')+ }+ return typeof value === 'number' ? [value] : []+}export type AccountRoleKey = 'csm' | 'account_executive' | 'account_owner'@@ -92,9 +103,9 @@ export interface AccountsViewUrlState {search?: stringtags?: string[]unassigned?: boolean- csm?: number- accountExecutive?: number- accountOwner?: number+ csm?: number[]+ accountExecutive?: number[]+ accountOwner?: number[]sort?: NonNullable<AccountSortOrder>columns?: string[]tileFilter?: TileFilter@@ -169,19 +180,19 @@ export const accountsLogic = kea<accountsLogicType>([},],csmFilter: [- null as RoleFilterValue,+ [] as RoleFilterValue,{setCsmFilter: (_, { value }) => value,},],accountExecutiveFilter: [- null as RoleFilterValue,+ [] as RoleFilterValue,{setAccountExecutiveFilter: (_, { value }) => value,},],accountOwnerFilter: [- null as RoleFilterValue,+ [] as RoleFilterValue,{setAccountOwnerFilter: (_, { value }) => value,},@@ -240,9 +251,9 @@ export const accountsLogic = kea<accountsLogicType>([[!!searchQuery.trim(),tagsFilter.length > 0,- csmFilter !== null,- accountExecutiveFilter !== null,- accountOwnerFilter !== null,+ csmFilter.length > 0,+ accountExecutiveFilter.length > 0,+ accountOwnerFilter.length > 0,allRolesUnassigned,].filter(Boolean).length,],@@ -280,13 +291,13 @@ export const accountsLogic = kea<accountsLogicType>([if (allRolesUnassigned) {state.unassigned = true}- if (csmFilter !== null) {+ if (csmFilter.length > 0) {state.csm = csmFilter}- if (accountExecutiveFilter !== null) {+ if (accountExecutiveFilter.length > 0) {state.accountExecutive = accountExecutiveFilter}- if (accountOwnerFilter !== null) {+ if (accountOwnerFilter.length > 0) {state.accountOwner = accountOwnerFilter}if (sortOrder) {@@ -344,13 +355,13 @@ export const accountsLogic = kea<accountsLogicType>([if (allRolesUnassigned) {source.allRolesUnassigned = true}- if (csmFilter !== null) {+ if (csmFilter.length > 0) {source.csm = csmFilter}- if (accountExecutiveFilter !== null) {+ if (accountExecutiveFilter.length > 0) {source.accountExecutive = accountExecutiveFilter}- if (accountOwnerFilter !== null) {+ if (accountOwnerFilter.length > 0) {source.accountOwner = accountOwnerFilter}if (tileFilter) {@@ -397,15 +408,18 @@ export const accountsLogic = kea<accountsLogicType>([breakcase 'csm':properties.value = values.csmFilter- properties.is_cleared = values.csmFilter === null+ properties.role_count = values.csmFilter.length+ properties.is_cleared = values.csmFilter.length === 0breakcase 'account_executive':properties.value = values.accountExecutiveFilter- properties.is_cleared = values.accountExecutiveFilter === null+ properties.role_count = values.accountExecutiveFilter.length+ properties.is_cleared = values.accountExecutiveFilter.length === 0breakcase 'account_owner':properties.value = values.accountOwnerFilter- properties.is_cleared = values.accountOwnerFilter === null+ properties.role_count = values.accountOwnerFilter.length+ properties.is_cleared = values.accountOwnerFilter.length === 0breakcase 'unassigned_only':properties.value = values.allRolesUnassigned@@ -416,29 +430,29 @@ export const accountsLogic = kea<accountsLogicType>([},setAllRolesUnassigned: ({ value }) => {if (value) {- if (values.csmFilter !== null) {- actions.setCsmFilter(null)+ if (values.csmFilter.length > 0) {+ actions.setCsmFilter([])}- if (values.accountExecutiveFilter !== null) {- actions.setAccountExecutiveFilter(null)+ if (values.accountExecutiveFilter.length > 0) {+ actions.setAccountExecutiveFilter([])}- if (values.accountOwnerFilter !== null) {- actions.setAccountOwnerFilter(null)+ if (values.accountOwnerFilter.length > 0) {+ actions.setAccountOwnerFilter([])}}},setCsmFilter: ({ value }) => {- if (value !== null && values.allRolesUnassigned) {+ if (value.length > 0 && values.allRolesUnassigned) {actions.setAllRolesUnassigned(false)}},setAccountExecutiveFilter: ({ value }) => {- if (value !== null && values.allRolesUnassigned) {+ if (value.length > 0 && values.allRolesUnassigned) {actions.setAllRolesUnassigned(false)}},setAccountOwnerFilter: ({ value }) => {- if (value !== null && values.allRolesUnassigned) {+ if (value.length > 0 && values.allRolesUnassigned) {actions.setAllRolesUnassigned(false)}},@@ -552,18 +566,18 @@ export const accountsLogic = kea<accountsLogicType>([actions.setAllRolesUnassigned(unassigned)}- const csm = view.csm ?? null- if (csm !== values.csmFilter) {+ const csm = normalizeRoleFilter(view.csm)+ if (!objectsEqual(csm, values.csmFilter)) {actions.setCsmFilter(csm)}- const accountExecutive = view.accountExecutive ?? null- if (accountExecutive !== values.accountExecutiveFilter) {+ const accountExecutive = normalizeRoleFilter(view.accountExecutive)+ if (!objectsEqual(accountExecutive, values.accountExecutiveFilter)) {actions.setAccountExecutiveFilter(accountExecutive)}- const accountOwner = view.accountOwner ?? null- if (accountOwner !== values.accountOwnerFilter) {+ const accountOwner = normalizeRoleFilter(view.accountOwner)+ if (!objectsEqual(accountOwner, values.accountOwnerFilter)) {actions.setAccountOwnerFilter(accountOwner)}diff --git a/products/customer_analytics/package.json b/products/customer_analytics/package.jsonindex 14bbfadc4922..583d1666448f 100644--- a/products/customer_analytics/package.json+++ b/products/customer_analytics/package.json@@ -18,6 +18,7 @@"@posthog/icons": "*","@storybook/react": "catalog:","@testing-library/dom": "*",+ "@testing-library/react": "*","@testing-library/user-event": "*","@types/react": "*","clsx": "*",diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.tsindex 53fd18316692..4671bfce875e 100644--- a/products/dashboards/frontend/generated/api.schemas.ts+++ b/products/dashboards/frontend/generated/api.schemas.ts@@ -7019,10 +7019,13 @@ export interface AccountsQueryResponseApi {}export interface AccountsQueryApi {- accountExecutive?: string | number | null- accountOwner?: string | number | null+ /** 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- csm?: string | 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 3d19593f9c14..67ee9c74d426 100644--- a/products/product_analytics/frontend/generated/api.schemas.ts+++ b/products/product_analytics/frontend/generated/api.schemas.ts@@ -6712,10 +6712,13 @@ export interface AccountsQueryResponseApi {}export interface AccountsQueryApi {- accountExecutive?: string | number | null- accountOwner?: string | number | null+ /** 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- csm?: string | 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 ea94fb33732c..58a14c501445 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -509,10 +509,13 @@ export namespace Schemas {}export interface AccountsQuery {- accountExecutive?: string | number | null;- accountOwner?: string | number | null;+ /** 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;- csm?: string | 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';