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): filter accounts by native fields (#86828)

Arthur Moreira de Deus17e484483c6f
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index ee740ea2a1f0..eae45728c378 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -5757,9 +5757,9 @@ snapshots:
scenes-app-customer-analytics-accounts--default--light:
hash: v1.k794b7964.faa5deb2da376bb4364cc185f6ca36d5ef4e5f12af269420f106569f0847011d.I72hc0cqrIF69Nf3LBXC_FxP4Wb9n8qYouNiokLvDv4
scenes-app-customer-analytics-accounts--empty--dark:
- hash: v1.k794b7964.892b7da6722a32bd8383152a945e4bbc30eefebf1b9daa79d615e55a969e1a52._oCcXCKvTuiGNNd4h0WZ2YoMvWXtHmgHCxHmljYucH0
+ hash: v1.k794b7964.335e429043f942468f4d038a2089b48bc2e2c4fd02dff40af100bb8e46e9731a.0yyxMsPpYP8LN8AMi5eNS6uZqCB5w0EQKMKSXfxoqtQ
scenes-app-customer-analytics-accounts--empty--light:
- hash: v1.k794b7964.fc9180344a16b4c4831f1c377d8f603b5df857f6f9822bb3075e95d8290659a4.eZFjKAI4DZ4GhnNMihMFzc7-Eu_7X5Pf-rBe1j1cP5M
+ hash: v1.k794b7964.3cf93a7ca9fe5453e14210067583f16a552a95cdf5882a11ec97ef1b57b35c68.OukR8G27tpqoK_OXjeHBf4HvZPbFTFQ04lipBl4DsFc
scenes-app-customer-analytics-accounts--feature-gate-off--dark:
hash: v1.k794b7964.4b8d5226ee154debdf333ff93d65a90ca766bcb25951e1baf36affb8b84b548d.dWZSHssPc83RkHVE-JPJA562bJR7MUim2yfqhjfNE50
scenes-app-customer-analytics-accounts--feature-gate-off--light:
diff --git a/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx b/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx
index 5a14f1c901be..d8a2e7915b17 100644
--- a/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx
+++ b/frontend/src/lib/components/PropertiesTable/PropertiesTable.tsx
@@ -266,6 +266,7 @@ export function PropertiesTable({
[PropertyDefinitionType.Event]: TaxonomicFilterGroupType.EventProperties,
[PropertyDefinitionType.EventMetadata]: TaxonomicFilterGroupType.EventMetadata,
[PropertyDefinitionType.RevenueAnalytics]: TaxonomicFilterGroupType.RevenueAnalyticsProperties,
+ [PropertyDefinitionType.Account]: TaxonomicFilterGroupType.AccountFields,
[PropertyDefinitionType.AccountCustomProperty]: TaxonomicFilterGroupType.AccountCustomProperties,
[PropertyDefinitionType.Person]: TaxonomicFilterGroupType.PersonProperties,
[PropertyDefinitionType.PersonMetadata]: TaxonomicFilterGroupType.PersonMetadata,
diff --git a/frontend/src/lib/components/PropertyFilters/components/taxonomicPropertyFilterLogic.ts b/frontend/src/lib/components/PropertyFilters/components/taxonomicPropertyFilterLogic.ts
index 446893e3f23e..be80f27dab9e 100644
--- a/frontend/src/lib/components/PropertyFilters/components/taxonomicPropertyFilterLogic.ts
+++ b/frontend/src/lib/components/PropertyFilters/components/taxonomicPropertyFilterLogic.ts
@@ -239,6 +239,11 @@ export const taxonomicPropertyFilterLogic = kea<taxonomicPropertyFilterLogicType
eventMetadataFilter.label = item.name
}
+ if (propertyType === PropertyFilterType.Account && item?.name) {
+ const accountPropertyFilter = filter as { label?: string }
+ accountPropertyFilter.label = item.name
+ }
+
// The key is the definition id (a UUID), so keep the human-readable name for display
if (propertyType === PropertyFilterType.AccountCustomProperty && item?.name) {
const accountCustomPropertyFilter = filter as AccountCustomPropertyFilter
diff --git a/frontend/src/lib/components/PropertyFilters/propertyFilterLogic.ts b/frontend/src/lib/components/PropertyFilters/propertyFilterLogic.ts
index 93f9e4337f65..e1ab16f64dbd 100644
--- a/frontend/src/lib/components/PropertyFilters/propertyFilterLogic.ts
+++ b/frontend/src/lib/components/PropertyFilters/propertyFilterLogic.ts
@@ -35,6 +35,7 @@ const TAXONOMIC_GROUP_TYPE_TO_DISPLAY_NAME: Partial<Record<TaxonomicFilterGroupT
[TaxonomicFilterGroupType.FeatureFlags]: 'Feature flags',
[TaxonomicFilterGroupType.ErrorTrackingIssues]: 'Error tracking issues',
[TaxonomicFilterGroupType.RevenueAnalyticsProperties]: 'Revenue analytics',
+ [TaxonomicFilterGroupType.AccountFields]: 'Account fields',
[TaxonomicFilterGroupType.AccountCustomProperties]: 'Account custom properties',
}
diff --git a/frontend/src/lib/components/PropertyFilters/utils.ts b/frontend/src/lib/components/PropertyFilters/utils.ts
index 4abadea0a5a2..911db49194d3 100644
--- a/frontend/src/lib/components/PropertyFilters/utils.ts
+++ b/frontend/src/lib/components/PropertyFilters/utils.ts
@@ -117,6 +117,7 @@ export const PROPERTY_FILTER_TYPE_TO_TAXONOMIC_FILTER_GROUP_TYPE: Record<Propert
[PropertyFilterType.Person]: TaxonomicFilterGroupType.PersonProperties,
[PropertyFilterType.Event]: TaxonomicFilterGroupType.EventProperties,
[PropertyFilterType.InternalEvent]: TaxonomicFilterGroupType.EventProperties,
+ [PropertyFilterType.Account]: TaxonomicFilterGroupType.AccountFields,
[PropertyFilterType.AccountCustomProperty]: TaxonomicFilterGroupType.AccountCustomProperties,
[PropertyFilterType.EventMetadata]: TaxonomicFilterGroupType.EventMetadata,
[PropertyFilterType.PersonMetadata]: TaxonomicFilterGroupType.PersonMetadata,
@@ -446,6 +447,7 @@ const propertyFilterMapping: Partial<Record<PropertyFilterType, TaxonomicFilterG
[PropertyFilterType.SpanAttribute]: TaxonomicFilterGroupType.SpanAttributes,
[PropertyFilterType.SpanResourceAttribute]: TaxonomicFilterGroupType.SpanResourceAttributes,
[PropertyFilterType.RevenueAnalytics]: TaxonomicFilterGroupType.RevenueAnalyticsProperties,
+ [PropertyFilterType.Account]: TaxonomicFilterGroupType.AccountFields,
[PropertyFilterType.AccountCustomProperty]: TaxonomicFilterGroupType.AccountCustomProperties,
[PropertyFilterType.Flag]: TaxonomicFilterGroupType.FeatureFlags,
[PropertyFilterType.WorkflowVariable]: TaxonomicFilterGroupType.WorkflowVariables,
@@ -503,6 +505,7 @@ export function propertyFilterTypeToPropertyDefinitionType(
[PropertyFilterType.SpanAttribute]: PropertyDefinitionType.SpanAttribute,
[PropertyFilterType.SpanResourceAttribute]: PropertyDefinitionType.SpanResourceAttribute,
[PropertyFilterType.RevenueAnalytics]: PropertyDefinitionType.RevenueAnalytics,
+ [PropertyFilterType.Account]: PropertyDefinitionType.Account,
[PropertyFilterType.AccountCustomProperty]: PropertyDefinitionType.AccountCustomProperty,
[PropertyFilterType.Flag]: PropertyDefinitionType.FlagValue,
[PropertyFilterType.WorkflowVariable]: PropertyDefinitionType.WorkflowVariable,
diff --git a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
index 68e9730f48d1..4727fd651759 100644
--- a/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/taxonomicFilterLogic.tsx
@@ -69,6 +69,7 @@ import { capitalizeFirstLetter, pluralize } from 'lib/utils/strings'
import { toParams } from 'lib/utils/url'
import {
getAccountCustomPropertyDefinitionIcon,
+ getAccountFieldDefinitionIcon,
getEventDefinitionIcon,
getEventMetadataDefinitionIcon,
getPersonPropertyDefinitionIcon,
@@ -1351,8 +1352,17 @@ export const taxonomicFilterLogic = kea<taxonomicFilterLogicType>([
getPopoverHeader: () => 'Revenue analytics properties',
},
{
- name: 'Custom properties',
- searchPlaceholder: 'custom properties',
+ name: 'Account fields',
+ searchPlaceholder: 'account fields',
+ type: TaxonomicFilterGroupType.AccountFields,
+ getIcon: getAccountFieldDefinitionIcon,
+ getName: (option: PropertyDefinition) => option.name,
+ getValue: (option: PropertyDefinition) => option.id,
+ getPopoverHeader: () => 'Account field',
+ },
+ {
+ name: 'Account custom properties',
+ searchPlaceholder: 'account custom properties',
type: TaxonomicFilterGroupType.AccountCustomProperties,
// Account custom property definitions are per-team API data, so the
// options come from the consumer via `optionsFromProp` — items carry
diff --git a/frontend/src/lib/components/TaxonomicFilter/types.ts b/frontend/src/lib/components/TaxonomicFilter/types.ts
index d7e7b34db0b9..4ef78f19486b 100644
--- a/frontend/src/lib/components/TaxonomicFilter/types.ts
+++ b/frontend/src/lib/components/TaxonomicFilter/types.ts
@@ -341,6 +341,7 @@ export enum TaxonomicFilterGroupType {
Replay = 'replay',
ReplaySavedFilters = 'replay_saved_filters',
RevenueAnalyticsProperties = 'revenue_analytics_properties',
+ AccountFields = 'account_fields',
AccountCustomProperties = 'account_custom_properties',
Resources = 'resources',
ErrorTrackingProperties = 'error_tracking_properties',
diff --git a/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx b/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx
index e65a2a923991..84e5f3a53d9b 100644
--- a/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx
+++ b/frontend/src/lib/components/TaxonomicFilter/utils/buildTaxonomicGroups.tsx
@@ -31,6 +31,7 @@ import { isString } from 'lib/utils/guards'
import { pluralize } from 'lib/utils/strings'
import {
getAccountCustomPropertyDefinitionIcon,
+ getAccountFieldDefinitionIcon,
getEventDefinitionIcon,
getEventMetadataDefinitionIcon,
getPersonPropertyDefinitionIcon,
@@ -536,8 +537,17 @@ export function buildTaxonomicGroups(ctx: BuildTaxonomicGroupsContext): Taxonomi
getPopoverHeader: () => 'Revenue analytics properties',
},
{
- name: 'Custom properties',
- searchPlaceholder: 'custom properties',
+ name: 'Account fields',
+ searchPlaceholder: 'account fields',
+ type: TaxonomicFilterGroupType.AccountFields,
+ getIcon: getAccountFieldDefinitionIcon,
+ getName: (option: PropertyDefinition) => option.name,
+ getValue: (option: PropertyDefinition) => option.id,
+ getPopoverHeader: () => 'Account field',
+ },
+ {
+ name: 'Account custom properties',
+ searchPlaceholder: 'account custom properties',
type: TaxonomicFilterGroupType.AccountCustomProperties,
// Mirrors the legacy taxonomicFilterLogic group: account custom property definitions
// are per-team API data, so the options come from the consumer via `optionsFromProp` —
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 6105689343ae..b574a413af99 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -273,6 +273,43 @@
"required": ["kind", "field"],
"type": "object"
},
+ "AccountsTableAccountFieldFilter": {
+ "additionalProperties": false,
+ "properties": {
+ "field": {
+ "$ref": "#/definitions/AccountsTableAccountField"
+ },
+ "kind": {
+ "const": "account_field",
+ "type": "string"
+ },
+ "operator": {
+ "$ref": "#/definitions/AccountsTableAccountFieldOperator"
+ },
+ "values": {
+ "items": {
+ "type": "string"
+ },
+ "type": "array"
+ }
+ },
+ "required": ["kind", "field", "operator"],
+ "type": "object"
+ },
+ "AccountsTableAccountFieldOperator": {
+ "enum": [
+ "exact",
+ "is_not",
+ "icontains",
+ "not_icontains",
+ "is_set",
+ "is_not_set",
+ "is_date_exact",
+ "is_date_before",
+ "is_date_after"
+ ],
+ "type": "string"
+ },
"AccountsTableAccountIdFilter": {
"additionalProperties": false,
"properties": {
@@ -505,6 +542,9 @@
{
"$ref": "#/definitions/AccountsTableAccountIdFilter"
},
+ {
+ "$ref": "#/definitions/AccountsTableAccountFieldFilter"
+ },
{
"$ref": "#/definitions/AccountsTableCustomPropertyFilter"
}
@@ -38193,6 +38233,7 @@
"data_warehouse_person_property",
"error_tracking_issue",
"revenue_analytics",
+ "account",
"account_custom_property",
"flag",
"log",
@@ -51007,6 +51048,7 @@
"replay",
"replay_saved_filters",
"revenue_analytics_properties",
+ "account_fields",
"account_custom_properties",
"resources",
"error_tracking_properties",
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index 57cb3ee0fc99..d89534e3ee78 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -2968,6 +2968,25 @@ export interface AccountsTableAccountIdFilter {
accountId: string
}
+export enum AccountsTableAccountFieldOperator {
+ Exact = 'exact',
+ IsNot = 'is_not',
+ Contains = 'icontains',
+ DoesNotContain = 'not_icontains',
+ IsSet = 'is_set',
+ IsNotSet = 'is_not_set',
+ DateExact = 'is_date_exact',
+ DateBefore = 'is_date_before',
+ DateAfter = 'is_date_after',
+}
+
+export interface AccountsTableAccountFieldFilter {
+ kind: 'account_field'
+ field: AccountsTableAccountField
+ operator: AccountsTableAccountFieldOperator
+ values?: string[]
+}
+
export enum AccountsTableCustomPropertyOperator {
Exact = 'exact',
IsNot = 'is_not',
@@ -3004,6 +3023,7 @@ export type AccountsTableFilter =
| AccountsTableAssignedToFilter
| AccountsTableUnassignedFilter
| AccountsTableAccountIdFilter
+ | AccountsTableAccountFieldFilter
| AccountsTableCustomPropertyFilter
export type AccountsTableCustomPropertyValue = string | number | boolean | null
diff --git a/frontend/src/scenes/data-management/events/DefinitionHeader.tsx b/frontend/src/scenes/data-management/events/DefinitionHeader.tsx
index 1f69592fc4c1..c0ffb85d0e04 100644
--- a/frontend/src/scenes/data-management/events/DefinitionHeader.tsx
+++ b/frontend/src/scenes/data-management/events/DefinitionHeader.tsx
@@ -75,6 +75,12 @@ export function getPropertyDefinitionIcon(definition: PropertyDefinition): JSX.E
)
}
+export function getAccountFieldDefinitionIcon(): JSX.Element {
+ return (
+ <IconWithBadge icon={<IconList />} tooltipTitle="Account field" className="taxonomy-icon taxonomy-icon-muted" />
+ )
+}
+
export function getAccountCustomPropertyDefinitionIcon(
definition: PropertyDefinition & { is_canonical?: boolean }
): JSX.Element {
diff --git a/frontend/src/scenes/insights/filters/BreakdownFilter/taxonomicBreakdownFilterLogic.ts b/frontend/src/scenes/insights/filters/BreakdownFilter/taxonomicBreakdownFilterLogic.ts
index d6f9eb03dbb6..f4e809d30c00 100644
--- a/frontend/src/scenes/insights/filters/BreakdownFilter/taxonomicBreakdownFilterLogic.ts
+++ b/frontend/src/scenes/insights/filters/BreakdownFilter/taxonomicBreakdownFilterLogic.ts
@@ -121,6 +121,7 @@ export interface taxonomicBreakdownFilterLogicValues {
| TaxonomicFilterGroupType.Replay
| TaxonomicFilterGroupType.ReplaySavedFilters
| TaxonomicFilterGroupType.RevenueAnalyticsProperties
+ | TaxonomicFilterGroupType.AccountFields
| TaxonomicFilterGroupType.AccountCustomProperties
| TaxonomicFilterGroupType.Resources
| TaxonomicFilterGroupType.ErrorTrackingProperties
@@ -285,6 +286,7 @@ export interface taxonomicBreakdownFilterLogicMeta {
| TaxonomicFilterGroupType.Replay
| TaxonomicFilterGroupType.ReplaySavedFilters
| TaxonomicFilterGroupType.RevenueAnalyticsProperties
+ | TaxonomicFilterGroupType.AccountFields
| TaxonomicFilterGroupType.AccountCustomProperties
| TaxonomicFilterGroupType.Resources
| TaxonomicFilterGroupType.ErrorTrackingProperties
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index e5b6a54e4fc7..8e009c333f52 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -1176,6 +1176,7 @@ export enum PropertyFilterType {
DataWarehousePersonProperty = 'data_warehouse_person_property',
ErrorTrackingIssue = 'error_tracking_issue',
RevenueAnalytics = 'revenue_analytics',
+ Account = 'account',
/** Customer analytics account custom property — the key is the property definition id */
AccountCustomProperty = 'account_custom_property',
/** Feature flag dependency */
@@ -4789,6 +4790,7 @@ export enum PropertyDefinitionType {
Event = 'event',
EventMetadata = 'event_metadata',
RevenueAnalytics = 'revenue_analytics',
+ Account = 'account',
AccountCustomProperty = 'account_custom_property',
Person = 'person',
PersonMetadata = 'person_metadata',
diff --git a/posthog/schema.py b/posthog/schema.py
index 44a212bdeb4d..20fc57753f3c 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -14,6 +14,7 @@ from posthog.schema_discriminators import property_filter_discriminator
from posthog.schema_enums import (
AccessControlLevel as AccessControlLevel,
AccountsTableAccountField as AccountsTableAccountField,
+ AccountsTableAccountFieldOperator as AccountsTableAccountFieldOperator,
AccountsTableAggregation as AccountsTableAggregation,
AccountsTableCustomPropertyOperator as AccountsTableCustomPropertyOperator,
AccountsTableSortDirection as AccountsTableSortDirection,
@@ -3091,6 +3092,16 @@ class AccountCustomPropertyFilter(BaseModel):
value: list[str | float | bool] | str | float | bool | None = None
+class AccountsTableAccountFieldFilter(BaseModel):
+ model_config = ConfigDict(
+ extra="forbid",
+ )
+ field: AccountsTableAccountField
+ kind: Literal["account_field"] = "account_field"
+ operator: AccountsTableAccountFieldOperator
+ values: list[str] | None = None
+
+
class AccountsTableAggregateMetric(BaseModel):
model_config = ConfigDict(
extra="forbid",
@@ -24622,6 +24633,7 @@ class AccountsTableQuery(BaseModel):
| AccountsTableAssignedToFilter
| AccountsTableUnassignedFilter
| AccountsTableAccountIdFilter
+ | AccountsTableAccountFieldFilter
| AccountsTableCustomPropertyFilter
]
| None
diff --git a/posthog/schema_enums.py b/posthog/schema_enums.py
index 3ed14ecf229b..34797ee1e6b9 100644
--- a/posthog/schema_enums.py
+++ b/posthog/schema_enums.py
@@ -44,6 +44,18 @@ class AccountsTableAccountField(StrEnum):
ZENDESK_ID = "zendesk_id"
+class AccountsTableAccountFieldOperator(StrEnum):
+ EXACT = "exact"
+ IS_NOT = "is_not"
+ ICONTAINS = "icontains"
+ NOT_ICONTAINS = "not_icontains"
+ IS_SET = "is_set"
+ IS_NOT_SET = "is_not_set"
+ IS_DATE_EXACT = "is_date_exact"
+ IS_DATE_BEFORE = "is_date_before"
+ IS_DATE_AFTER = "is_date_after"
+
+
class AccountsTableAggregation(StrEnum):
SUM = "sum"
AVG = "avg"
@@ -3617,6 +3629,7 @@ class PropertyFilterType(StrEnum):
DATA_WAREHOUSE_PERSON_PROPERTY = "data_warehouse_person_property"
ERROR_TRACKING_ISSUE = "error_tracking_issue"
REVENUE_ANALYTICS = "revenue_analytics"
+ ACCOUNT = "account"
ACCOUNT_CUSTOM_PROPERTY = "account_custom_property"
FLAG = "flag"
LOG = "log"
@@ -4043,6 +4056,7 @@ class TaxonomicFilterGroupType(StrEnum):
REPLAY = "replay"
REPLAY_SAVED_FILTERS = "replay_saved_filters"
REVENUE_ANALYTICS_PROPERTIES = "revenue_analytics_properties"
+ ACCOUNT_FIELDS = "account_fields"
ACCOUNT_CUSTOM_PROPERTIES = "account_custom_properties"
RESOURCES = "resources"
ERROR_TRACKING_PROPERTIES = "error_tracking_properties"
diff --git a/products/customer_analytics/backend/facade/api.py b/products/customer_analytics/backend/facade/api.py
index a86d40b8bb40..45223d64be6b 100644
--- a/products/customer_analytics/backend/facade/api.py
+++ b/products/customer_analytics/backend/facade/api.py
@@ -2684,20 +2684,110 @@ def _validate_account_table_definitions(
return custom_property_display_types
+ACCOUNT_TABLE_TEXT_FIELDS = frozenset(
+ {
+ contracts.AccountTableField.NAME,
+ contracts.AccountTableField.EXTERNAL_ID,
+ contracts.AccountTableField.STRIPE_CUSTOMER_ID,
+ contracts.AccountTableField.HUBSPOT_DEAL_ID,
+ contracts.AccountTableField.BILLING_ID,
+ contracts.AccountTableField.SFDC_ID,
+ contracts.AccountTableField.ZENDESK_ID,
+ }
+)
+ACCOUNT_TABLE_DATETIME_FIELDS = frozenset(
+ {
+ contracts.AccountTableField.CREATED_AT,
+ contracts.AccountTableField.UPDATED_AT,
+ contracts.AccountTableField.CHURNED_AT,
+ contracts.AccountTableField.IGNORED_AT,
+ }
+)
+ACCOUNT_TABLE_DIRECT_FIELDS = {
+ contracts.AccountTableField.NAME: "name",
+ contracts.AccountTableField.EXTERNAL_ID: "external_id",
+ contracts.AccountTableField.CREATED_AT: "created_at",
+ contracts.AccountTableField.UPDATED_AT: "updated_at",
+ contracts.AccountTableField.CHURNED_AT: "churned_at",
+ contracts.AccountTableField.IGNORED_AT: "ignored_at",
+}
+
+
def _coerce_datetime_filter_value(value: float | bool | str) -> datetime:
if not isinstance(value, str):
- raise InvalidAccountTableColumn("Date custom property filters require ISO-8601 values.")
+ raise InvalidAccountTableColumn("Date filters require ISO-8601 values.")
parsed_datetime = parse_datetime(value)
if parsed_datetime is None:
parsed_date = parse_date(value)
if parsed_date is None:
- raise InvalidAccountTableColumn("Date custom property filters require ISO-8601 values.")
+ raise InvalidAccountTableColumn("Date filters require ISO-8601 values.")
parsed_datetime = datetime.combine(parsed_date, time.min, tzinfo=UTC)
elif timezone.is_naive(parsed_datetime):
parsed_datetime = timezone.make_aware(parsed_datetime, UTC)
return parsed_datetime
+def _apply_account_table_field_filter(
+ queryset: QuerySet[Account], filter_: contracts.AccountTableFieldFilter
+) -> QuerySet[Account]:
+ field = filter_.field
+ operator = filter_.operator
+ values = filter_.values
+ field_lookup = ACCOUNT_TABLE_DIRECT_FIELDS.get(field)
+ if field_lookup is None:
+ field_lookup = f"_account_table_filter_{field.value}"
+ queryset = queryset.annotate(**{field_lookup: KeyTextTransform(field.value, "_properties")})
+
+ if operator == contracts.AccountTableFieldOperator.IS_SET:
+ return queryset.filter(**{f"{field_lookup}__isnull": False})
+ if operator == contracts.AccountTableFieldOperator.IS_NOT_SET:
+ return queryset.filter(**{f"{field_lookup}__isnull": True})
+ if not values:
+ raise InvalidAccountTableColumn("Account field filters require at least one value.")
+
+ if field in ACCOUNT_TABLE_TEXT_FIELDS:
+ if operator == contracts.AccountTableFieldOperator.EXACT:
+ return queryset.filter(**{f"{field_lookup}__in": values})
+ if operator == contracts.AccountTableFieldOperator.IS_NOT:
+ return queryset.filter(Q(**{f"{field_lookup}__isnull": True}) | ~Q(**{f"{field_lookup}__in": values}))
+ if operator in {
+ contracts.AccountTableFieldOperator.CONTAINS,
+ contracts.AccountTableFieldOperator.DOES_NOT_CONTAIN,
+ }:
+ predicate = Q()
+ for value in values:
+ predicate |= Q(**{f"{field_lookup}__icontains": value})
+ if operator == contracts.AccountTableFieldOperator.DOES_NOT_CONTAIN:
+ return queryset.filter(Q(**{f"{field_lookup}__isnull": True}) | ~predicate)
+ return queryset.filter(predicate)
+ raise InvalidAccountTableColumn(f"Operator {operator.value} does not support text account fields.")
+
+ if field in ACCOUNT_TABLE_DATETIME_FIELDS:
+ if len(values) != 1:
+ raise InvalidAccountTableColumn("Date account field filters require one value.")
+ target = _coerce_datetime_filter_value(values[0])
+ if operator == contracts.AccountTableFieldOperator.DATE_EXACT:
+ target_date = target.replace(hour=0, minute=0, second=0, microsecond=0)
+ return queryset.filter(
+ **{f"{field_lookup}__gte": target_date, f"{field_lookup}__lt": target_date + timedelta(days=1)}
+ )
+ lookup = {
+ contracts.AccountTableFieldOperator.DATE_BEFORE: "lt",
+ contracts.AccountTableFieldOperator.DATE_AFTER: "gt",
+ }.get(operator)
+ if lookup is None:
+ raise InvalidAccountTableColumn(f"Operator {operator.value} does not support date account fields.")
+ return queryset.filter(**{f"{field_lookup}__{lookup}": target})
+
+ raise InvalidAccountTableColumn(f"Unsupported account table field: {field.value}")
+
+
+def _filters_account_table_field(
+ filters: tuple[contracts.AccountTableFilter, ...], field: contracts.AccountTableField
+) -> bool:
+ return any(isinstance(filter_, contracts.AccountTableFieldFilter) and filter_.field == field for filter_ in filters)
+
+
def _coerce_custom_property_filter_values(
filter_: contracts.AccountTableCustomPropertyFilter, display_type: DisplayType
) -> tuple[float | bool | str | datetime, ...]:
@@ -2837,6 +2927,8 @@ def _apply_account_table_filters(
queryset = queryset.filter(~Exists(active_relationships))
elif isinstance(filter_, contracts.AccountTableAccountIdFilter):
queryset = queryset.filter(id=filter_.account_id)
+ elif isinstance(filter_, contracts.AccountTableFieldFilter):
+ queryset = _apply_account_table_field_filter(queryset, filter_)
elif isinstance(filter_, contracts.AccountTableCustomPropertyFilter):
active_values = CustomPropertyValue.objects.for_team(team_id).filter(
account_id=OuterRef("pk"), definition_id=filter_.definition_id, is_deleted=False
@@ -2979,9 +3071,9 @@ def query_accounts_metrics(
raise InvalidAccountTableColumn("Account table metrics require numeric custom properties.")
accounts = _accounts_queryset(team_id, user_access_control)
- if not include_churned:
+ if not include_churned and not _filters_account_table_field(filters, contracts.AccountTableField.CHURNED_AT):
accounts = accounts.filter(churned_at__isnull=True)
- if not include_ignored:
+ if not include_ignored and not _filters_account_table_field(filters, contracts.AccountTableField.IGNORED_AT):
accounts = accounts.filter(ignored_at__isnull=True)
accounts = _apply_account_table_filters(
accounts,
@@ -3059,9 +3151,9 @@ def query_accounts_table(
)
queryset = _accounts_queryset(team_id, user_access_control)
- if not include_churned:
+ if not include_churned and not _filters_account_table_field(filters, contracts.AccountTableField.CHURNED_AT):
queryset = queryset.filter(churned_at__isnull=True)
- if not include_ignored:
+ if not include_ignored and not _filters_account_table_field(filters, contracts.AccountTableField.IGNORED_AT):
queryset = queryset.filter(ignored_at__isnull=True)
queryset = _apply_account_table_filters(
queryset,
diff --git a/products/customer_analytics/backend/facade/contracts.py b/products/customer_analytics/backend/facade/contracts.py
index 43eaa9261f17..01b152e85b02 100644
--- a/products/customer_analytics/backend/facade/contracts.py
+++ b/products/customer_analytics/backend/facade/contracts.py
@@ -235,6 +235,25 @@ class AccountTableAccountIdFilter:
account_id: UUID
+class AccountTableFieldOperator(str, Enum):
+ EXACT = "exact"
+ IS_NOT = "is_not"
+ CONTAINS = "icontains"
+ DOES_NOT_CONTAIN = "not_icontains"
+ IS_SET = "is_set"
+ IS_NOT_SET = "is_not_set"
+ DATE_EXACT = "is_date_exact"
+ DATE_BEFORE = "is_date_before"
+ DATE_AFTER = "is_date_after"
+
+
+@dataclass(frozen=True, kw_only=True)
+class AccountTableFieldFilter:
+ field: AccountTableField
+ operator: AccountTableFieldOperator
+ values: tuple[str, ...] = ()
+
+
class AccountTableCustomPropertyOperator(str, Enum):
EXACT = "exact"
IS_NOT = "is_not"
@@ -266,6 +285,7 @@ AccountTableFilter = (
| AccountTableAssignedToFilter
| AccountTableUnassignedFilter
| AccountTableAccountIdFilter
+ | AccountTableFieldFilter
| AccountTableCustomPropertyFilter
)
diff --git a/products/customer_analytics/backend/hogql_queries/accounts_table_query_runner.py b/products/customer_analytics/backend/hogql_queries/accounts_table_query_runner.py
index 8e6a6778b392..c24eb302aa04 100644
--- a/products/customer_analytics/backend/hogql_queries/accounts_table_query_runner.py
+++ b/products/customer_analytics/backend/hogql_queries/accounts_table_query_runner.py
@@ -5,6 +5,7 @@ from rest_framework.exceptions import ValidationError
from posthog.schema import (
AccountsTableAccountFieldColumn,
+ AccountsTableAccountFieldFilter,
AccountsTableAccountIdFilter,
AccountsTableAggregateMetric,
AccountsTableAssignedToFilter,
@@ -115,7 +116,7 @@ class AccountsTableQueryRunner(AnalyticsQueryRunner[AccountsTableQueryResponse])
else filter_.userIds
if isinstance(filter_, AccountsTableAssignedToFilter)
else filter_.values or []
- if isinstance(filter_, AccountsTableCustomPropertyFilter)
+ if isinstance(filter_, AccountsTableAccountFieldFilter | AccountsTableCustomPropertyFilter)
else []
)
if len(filter_values) > ACCOUNTS_TABLE_MAX_FILTER_VALUES:
@@ -138,6 +139,14 @@ class AccountsTableQueryRunner(AnalyticsQueryRunner[AccountsTableQueryResponse])
filters.append(contracts.AccountTableUnassignedFilter())
elif isinstance(filter_, AccountsTableAccountIdFilter):
filters.append(contracts.AccountTableAccountIdFilter(account_id=UUID(filter_.accountId)))
+ elif isinstance(filter_, AccountsTableAccountFieldFilter):
+ filters.append(
+ contracts.AccountTableFieldFilter(
+ field=contracts.AccountTableField(filter_.field.value),
+ operator=contracts.AccountTableFieldOperator(filter_.operator.value),
+ values=tuple(filter_.values or ()),
+ )
+ )
elif isinstance(filter_, AccountsTableCustomPropertyFilter):
filters.append(
contracts.AccountTableCustomPropertyFilter(
diff --git a/products/customer_analytics/backend/hogql_queries/test/test_accounts_table_query_runner.py b/products/customer_analytics/backend/hogql_queries/test/test_accounts_table_query_runner.py
index 5e0dca92940a..22fded54a2cb 100644
--- a/products/customer_analytics/backend/hogql_queries/test/test_accounts_table_query_runner.py
+++ b/products/customer_analytics/backend/hogql_queries/test/test_accounts_table_query_runner.py
@@ -14,6 +14,8 @@ from rest_framework.exceptions import ValidationError
from posthog.schema import (
AccountsTableAccountField,
AccountsTableAccountFieldColumn,
+ AccountsTableAccountFieldFilter,
+ AccountsTableAccountFieldOperator,
AccountsTableAccountIdFilter,
AccountsTableAggregateMetric,
AccountsTableAggregation,
@@ -54,6 +56,7 @@ from products.customer_analytics.backend.hogql_queries.accounts_table_query_runn
AccountsTableQueryRunner,
)
from products.customer_analytics.backend.models import (
+ Account,
AccountRelationship,
AccountRelationshipDefinition,
CustomPropertyValue,
@@ -440,6 +443,184 @@ class TestAccountsTableQueryRunner(BaseTest):
assert [row.id for row in unassigned_response.results] == [str(unassigned_account.id)]
assert [row.id for row in account_response.results] == [str(assigned_account.id)]
+ @parameterized.expand(
+ [
+ (
+ "name_contains",
+ AccountsTableAccountField.NAME,
+ AccountsTableAccountFieldOperator.ICONTAINS,
+ ["ter"],
+ {"Enterprise"},
+ ),
+ (
+ "connection_id_exact",
+ AccountsTableAccountField.STRIPE_CUSTOMER_ID,
+ AccountsTableAccountFieldOperator.EXACT,
+ ["cus_123"],
+ {"Enterprise"},
+ ),
+ (
+ "negative_includes_unset",
+ AccountsTableAccountField.STRIPE_CUSTOMER_ID,
+ AccountsTableAccountFieldOperator.IS_NOT,
+ ["cus_123"],
+ {"Basic"},
+ ),
+ (
+ "created_exact",
+ AccountsTableAccountField.CREATED_AT,
+ AccountsTableAccountFieldOperator.IS_DATE_EXACT,
+ ["2026-01-01"],
+ {"Enterprise"},
+ ),
+ (
+ "created_before",
+ AccountsTableAccountField.CREATED_AT,
+ AccountsTableAccountFieldOperator.IS_DATE_BEFORE,
+ ["2026-01-15"],
+ {"Enterprise"},
+ ),
+ (
+ "created_after",
+ AccountsTableAccountField.CREATED_AT,
+ AccountsTableAccountFieldOperator.IS_DATE_AFTER,
+ ["2026-01-15"],
+ {"Basic"},
+ ),
+ (
+ "ignored_is_set",
+ AccountsTableAccountField.IGNORED_AT,
+ AccountsTableAccountFieldOperator.IS_SET,
+ [],
+ {"Enterprise"},
+ ),
+ (
+ "ignored_is_not_set",
+ AccountsTableAccountField.IGNORED_AT,
+ AccountsTableAccountFieldOperator.IS_NOT_SET,
+ [],
+ {"Basic"},
+ ),
+ ]
+ )
+ def test_filters_native_account_fields(
+ self,
+ _name: str,
+ field: AccountsTableAccountField,
+ operator: AccountsTableAccountFieldOperator,
+ values: list[str],
+ expected_names: set[str],
+ ) -> None:
+ enterprise = create_account(
+ team_id=self.team.id,
+ name="Enterprise",
+ ignored_at=(datetime(2026, 1, 5, tzinfo=UTC) if field == AccountsTableAccountField.IGNORED_AT else None),
+ _properties={"stripe_customer_id": "cus_123"},
+ )
+ basic = create_account(team_id=self.team.id, name="Basic")
+ Account.objects.unscoped().filter(id=enterprise.id).update(created_at=datetime(2026, 1, 1, tzinfo=UTC))
+ Account.objects.unscoped().filter(id=basic.id).update(created_at=datetime(2026, 2, 1, tzinfo=UTC))
+
+ response = self._run(
+ AccountsTableQuery(
+ columns=[],
+ filters=[AccountsTableAccountFieldFilter(field=field, operator=operator, values=values)],
+ )
+ )
+
+ assert {row.name for row in response.results} == expected_names
+
+ @parameterized.expand(
+ [
+ (
+ "ignored",
+ [
+ AccountsTableAccountFieldFilter(
+ field=AccountsTableAccountField.IGNORED_AT,
+ operator=AccountsTableAccountFieldOperator.IS_SET,
+ )
+ ],
+ {"Active ignored"},
+ ),
+ (
+ "churned",
+ [
+ AccountsTableAccountFieldFilter(
+ field=AccountsTableAccountField.CHURNED_AT,
+ operator=AccountsTableAccountFieldOperator.IS_SET,
+ )
+ ],
+ {"Churned tracked"},
+ ),
+ (
+ "churned_and_ignored",
+ [
+ AccountsTableAccountFieldFilter(
+ field=AccountsTableAccountField.CHURNED_AT,
+ operator=AccountsTableAccountFieldOperator.IS_SET,
+ ),
+ AccountsTableAccountFieldFilter(
+ field=AccountsTableAccountField.IGNORED_AT,
+ operator=AccountsTableAccountFieldOperator.IS_SET,
+ ),
+ ],
+ {"Churned ignored"},
+ ),
+ ]
+ )
+ def test_lifecycle_filters_include_the_requested_state_for_rows_and_metrics(
+ self,
+ _name: str,
+ filters: list[AccountsTableAccountFieldFilter],
+ expected_names: set[str],
+ ) -> None:
+ timestamp = datetime(2026, 1, 1, tzinfo=UTC)
+ create_account(team_id=self.team.id, name="Active tracked")
+ create_account(team_id=self.team.id, name="Active ignored", ignored_at=timestamp)
+ create_account(team_id=self.team.id, name="Churned tracked", churned_at=timestamp)
+ create_account(team_id=self.team.id, name="Churned ignored", churned_at=timestamp, ignored_at=timestamp)
+
+ rows = self._run(AccountsTableQuery(columns=[], filters=filters)).results
+ metrics = self._run(
+ AccountsTableQuery(columns=[], filters=filters, metrics=[AccountsTableCountMetric()])
+ ).metricsResults
+
+ assert {row.name for row in rows} == expected_names
+ assert metrics == [len(expected_names)]
+
+ @parameterized.expand(
+ [
+ (
+ "date_on_text",
+ AccountsTableAccountField.NAME,
+ AccountsTableAccountFieldOperator.IS_DATE_AFTER,
+ ["2026-01-01"],
+ ),
+ (
+ "contains_on_date",
+ AccountsTableAccountField.CREATED_AT,
+ AccountsTableAccountFieldOperator.ICONTAINS,
+ ["2026"],
+ ),
+ ]
+ )
+ def test_rejects_account_field_operator_for_wrong_type(
+ self,
+ _name: str,
+ field: AccountsTableAccountField,
+ operator: AccountsTableAccountFieldOperator,
+ values: list[str],
+ ) -> None:
+ create_account(team_id=self.team.id, name="Account")
+
+ with self.assertRaises(ValidationError):
+ self._run(
+ AccountsTableQuery(
+ columns=[],
+ filters=[AccountsTableAccountFieldFilter(field=field, operator=operator, values=values)],
+ )
+ )
+
@parameterized.expand(
[
("greater_than", AccountsTableCustomPropertyOperator.GT, [10], {"High"}),
diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
index e53d46ebd114..55f59520ac36 100644
--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md
+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
@@ -21,7 +21,7 @@ AccountsTabContent ── binds dataNodeLogic(ACCOUNTS_TABLE_DATA_NODE_KEY, acc
└─ 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) /
-│ "my accounts" / custom-property PropertyFilters on the left,
+│ "my accounts" / native-field and custom-property filters on the left,
│ AccountsOverviewTilesButton + AccountsColumnConfigurator on the right
├── AccountsOverviewTiles metric tiles across the filtered set
└── AccountsTable the DataTable; keyed row renderers; controlled row expansion
@@ -44,7 +44,7 @@ AccountsTabContent ── binds dataNodeLogic(ACCOUNTS_TABLE_DATA_NODE_KEY, acc
| Logic | Owns |
| ----------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| `accountsLogic` | The hub. Search (debounced), tag / assigned-to/unassigned / custom-property filters, sort, inline role assignment, typed Postgres list and metrics queries, shareable URL-hash view state, and `openAccount` (the Max entry point). `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 / assigned-to/unassigned / native-field / custom-property filters, sort, inline role assignment, typed Postgres list and metrics queries, shareable URL-hash view state, and `openAccount` (the Max entry point). `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). 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. |
@@ -85,11 +85,12 @@ The Postgres runner returns `{ timestamp, value }` history points ascending (wit
Fewer than 2 in-window points falls back to rendering the latest value plainly.
The config persists per view via `ColumnConfiguration.properties.column_display` (round-tripped in `accountsViewState.ts`), and sorting uses the scalar custom property even when the displayed cell loads history.
-**Custom property filters** let users filter the list by custom properties, with the same look and feel as property filters elsewhere (the persons list): `AccountsTabFilters` renders the shared `PropertyFilters` component restricted to the `TaxonomicFilterGroupType.AccountCustomProperties` group (rendered only when the team has definitions).
-The picker options come from `accountsColumnConfigLogic.customPropertyTaxonomicOptions` via `optionsFromProp` — the filter `key` is the definition **id** (stable across renames), and the definition name rides on the filter's `label` for display.
-Operator sets honor the property's display type (numeric/boolean/date/string) because `accountsColumnConfigLogic` seeds `propertyDefinitionsModel` under `PropertyDefinitionType.AccountCustomProperty`. The dropdown is narrowed to operators the Postgres runner supports. Regex and negative regex operators are not available.
-`accountsTableQuery.ts` translates each `AccountCustomPropertyFilter` into a typed filter. The backend chooses string, numeric, boolean, or datetime storage from the definition. Negative operators include accounts where the property is unset. Filters for deleted definitions, regex operators, or incompatible display types are omitted rather than changing query engines.
-Value suggestions load from`GET /api/projects/:team_id/custom_property_definitions/values/?key=<definition-id>&value=<search>`(the group's`valuesEndpoint`): select → option labels, boolean → true/false, text/numeric → distinct active values; date pickers need no suggestions.
+**Account filters** use one shared `PropertyFilters` control with two groups: native Account fields and Account custom properties.
+Native fields cover names, external and connection IDs, created and updated timestamps, and the `churned_at` and `ignored_at` lifecycle timestamps. Text fields support exact, negative, contains, and set operators. Timestamp fields support exact date, before, after, and set operators. A lifecycle timestamp filter includes that normally hidden state before applying its predicate, so `Ignored at is set` returns ignored accounts while an unfiltered list still hides them.
+Custom property options come from `accountsColumnConfigLogic.customPropertyTaxonomicOptions` via `optionsFromProp`. The filter `key` is the stable definition ID, and the definition name rides on the filter's `label` for display.
+Operator sets honor each field's type because `accountsColumnConfigLogic` seeds `propertyDefinitionsModel` under `PropertyDefinitionType.Account` and `PropertyDefinitionType.AccountCustomProperty`. The dropdown is narrowed to operators the Postgres runner supports. Regex and negative regex operators are not available.
+`accountsTableQuery.ts` translates both filter kinds into typed query filters. The backend filters native model or JSON fields directly and chooses custom-property storage from the definition type. Negative operators include accounts where the value is unset. Invalid native combinations and deleted or incompatible custom properties are omitted rather than changing query engines.
+Custom property value suggestions load from `GET /api/projects/:team_id/custom_property_definitions/values/?key=<definition-id>&value=<search>`. Native account fields do not fetch suggestions.
**Overview tile math** (`accountsOverviewTilesLogic` / `AccountsOverviewTilesEditor`). A tile's metric is a discriminated union: `count`, the column aggregations `sum`/`avg`/`min`/`max`/`median`, and `count_threshold`. `tileQueryMetric` translates these into the typed `AccountsTableMetric` union. Column aggregations carry an optional `scale` multiplier, and threshold tiles translate into typed custom-property filters when clicked.
@@ -163,7 +164,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, custom-property filters, 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, 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. 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)
diff --git a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx
index 22ae74322714..c07b8c52c806 100644
--- a/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx
+++ b/products/customer_analytics/frontend/components/Accounts/AccountsTabFilters.tsx
@@ -16,24 +16,23 @@ import { TaxonomicFilterGroupType } from 'lib/components/TaxonomicFilter/types'
import { tagsModel } from '~/models/tagsModel'
import { dataNodeLogic } from '~/queries/nodes/DataNode/dataNodeLogic'
-import type { AccountCustomPropertyFilter } from '~/types'
+import type { AnyPropertyFilter } from '~/types'
import { accountsColumnConfigLogic } from './accountsColumnConfigLogic'
import { AccountsColumnConfigurator } from './AccountsColumnConfigurator'
-import { ACCOUNT_CUSTOM_PROPERTY_OPERATOR_ALLOWLIST } from './accountsCustomPropertyFilters'
import { accountsLogic, RoleFilterValue } from './accountsLogic'
import { AccountsOverviewTilesButton } from './AccountsOverviewTilesButton'
+import {
+ ACCOUNT_FIELD_TAXONOMIC_OPTIONS,
+ ACCOUNT_FILTER_OPERATOR_ALLOWLIST,
+ accountFilterStaticValueOptions,
+ type AccountFilter,
+} from './accountsPropertyFilters'
import { AccountsViewSelector } from './AccountsViewSelector'
export function AccountsTabFilters(): JSX.Element {
- const {
- searchInput,
- tagsFilter,
- allRolesUnassigned,
- assignedToCurrentUser,
- assignedToFilter,
- customPropertyFilters,
- } = useValues(accountsLogic)
+ const { searchInput, tagsFilter, allRolesUnassigned, assignedToCurrentUser, assignedToFilter, accountFilters } =
+ useValues(accountsLogic)
const { responseLoading: accountsLoading } = useValues(dataNodeLogic)
const {
setSearchInput,
@@ -41,7 +40,7 @@ export function AccountsTabFilters(): JSX.Element {
setAllRolesUnassigned,
setAssignedToCurrentUser,
setAssignedToFilter,
- setCustomPropertyFilters,
+ updateAccountFilters,
refresh,
reportFilterChange,
} = useActions(accountsLogic)
@@ -141,23 +140,23 @@ export function AccountsTabFilters(): JSX.Element {
data-attr="accounts-my-accounts-filter"
/>
- {customPropertyTaxonomicOptions.length > 0 && (
- <PropertyFilters
- propertyFilters={customPropertyFilters}
- onChange={(filters) => {
- setCustomPropertyFilters(filters as AccountCustomPropertyFilter[])
- reportFilterChange('custom_property')
- }}
- pageKey="customer-analytics-accounts-custom-properties"
- taxonomicGroupTypes={[TaxonomicFilterGroupType.AccountCustomProperties]}
- taxonomicFilterOptionsFromProp={{
- [TaxonomicFilterGroupType.AccountCustomProperties]: customPropertyTaxonomicOptions,
- }}
- operatorAllowlist={ACCOUNT_CUSTOM_PROPERTY_OPERATOR_ALLOWLIST}
- buttonSize="small"
- hasRowOperator={false}
- />
- )}
+ <PropertyFilters
+ propertyFilters={accountFilters as unknown as AnyPropertyFilter[]}
+ onChange={(filters) => updateAccountFilters(filters as unknown as AccountFilter[])}
+ pageKey="customer-analytics-accounts-custom-properties"
+ taxonomicGroupTypes={[
+ TaxonomicFilterGroupType.AccountFields,
+ TaxonomicFilterGroupType.AccountCustomProperties,
+ ]}
+ taxonomicFilterOptionsFromProp={{
+ [TaxonomicFilterGroupType.AccountFields]: ACCOUNT_FIELD_TAXONOMIC_OPTIONS,
+ [TaxonomicFilterGroupType.AccountCustomProperties]: customPropertyTaxonomicOptions,
+ }}
+ operatorAllowlist={ACCOUNT_FILTER_OPERATOR_ALLOWLIST}
+ staticValueOptions={accountFilterStaticValueOptions}
+ buttonSize="small"
+ hasRowOperator={false}
+ />
</div>
<div className="flex flex-wrap gap-2 items-center">
<AccountsOverviewTilesButton />
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsColumnConfigLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountsColumnConfigLogic.ts
index fddcb2334b47..e22242bf6042 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsColumnConfigLogic.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsColumnConfigLogic.ts
@@ -21,7 +21,7 @@ import type {
CustomPropertyDefinitionApi,
} from 'products/customer_analytics/frontend/generated/api.schemas'
-import { propertyTypeForDisplayType } from './accountsCustomPropertyFilters'
+import { ACCOUNT_FIELD_TAXONOMIC_OPTIONS, propertyTypeForDisplayType } from './accountsPropertyFilters'
// Mandatory — the backend emits it as `tuple(name, external_id, id)` so the
// row identity (id) and copy-able external_id ride along with the display name.
@@ -826,6 +826,14 @@ export const accountsColumnConfigLogic = kea<accountsColumnConfigLogicType>([
},
})),
afterMount(({ actions, values }) => {
+ updatePropertyDefinitions(
+ Object.fromEntries(
+ ACCOUNT_FIELD_TAXONOMIC_OPTIONS.map((option) => [
+ `${PropertyDefinitionType.Account}/${option.id}`,
+ { id: option.id, name: option.id, property_type: option.property_type },
+ ])
+ )
+ )
// Lazily fetch the database schema only if it isn't already in flight / loaded.
// databaseTableListLogic dedupes concurrent calls internally.
if (!values.allTablesMap || Object.keys(values.allTablesMap).length === 0) {
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsCustomPropertyFilters.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsCustomPropertyFilters.test.ts
deleted file mode 100644
index bb402210a3f9..000000000000
--- a/products/customer_analytics/frontend/components/Accounts/accountsCustomPropertyFilters.test.ts
+++ /dev/null
@@ -1,22 +0,0 @@
-import { PropertyOperator, PropertyType } from '~/types'
-
-import { ACCOUNT_CUSTOM_PROPERTY_OPERATOR_ALLOWLIST, propertyTypeForDisplayType } from './accountsCustomPropertyFilters'
-
-describe('accountsCustomPropertyFilters', () => {
- it.each([
- ['number', PropertyType.Numeric],
- ['currency', PropertyType.Numeric],
- ['percent', PropertyType.Numeric],
- ['boolean', PropertyType.Boolean],
- ['date', PropertyType.DateTime],
- ['datetime', PropertyType.DateTime],
- ['text', PropertyType.String],
- ] as const)('maps %s definitions to %s filters', (displayType, propertyType) => {
- expect(propertyTypeForDisplayType(displayType)).toBe(propertyType)
- })
-
- it('does not offer regex operators for Postgres account filters', () => {
- expect(ACCOUNT_CUSTOM_PROPERTY_OPERATOR_ALLOWLIST).not.toContain(PropertyOperator.Regex)
- expect(ACCOUNT_CUSTOM_PROPERTY_OPERATOR_ALLOWLIST).not.toContain(PropertyOperator.NotRegex)
- })
-})
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsCustomPropertyFilters.ts b/products/customer_analytics/frontend/components/Accounts/accountsCustomPropertyFilters.ts
deleted file mode 100644
index 5708b96841a2..000000000000
--- a/products/customer_analytics/frontend/components/Accounts/accountsCustomPropertyFilters.ts
+++ /dev/null
@@ -1,35 +0,0 @@
-import { PropertyOperator, PropertyType } from '~/types'
-
-import type { CustomPropertyDisplayTypeEnumApi } from 'products/customer_analytics/frontend/generated/api.schemas'
-
-export function propertyTypeForDisplayType(displayType: CustomPropertyDisplayTypeEnumApi): PropertyType {
- switch (displayType) {
- case 'number':
- case 'currency':
- case 'percent':
- return PropertyType.Numeric
- case 'boolean':
- return PropertyType.Boolean
- case 'date':
- case 'datetime':
- return PropertyType.DateTime
- default:
- return PropertyType.String
- }
-}
-
-export const ACCOUNT_CUSTOM_PROPERTY_OPERATOR_ALLOWLIST: PropertyOperator[] = [
- PropertyOperator.Exact,
- PropertyOperator.IsNot,
- PropertyOperator.IContains,
- PropertyOperator.NotIContains,
- PropertyOperator.GreaterThan,
- PropertyOperator.GreaterThanOrEqual,
- PropertyOperator.LessThan,
- PropertyOperator.LessThanOrEqual,
- PropertyOperator.IsSet,
- PropertyOperator.IsNotSet,
- PropertyOperator.IsDateExact,
- PropertyOperator.IsDateBefore,
- PropertyOperator.IsDateAfter,
-]
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts
index 26e75c3aa6bf..6f3621282876 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsLogic.test.ts
@@ -2,11 +2,17 @@ import { MOCK_DEFAULT_TEAM } from '~/lib/api.mock'
import { router } from 'kea-router'
import { expectLogic } from 'kea-test-utils'
+import posthog from 'posthog-js'
import { urls } from 'scenes/urls'
import { userLogic } from 'scenes/userLogic'
-import { AccountsTableCustomPropertyOperator, type AccountsTableQuery } from '~/queries/schema/schema-general'
+import {
+ AccountsTableAccountField,
+ AccountsTableAccountFieldOperator,
+ AccountsTableCustomPropertyOperator,
+ type AccountsTableQuery,
+} from '~/queries/schema/schema-general'
import { initKeaTests } from '~/test/init'
import { PropertyFilterType, PropertyOperator, type UserBasicType, type UserType } from '~/types'
@@ -34,6 +40,7 @@ import {
} from './accountsColumnConfigLogic'
import { DEFAULT_ACCOUNT_TAB, accountsExpansionLogic } from './accountsExpansionLogic'
import { accountsLogic, savingRoleKey } from './accountsLogic'
+import { AccountsEvents } from './constants'
const assignedToFilterOf = (query: AccountsTableQuery | null): number[] | undefined =>
query?.filters?.find((filter) => filter.kind === 'assigned_to')?.userIds
@@ -182,7 +189,7 @@ describe('accountsLogic', () => {
display_type: 'currency',
} as CustomPropertyDefinitionApi,
])
- logic.actions.setCustomPropertyFilters([
+ logic.actions.updateAccountFilters([
{
type: PropertyFilterType.AccountCustomProperty,
key: CSM_DEFINITION_ID,
@@ -191,10 +198,54 @@ describe('accountsLogic', () => {
},
])
- expect(logic.values.customPropertyFilters).toEqual([])
+ expect(logic.values.accountFilters).toEqual([])
expect(logic.values.activeFilterCount).toBe(0)
})
+ it('adds native account filters to the query and shareable view state', () => {
+ logic.actions.updateAccountFilters([
+ {
+ type: PropertyFilterType.Account,
+ key: AccountsTableAccountField.IgnoredAt,
+ label: 'Ignored at',
+ operator: PropertyOperator.IsSet,
+ value: null,
+ },
+ ])
+
+ expect(logic.values.accountsQuerySource?.filters).toContainEqual({
+ kind: 'account_field',
+ field: AccountsTableAccountField.IgnoredAt,
+ operator: AccountsTableAccountFieldOperator.IsSet,
+ values: [],
+ })
+ expect(logic.values.viewUrlState.customProperties).toEqual(logic.values.accountFilters)
+ })
+
+ it('captures native filter shape without its field or value', () => {
+ const capture = jest.spyOn(posthog, 'capture').mockImplementation()
+
+ logic.actions.updateAccountFilters([
+ {
+ type: PropertyFilterType.Account,
+ key: AccountsTableAccountField.ExternalId,
+ operator: PropertyOperator.Exact,
+ value: 'private-value',
+ },
+ ])
+
+ expect(capture).toHaveBeenCalledWith(AccountsEvents.FilterChanged, {
+ filter_type: 'account_field',
+ field_kind: 'account_field',
+ operator: PropertyOperator.Exact,
+ filter_count: 1,
+ is_cleared: false,
+ active_filter_count: 1,
+ })
+ expect(capture.mock.calls.at(-1)?.[1]).not.toHaveProperty('key')
+ expect(capture.mock.calls.at(-1)?.[1]).not.toHaveProperty('value')
+ })
+
it('setTagsFilter updates the reducer', () => {
logic.actions.setTagsFilter(['enterprise'])
expect(logic.values.tagsFilter).toEqual(['enterprise'])
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts
index c0be1205867e..23cc4d15bef5 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsLogic.ts
@@ -22,7 +22,7 @@ import {
NodeKind,
RefreshType,
} from '~/queries/schema/schema-general'
-import type { AccountCustomPropertyFilter, UserBasicType } from '~/types'
+import type { UserBasicType } from '~/types'
import {
accountsPartialUpdate,
@@ -48,6 +48,7 @@ import {
DEFAULT_ACCOUNT_TAB,
} from './accountsExpansionLogic'
import { accountsOverviewTilesLogic, TileFilter } from './accountsOverviewTilesLogic'
+import type { AccountFilter } from './accountsPropertyFilters'
import { sortAccountRows } from './accountsSort'
import {
AccountsTableQueryPlan,
@@ -55,7 +56,7 @@ import {
accountsTableCell,
buildAccountsTableQueryPlan,
isAccountsTableRow,
- supportedCustomPropertyFilters,
+ supportedAccountFilters,
} from './accountsTableQuery'
import { normalizeRoleFilter } from './accountsViewState'
import { AccountsEvents } from './constants'
@@ -95,7 +96,7 @@ function clearSortIfColumnRemoved(values: SortLikeValues, actions: SortLikeActio
export type RoleFilterValue = number[]
-export type AccountFilterType = 'tag' | 'unassigned_only' | 'my_accounts' | 'assigned_to' | 'custom_property'
+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.
@@ -135,7 +136,7 @@ export interface AccountsViewUrlState {
columns?: string[]
columnDisplay?: AccountColumnDisplayState
tileFilter?: TileFilter
- customProperties?: AccountCustomPropertyFilter[]
+ customProperties?: AccountFilter[]
}
// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
@@ -155,6 +156,7 @@ export interface accountsLogicValues {
listHasMoreData: boolean // dataNodeLogic
currentTeamId: number | null // teamLogic
user: UserType | null // userLogic
+ accountFilters: AccountFilter[]
accountIdFilter: string | null
accountsDataTableQuery: DataTableNode
accountsQuerySource: AccountsTableQuery | null
@@ -166,7 +168,6 @@ export interface accountsLogicValues {
assignedToFilter: RoleFilterValue
canSortClientSide: boolean
currentUserId: number | null
- customPropertyFilters: AccountCustomPropertyFilter[]
isRoleSaving: (accountId: string, column: string) => boolean
isTagsSaving: (accountId: string) => boolean
listPaginated: boolean
@@ -295,6 +296,9 @@ export interface accountsLogicActions {
accountId: string
column: string
}
+ setAccountFilters: (filters: AccountFilter[]) => {
+ filters: AccountFilter[]
+ }
setAccountIdFilter: (accountId: string | null) => {
accountId: string | null
}
@@ -307,9 +311,6 @@ export interface accountsLogicActions {
setAssignedToFilter: (value: RoleFilterValue) => {
value: RoleFilterValue
}
- setCustomPropertyFilters: (filters: AccountCustomPropertyFilter[]) => {
- filters: AccountCustomPropertyFilter[]
- }
setRelationshipOverride: (
accountId: string,
column: string,
@@ -347,6 +348,9 @@ export interface accountsLogicActions {
toggleSort: (column: AccountSortableColumn) => {
column: string
}
+ updateAccountFilters: (filters: AccountFilter[]) => {
+ filters: AccountFilter[]
+ }
updateAccountRole: (
accountId: string,
column: string,
@@ -377,7 +381,7 @@ export interface accountsLogicMeta {
tagsFilter: string[],
allRolesUnassigned: boolean,
assignedToFilter: RoleFilterValue,
- customPropertyFilters: AccountCustomPropertyFilter[]
+ accountFilters: AccountFilter[]
) => number
viewUrlState: (
searchQuery: string,
@@ -388,7 +392,7 @@ export interface accountsLogicMeta {
selectColumns: string[],
defaultSelectColumns: string[],
tileFilter: TileFilter | null,
- customPropertyFilters: AccountCustomPropertyFilter[],
+ accountFilters: AccountFilter[],
columnDisplay: AccountColumnDisplayState
) => AccountsViewUrlState
canSortClientSide: (listHasMoreData: boolean, listPaginated: boolean) => boolean
@@ -406,7 +410,7 @@ export interface accountsLogicMeta {
assignedToFilter: RoleFilterValue,
accountIdFilter: string | null,
tileFilter: TileFilter | null,
- customPropertyFilters: AccountCustomPropertyFilter[],
+ accountFilters: AccountFilter[],
customPropertyDefinitionsById: Record<string, CustomPropertyDefinitionApi>,
columnDisplay: AccountColumnDisplayState,
sortOrder: AccountSortOrder,
@@ -495,7 +499,8 @@ export const accountsLogic = kea<accountsLogicType>([
setSearchInput: (query: string) => ({ query }),
setSearchQuery: (query: string) => ({ query }),
setTagsFilter: (tags: string[]) => ({ tags }),
- setCustomPropertyFilters: (filters: AccountCustomPropertyFilter[]) => ({ filters }),
+ setAccountFilters: (filters: AccountFilter[]) => ({ filters }),
+ updateAccountFilters: (filters: AccountFilter[]) => ({ filters }),
setAllRolesUnassigned: (value: boolean) => ({ value }),
setAssignedToFilter: (value: RoleFilterValue) => ({ value }),
// Shortcut for the "My accounts" checkbox — resolves to the current
@@ -557,10 +562,10 @@ export const accountsLogic = kea<accountsLogicType>([
setTagsFilter: (_, { tags }) => tags,
},
],
- customPropertyFilters: [
- [] as AccountCustomPropertyFilter[],
+ accountFilters: [
+ [] as AccountFilter[],
{
- setCustomPropertyFilters: (_, { filters }) => filters,
+ setAccountFilters: (_, { filters }) => filters,
},
],
allRolesUnassigned: [
@@ -675,20 +680,20 @@ export const accountsLogic = kea<accountsLogicType>([
!!savingTags[accountId],
],
activeFilterCount: [
- (s) => [s.searchQuery, s.tagsFilter, s.allRolesUnassigned, s.assignedToFilter, s.customPropertyFilters],
+ (s) => [s.searchQuery, s.tagsFilter, s.allRolesUnassigned, s.assignedToFilter, s.accountFilters],
(
searchQuery: string,
tagsFilter: string[],
allRolesUnassigned: boolean,
assignedToFilter: RoleFilterValue,
- customPropertyFilters: AccountCustomPropertyFilter[]
+ accountFilters: AccountFilter[]
): number =>
[
!!searchQuery.trim(),
tagsFilter.length > 0,
allRolesUnassigned,
assignedToFilter.length > 0,
- customPropertyFilters.length > 0,
+ accountFilters.length > 0,
].filter(Boolean).length,
],
viewUrlState: [
@@ -701,7 +706,7 @@ export const accountsLogic = kea<accountsLogicType>([
s.selectColumns,
s.defaultSelectColumns,
s.tileFilter,
- s.customPropertyFilters,
+ s.accountFilters,
s.columnDisplay,
],
(
@@ -713,7 +718,7 @@ export const accountsLogic = kea<accountsLogicType>([
selectColumns: string[],
defaultSelectColumns: string[],
tileFilter: TileFilter | null,
- customPropertyFilters: AccountCustomPropertyFilter[],
+ accountFilters: AccountFilter[],
columnDisplay: AccountColumnDisplayState
): AccountsViewUrlState => {
const state: AccountsViewUrlState = {}
@@ -742,8 +747,8 @@ export const accountsLogic = kea<accountsLogicType>([
if (tileFilter) {
state.tileFilter = tileFilter
}
- if (customPropertyFilters.length > 0) {
- state.customProperties = customPropertyFilters
+ if (accountFilters.length > 0) {
+ state.customProperties = accountFilters
}
return state
},
@@ -776,7 +781,7 @@ export const accountsLogic = kea<accountsLogicType>([
s.assignedToFilter,
s.accountIdFilter,
s.tileFilter,
- s.customPropertyFilters,
+ s.accountFilters,
s.customPropertyDefinitionsById,
s.columnDisplay,
s.sortOrder,
@@ -791,7 +796,7 @@ export const accountsLogic = kea<accountsLogicType>([
assignedToFilter: RoleFilterValue,
accountIdFilter: string | null,
tileFilter: TileFilter | null,
- customPropertyFilters: AccountCustomPropertyFilter[],
+ accountFilters: AccountFilter[],
customPropertyDefinitionsById: Record<string, CustomPropertyDefinitionApi>,
columnDisplay: AccountColumnDisplayState,
sortOrder: AccountSortOrder,
@@ -805,7 +810,7 @@ export const accountsLogic = kea<accountsLogicType>([
assignedToFilter,
accountIdFilter,
tileFilter,
- customPropertyFilters,
+ accountFilters,
customPropertyDefinitionsById,
columnDisplay,
sortOrder,
@@ -856,26 +861,45 @@ export const accountsLogic = kea<accountsLogicType>([
},
],
}),
- listeners(({ actions, values, cache }) => ({
+ listeners(({ actions, values, cache, selectors }) => ({
loadCustomPropertyDefinitionsSuccess: ({ customPropertyDefinitions }) => {
cache.customPropertyDefinitionsLoaded = true
const definitionsById = Object.fromEntries(
customPropertyDefinitions.map((definition) => [definition.id, definition])
)
- const supportedFilters = supportedCustomPropertyFilters(values.customPropertyFilters, definitionsById)
- if (!objectsEqual(supportedFilters, values.customPropertyFilters)) {
- actions.setCustomPropertyFilters(supportedFilters)
+ const supportedFilters = supportedAccountFilters(values.accountFilters, definitionsById)
+ if (!objectsEqual(supportedFilters, values.accountFilters)) {
+ actions.setAccountFilters(supportedFilters)
}
},
- setCustomPropertyFilters: ({ filters }) => {
+ setAccountFilters: ({ filters }) => {
if (!cache.customPropertyDefinitionsLoaded) {
return
}
- const supportedFilters = supportedCustomPropertyFilters(filters, values.customPropertyDefinitionsById)
+ const supportedFilters = supportedAccountFilters(filters, values.customPropertyDefinitionsById)
if (!objectsEqual(supportedFilters, filters)) {
- actions.setCustomPropertyFilters(supportedFilters)
+ actions.setAccountFilters(supportedFilters)
}
},
+ updateAccountFilters: ({ filters }, _, __, previousState) => {
+ const supportedFilters = cache.customPropertyDefinitionsLoaded
+ ? supportedAccountFilters(filters, values.customPropertyDefinitionsById)
+ : filters
+ const previousFilters = selectors.accountFilters(previousState)
+ const changedFilter =
+ supportedFilters.find((filter, index) => !objectsEqual(filter, previousFilters[index])) ??
+ previousFilters.find((filter, index) => !objectsEqual(filter, supportedFilters[index]))
+ actions.setAccountFilters(supportedFilters)
+ const fieldKind = changedFilter?.type === 'account' ? 'account_field' : 'custom_property'
+ posthog.capture(AccountsEvents.FilterChanged, {
+ filter_type: fieldKind,
+ field_kind: fieldKind,
+ operator: changedFilter?.operator,
+ filter_count: supportedFilters.length,
+ is_cleared: supportedFilters.length === 0,
+ active_filter_count: values.activeFilterCount,
+ })
+ },
setSearchInput: async ({ query }, breakpoint) => {
await breakpoint(SEARCH_DEBOUNCE_MS)
actions.setSearchQuery(query)
@@ -910,11 +934,6 @@ export const accountsLogic = kea<accountsLogicType>([
properties.role_count = values.assignedToFilter.length
properties.is_cleared = values.assignedToFilter.length === 0
break
- // Only the shape is logged — property values can carry customer data.
- case 'custom_property':
- properties.filter_count = values.customPropertyFilters.length
- properties.is_cleared = values.customPropertyFilters.length === 0
- break
}
posthog.capture(AccountsEvents.FilterChanged, properties)
},
@@ -1083,8 +1102,8 @@ export const accountsLogic = kea<accountsLogicType>([
if (values.assignedToFilter.length > 0) {
actions.setAssignedToFilter([])
}
- if (values.customPropertyFilters.length > 0) {
- actions.setCustomPropertyFilters([])
+ if (values.accountFilters.length > 0) {
+ actions.setAccountFilters([])
}
const term = externalId || name
if (term) {
@@ -1135,7 +1154,7 @@ export const accountsLogic = kea<accountsLogicType>([
return {
setSearchQuery: toUrl,
setTagsFilter: toUrl,
- setCustomPropertyFilters: toUrl,
+ setAccountFilters: toUrl,
setAllRolesUnassigned: toUrl,
setAssignedToFilter: toUrl,
setSortOrder: toUrl,
@@ -1179,8 +1198,8 @@ export const accountsLogic = kea<accountsLogicType>([
}
const customProperties = Array.isArray(view.customProperties) ? view.customProperties : []
- if (!objectsEqual(customProperties, values.customPropertyFilters)) {
- actions.setCustomPropertyFilters(customProperties)
+ if (!objectsEqual(customProperties, values.accountFilters)) {
+ actions.setAccountFilters(customProperties)
}
const unassigned = view.unassigned ?? false
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsPropertyFilters.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsPropertyFilters.test.ts
new file mode 100644
index 000000000000..8f062b224e92
--- /dev/null
+++ b/products/customer_analytics/frontend/components/Accounts/accountsPropertyFilters.test.ts
@@ -0,0 +1,43 @@
+import { AccountsTableAccountField } from '~/queries/schema/schema-general'
+import { PropertyOperator, PropertyType } from '~/types'
+
+import {
+ ACCOUNT_FIELD_PROPERTY_TYPES,
+ ACCOUNT_FIELD_TAXONOMIC_OPTIONS,
+ ACCOUNT_FILTER_OPERATOR_ALLOWLIST,
+ accountFilterStaticValueOptions,
+ propertyTypeForDisplayType,
+} from './accountsPropertyFilters'
+
+describe('accountsPropertyFilters', () => {
+ it.each([
+ ['number', PropertyType.Numeric],
+ ['currency', PropertyType.Numeric],
+ ['percent', PropertyType.Numeric],
+ ['boolean', PropertyType.Boolean],
+ ['date', PropertyType.DateTime],
+ ['datetime', PropertyType.DateTime],
+ ['text', PropertyType.String],
+ ] as const)('maps %s definitions to %s filters', (displayType, propertyType) => {
+ expect(propertyTypeForDisplayType(displayType)).toBe(propertyType)
+ })
+
+ it('defines every native account field with its filter type', () => {
+ expect(ACCOUNT_FIELD_TAXONOMIC_OPTIONS.map(({ id }) => id)).toEqual(Object.values(AccountsTableAccountField))
+ expect(ACCOUNT_FIELD_PROPERTY_TYPES[AccountsTableAccountField.IgnoredAt]).toBe(PropertyType.DateTime)
+ expect(ACCOUNT_FIELD_PROPERTY_TYPES[AccountsTableAccountField.ExternalId]).toBe(PropertyType.String)
+ })
+
+ it('does not offer regex operators for Postgres account filters', () => {
+ expect(ACCOUNT_FILTER_OPERATOR_ALLOWLIST).not.toContain(PropertyOperator.Regex)
+ expect(ACCOUNT_FILTER_OPERATOR_ALLOWLIST).not.toContain(PropertyOperator.NotRegex)
+ })
+
+ it('suppresses value fetches for native fields but lets custom properties fetch', () => {
+ for (const { id } of ACCOUNT_FIELD_TAXONOMIC_OPTIONS) {
+ expect(accountFilterStaticValueOptions(id)).toEqual([])
+ }
+ // Custom property keys are definition ids, which must keep fetching from their endpoint
+ expect(accountFilterStaticValueOptions('123')).toBeNull()
+ })
+})
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsPropertyFilters.ts b/products/customer_analytics/frontend/components/Accounts/accountsPropertyFilters.ts
new file mode 100644
index 000000000000..79b0b7a795c2
--- /dev/null
+++ b/products/customer_analytics/frontend/components/Accounts/accountsPropertyFilters.ts
@@ -0,0 +1,144 @@
+import type { PropValue } from '~/models/propertyDefinitionsModel'
+import { AccountsTableAccountField } from '~/queries/schema/schema-general'
+import {
+ AccountCustomPropertyFilter,
+ PropertyDefinitionType,
+ PropertyFilterType,
+ PropertyOperator,
+ PropertyType,
+} from '~/types'
+
+import type { CustomPropertyDisplayTypeEnumApi } from 'products/customer_analytics/frontend/generated/api.schemas'
+
+export type AccountPropertyFilter = Omit<AccountCustomPropertyFilter, 'type'> & {
+ type: PropertyFilterType.Account
+}
+
+export type AccountFilter = AccountPropertyFilter | AccountCustomPropertyFilter
+
+export interface AccountFieldTaxonomicOption {
+ id: AccountsTableAccountField
+ name: string
+ property_type: PropertyType
+ type: PropertyDefinitionType.Account
+}
+
+export const ACCOUNT_FIELD_TAXONOMIC_OPTIONS: AccountFieldTaxonomicOption[] = [
+ {
+ id: AccountsTableAccountField.Name,
+ name: 'Name',
+ property_type: PropertyType.String,
+ type: PropertyDefinitionType.Account,
+ },
+ {
+ id: AccountsTableAccountField.ExternalId,
+ name: 'External ID',
+ property_type: PropertyType.String,
+ type: PropertyDefinitionType.Account,
+ },
+ {
+ id: AccountsTableAccountField.CreatedAt,
+ name: 'Created at',
+ property_type: PropertyType.DateTime,
+ type: PropertyDefinitionType.Account,
+ },
+ {
+ id: AccountsTableAccountField.UpdatedAt,
+ name: 'Updated at',
+ property_type: PropertyType.DateTime,
+ type: PropertyDefinitionType.Account,
+ },
+ {
+ id: AccountsTableAccountField.ChurnedAt,
+ name: 'Churned at',
+ property_type: PropertyType.DateTime,
+ type: PropertyDefinitionType.Account,
+ },
+ {
+ id: AccountsTableAccountField.IgnoredAt,
+ name: 'Ignored at',
+ property_type: PropertyType.DateTime,
+ type: PropertyDefinitionType.Account,
+ },
+ {
+ id: AccountsTableAccountField.StripeCustomerId,
+ name: 'Stripe customer ID',
+ property_type: PropertyType.String,
+ type: PropertyDefinitionType.Account,
+ },
+ {
+ id: AccountsTableAccountField.HubspotDealId,
+ name: 'HubSpot deal ID',
+ property_type: PropertyType.String,
+ type: PropertyDefinitionType.Account,
+ },
+ {
+ id: AccountsTableAccountField.BillingId,
+ name: 'Billing ID',
+ property_type: PropertyType.String,
+ type: PropertyDefinitionType.Account,
+ },
+ {
+ id: AccountsTableAccountField.SalesforceId,
+ name: 'Salesforce ID',
+ property_type: PropertyType.String,
+ type: PropertyDefinitionType.Account,
+ },
+ {
+ id: AccountsTableAccountField.ZendeskId,
+ name: 'Zendesk ID',
+ property_type: PropertyType.String,
+ type: PropertyDefinitionType.Account,
+ },
+]
+
+export const ACCOUNT_FIELD_PROPERTY_TYPES = Object.fromEntries(
+ ACCOUNT_FIELD_TAXONOMIC_OPTIONS.map(({ id, property_type }) => [id, property_type])
+) as Record<AccountsTableAccountField, PropertyType>
+
+export function isAccountPropertyFilter(filter: AccountFilter): filter is AccountPropertyFilter {
+ return filter.type === PropertyFilterType.Account
+}
+
+export function propertyTypeForDisplayType(displayType: CustomPropertyDisplayTypeEnumApi): PropertyType {
+ switch (displayType) {
+ case 'number':
+ case 'currency':
+ case 'percent':
+ return PropertyType.Numeric
+ case 'boolean':
+ return PropertyType.Boolean
+ case 'date':
+ case 'datetime':
+ return PropertyType.DateTime
+ default:
+ return PropertyType.String
+ }
+}
+
+export const ACCOUNT_FILTER_OPERATOR_ALLOWLIST: PropertyOperator[] = [
+ PropertyOperator.Exact,
+ PropertyOperator.IsNot,
+ PropertyOperator.IContains,
+ PropertyOperator.NotIContains,
+ PropertyOperator.GreaterThan,
+ PropertyOperator.GreaterThanOrEqual,
+ PropertyOperator.LessThan,
+ PropertyOperator.LessThanOrEqual,
+ PropertyOperator.IsSet,
+ PropertyOperator.IsNotSet,
+ PropertyOperator.IsDateExact,
+ PropertyOperator.IsDateBefore,
+ PropertyOperator.IsDateAfter,
+]
+
+export const ACCOUNT_CUSTOM_PROPERTY_OPERATOR_ALLOWLIST = ACCOUNT_FILTER_OPERATOR_ALLOWLIST
+
+const NATIVE_ACCOUNT_FIELD_KEYS = new Set<string>(ACCOUNT_FIELD_TAXONOMIC_OPTIONS.map(({ id }) => id))
+
+// Native account fields have no property-values endpoint, so an empty static list
+// suppresses the value fetch that would otherwise 404 and toast. Custom properties
+// return null so they still fetch suggestions from their own endpoint.
+export function accountFilterStaticValueOptions(propertyKey: string): PropValue[] | null {
+ return NATIVE_ACCOUNT_FIELD_KEYS.has(propertyKey) ? [] : null
+}
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.test.ts
index d84da031345f..a77b3d577c55 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.test.ts
@@ -1,5 +1,6 @@
import {
AccountsTableAccountField,
+ AccountsTableAccountFieldOperator,
AccountsTableCustomPropertyOperator,
AccountsTableSortDirection,
NodeKind,
@@ -8,6 +9,7 @@ import { AccountCustomPropertyFilter, PropertyFilterType, PropertyOperator } fro
import type { CustomPropertyDefinitionApi } from 'products/customer_analytics/frontend/generated/api.schemas'
+import type { AccountPropertyFilter } from './accountsPropertyFilters'
import {
AccountsTableQueryPlan,
BuildAccountsTableQueryPlanInput,
@@ -24,6 +26,16 @@ const definition = {
display_type: 'currency',
} as CustomPropertyDefinitionApi
+function accountFieldFilter(overrides: Partial<AccountPropertyFilter> = {}): AccountPropertyFilter {
+ return {
+ type: PropertyFilterType.Account,
+ key: AccountsTableAccountField.IgnoredAt,
+ operator: PropertyOperator.IsSet,
+ value: null,
+ ...overrides,
+ }
+}
+
function customFilter(overrides: Partial<AccountCustomPropertyFilter> = {}): AccountCustomPropertyFilter {
return {
type: PropertyFilterType.AccountCustomProperty,
@@ -49,7 +61,7 @@ function queryInput(overrides: Partial<BuildAccountsTableQueryPlanInput> = {}):
assignedToFilter: [],
accountIdFilter: null,
tileFilter: null,
- customPropertyFilters: [],
+ accountFilters: [],
customPropertyDefinitionsById: { [CUSTOM_PROPERTY_ID]: definition },
columnDisplay: {},
sortOrder: null,
@@ -65,7 +77,7 @@ describe('accountsTableQuery', () => {
searchQuery: ' acme ',
tagsFilter: ['enterprise'],
assignedToFilter: [7, 9],
- customPropertyFilters: [customFilter()],
+ accountFilters: [customFilter()],
sortOrder: { column: 'csm', direction: 'desc' },
canSortClientSide: false,
})
@@ -97,6 +109,52 @@ describe('accountsTableQuery', () => {
})
})
+ it('translates typed native account field filters', () => {
+ const plan = buildAccountsTableQueryPlan(
+ queryInput({
+ accountFilters: [
+ accountFieldFilter(),
+ accountFieldFilter({
+ key: AccountsTableAccountField.CreatedAt,
+ operator: PropertyOperator.IsDateAfter,
+ value: '2026-08-01',
+ }),
+ ],
+ })
+ )
+
+ expect(plan.query.filters).toEqual([
+ {
+ kind: 'account_field',
+ field: AccountsTableAccountField.IgnoredAt,
+ operator: AccountsTableAccountFieldOperator.IsSet,
+ values: [],
+ },
+ {
+ kind: 'account_field',
+ field: AccountsTableAccountField.CreatedAt,
+ operator: AccountsTableAccountFieldOperator.DateAfter,
+ values: ['2026-08-01'],
+ },
+ ])
+ })
+
+ it('omits incompatible native account field filters', () => {
+ const plan = buildAccountsTableQueryPlan(
+ queryInput({
+ accountFilters: [
+ accountFieldFilter({
+ key: AccountsTableAccountField.Name,
+ operator: PropertyOperator.IsDateAfter,
+ value: '2026-08-01',
+ }),
+ ],
+ })
+ )
+
+ expect(plan.query.filters).toEqual([])
+ })
+
it('translates saved custom-property history display configuration', () => {
const plan = buildAccountsTableQueryPlan(
queryInput({
@@ -215,7 +273,7 @@ describe('accountsTableQuery', () => {
const plan = buildAccountsTableQueryPlan(
queryInput({
customPropertyDefinitionsById: { [CUSTOM_PROPERTY_ID]: incompatibleDefinition },
- customPropertyFilters: [customFilter({ operator })],
+ accountFilters: [customFilter({ operator })],
})
)
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.ts b/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.ts
index 6229a3003aa7..5c2e9b8f3cff 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsTableQuery.ts
@@ -2,6 +2,8 @@ import { isUUIDLike } from 'lib/utils/guards'
import {
AccountsTableAccountField,
+ AccountsTableAccountFieldFilter,
+ AccountsTableAccountFieldOperator,
AccountsTableAccountIdFilter,
AccountsTableAssignedToFilter,
AccountsTableColumn,
@@ -17,7 +19,7 @@ import {
AccountsTableUnassignedFilter,
NodeKind,
} from '~/queries/schema/schema-general'
-import { AccountCustomPropertyFilter, PropertyOperator } from '~/types'
+import { AccountCustomPropertyFilter, PropertyOperator, PropertyType } from '~/types'
import type { CustomPropertyDefinitionApi } from 'products/customer_analytics/frontend/generated/api.schemas'
@@ -26,6 +28,7 @@ import { isNumericDisplayType } from '../../scenes/CustomerAnalyticsConfiguratio
import type { AccountColumnDisplayState } from './accountsColumnConfigLogic'
import type { AccountSortOrder, RoleFilterValue } from './accountsLogic'
import type { TileFilter } from './accountsOverviewTilesLogic'
+import { ACCOUNT_FIELD_PROPERTY_TYPES, AccountFilter, isAccountPropertyFilter } from './accountsPropertyFilters'
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]*$/
@@ -35,6 +38,34 @@ const JSON_ACCOUNT_FIELD_REGEX = /^JSONExtractString\((?:accounts\.)?properties,
const ACCOUNT_FIELD_VALUES = new Set<string>(Object.values(AccountsTableAccountField))
+const ACCOUNT_FIELD_OPERATOR_MAP: Partial<Record<PropertyOperator, AccountsTableAccountFieldOperator>> = {
+ [PropertyOperator.Exact]: AccountsTableAccountFieldOperator.Exact,
+ [PropertyOperator.IsNot]: AccountsTableAccountFieldOperator.IsNot,
+ [PropertyOperator.IContains]: AccountsTableAccountFieldOperator.Contains,
+ [PropertyOperator.NotIContains]: AccountsTableAccountFieldOperator.DoesNotContain,
+ [PropertyOperator.IsSet]: AccountsTableAccountFieldOperator.IsSet,
+ [PropertyOperator.IsNotSet]: AccountsTableAccountFieldOperator.IsNotSet,
+ [PropertyOperator.IsDateExact]: AccountsTableAccountFieldOperator.DateExact,
+ [PropertyOperator.IsDateBefore]: AccountsTableAccountFieldOperator.DateBefore,
+ [PropertyOperator.IsDateAfter]: AccountsTableAccountFieldOperator.DateAfter,
+}
+
+const ACCOUNT_FIELD_TEXT_OPERATORS = new Set<AccountsTableAccountFieldOperator>([
+ AccountsTableAccountFieldOperator.Exact,
+ AccountsTableAccountFieldOperator.IsNot,
+ AccountsTableAccountFieldOperator.Contains,
+ AccountsTableAccountFieldOperator.DoesNotContain,
+ AccountsTableAccountFieldOperator.IsSet,
+ AccountsTableAccountFieldOperator.IsNotSet,
+])
+const ACCOUNT_FIELD_DATE_OPERATORS = new Set<AccountsTableAccountFieldOperator>([
+ AccountsTableAccountFieldOperator.DateExact,
+ AccountsTableAccountFieldOperator.DateBefore,
+ AccountsTableAccountFieldOperator.DateAfter,
+ AccountsTableAccountFieldOperator.IsSet,
+ AccountsTableAccountFieldOperator.IsNotSet,
+])
+
const CUSTOM_PROPERTY_OPERATOR_MAP: Partial<Record<PropertyOperator, AccountsTableCustomPropertyOperator>> = {
[PropertyOperator.Exact]: AccountsTableCustomPropertyOperator.Exact,
[PropertyOperator.IsNot]: AccountsTableCustomPropertyOperator.IsNot,
@@ -70,7 +101,7 @@ export interface BuildAccountsTableQueryPlanInput {
assignedToFilter: RoleFilterValue
accountIdFilter: string | null
tileFilter: TileFilter | null
- customPropertyFilters: AccountCustomPropertyFilter[]
+ accountFilters: AccountFilter[]
customPropertyDefinitionsById: Record<string, CustomPropertyDefinitionApi>
columnDisplay: AccountColumnDisplayState
sortOrder: AccountSortOrder
@@ -121,6 +152,32 @@ export function columnFromExpression(
return accountField ? { kind: 'account_field', field: accountField } : null
}
+function accountFieldFilter(filter: AccountFilter): AccountsTableAccountFieldFilter | null {
+ if (!isAccountPropertyFilter(filter) || !ACCOUNT_FIELD_VALUES.has(filter.key)) {
+ return null
+ }
+ const field = filter.key as AccountsTableAccountField
+ const propertyType = ACCOUNT_FIELD_PROPERTY_TYPES[field]
+ const operator = ACCOUNT_FIELD_OPERATOR_MAP[filter.operator]
+ if (!operator) {
+ return null
+ }
+ if (
+ (propertyType === PropertyType.String && !ACCOUNT_FIELD_TEXT_OPERATORS.has(operator)) ||
+ (propertyType === PropertyType.DateTime && !ACCOUNT_FIELD_DATE_OPERATORS.has(operator))
+ ) {
+ return null
+ }
+ const rawValues = Array.isArray(filter.value) ? filter.value : filter.value == null ? [] : [filter.value]
+ const values = rawValues.filter((value): value is string => typeof value === 'string')
+ const doesNotNeedValues =
+ operator === AccountsTableAccountFieldOperator.IsSet || operator === AccountsTableAccountFieldOperator.IsNotSet
+ if (!doesNotNeedValues && values.length === 0) {
+ return null
+ }
+ return { kind: 'account_field', field, operator, values }
+}
+
function customPropertyFilter(
filter: AccountCustomPropertyFilter,
definitionsById: Record<string, CustomPropertyDefinitionApi>
@@ -178,11 +235,15 @@ function customPropertyFilter(
}
}
-export function supportedCustomPropertyFilters(
- filters: AccountCustomPropertyFilter[],
+export function supportedAccountFilters(
+ filters: AccountFilter[],
definitionsById: Record<string, CustomPropertyDefinitionApi>
-): AccountCustomPropertyFilter[] {
- return filters.filter((filter) => customPropertyFilter(filter, definitionsById) !== null)
+): AccountFilter[] {
+ return filters.filter((filter) =>
+ isAccountPropertyFilter(filter)
+ ? accountFieldFilter(filter) !== null
+ : customPropertyFilter(filter, definitionsById) !== null
+ )
}
function queryFilters(input: BuildAccountsTableQueryPlanInput): AccountsTableFilter[] {
@@ -204,8 +265,10 @@ function queryFilters(input: BuildAccountsTableQueryPlanInput): AccountsTableFil
if (input.assignedToFilter.length > 0) {
filters.push({ kind: 'assigned_to', userIds: input.assignedToFilter } satisfies AccountsTableAssignedToFilter)
}
- for (const filter of input.customPropertyFilters) {
- const translatedFilter = customPropertyFilter(filter, input.customPropertyDefinitionsById)
+ for (const filter of input.accountFilters) {
+ const translatedFilter = isAccountPropertyFilter(filter)
+ ? accountFieldFilter(filter)
+ : customPropertyFilter(filter, input.customPropertyDefinitionsById)
if (translatedFilter) {
filters.push(translatedFilter)
}
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsViewState.test.ts b/products/customer_analytics/frontend/components/Accounts/accountsViewState.test.ts
index 4d410250301e..6139c9cb10da 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsViewState.test.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsViewState.test.ts
@@ -1,4 +1,4 @@
-import { AccountsTableCustomPropertyOperator } from '~/queries/schema/schema-general'
+import { AccountsTableAccountField, AccountsTableCustomPropertyOperator } from '~/queries/schema/schema-general'
import { PropertyFilterType, PropertyOperator } from '~/types'
import { ACCOUNTS_DEFAULT_COLUMNS } from './accountsColumnConfigLogic'
@@ -69,6 +69,13 @@ describe('serializeAccountsView / deserializeAccountsView', () => {
},
},
customProperties: [
+ {
+ type: PropertyFilterType.Account as const,
+ key: AccountsTableAccountField.IgnoredAt,
+ operator: PropertyOperator.IsSet,
+ value: null,
+ label: 'Ignored at',
+ },
{
type: PropertyFilterType.AccountCustomProperty as const,
key: '11111111-2222-3333-4444-555555555555',
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsViewState.ts b/products/customer_analytics/frontend/components/Accounts/accountsViewState.ts
index c72bf5f2383b..8ca65194aac5 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsViewState.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsViewState.ts
@@ -1,10 +1,9 @@
-import type { AccountCustomPropertyFilter } from '~/types'
-
import { ColumnConfigurationApi } from 'products/product_analytics/frontend/generated/api.schemas'
import { ACCOUNTS_DEFAULT_COLUMNS, AccountColumnDisplayState } from './accountsColumnConfigLogic'
import type { AccountSortOrder, RoleFilterValue } from './accountsLogic'
import type { AccountsOverviewTile, TileFilter } from './accountsOverviewTilesLogic'
+import type { AccountFilter } from './accountsPropertyFilters'
import { DEFAULT_TILES } from './constants'
export interface AccountsViewFilters {
@@ -13,7 +12,7 @@ export interface AccountsViewFilters {
unassigned: boolean
assignedTo: RoleFilterValue
tileFilter: TileFilter | null
- customProperties: AccountCustomPropertyFilter[]
+ customProperties: AccountFilter[]
}
export interface AccountsViewProperties {
diff --git a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.ts b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.ts
index 85f5147dc52b..5b3282f150e0 100644
--- a/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.ts
+++ b/products/customer_analytics/frontend/components/Accounts/accountsViewsLogic.ts
@@ -15,13 +15,13 @@ import { userLogic } from 'scenes/userLogic'
import { ColumnConfigurationApi } from 'products/product_analytics/frontend/generated/api.schemas'
import type { UserType } from '../../../../../frontend/src/types'
-import type { AccountCustomPropertyFilter } 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 { accountsOverviewTilesLogic } from './accountsOverviewTilesLogic'
import type { AccountsOverviewTile, TileFilter } from './accountsOverviewTilesLogic'
+import type { AccountFilter } from './accountsPropertyFilters'
import {
AccountsViewProperties,
AccountsViewState,
@@ -36,9 +36,9 @@ export type ViewVisibility = 'private' | 'shared'
export interface accountsViewsLogicValues {
columnDisplay: AccountColumnDisplayState // accountsColumnConfigLogic
selectColumns: string[] // accountsColumnConfigLogic
+ accountFilters: AccountFilter[] // accountsLogic
allRolesUnassigned: boolean // accountsLogic
assignedToFilter: RoleFilterValue // accountsLogic
- customPropertyFilters: AccountCustomPropertyFilter[] // accountsLogic
searchQuery: string // accountsLogic
sortOrder: AccountSortOrder // accountsLogic
tagsFilter: string[] // accountsLogic
@@ -117,15 +117,15 @@ export interface accountsViewsLogicActions {
setSelectColumns: (columns: string[]) => {
columns: string[]
} // accountsColumnConfigLogic
+ setAccountFilters: (filters: AccountFilter[]) => {
+ filters: AccountFilter[]
+ } // accountsLogic
setAllRolesUnassigned: (value: boolean) => {
value: boolean
} // accountsLogic
setAssignedToFilter: (value: RoleFilterValue) => {
value: RoleFilterValue
} // accountsLogic
- setCustomPropertyFilters: (filters: AccountCustomPropertyFilter[]) => {
- filters: AccountCustomPropertyFilter[]
- } // accountsLogic
setSearchQuery: (query: string) => {
query: string
} // accountsLogic
@@ -356,7 +356,7 @@ export interface accountsViewsLogicMeta {
sortOrder: AccountSortOrder,
tileFilter: TileFilter | null,
tiles: AccountsOverviewTile[],
- customPropertyFilters: AccountCustomPropertyFilter[],
+ accountFilters: AccountFilter[],
columnDisplay: AccountColumnDisplayState
) => AccountsViewState
currentView: (views: ColumnConfigurationApi[], currentViewId: string | null) => ColumnConfigurationApi | null
@@ -383,14 +383,7 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
accountsColumnConfigLogic,
['selectColumns', 'columnDisplay'],
accountsLogic,
- [
- 'searchQuery',
- 'tagsFilter',
- 'allRolesUnassigned',
- 'assignedToFilter',
- 'sortOrder',
- 'customPropertyFilters',
- ],
+ ['searchQuery', 'tagsFilter', 'allRolesUnassigned', 'assignedToFilter', 'sortOrder', 'accountFilters'],
accountsOverviewTilesLogic,
['tiles', 'tileFilter'],
],
@@ -404,7 +397,7 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
'setAllRolesUnassigned',
'setAssignedToFilter',
'setSortOrder',
- 'setCustomPropertyFilters',
+ 'setAccountFilters',
],
accountsOverviewTilesLogic,
['setTiles', 'setTileFilter'],
@@ -499,7 +492,7 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
s.sortOrder,
s.tileFilter,
s.tiles,
- s.customPropertyFilters,
+ s.accountFilters,
s.columnDisplay,
],
(
@@ -511,7 +504,7 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
sortOrder: import('./accountsLogic').AccountSortOrder,
tileFilter: null | import('./accountsOverviewTilesLogic').TileFilter,
tiles: import('./accountsOverviewTilesLogic').AccountsOverviewTile[],
- customPropertyFilters: import('~/types').AccountCustomPropertyFilter[],
+ accountFilters: import('./accountsPropertyFilters').AccountFilter[],
columnDisplay: import('./accountsColumnConfigLogic').AccountColumnDisplayState
): AccountsViewState => ({
columns: selectColumns,
@@ -522,7 +515,7 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
unassigned: allRolesUnassigned,
assignedTo: assignedToFilter,
tileFilter,
- customProperties: customPropertyFilters,
+ customProperties: accountFilters,
},
tiles,
columnDisplay,
@@ -595,7 +588,7 @@ export const accountsViewsLogic = kea<accountsViewsLogicType>([
// 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)
- actions.setCustomPropertyFilters(state.filters.customProperties)
+ actions.setAccountFilters(state.filters.customProperties)
actions.setSortOrder(state.sortOrder)
actions.setTiles(state.tiles)
actions.setTileFilter(state.filters.tileFilter)
diff --git a/products/dashboards/frontend/generated/api.schemas.ts b/products/dashboards/frontend/generated/api.schemas.ts
index 10364bf04eef..c1551ce712a3 100644
--- a/products/dashboards/frontend/generated/api.schemas.ts
+++ b/products/dashboards/frontend/generated/api.schemas.ts
@@ -5369,6 +5369,7 @@ export const TaxonomicFilterGroupTypeApi = {
Replay: 'replay',
ReplaySavedFilters: 'replay_saved_filters',
RevenueAnalyticsProperties: 'revenue_analytics_properties',
+ AccountFields: 'account_fields',
AccountCustomProperties: 'account_custom_properties',
Resources: 'resources',
ErrorTrackingProperties: 'error_tracking_properties',
@@ -8202,6 +8203,28 @@ export interface AccountsTableAccountIdFilterApi {
kind?: 'account_id'
}
+export type AccountsTableAccountFieldOperatorApi =
+ (typeof AccountsTableAccountFieldOperatorApi)[keyof typeof AccountsTableAccountFieldOperatorApi]
+
+export const AccountsTableAccountFieldOperatorApi = {
+ Exact: 'exact',
+ IsNot: 'is_not',
+ Icontains: 'icontains',
+ NotIcontains: 'not_icontains',
+ IsSet: 'is_set',
+ IsNotSet: 'is_not_set',
+ IsDateExact: 'is_date_exact',
+ IsDateBefore: 'is_date_before',
+ IsDateAfter: 'is_date_after',
+} as const
+
+export interface AccountsTableAccountFieldFilterApi {
+ field: AccountsTableAccountFieldApi
+ kind?: 'account_field'
+ operator: AccountsTableAccountFieldOperatorApi
+ values?: string[] | null
+}
+
export type AccountsTableCustomPropertyOperatorApi =
(typeof AccountsTableCustomPropertyOperatorApi)[keyof typeof AccountsTableCustomPropertyOperatorApi]
@@ -8337,6 +8360,7 @@ export interface AccountsTableQueryApi {
| AccountsTableAssignedToFilterApi
| AccountsTableUnassignedFilterApi
| AccountsTableAccountIdFilterApi
+ | AccountsTableAccountFieldFilterApi
| AccountsTableCustomPropertyFilterApi
)[]
| null
diff --git a/products/product_analytics/frontend/generated/api.schemas.ts b/products/product_analytics/frontend/generated/api.schemas.ts
index f8bd3f44d77d..c97e3ffc721a 100644
--- a/products/product_analytics/frontend/generated/api.schemas.ts
+++ b/products/product_analytics/frontend/generated/api.schemas.ts
@@ -4531,6 +4531,7 @@ export const TaxonomicFilterGroupTypeApi = {
Replay: 'replay',
ReplaySavedFilters: 'replay_saved_filters',
RevenueAnalyticsProperties: 'revenue_analytics_properties',
+ AccountFields: 'account_fields',
AccountCustomProperties: 'account_custom_properties',
Resources: 'resources',
ErrorTrackingProperties: 'error_tracking_properties',
@@ -7364,6 +7365,28 @@ export interface AccountsTableAccountIdFilterApi {
kind?: 'account_id'
}
+export type AccountsTableAccountFieldOperatorApi =
+ (typeof AccountsTableAccountFieldOperatorApi)[keyof typeof AccountsTableAccountFieldOperatorApi]
+
+export const AccountsTableAccountFieldOperatorApi = {
+ Exact: 'exact',
+ IsNot: 'is_not',
+ Icontains: 'icontains',
+ NotIcontains: 'not_icontains',
+ IsSet: 'is_set',
+ IsNotSet: 'is_not_set',
+ IsDateExact: 'is_date_exact',
+ IsDateBefore: 'is_date_before',
+ IsDateAfter: 'is_date_after',
+} as const
+
+export interface AccountsTableAccountFieldFilterApi {
+ field: AccountsTableAccountFieldApi
+ kind?: 'account_field'
+ operator: AccountsTableAccountFieldOperatorApi
+ values?: string[] | null
+}
+
export type AccountsTableCustomPropertyOperatorApi =
(typeof AccountsTableCustomPropertyOperatorApi)[keyof typeof AccountsTableCustomPropertyOperatorApi]
@@ -7499,6 +7522,7 @@ export interface AccountsTableQueryApi {
| AccountsTableAssignedToFilterApi
| AccountsTableUnassignedFilterApi
| AccountsTableAccountIdFilterApi
+ | AccountsTableAccountFieldFilterApi
| AccountsTableCustomPropertyFilterApi
)[]
| null
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/StepTrigger.tsx b/products/workflows/frontend/Workflows/hogflows/steps/StepTrigger.tsx
index b38e273c5246..b70d8caa16fb 100644
--- a/products/workflows/frontend/Workflows/hogflows/steps/StepTrigger.tsx
+++ b/products/workflows/frontend/Workflows/hogflows/steps/StepTrigger.tsx
@@ -49,7 +49,7 @@ import { tagsModel } from '~/models/tagsModel'
import { PropertyFilterType } from '~/types'
import { accountsColumnConfigLogic } from 'products/customer_analytics/frontend/components/Accounts/accountsColumnConfigLogic'
-import { ACCOUNT_CUSTOM_PROPERTY_OPERATOR_ALLOWLIST } from 'products/customer_analytics/frontend/components/Accounts/accountsCustomPropertyFilters'
+import { ACCOUNT_CUSTOM_PROPERTY_OPERATOR_ALLOWLIST } from 'products/customer_analytics/frontend/components/Accounts/accountsPropertyFilters'
// Side-effect imports: register product-specific trigger types
import 'products/workflows/frontend/Workflows/hogflows/registry/triggers'
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 5f902e484250..b1a1dffc2e51 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -948,6 +948,28 @@ export namespace Schemas {
kind?: 'account_field';
}
+ export type AccountsTableAccountFieldOperator = typeof AccountsTableAccountFieldOperator[keyof typeof AccountsTableAccountFieldOperator];
+
+
+ export const AccountsTableAccountFieldOperator = {
+ Exact: 'exact',
+ IsNot: 'is_not',
+ Icontains: 'icontains',
+ NotIcontains: 'not_icontains',
+ IsSet: 'is_set',
+ IsNotSet: 'is_not_set',
+ IsDateExact: 'is_date_exact',
+ IsDateBefore: 'is_date_before',
+ IsDateAfter: 'is_date_after',
+ } as const;
+
+ export interface AccountsTableAccountFieldFilter {
+ field: AccountsTableAccountField;
+ kind?: 'account_field';
+ operator: AccountsTableAccountFieldOperator;
+ values?: string[] | null;
+ }
+
export interface AccountsTableAccountIdFilter {
accountId: string;
kind?: 'account_id';
@@ -1175,7 +1197,7 @@ export namespace Schemas {
/** Columns to load for each account. Account identity fields are always returned. */
columns: (AccountsTableAccountFieldColumn | AccountsTableTagsColumn | AccountsTableNoteCountColumn | AccountsTableRelationshipColumn | AccountsTableCustomPropertyColumn | AccountsTableCustomPropertyHistoryColumn)[];
/** Filters are combined with AND. Values within tag and assignment filters use OR. */
- filters?: (AccountsTableSearchFilter | AccountsTableTagsFilter | AccountsTableAssignedToFilter | AccountsTableUnassignedFilter | AccountsTableAccountIdFilter | AccountsTableCustomPropertyFilter)[] | null;
+ filters?: (AccountsTableSearchFilter | AccountsTableTagsFilter | AccountsTableAssignedToFilter | AccountsTableUnassignedFilter | AccountsTableAccountIdFilter | AccountsTableAccountFieldFilter | AccountsTableCustomPropertyFilter)[] | null;
/** Include churned accounts. Churned accounts are hidden by default. */
includeChurned?: boolean | null;
/** Include ignored accounts. Ignored accounts are hidden by default. */
@@ -6709,6 +6731,7 @@ export namespace Schemas {
Replay: 'replay',
ReplaySavedFilters: 'replay_saved_filters',
RevenueAnalyticsProperties: 'revenue_analytics_properties',
+ AccountFields: 'account_fields',
AccountCustomProperties: 'account_custom_properties',
Resources: 'resources',
ErrorTrackingProperties: 'error_tracking_properties',