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): add default pinned account properties (#108076)

Arthur Moreira de Deus2c1b4fb044ae
diff --git a/docs/internal/customer-analytics/accounts-table.md b/docs/internal/customer-analytics/accounts-table.md
index c159e8c6d865..845ac1427ce9 100644
--- a/docs/internal/customer-analytics/accounts-table.md
+++ b/docs/internal/customer-analytics/accounts-table.md
@@ -1,5 +1,16 @@
# Accounts table
+## Default pinned account properties
+
+Project admins choose an ordered set of default pinned properties under Customer analytics > Accounts settings.
+The defaults can include account custom properties and relationships.
+They appear in account detail sidebars and expanded Accounts rows until a user saves a personal selection.
+
+The user configuration inherits when it has no personal selection, including historical empty lists without an override marker or legacy pinned IDs.
+Reads resolve the current project defaults without copying them into the user row, so later project changes reach every user who still inherits.
+A personal save stores the complete ordered list and an override marker.
+A saved empty list means the user chose no pinned properties and no longer inherits project changes.
+
## Query scheduling
Account row and overview requests use a dedicated frontend queue with two concurrent slots.
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index fc9c8a65bd71..ebb5c5f57d01 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -2412,6 +2412,10 @@ snapshots:
hash: v1.k794b7964.a1866d682eb35809e8a9bea08ec0c7af8cb77581e4667745851bd9db5f49918d.mhIpdnK7yIoTFvovSR-wJrEHGV_7_T3eTvSNRv0UbtY
customer-analytics-custom-property-sync-runs--loading--light:
hash: v1.k794b7964.b376cab90219eb5e85b659c1399b40c0d60caf7a91b006c0d168375ed365d2af.61Y57PmrNuzzIfBps59FSyMmFnBf3yzKDcPD6vs5VHI
+ customer-analytics-default-pinned-properties--configured--dark:
+ hash: v1.k794b7964.da6302477c0838d6cbfdabb09aa1e242f0c3c1f7f917bcb54299580dcfa9f995.tjq8S-BHBPQ8gWdwEr_XUyL3BIxpNCFT4tyYjLGk-ZE
+ customer-analytics-default-pinned-properties--configured--light:
+ hash: v1.k794b7964.273b9a90ceade3a30ad9f01f4c9ff61353db29c0fadb46daab82e4a6024a9598.jau9WlsA3gZxLy-MyeDNK7yWZy3N41Er9y90hvTrmcg
customer-analytics-feature-requests-github-issue--archived--dark:
hash: v1.k794b7964.6353d8360a139bb403c1ece6b033793a0e9d71ece3e3624c40097d702b8a8393.ZF8kHNdiifHQUHTWzRM0a4tvySXtrbkKOm5fB0l2ie8
customer-analytics-feature-requests-github-issue--archived--light:
diff --git a/frontend/src/generated/core/api.schemas.ts b/frontend/src/generated/core/api.schemas.ts
index b7b81f35f04b..58e217d5e068 100644
--- a/frontend/src/generated/core/api.schemas.ts
+++ b/frontend/src/generated/core/api.schemas.ts
@@ -1814,6 +1814,28 @@ export interface TeamMarketingAnalyticsConfigApi {
campaign_field_preferences?: MarketingAnalyticsCampaignFieldPreferencesApi
}
+/**
+ * * `custom_property` - Custom property
+ * * `relationship` - Relationship
+ */
+export type AccountPropertyPinKindEnumApi =
+ (typeof AccountPropertyPinKindEnumApi)[keyof typeof AccountPropertyPinKindEnumApi]
+
+export const AccountPropertyPinKindEnumApi = {
+ CustomProperty: 'custom_property',
+ Relationship: 'relationship',
+} as const
+
+export interface TeamCustomerAnalyticsPinnedAccountPropertyApi {
+ /** Definition type for this default pinned account property.
+ *
+ * * `custom_property` - Custom property
+ * * `relationship` - Relationship */
+ kind: AccountPropertyPinKindEnumApi
+ /** Project-scoped custom property or relationship definition UUID. */
+ id: string
+}
+
export interface TeamCustomerAnalyticsConfigApi {
/** Event used as the activity signal (DAU/WAU/MAU). */
activity_event?: unknown
@@ -1830,6 +1852,8 @@ export interface TeamCustomerAnalyticsConfigApi {
* @nullable
*/
account_group_type_index?: number | null
+ /** Ordered account properties shown until a user saves a personal pinned-property selection. Pass an empty list to show no properties by default. */
+ default_pinned_properties?: TeamCustomerAnalyticsPinnedAccountPropertyApi[]
}
/**
diff --git a/frontend/src/queries/schema.json b/frontend/src/queries/schema.json
index 71c6610ffe4c..ab390d8a2b60 100644
--- a/frontend/src/queries/schema.json
+++ b/frontend/src/queries/schema.json
@@ -18117,6 +18117,12 @@
}
]
},
+ "default_pinned_properties": {
+ "items": {
+ "$ref": "#/definitions/CustomerAnalyticsPinnedProperty"
+ },
+ "type": "array"
+ },
"payment_event": {
"anyOf": [
{
@@ -18167,6 +18173,20 @@
],
"type": "object"
},
+ "CustomerAnalyticsPinnedProperty": {
+ "additionalProperties": false,
+ "properties": {
+ "id": {
+ "type": "string"
+ },
+ "kind": {
+ "enum": ["custom_property", "relationship"],
+ "type": "string"
+ }
+ },
+ "required": ["kind", "id"],
+ "type": "object"
+ },
"DangerousOperationResponse": {
"additionalProperties": false,
"description": "Response returned when a tool operation requires user approval",
diff --git a/frontend/src/queries/schema/schema-general.ts b/frontend/src/queries/schema/schema-general.ts
index 4007e69ea1a3..402c605b4423 100644
--- a/frontend/src/queries/schema/schema-general.ts
+++ b/frontend/src/queries/schema/schema-general.ts
@@ -8902,6 +8902,11 @@ export interface EndpointsUsageTrendsQuery extends EndpointsUsageQueryBase<Endpo
compareFilter?: CompareFilter
}
+export interface CustomerAnalyticsPinnedProperty {
+ kind: 'custom_property' | 'relationship'
+ id: string
+}
+
export interface CustomerAnalyticsConfig {
activity_event: EventsNode | ActionsNode
signup_pageview_event: EventsNode | ActionsNode
@@ -8909,6 +8914,7 @@ export interface CustomerAnalyticsConfig {
subscription_event: EventsNode | ActionsNode
payment_event: EventsNode | ActionsNode
account_group_type_index?: integer | null
+ default_pinned_properties?: CustomerAnalyticsPinnedProperty[]
}
/**
diff --git a/posthog/api/team.py b/posthog/api/team.py
index fc31da37f316..a64c90d76962 100644
--- a/posthog/api/team.py
+++ b/posthog/api/team.py
@@ -123,6 +123,12 @@ from products.access_control.backend.presentation.access_control import (
UserAccessControlSerializerMixin,
)
from products.access_control.backend.presentation.access_control_settings import AccessControlSettingsViewSetMixin
+from products.customer_analytics.backend.facade.account_property_pins import (
+ InvalidPinnedAccountProperties,
+ validate_pinned_account_properties,
+)
+from products.customer_analytics.backend.facade.contracts import PinnedAccountProperty
+from products.customer_analytics.backend.facade.enums import ACCOUNT_PROPERTY_PIN_KIND_CHOICES
from products.customer_analytics.backend.facade.team_extension import TeamCustomerAnalyticsConfig
from products.feature_flags.backend.facade.enums import FlagEvaluationsMode
from products.feature_flags.backend.facade.flags import get_usage_tab_flag_evaluations_mode
@@ -1061,6 +1067,17 @@ class TeamFeatureFlagPolicyConfigSerializer(serializers.ModelSerializer, UserAcc
fields = ["require_tags"]
+class TeamCustomerAnalyticsPinnedAccountPropertySerializer(serializers.Serializer):
+ kind = serializers.ChoiceField(
+ choices=ACCOUNT_PROPERTY_PIN_KIND_CHOICES,
+ help_text="Definition type for this default pinned account property.",
+ )
+ id = serializers.UUIDField(help_text="Project-scoped custom property or relationship definition UUID.")
+
+ class Meta:
+ ref_name = "TeamCustomerAnalyticsPinnedAccountProperty"
+
+
class TeamCustomerAnalyticsConfigSerializer(serializers.ModelSerializer, UserAccessControlSerializerMixin):
activity_event = serializers.JSONField(required=False, help_text="Event used as the activity signal (DAU/WAU/MAU).")
signup_pageview_event = serializers.JSONField(
@@ -1079,6 +1096,15 @@ class TeamCustomerAnalyticsConfigSerializer(serializers.ModelSerializer, UserAcc
"Must reference an existing group type configured for the project."
),
)
+ default_pinned_properties = TeamCustomerAnalyticsPinnedAccountPropertySerializer(
+ many=True,
+ allow_empty=True,
+ required=False,
+ help_text=(
+ "Ordered account properties shown until a user saves a personal pinned-property selection. "
+ "Pass an empty list to show no properties by default."
+ ),
+ )
class Meta:
model = TeamCustomerAnalyticsConfig
@@ -1089,6 +1115,7 @@ class TeamCustomerAnalyticsConfigSerializer(serializers.ModelSerializer, UserAcc
"subscription_event",
"payment_event",
"account_group_type_index",
+ "default_pinned_properties",
]
def update(
@@ -1105,6 +1132,19 @@ class TeamCustomerAnalyticsConfigSerializer(serializers.ModelSerializer, UserAcc
def validate_account_group_type_index(value):
return validate_group_type_index("account_group_type_index", value)
+ def validate_default_pinned_properties(self, value: list[dict[str, Any]]) -> list[dict[str, Any]]:
+ if self.instance is None:
+ return value
+ pinned_properties = [PinnedAccountProperty(kind=reference["kind"], id=reference["id"]) for reference in value]
+ try:
+ validate_pinned_account_properties(
+ team_id=self.instance.team_id,
+ pinned_properties=pinned_properties,
+ )
+ except InvalidPinnedAccountProperties as error:
+ raise serializers.ValidationError(error.errors)
+ return [{"kind": reference["kind"], "id": str(reference["id"])} for reference in value]
+
_VALID_TRIGGER_PROPERTY_OPERATORS = {
"exact",
@@ -2446,6 +2486,7 @@ class TeamSerializer(serializers.ModelSerializer, UserPermissionsSerializerMixin
"subscription_event": instance.customer_analytics_config.subscription_event,
"payment_event": instance.customer_analytics_config.payment_event,
"account_group_type_index": instance.customer_analytics_config.account_group_type_index,
+ "default_pinned_properties": instance.customer_analytics_config.default_pinned_properties,
}
serializer = TeamCustomerAnalyticsConfigSerializer(
diff --git a/posthog/api/test/test_project.py b/posthog/api/test/test_project.py
index a487dd57dab6..d999e91621ec 100644
--- a/posthog/api/test/test_project.py
+++ b/posthog/api/test/test_project.py
@@ -1141,17 +1141,69 @@ class TestProjectAPI(team_api_test_factory()): # type: ignore
def test_customer_analytics_config_writes_through_to_team(self):
self.organization_membership.level = OrganizationMembership.Level.ADMIN
self.organization_membership.save()
+ definition_response = self.client.post(
+ f"/api/projects/{self.project.id}/custom_property_definitions/",
+ {"name": "Annual recurring revenue", "display_type": "currency", "is_big_number": True},
+ format="json",
+ )
+ self.assertEqual(definition_response.status_code, status.HTTP_201_CREATED, definition_response.json())
+ default_pins = [{"kind": "custom_property", "id": definition_response.json()["id"]}]
response = self.client.patch(
f"/api/projects/{self.project.id}/",
- {"customer_analytics_config": {"activity_event": "$pageview"}},
+ {
+ "customer_analytics_config": {
+ "activity_event": "$pageview",
+ "default_pinned_properties": default_pins,
+ }
+ },
format="json",
)
self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
self.assertEqual(response.json()["customer_analytics_config"]["activity_event"], "$pageview")
+ self.assertEqual(
+ response.json()["customer_analytics_config"]["default_pinned_properties"],
+ default_pins,
+ )
self.team.refresh_from_db()
self.assertEqual(self.team.customer_analytics_config.activity_event, "$pageview")
+ self.assertEqual(self.team.customer_analytics_config.default_pinned_properties, default_pins)
+
+ def test_customer_analytics_default_pins_reject_invalid_references(self):
+ self.organization_membership.level = OrganizationMembership.Level.ADMIN
+ self.organization_membership.save()
+ definition_response = self.client.post(
+ f"/api/projects/{self.project.id}/custom_property_definitions/",
+ {"name": "Annual recurring revenue", "display_type": "currency", "is_big_number": True},
+ format="json",
+ )
+ self.assertEqual(definition_response.status_code, status.HTTP_201_CREATED, definition_response.json())
+ reference = {"kind": "custom_property", "id": definition_response.json()["id"]}
+
+ response = self.client.patch(
+ f"/api/projects/{self.project.id}/",
+ {"customer_analytics_config": {"default_pinned_properties": [reference, reference]}},
+ format="json",
+ )
+
+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST, response.json())
+ self.assertIn("duplicates", response.json()["detail"])
+
+ def test_project_member_cannot_change_customer_analytics_default_pins(self):
+ self.organization_membership.level = OrganizationMembership.Level.MEMBER
+ self.organization_membership.save()
+
+ response = self.client.patch(
+ f"/api/projects/{self.project.id}/",
+ {"customer_analytics_config": {"default_pinned_properties": []}},
+ format="json",
+ )
+
+ self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN, response.json())
+ config = get_or_create_team_extension(self.team, TeamCustomerAnalyticsConfig)
+ config.refresh_from_db()
+ self.assertEqual(config.default_pinned_properties, [])
def test_customer_analytics_config_save_keeps_track_rules_written_meanwhile(self):
config = get_or_create_team_extension(self.team, TeamCustomerAnalyticsConfig)
diff --git a/posthog/schema.py b/posthog/schema.py
index beba05d87d98..9fb04934d82e 100644
--- a/posthog/schema.py
+++ b/posthog/schema.py
@@ -156,6 +156,7 @@ from posthog.schema_enums import (
Kind as Kind,
Kind1 as Kind1,
Kind2 as Kind2,
+ Kind3 as Kind3,
LegendPosition as LegendPosition,
LifecycleToggle as LifecycleToggle,
LimitContext as LimitContext,
@@ -1096,6 +1097,14 @@ class ConditionalFormattingRule(BaseModel):
templateId: str
+class CustomerAnalyticsPinnedProperty(BaseModel):
+ model_config = ConfigDict(
+ extra="forbid",
+ )
+ id: str
+ kind: Kind
+
+
class DangerousOperationResponse(BaseModel):
model_config = ConfigDict(
extra="forbid",
@@ -5296,7 +5305,7 @@ class ExperimentApiEventSource(BaseModel):
description="Event name, e.g. '$pageview'. Required for EventsNode.",
)
id: int | None = Field(default=None, description="Action ID. Required for ActionsNode.")
- kind: Kind
+ kind: Kind1
math: ExperimentMetricMathType | None = Field(
default=None,
description=(
@@ -5338,7 +5347,7 @@ class ExperimentApiRetentionStart(BaseModel):
description="Event name, e.g. '$pageview'. Required for EventsNode.",
)
id: int | None = Field(default=None, description="Action ID. Required for ActionsNode.")
- kind: Kind2 = Field(
+ kind: Kind3 = Field(
...,
description=(
"Pass 'ExperimentExposureNode' to start retention from the experiment's own"
@@ -27314,7 +27323,7 @@ class ExperimentApiExposureConfig(BaseModel):
description=("Custom exposure event name. Required when kind is 'ExperimentEventExposureConfig'."),
)
id: int | None = Field(default=None, description="Action ID. Required when kind is 'ActionsNode'.")
- kind: Kind1 | None = Field(
+ kind: Kind2 | None = Field(
default=None,
description=(
"Defaults to 'ExperimentEventExposureConfig' when omitted. Pass 'ActionsNode' for an action-based exposure."
@@ -29628,6 +29637,7 @@ class CustomerAnalyticsConfig(BaseModel):
)
account_group_type_index: int | None = None
activity_event: EventsNode | ActionsNode
+ default_pinned_properties: list[CustomerAnalyticsPinnedProperty] | None = None
payment_event: EventsNode | ActionsNode
signup_event: EventsNode | ActionsNode
signup_pageview_event: EventsNode | ActionsNode
diff --git a/posthog/schema_enums.py b/posthog/schema_enums.py
index ef3913cf1992..7f67d3dc452c 100644
--- a/posthog/schema_enums.py
+++ b/posthog/schema_enums.py
@@ -953,6 +953,11 @@ class CustomChannelOperator(StrEnum):
NOT_REGEX = "not_regex"
+class Kind(StrEnum):
+ CUSTOM_PROPERTY = "custom_property"
+ RELATIONSHIP = "relationship"
+
+
class DataColorToken(StrEnum):
PRESET_1 = "preset-1"
PRESET_2 = "preset-2"
@@ -1257,12 +1262,12 @@ class MultipleVariantHandling(StrEnum):
FIRST_SEEN = "first_seen"
-class Kind(StrEnum):
+class Kind1(StrEnum):
EVENTS_NODE = "EventsNode"
ACTIONS_NODE = "ActionsNode"
-class Kind1(StrEnum):
+class Kind2(StrEnum):
EXPERIMENT_EVENT_EXPOSURE_CONFIG = "ExperimentEventExposureConfig"
ACTIONS_NODE = "ActionsNode"
@@ -1272,7 +1277,7 @@ class StartHandling(StrEnum):
LAST_SEEN = "last_seen"
-class Kind2(StrEnum):
+class Kind3(StrEnum):
EVENTS_NODE = "EventsNode"
ACTIONS_NODE = "ActionsNode"
EXPERIMENT_EXPOSURE_NODE = "ExperimentExposureNode"
diff --git a/posthog/settings/web.py b/posthog/settings/web.py
index a385d1d48ec7..a628277c7bf5 100644
--- a/posthog/settings/web.py
+++ b/posthog/settings/web.py
@@ -624,6 +624,8 @@ SPECTACULAR_SETTINGS = {
"RoleEnum": ["primary", "supporting"],
# replay_vision alert destinations: the create body and the alert's listed destinations share this set.
"VisionAlertDestinationTypeEnum": ["slack", "webhook"],
+ # The API-only pin kind uses StrEnum; name its component without a Django Choices class.
+ "AccountPropertyPinKindEnum": "products.customer_analytics.backend.facade.enums.ACCOUNT_PROPERTY_PIN_KIND_CHOICES",
"ExperimentStatusEnum": ["draft", "running", "paused", "exposure_frozen", "stopped"],
"ErrorTrackingIssueStatusEnum": ["archived", "active", "resolved", "pending_release", "suppressed", "all"],
# The subset a client may write. Shared by the single-issue and bulk write serializers,
diff --git a/products/customer_analytics/backend/facade/account_property_pins.py b/products/customer_analytics/backend/facade/account_property_pins.py
new file mode 100644
index 000000000000..94f214c55235
--- /dev/null
+++ b/products/customer_analytics/backend/facade/account_property_pins.py
@@ -0,0 +1,15 @@
+from collections.abc import Sequence
+
+from products.customer_analytics.backend.facade.contracts import InvalidPinnedAccountProperties, PinnedAccountProperty
+from products.customer_analytics.backend.facade.enums import AccountPropertyPinKind
+from products.customer_analytics.backend.logic.account_property_pins import validate_pinned_properties
+
+
+def validate_pinned_account_properties(*, team_id: int, pinned_properties: Sequence[PinnedAccountProperty]) -> None:
+ validate_pinned_properties(
+ team_id=team_id,
+ references=[(AccountPropertyPinKind(reference.kind), reference.id) for reference in pinned_properties],
+ )
+
+
+__all__ = ["InvalidPinnedAccountProperties", "validate_pinned_account_properties"]
diff --git a/products/customer_analytics/backend/facade/api.py b/products/customer_analytics/backend/facade/api.py
index 13942645b07f..a2d975a8b71c 100644
--- a/products/customer_analytics/backend/facade/api.py
+++ b/products/customer_analytics/backend/facade/api.py
@@ -1286,16 +1286,19 @@ def delete_account_view(*, team_id: int, user_id: int, view_id: UUID, expected_v
# --- UserCustomerAnalyticsConfig ---
-InvalidPinnedAccountProperties = _user_customer_analytics_config_logic.InvalidPinnedAccountProperties
+InvalidPinnedAccountProperties = contracts.InvalidPinnedAccountProperties
def _to_user_customer_analytics_config(
config: UserCustomerAnalyticsConfigModel,
) -> contracts.UserCustomerAnalyticsConfig:
- raw_references = config.properties[_user_customer_analytics_config_logic.PINNED_PROPERTIES_KEY]
+ raw_references = _user_customer_analytics_config_logic.read_pinned_properties(config)
return contracts.UserCustomerAnalyticsConfig(
pinned_properties=[
- contracts.PinnedAccountProperty(kind=reference["kind"], id=UUID(str(reference["id"])))
+ contracts.PinnedAccountProperty(
+ kind=cast(Literal["custom_property", "relationship"], reference["kind"]),
+ id=UUID(str(reference["id"])),
+ )
for reference in raw_references
],
task_digest=_user_customer_analytics_config_logic.read_task_digest(config),
diff --git a/products/customer_analytics/backend/facade/contracts.py b/products/customer_analytics/backend/facade/contracts.py
index 72025604234b..f86bce0b5955 100644
--- a/products/customer_analytics/backend/facade/contracts.py
+++ b/products/customer_analytics/backend/facade/contracts.py
@@ -59,6 +59,12 @@ class PinnedAccountProperty:
id: UUID
+class InvalidPinnedAccountProperties(ValueError):
+ def __init__(self, errors: list[str]) -> None:
+ super().__init__("; ".join(errors))
+ self.errors = errors
+
+
TASK_DIGEST_SEND_TIME_FORMAT = "%H:%M"
diff --git a/products/customer_analytics/backend/facade/enums.py b/products/customer_analytics/backend/facade/enums.py
index 9509eacbf8bd..33768e04ff49 100644
--- a/products/customer_analytics/backend/facade/enums.py
+++ b/products/customer_analytics/backend/facade/enums.py
@@ -1,13 +1,19 @@
-from enum import Enum
+from enum import StrEnum
from posthog.enums import LabeledStrEnum
-class AccountPropertyPinKind(str, Enum):
+class AccountPropertyPinKind(StrEnum):
CUSTOM_PROPERTY = "custom_property"
RELATIONSHIP = "relationship"
+ACCOUNT_PROPERTY_PIN_KIND_CHOICES: tuple[tuple[str, str], ...] = (
+ (AccountPropertyPinKind.CUSTOM_PROPERTY.value, "Custom property"),
+ (AccountPropertyPinKind.RELATIONSHIP.value, "Relationship"),
+)
+
+
class AccountViewVisibility(LabeledStrEnum):
PRIVATE = "private", "Personal"
TEAM = "team", "Team"
@@ -57,4 +63,5 @@ __all__ = [
"OwnershipRoleDiagnostic",
"OwnershipRoleState",
"TaskDigestCadence",
+ "ACCOUNT_PROPERTY_PIN_KIND_CHOICES",
]
diff --git a/products/customer_analytics/backend/logic/account_property_pins.py b/products/customer_analytics/backend/logic/account_property_pins.py
new file mode 100644
index 000000000000..f45595393a63
--- /dev/null
+++ b/products/customer_analytics/backend/logic/account_property_pins.py
@@ -0,0 +1,61 @@
+from collections.abc import Sequence
+from uuid import UUID
+
+from posthog.models.scoping.manager import resolve_effective_team_id
+
+from products.customer_analytics.backend.facade.contracts import InvalidPinnedAccountProperties
+from products.customer_analytics.backend.facade.enums import AccountPropertyPinKind
+from products.customer_analytics.backend.models import (
+ AccountRelationshipDefinition,
+ CustomPropertyDefinition,
+ TargetType,
+)
+
+MAX_PINNED_PROPERTIES = 50
+
+
+def validate_pinned_properties(*, team_id: int, references: Sequence[tuple[AccountPropertyPinKind, UUID]]) -> None:
+ if len(references) > MAX_PINNED_PROPERTIES:
+ raise InvalidPinnedAccountProperties([f"Pin at most {MAX_PINNED_PROPERTIES} account properties."])
+
+ errors: list[str] = []
+ first_index_by_reference: dict[tuple[AccountPropertyPinKind, UUID], int] = {}
+ for index, reference in enumerate(references):
+ if reference in first_index_by_reference:
+ errors.append(f"Item {index + 1} duplicates item {first_index_by_reference[reference] + 1}.")
+ else:
+ first_index_by_reference[reference] = index
+
+ canonical_team_id = resolve_effective_team_id(team_id)
+ referenced_ids = {definition_id for _, definition_id in references}
+ custom_property_targets = dict(
+ CustomPropertyDefinition.objects.for_team(canonical_team_id)
+ .filter(id__in=referenced_ids)
+ .values_list("id", "target_type")
+ )
+ matching_relationship_ids = set(
+ AccountRelationshipDefinition.objects.for_team(canonical_team_id)
+ .filter(id__in=referenced_ids)
+ .values_list("id", flat=True)
+ )
+
+ for index, (kind, definition_id) in enumerate(references):
+ item = index + 1
+ if kind == AccountPropertyPinKind.CUSTOM_PROPERTY:
+ target_type = custom_property_targets.get(definition_id)
+ if target_type is not None:
+ if target_type != TargetType.ACCOUNT.value:
+ errors.append(f"Item {item} must reference an account property.")
+ elif definition_id in matching_relationship_ids:
+ errors.append(f"Item {item} is a relationship, not a custom property.")
+ else:
+ errors.append(f"Item {item} custom property was not found in this project.")
+ elif definition_id in matching_relationship_ids:
+ continue
+ elif definition_id in custom_property_targets:
+ errors.append(f"Item {item} is a custom property, not a relationship.")
+ else:
+ errors.append(f"Item {item} relationship was not found in this project.")
+
+ if errors:
+ raise InvalidPinnedAccountProperties(errors)
diff --git a/products/customer_analytics/backend/logic/user_customer_analytics_config.py b/products/customer_analytics/backend/logic/user_customer_analytics_config.py
index 1580c3bf677c..9db3a6d4a52e 100644
--- a/products/customer_analytics/backend/logic/user_customer_analytics_config.py
+++ b/products/customer_analytics/backend/logic/user_customer_analytics_config.py
@@ -1,6 +1,6 @@
from collections.abc import Sequence
from datetime import datetime, time
-from typing import Any
+from typing import Any, cast
from uuid import UUID
from django.db import transaction
@@ -9,26 +9,15 @@ from posthog.models.scoping.manager import resolve_effective_team_id
from products.customer_analytics.backend.facade import contracts
from products.customer_analytics.backend.facade.enums import AccountPropertyPinKind, TaskDigestCadence
-from products.customer_analytics.backend.models import (
- AccountRelationshipDefinition,
- CustomPropertyDefinition,
- TargetType,
- UserCustomerAnalyticsConfig,
-)
+from products.customer_analytics.backend.logic.account_property_pins import validate_pinned_properties
+from products.customer_analytics.backend.models import TeamCustomerAnalyticsConfig, UserCustomerAnalyticsConfig
PINNED_PROPERTIES_KEY = "pinned_properties"
-MAX_PINNED_PROPERTIES = 50
-
+PINNED_PROPERTIES_OVERRIDE_KEY = "pinned_properties_override"
TASK_DIGEST_KEY = "task_digest"
DEFAULT_TASK_DIGEST = contracts.TaskDigestPreferences()
-class InvalidPinnedAccountProperties(ValueError):
- def __init__(self, errors: list[str]) -> None:
- super().__init__("; ".join(errors))
- self.errors = errors
-
-
@transaction.atomic
def get_or_create_config(*, team_id: int, user_id: int) -> UserCustomerAnalyticsConfig:
# Resolve an environment (child team) id to its root team once. `for_team` canonicalizes its
@@ -38,7 +27,7 @@ def get_or_create_config(*, team_id: int, user_id: int) -> UserCustomerAnalytics
config, _ = UserCustomerAnalyticsConfig.objects.for_team(canonical_team_id, canonical=True).get_or_create(
team_id=canonical_team_id,
user_id=user_id,
- defaults={"properties": {PINNED_PROPERTIES_KEY: []}},
+ defaults={"properties": {}},
)
config = (
UserCustomerAnalyticsConfig.objects.for_team(canonical_team_id, canonical=True)
@@ -48,6 +37,9 @@ def get_or_create_config(*, team_id: int, user_id: int) -> UserCustomerAnalytics
if PINNED_PROPERTIES_KEY in config.properties:
return config
+ if not config.pinned_custom_property_definition_ids:
+ return config
+
legacy_references = [
{"kind": AccountPropertyPinKind.CUSTOM_PROPERTY.value, "id": str(definition_id)}
for definition_id in config.pinned_custom_property_definition_ids
@@ -61,11 +53,12 @@ def get_or_create_config(*, team_id: int, user_id: int) -> UserCustomerAnalytics
def update_pinned_properties(
*, team_id: int, user_id: int, references: Sequence[tuple[AccountPropertyPinKind, UUID]]
) -> UserCustomerAnalyticsConfig:
- _validate_pinned_properties(team_id=team_id, references=references)
+ validate_pinned_properties(team_id=team_id, references=references)
config = get_or_create_config(team_id=team_id, user_id=user_id)
config.properties = {
**config.properties,
PINNED_PROPERTIES_KEY: [{"kind": kind.value, "id": str(definition_id)} for kind, definition_id in references],
+ PINNED_PROPERTIES_OVERRIDE_KEY: True,
}
config.pinned_custom_property_definition_ids = [
definition_id for kind, definition_id in references if kind == AccountPropertyPinKind.CUSTOM_PROPERTY
@@ -74,6 +67,22 @@ def update_pinned_properties(
return config
+def read_pinned_properties(config: UserCustomerAnalyticsConfig) -> list[dict[str, str]]:
+ stored = config.properties.get(PINNED_PROPERTIES_KEY)
+ if isinstance(stored, list) and (
+ stored
+ or config.properties.get(PINNED_PROPERTIES_OVERRIDE_KEY) is True
+ or config.pinned_custom_property_definition_ids
+ ):
+ return cast(list[dict[str, str]], stored)
+ defaults = (
+ TeamCustomerAnalyticsConfig.objects.filter(team_id=config.team_id)
+ .values_list("default_pinned_properties", flat=True)
+ .first()
+ )
+ return cast(list[dict[str, str]], defaults) if isinstance(defaults, list) else []
+
+
def read_task_digest(config: UserCustomerAnalyticsConfig) -> contracts.TaskDigestPreferences:
"""Read the digest preferences, filling in a disabled default for anything the row does not
hold. A row written before this key existed, or holding only some of the three values, still
@@ -124,49 +133,3 @@ def _read_send_time(stored: dict[str, Any]) -> str:
return DEFAULT_TASK_DIGEST.send_time
return parsed.strftime(contracts.TASK_DIGEST_SEND_TIME_FORMAT)
return DEFAULT_TASK_DIGEST.send_time
-
-
-def _validate_pinned_properties(*, team_id: int, references: Sequence[tuple[AccountPropertyPinKind, UUID]]) -> None:
- if len(references) > MAX_PINNED_PROPERTIES:
- raise InvalidPinnedAccountProperties([f"Pin at most {MAX_PINNED_PROPERTIES} account properties."])
-
- errors: list[str] = []
- first_index_by_reference: dict[tuple[AccountPropertyPinKind, UUID], int] = {}
- for index, reference in enumerate(references):
- if reference in first_index_by_reference:
- errors.append(f"Item {index + 1} duplicates item {first_index_by_reference[reference] + 1}.")
- else:
- first_index_by_reference[reference] = index
-
- referenced_ids = {definition_id for _, definition_id in references}
- custom_property_targets = dict(
- CustomPropertyDefinition.objects.for_team(team_id)
- .filter(id__in=referenced_ids)
- .values_list("id", "target_type")
- )
- matching_relationship_ids = set(
- AccountRelationshipDefinition.objects.for_team(team_id)
- .filter(id__in=referenced_ids)
- .values_list("id", flat=True)
- )
-
- for index, (kind, definition_id) in enumerate(references):
- item = index + 1
- if kind == AccountPropertyPinKind.CUSTOM_PROPERTY:
- target_type = custom_property_targets.get(definition_id)
- if target_type is not None:
- if target_type != TargetType.ACCOUNT.value:
- errors.append(f"Item {item} must reference an account property.")
- elif definition_id in matching_relationship_ids:
- errors.append(f"Item {item} is a relationship, not a custom property.")
- else:
- errors.append(f"Item {item} custom property was not found in this project.")
- elif definition_id in matching_relationship_ids:
- continue
- elif definition_id in custom_property_targets:
- errors.append(f"Item {item} is a custom property, not a relationship.")
- else:
- errors.append(f"Item {item} relationship was not found in this project.")
-
- if errors:
- raise InvalidPinnedAccountProperties(errors)
diff --git a/products/customer_analytics/backend/migrations/0060_teamcustomeranalyticsconfig_default_pinned_properties.py b/products/customer_analytics/backend/migrations/0060_teamcustomeranalyticsconfig_default_pinned_properties.py
new file mode 100644
index 000000000000..2dec4bb21263
--- /dev/null
+++ b/products/customer_analytics/backend/migrations/0060_teamcustomeranalyticsconfig_default_pinned_properties.py
@@ -0,0 +1,13 @@
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ dependencies = [("customer_analytics", "0059_account_view")]
+
+ operations = [
+ migrations.AddField(
+ model_name="teamcustomeranalyticsconfig",
+ name="default_pinned_properties",
+ field=models.JSONField(default=list),
+ ),
+ ]
diff --git a/products/customer_analytics/backend/migrations/max_migration.txt b/products/customer_analytics/backend/migrations/max_migration.txt
index e0d47da63581..db8c804c4757 100644
--- a/products/customer_analytics/backend/migrations/max_migration.txt
+++ b/products/customer_analytics/backend/migrations/max_migration.txt
@@ -1 +1 @@
-0059_account_view
+0060_teamcustomeranalyticsconfig_default_pinned_properties
diff --git a/products/customer_analytics/backend/models/team_customer_analytics_config.py b/products/customer_analytics/backend/models/team_customer_analytics_config.py
index 0bae29975b34..67afbfbf9e13 100644
--- a/products/customer_analytics/backend/models/team_customer_analytics_config.py
+++ b/products/customer_analytics/backend/models/team_customer_analytics_config.py
@@ -28,6 +28,7 @@ class TeamCustomerAnalyticsConfig(models.Model):
subscription_event = field_access_control(models.JSONField(default=dict), "project", "admin")
payment_event = field_access_control(models.JSONField(default=dict), "project", "admin")
account_group_type_index = field_access_control(models.IntegerField(null=True, blank=True), "project", "admin")
+ default_pinned_properties = field_access_control(models.JSONField(default=list), "project", "admin")
account_track_rules = field_access_control(
models.JSONField(default=default_account_track_rules), "project", "admin"
)
diff --git a/products/customer_analytics/backend/presentation/views/serializers.py b/products/customer_analytics/backend/presentation/views/serializers.py
index fcf488d65b92..789e56ff28bc 100644
--- a/products/customer_analytics/backend/presentation/views/serializers.py
+++ b/products/customer_analytics/backend/presentation/views/serializers.py
@@ -83,7 +83,7 @@ from products.customer_analytics.backend.facade.contracts import (
MeetingView,
)
from products.customer_analytics.backend.facade.enums import (
- AccountPropertyPinKind,
+ ACCOUNT_PROPERTY_PIN_KIND_CHOICES,
AccountRelationshipSource,
AccountViewVisibility,
TaskDigestCadence,
@@ -2220,10 +2220,7 @@ class CustomPropertyValueSuggestionsResponseSerializer(serializers.Serializer):
class PinnedAccountPropertySerializer(serializers.Serializer):
kind = serializers.ChoiceField(
- choices=[
- (AccountPropertyPinKind.CUSTOM_PROPERTY.value, "Custom property"),
- (AccountPropertyPinKind.RELATIONSHIP.value, "Relationship"),
- ],
+ choices=ACCOUNT_PROPERTY_PIN_KIND_CHOICES,
help_text="Definition type for this pinned account property.",
)
id = serializers.UUIDField(
diff --git a/products/customer_analytics/backend/presentation/views/views.py b/products/customer_analytics/backend/presentation/views/views.py
index 20a248f33272..797f10f7adb0 100644
--- a/products/customer_analytics/backend/presentation/views/views.py
+++ b/products/customer_analytics/backend/presentation/views/views.py
@@ -1026,7 +1026,7 @@ class UserCustomerAnalyticsConfigViewSet(TeamAndOrgViewSetMixin, viewsets.Generi
summary="Get account sidebar configuration",
description=(
"Get the requesting user's account sidebar and task digest configuration for this project. "
- "The first read creates an empty configuration row."
+ "Project defaults are returned until the user saves a personal pinned-property selection."
),
)
def retrieve(self, request: Request, *args: Any, **kwargs: Any) -> Response:
diff --git a/products/customer_analytics/backend/test/test_user_customer_analytics_config_api.py b/products/customer_analytics/backend/test/test_user_customer_analytics_config_api.py
index 4d4c2b18ede2..fc8af2e51e87 100644
--- a/products/customer_analytics/backend/test/test_user_customer_analytics_config_api.py
+++ b/products/customer_analytics/backend/test/test_user_customer_analytics_config_api.py
@@ -14,10 +14,12 @@ from posthog.models.oauth import OAuthAccessToken, OAuthApplication
from posthog.models.organization import OrganizationMembership
from posthog.models.personal_api_key import PersonalAPIKey
from posthog.models.team import Team
+from posthog.models.team.extensions import get_or_create_team_extension
from posthog.models.user import User
from posthog.models.utils import generate_random_token_personal, hash_key_value
from products.access_control.backend.models.access_control import AccessControl
+from products.customer_analytics.backend.facade.team_extension import TeamCustomerAnalyticsConfig
from products.customer_analytics.backend.models import (
AccountRelationshipDefinition,
CustomPropertyDefinition,
@@ -54,13 +56,29 @@ class TestUserCustomerAnalyticsConfigAPI(APIBaseTest):
name=f"Relationship {uuid4()}",
)
- def test_get_creates_empty_config_without_rewriting_an_explicit_empty_list(self) -> None:
+ def test_get_inherits_dynamic_defaults_without_rewriting_an_explicit_empty_list(self) -> None:
+ default_property = self._custom_property()
+ project_config = get_or_create_team_extension(self.team, TeamCustomerAnalyticsConfig)
+ project_config.default_pinned_properties = [{"kind": "custom_property", "id": str(default_property.id)}]
+ project_config.save(update_fields=["default_pinned_properties"])
+
response = self.client.get(self.endpoint)
+ inherited = [{"kind": "custom_property", "id": str(default_property.id)}]
self.assertEqual(response.status_code, status.HTTP_200_OK, response.json())
- self.assertEqual(response.json(), config_body([]))
+ self.assertEqual(response.json(), config_body(inherited))
config = UserCustomerAnalyticsConfig.objects.for_team(self.team.id).get(user_id=self.user.id)
- self.assertEqual(config.properties, {"pinned_properties": []})
+ self.assertEqual(config.properties, {})
+
+ default_relationship = self._relationship()
+ project_config.default_pinned_properties = [{"kind": "relationship", "id": str(default_relationship.id)}]
+ project_config.save(update_fields=["default_pinned_properties"])
+ self.assertEqual(
+ self.client.get(self.endpoint).json(),
+ config_body([{"kind": "relationship", "id": str(default_relationship.id)}]),
+ )
+ config.refresh_from_db()
+ self.assertEqual(config.properties, {})
legacy_definition = self._custom_property()
config.properties = {"pinned_properties": [], "future_setting": "kept"}
@@ -76,6 +94,18 @@ class TestUserCustomerAnalyticsConfigAPI(APIBaseTest):
self.assertEqual(config.properties, {"pinned_properties": [], "future_setting": "kept"})
self.assertEqual(config.updated_at, updated_at)
+ config.pinned_custom_property_definition_ids = []
+ config.save(update_fields=["pinned_custom_property_definition_ids"])
+ self.assertEqual(self.client.get(self.endpoint).json(), config_body(project_config.default_pinned_properties))
+ config.refresh_from_db()
+ self.assertEqual(config.properties, {"pinned_properties": [], "future_setting": "kept"})
+
+ cleared = self.client.patch(self.endpoint, {"pinned_properties": []}, format="json")
+ self.assertEqual(cleared.json(), config_body([]))
+ config.refresh_from_db()
+ self.assertTrue(config.properties["pinned_properties_override"])
+ self.assertEqual(self.client.get(self.endpoint).json(), config_body([]))
+
def test_get_migrates_legacy_custom_property_ids_in_order(self) -> None:
first = self._custom_property()
second = self._custom_property()
@@ -116,6 +146,11 @@ class TestUserCustomerAnalyticsConfigAPI(APIBaseTest):
self.assertEqual(config.properties["pinned_properties"], pinned_properties)
self.assertEqual(config.pinned_custom_property_definition_ids, [first_custom.id, second_custom.id])
+ project_config = get_or_create_team_extension(self.team, TeamCustomerAnalyticsConfig)
+ project_config.default_pinned_properties = [{"kind": "relationship", "id": str(relationship.id)}]
+ project_config.save(update_fields=["default_pinned_properties"])
+ self.assertEqual(self.client.get(self.endpoint).json(), config_body(pinned_properties))
+
payload: dict[str, object] | None
for payload in ({}, None):
with self.subTest(payload=payload):
@@ -130,6 +165,7 @@ class TestUserCustomerAnalyticsConfigAPI(APIBaseTest):
self.assertEqual(cleared.json(), config_body([]))
config.refresh_from_db()
self.assertEqual(config.properties["pinned_properties"], [])
+ self.assertTrue(config.properties["pinned_properties_override"])
self.assertEqual(config.pinned_custom_property_definition_ids, [])
def test_config_is_isolated_by_requesting_user_and_project(self) -> None:
@@ -168,6 +204,26 @@ class TestUserCustomerAnalyticsConfigAPI(APIBaseTest):
1,
)
+ def test_task_digest_only_row_keeps_inheriting_project_defaults(self) -> None:
+ default_property = self._custom_property()
+ inherited = [{"kind": "custom_property", "id": str(default_property.id)}]
+ project_config = get_or_create_team_extension(self.team, TeamCustomerAnalyticsConfig)
+ project_config.default_pinned_properties = inherited
+ project_config.save(update_fields=["default_pinned_properties"])
+
+ response = self.client.patch(
+ self.endpoint,
+ {"task_digest": {"enabled": True, "send_time": "07:30"}},
+ format="json",
+ )
+
+ self.assertEqual(
+ response.json(),
+ config_body(inherited, {"enabled": True, "send_time": "07:30", "cadence": "weekdays"}),
+ )
+ config = UserCustomerAnalyticsConfig.objects.for_team(self.team.id).get(user_id=self.user.id)
+ self.assertNotIn("pinned_properties", config.properties)
+
def test_patch_task_digest_keeps_the_rest_of_the_configuration(self) -> None:
pinned = [{"kind": "custom_property", "id": str(self._custom_property().id)}]
self.client.patch(self.endpoint, {"pinned_properties": pinned}, format="json")
@@ -214,13 +270,18 @@ class TestUserCustomerAnalyticsConfigAPI(APIBaseTest):
# A raw id makes the lookup never match and the unique constraint reject every later call.
environment = Team.objects.create(organization=self.organization, parent_team=self.team, name="env")
environment_endpoint = f"/api/projects/{environment.id}/user_customer_analytics_config/@me/"
- pinned = [{"kind": "custom_property", "id": str(self._custom_property().id)}]
+ inherited = [{"kind": "custom_property", "id": str(self._custom_property().id)}]
+ project_config = get_or_create_team_extension(self.team, TeamCustomerAnalyticsConfig)
+ project_config.default_pinned_properties = inherited
+ project_config.save(update_fields=["default_pinned_properties"])
+ pinned = [{"kind": "relationship", "id": str(self._relationship().id)}]
first = self.client.get(environment_endpoint)
saved = self.client.patch(environment_endpoint, {"pinned_properties": pinned}, format="json")
reread = self.client.get(environment_endpoint)
self.assertEqual(first.status_code, status.HTTP_200_OK, first.json())
+ self.assertEqual(first.json(), config_body(inherited))
self.assertEqual(saved.status_code, status.HTTP_200_OK, saved.json())
self.assertEqual(reread.status_code, status.HTTP_200_OK, reread.json())
self.assertEqual(reread.json(), config_body(pinned))
diff --git a/products/customer_analytics/frontend/components/Accounts/AGENTS.md b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
index 9250da42894a..4204b1a2e02d 100644
--- a/products/customer_analytics/frontend/components/Accounts/AGENTS.md
+++ b/products/customer_analytics/frontend/components/Accounts/AGENTS.md
@@ -164,7 +164,8 @@ Authenticated human viewers heartbeat `accountsPresenceCreate` immediately on mo
Its top actions open the event stream configuration in `AccountEventStreamModal` on the left and the account editor on the right. The modal shows `AccountEventStreamMembership` for the current account and, when the stream is missing or turned off, `AccountEventStreamSetupBanner` with a link to the event stream settings. Settings links built from `eventStreamLogic.settingsUrl` pass the current page as `returnTo`, and the configuration scene's back arrow returns there when the path is inside customer analytics. It has no config form. It mounts both only while open, so `eventStreamLogic` loads on demand. The editor exposes the account name, website domain, billing ID, Slack channel ID, Salesforce ID, an existing Stripe ID, email domains, and known emails in one section. It cleans the email lists with the same helpers as meeting matching. The external ID stays read-only. The scene logic sends only the fields the user edited, on top of freshly loaded properties, and applies the saved account from the response. A failed save keeps the editor open. The sidebar captures when each modal opens and when an account edit saves.
Tag edits save through `accountsPartialUpdate` and update optimistically. Only the latest save can replace or reload the account.
Pinned property preferences belong to the current user and project, never to an account. `accountSidebarConfigLogic({ projectId })` owns their load, draft, cancel, reorder, and save lifecycle through generated API functions. Keep that logic keyed by project so switching projects cannot briefly expose another project's preferences.
-Omitting `pinned_properties` from a PATCH leaves existing pins unchanged; an explicit empty list clears them. Personal API keys and OAuth tokens need `account:write` for PATCH. Session-authenticated viewers can still personalize their own sidebar.
+Project admins set the ordered defaults under Customer analytics > Accounts settings. A user config without `properties.pinned_properties` reads those current defaults without copying them into the user row. The first personal save stores a complete override. An explicit empty list is an override with no pins.
+Omitting `pinned_properties` from a PATCH leaves existing pins unchanged. Personal API keys and OAuth tokens need `account:write` for PATCH. Session-authenticated viewers can still personalize their own sidebar.
The configuration is one ordered list containing both account custom-property and relationship references. Definitions load across every API page, account custom properties are filtered by target, and the shared limit is 50. Missing definitions remain visible as a stale warning; opening the configurator omits them from its draft, so the next save cleans them up.
The empty Properties state uses the hedgehog and primary **Pin properties** action, with no gear. Once at least one reference is pinned, the gear opens the same configurator.
Property reference keys at the component boundary are namespaced as `custom:<uuid>` and `relationship:<uuid>`; persistence maps custom keys back to the API's `custom_property` kind.
diff --git a/products/customer_analytics/frontend/generated/api.schemas.ts b/products/customer_analytics/frontend/generated/api.schemas.ts
index 570f2f8c1eba..7b72c8b1f000 100644
--- a/products/customer_analytics/frontend/generated/api.schemas.ts
+++ b/products/customer_analytics/frontend/generated/api.schemas.ts
@@ -4526,10 +4526,10 @@ export interface PatchedGroupUsageMetricApi {
* * `custom_property` - Custom property
* * `relationship` - Relationship
*/
-export type PinnedAccountPropertyKindEnumApi =
- (typeof PinnedAccountPropertyKindEnumApi)[keyof typeof PinnedAccountPropertyKindEnumApi]
+export type AccountPropertyPinKindEnumApi =
+ (typeof AccountPropertyPinKindEnumApi)[keyof typeof AccountPropertyPinKindEnumApi]
-export const PinnedAccountPropertyKindEnumApi = {
+export const AccountPropertyPinKindEnumApi = {
CustomProperty: 'custom_property',
Relationship: 'relationship',
} as const
@@ -4539,7 +4539,7 @@ export interface PinnedAccountPropertyApi {
*
* * `custom_property` - Custom property
* * `relationship` - Relationship */
- kind: PinnedAccountPropertyKindEnumApi
+ kind: AccountPropertyPinKindEnumApi
/** Team-scoped custom property or relationship definition UUID. */
id: string
}
diff --git a/products/customer_analytics/frontend/generated/api.ts b/products/customer_analytics/frontend/generated/api.ts
index 61ad311c6ace..78e233d5857c 100644
--- a/products/customer_analytics/frontend/generated/api.ts
+++ b/products/customer_analytics/frontend/generated/api.ts
@@ -2693,7 +2693,7 @@ export const getUserCustomerAnalyticsConfigRetrieveUrl = (projectId: string, id:
}
/**
- * Get the requesting user's account sidebar and task digest configuration for this project. The first read creates an empty configuration row.
+ * Get the requesting user's account sidebar and task digest configuration for this project. Project defaults are returned until the user saves a personal pinned-property selection.
* @summary Get account sidebar configuration
*/
export const userCustomerAnalyticsConfigRetrieve = async (
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/components/AccountPropertyConfigurator.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/components/AccountPropertyConfigurator.tsx
index 37f65bf0fac9..cb08575d8779 100644
--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/components/AccountPropertyConfigurator.tsx
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/components/AccountPropertyConfigurator.tsx
@@ -16,6 +16,7 @@ export interface AccountPropertyConfiguratorProps {
onSave: (pinnedPropertyKeys: string[]) => void
onCancel: () => void
saveDisabledReason?: string
+ title?: string
}
export function AccountPropertyConfigurator({
@@ -27,6 +28,7 @@ export function AccountPropertyConfigurator({
onSave,
onCancel,
saveDisabledReason,
+ title = 'Pin properties',
}: AccountPropertyConfiguratorProps): JSX.Element {
const optionsByKey = new Map(options.map((option) => [option.key, option]))
const selectedOptions = pinnedPropertyKeys.map(
@@ -62,7 +64,7 @@ export function AccountPropertyConfigurator({
return (
<LemonModal
isOpen={isOpen}
- title="Pin properties"
+ title={title}
onClose={onCancel}
footer={
<>
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomerAnalyticsAccountConfig.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomerAnalyticsAccountConfig.tsx
index c1fd54458fe1..2c5ceffa0e9d 100644
--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomerAnalyticsAccountConfig.tsx
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomerAnalyticsAccountConfig.tsx
@@ -14,6 +14,7 @@ import { CustomerAnalyticsConfig } from '~/queries/schema/schema-general'
import { GroupsIntroduction } from 'products/groups/frontend/components/GroupsIntroduction'
import { CustomPropertiesConfig } from './CustomPropertiesConfig'
+import { DefaultPinnedAccountProperties } from './DefaultPinnedAccountProperties'
import { RelationshipsConfig } from './RelationshipsConfig'
const NO_ACCOUNT_GROUP = -1
@@ -60,6 +61,8 @@ export function CustomerAnalyticsAccountConfig(): JSX.Element {
options={options}
/>
<LemonDivider />
+ <DefaultPinnedAccountProperties />
+ <LemonDivider />
<CustomPropertiesConfig />
<LemonDivider />
<RelationshipsConfig />
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/DefaultPinnedAccountProperties.stories.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/DefaultPinnedAccountProperties.stories.tsx
new file mode 100644
index 000000000000..a91f82e3f05e
--- /dev/null
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/DefaultPinnedAccountProperties.stories.tsx
@@ -0,0 +1,98 @@
+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'
+
+import { Meta, StoryObj } from '@storybook/react'
+import { within } from '@testing-library/dom'
+import userEvent from '@testing-library/user-event'
+import { useEffect } from 'react'
+
+import { teamLogic } from 'scenes/teamLogic'
+
+import { mswDecorator } from '~/mocks/browser'
+
+import { DefaultPinnedAccountProperties } from './DefaultPinnedAccountProperties'
+
+const CUSTOM_PROPERTY_ID = '01980d7c-0000-7000-8000-000000000001'
+const RELATIONSHIP_ID = '01980d7c-0000-7000-8000-000000000002'
+
+function DefaultPinnedAccountPropertiesStory(): JSX.Element {
+ useEffect(() => {
+ teamLogic.actions.loadCurrentTeamSuccess({
+ ...MOCK_DEFAULT_TEAM,
+ customer_analytics_config: {
+ ...MOCK_DEFAULT_TEAM.customer_analytics_config,
+ default_pinned_properties: [
+ { kind: 'custom_property', id: CUSTOM_PROPERTY_ID },
+ { kind: 'relationship', id: RELATIONSHIP_ID },
+ ],
+ },
+ })
+ }, [])
+
+ return (
+ <div className="max-w-240 p-6">
+ <DefaultPinnedAccountProperties />
+ </div>
+ )
+}
+
+const meta: Meta = {
+ component: DefaultPinnedAccountPropertiesStory,
+ title: 'Customer Analytics/Default pinned properties',
+ parameters: {
+ layout: 'fullscreen',
+ viewMode: 'story',
+ testOptions: {
+ waitForSelector: '[data-attr="configure-default-pinned-account-properties"]',
+ },
+ },
+ decorators: [
+ mswDecorator({
+ get: {
+ 'api/projects/:team_id/custom_property_definitions/': {
+ count: 1,
+ next: null,
+ previous: null,
+ results: [
+ {
+ id: CUSTOM_PROPERTY_ID,
+ name: 'Annual recurring revenue',
+ description: 'Current annual recurring revenue',
+ display_type: 'currency',
+ target_type: 'account',
+ is_canonical: false,
+ has_workflow_reference: false,
+ is_big_number: false,
+ options: null,
+ source: null,
+ },
+ ],
+ },
+ 'api/projects/:team_id/account_relationship_definitions/': {
+ count: 1,
+ next: null,
+ previous: null,
+ results: [
+ {
+ id: RELATIONSHIP_ID,
+ name: 'Customer success manager',
+ description: 'The customer success manager responsible for this account',
+ is_single_holder: true,
+ is_controlled: false,
+ },
+ ],
+ },
+ },
+ }),
+ ],
+}
+
+export default meta
+
+type Story = StoryObj<{}>
+
+export const Configured: Story = {
+ render: () => <DefaultPinnedAccountPropertiesStory />,
+ play: async ({ canvasElement }) => {
+ await userEvent.click(await within(canvasElement).findByText('Configure defaults'))
+ },
+}
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/DefaultPinnedAccountProperties.test.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/DefaultPinnedAccountProperties.test.tsx
new file mode 100644
index 000000000000..a16a896c818e
--- /dev/null
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/DefaultPinnedAccountProperties.test.tsx
@@ -0,0 +1,50 @@
+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'
+
+import '@testing-library/jest-dom'
+
+import { cleanup, render, screen, waitFor } from '@testing-library/react'
+
+import { OrganizationMembershipLevel } from 'lib/constants'
+import { teamLogic } from 'scenes/teamLogic'
+
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import { DefaultPinnedAccountProperties } from './DefaultPinnedAccountProperties'
+import { defaultPinnedAccountPropertiesLogic } from './defaultPinnedAccountPropertiesLogic'
+
+const CUSTOM_PROPERTIES_URL = '/api/projects/:team_id/custom_property_definitions/'
+const RELATIONSHIPS_URL = '/api/projects/:team_id/account_relationship_definitions/'
+
+describe('DefaultPinnedAccountProperties', () => {
+ const logic = defaultPinnedAccountPropertiesLogic()
+
+ beforeEach(() => {
+ initKeaTests()
+ useMocks({
+ get: {
+ [CUSTOM_PROPERTIES_URL]: { count: 0, results: [] },
+ [RELATIONSHIPS_URL]: { count: 0, results: [] },
+ },
+ })
+ teamLogic.mount()
+ teamLogic.actions.loadCurrentTeamSuccess({
+ ...MOCK_DEFAULT_TEAM,
+ effective_membership_level: OrganizationMembershipLevel.Member,
+ })
+ logic.mount()
+ })
+
+ afterEach(() => {
+ cleanup()
+ logic.unmount()
+ teamLogic.unmount()
+ })
+
+ it('disables project default changes for non-admins', async () => {
+ render(<DefaultPinnedAccountProperties />)
+
+ const button = screen.getByText('Configure defaults').closest('button')
+ await waitFor(() => expect(button).toHaveAttribute('aria-disabled', 'true'))
+ })
+})
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/DefaultPinnedAccountProperties.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/DefaultPinnedAccountProperties.tsx
new file mode 100644
index 000000000000..b218671f6a6e
--- /dev/null
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/DefaultPinnedAccountProperties.tsx
@@ -0,0 +1,96 @@
+import { useActions, useValues } from 'kea'
+
+import { LemonBanner, LemonButton } from '@posthog/lemon-ui'
+
+import { RestrictionScope, useRestrictedArea } from 'lib/components/RestrictedArea'
+import { TeamMembershipLevel } from 'lib/constants'
+
+import { AccountPropertyConfigurator } from 'products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/components/AccountPropertyConfigurator'
+
+import { defaultPinnedAccountPropertiesLogic } from './defaultPinnedAccountPropertiesLogic'
+
+export function DefaultPinnedAccountProperties(): JSX.Element {
+ const {
+ canSave,
+ defaultPinnedProperties,
+ definitionsLoadFailed,
+ definitionsLoading,
+ draftPinnedPropertyKeys,
+ isOpen,
+ propertyOptions,
+ saveFailed,
+ saving,
+ stalePinnedProperties,
+ } = useValues(defaultPinnedAccountPropertiesLogic)
+ const {
+ closeConfigurator,
+ openConfigurator,
+ retryDefinitions,
+ saveDefaultPinnedProperties,
+ setDraftPinnedPropertyKeys,
+ } = useActions(defaultPinnedAccountPropertiesLogic)
+ const restrictedReason = useRestrictedArea({
+ scope: RestrictionScope.Project,
+ minimumAccessLevel: TeamMembershipLevel.Admin,
+ })
+ const configureDisabledReason =
+ restrictedReason ??
+ (definitionsLoading ? 'Loading properties' : definitionsLoadFailed ? 'Could not load properties' : undefined)
+
+ return (
+ <div className="flex flex-col gap-2">
+ <div className="flex flex-wrap items-center justify-between gap-2">
+ <div>
+ <h3 className="mb-0">Default pinned properties</h3>
+ <p className="text-secondary mb-0">
+ Choose the account properties people see until they save their own selection.
+ </p>
+ </div>
+ <LemonButton
+ type="secondary"
+ onClick={openConfigurator}
+ disabledReason={configureDisabledReason}
+ data-attr="configure-default-pinned-account-properties"
+ >
+ Configure defaults
+ </LemonButton>
+ </div>
+ <p className="mb-0 text-sm text-secondary">
+ {defaultPinnedProperties.length === 0
+ ? 'No default properties selected.'
+ : `${defaultPinnedProperties.length} default ${
+ defaultPinnedProperties.length === 1 ? 'property' : 'properties'
+ } selected.`}
+ </p>
+ {definitionsLoadFailed ? (
+ <LemonBanner
+ type="error"
+ action={{ children: 'Try again', onClick: retryDefinitions, loading: definitionsLoading }}
+ >
+ Could not load the properties available for project defaults.
+ </LemonBanner>
+ ) : null}
+ {!definitionsLoading && !definitionsLoadFailed && stalePinnedProperties.length > 0 ? (
+ <LemonBanner type="warning">
+ Some default properties are no longer available. Open the configurator and save to remove them.
+ </LemonBanner>
+ ) : null}
+ {saveFailed ? (
+ <LemonBanner type="error">
+ Could not save the default pinned properties. Review them and try again.
+ </LemonBanner>
+ ) : null}
+ <AccountPropertyConfigurator
+ isOpen={isOpen}
+ title="Default pinned properties"
+ options={propertyOptions}
+ pinnedPropertyKeys={draftPinnedPropertyKeys}
+ saving={saving}
+ onChange={setDraftPinnedPropertyKeys}
+ onSave={saveDefaultPinnedProperties}
+ onCancel={closeConfigurator}
+ saveDisabledReason={restrictedReason ?? (!saving && !canSave ? 'No changes to save' : undefined)}
+ />
+ </div>
+ )
+}
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.ts
index 6a2eeadf228d..25417f85c5fc 100644
--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.ts
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/customPropertyDefinitionsLogic.ts
@@ -244,6 +244,7 @@ export interface customPropertyDefinitionsLogicValues {
customPropertyFormValidationErrors: DeepPartialMap<CustomPropertyFormValues, ValidationErrorType>
definitions: CustomPropertyDefinitionApi[]
definitionsInitialLoading: boolean
+ definitionsLoadFailed: boolean
definitionsLoading: boolean
editingDefinition: CustomPropertyDefinitionApi | null
editingHasWorkflowReference: boolean
@@ -639,6 +640,14 @@ export const customPropertyDefinitionsLogic = kea<customPropertyDefinitionsLogic
pollRunsStatus: ({ sourceId }: { sourceId: string }) => ({ sourceId }),
}),
reducers({
+ definitionsLoadFailed: [
+ false,
+ {
+ loadDefinitions: () => false,
+ loadDefinitionsSuccess: () => false,
+ loadDefinitionsFailure: () => true,
+ },
+ ],
searchTerm: [
'',
{
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/defaultPinnedAccountPropertiesLogic.test.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/defaultPinnedAccountPropertiesLogic.test.ts
new file mode 100644
index 000000000000..b95f5535c4cb
--- /dev/null
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/defaultPinnedAccountPropertiesLogic.test.ts
@@ -0,0 +1,158 @@
+import { MOCK_DEFAULT_TEAM } from 'lib/api.mock'
+
+import { waitFor } from '@testing-library/react'
+import { expectLogic } from 'kea-test-utils'
+
+import { teamLogic } from 'scenes/teamLogic'
+
+import { resumeKeaLoadersErrors, silenceKeaLoadersErrors } from '~/initKea'
+import { useMocks } from '~/mocks/jest'
+import { initKeaTests } from '~/test/init'
+
+import type {
+ AccountRelationshipDefinitionApi,
+ CustomPropertyDefinitionApi,
+ PinnedAccountPropertyApi,
+} from 'products/customer_analytics/frontend/generated/api.schemas'
+
+import { defaultPinnedAccountPropertiesLogic } from './defaultPinnedAccountPropertiesLogic'
+
+const CUSTOM_PROPERTIES_URL = '/api/projects/:team_id/custom_property_definitions/'
+const RELATIONSHIPS_URL = '/api/projects/:team_id/account_relationship_definitions/'
+const TEAM_URL = '/api/environments/:team_id/'
+
+interface TeamUpdateBody {
+ customer_analytics_config: {
+ default_pinned_properties: PinnedAccountPropertyApi[]
+ }
+}
+
+const customProperty = {
+ id: 'custom-1',
+ name: 'Annual recurring revenue',
+ description: null,
+ display_type: 'currency',
+ target_type: 'account',
+ is_big_number: false,
+ is_canonical: false,
+ options: null,
+ source: null,
+ created_at: '2026-01-01T00:00:00Z',
+ created_by: 1,
+ updated_at: '2026-01-01T00:00:00Z',
+ references: [],
+ has_workflow_reference: false,
+} as CustomPropertyDefinitionApi
+
+const relationship: AccountRelationshipDefinitionApi = {
+ id: 'relationship-1',
+ name: 'Customer success manager',
+ description: null,
+ is_single_holder: true,
+ is_controlled: false,
+}
+
+describe('defaultPinnedAccountPropertiesLogic', () => {
+ const logic = defaultPinnedAccountPropertiesLogic()
+
+ beforeEach(() => {
+ initKeaTests()
+ })
+
+ afterEach(() => {
+ logic.unmount()
+ teamLogic.unmount()
+ resumeKeaLoadersErrors()
+ })
+
+ it('loads, cleans stale references, saves order, and clears defaults', async () => {
+ const submittedBodies: TeamUpdateBody[] = []
+ useMocks({
+ get: {
+ [CUSTOM_PROPERTIES_URL]: { count: 1, results: [customProperty] },
+ [RELATIONSHIPS_URL]: { count: 1, results: [relationship] },
+ },
+ patch: {
+ [TEAM_URL]: async ({ request }) => {
+ const body = (await request.json()) as TeamUpdateBody
+ submittedBodies.push(body)
+ return {
+ ...MOCK_DEFAULT_TEAM,
+ customer_analytics_config: {
+ ...MOCK_DEFAULT_TEAM.customer_analytics_config,
+ ...body.customer_analytics_config,
+ },
+ }
+ },
+ },
+ })
+ teamLogic.mount()
+ teamLogic.actions.loadCurrentTeamSuccess({
+ ...MOCK_DEFAULT_TEAM,
+ customer_analytics_config: {
+ ...MOCK_DEFAULT_TEAM.customer_analytics_config,
+ default_pinned_properties: [
+ { kind: 'custom_property', id: customProperty.id },
+ { kind: 'custom_property', id: 'missing' },
+ ],
+ },
+ })
+ logic.mount()
+
+ await waitFor(() => expect(logic.values.definitionsLoading).toBe(false))
+
+ expect(logic.values.stalePinnedProperties).toEqual([{ kind: 'custom_property', id: 'missing' }])
+ logic.actions.openConfigurator()
+ expect(logic.values.draftPinnedPropertyKeys).toEqual(['custom:custom-1'])
+ logic.actions.setDraftPinnedPropertyKeys(['relationship:relationship-1', 'custom:custom-1'])
+
+ await expectLogic(logic, () => logic.actions.saveDefaultPinnedProperties())
+ .toDispatchActions(['saveDefaultPinnedPropertiesSuccess'])
+ .toFinishAllListeners()
+
+ expect(submittedBodies[0]).toEqual({
+ customer_analytics_config: {
+ default_pinned_properties: [
+ { kind: 'relationship', id: relationship.id },
+ { kind: 'custom_property', id: customProperty.id },
+ ],
+ },
+ })
+ expect(logic.values.isOpen).toBe(false)
+
+ logic.actions.openConfigurator()
+ logic.actions.setDraftPinnedPropertyKeys([])
+ await expectLogic(logic, () => logic.actions.saveDefaultPinnedProperties())
+ .toDispatchActions(['saveDefaultPinnedPropertiesSuccess'])
+ .toFinishAllListeners()
+
+ expect(submittedBodies[1]).toEqual({
+ customer_analytics_config: { default_pinned_properties: [] },
+ })
+ })
+
+ it('blocks changes when available definitions fail to load', async () => {
+ silenceKeaLoadersErrors()
+ useMocks({
+ get: {
+ [CUSTOM_PROPERTIES_URL]: () => [500, { detail: 'Could not load custom properties.' }],
+ [RELATIONSHIPS_URL]: { count: 0, results: [] },
+ },
+ })
+ teamLogic.mount()
+ teamLogic.actions.loadCurrentTeamSuccess({
+ ...MOCK_DEFAULT_TEAM,
+ customer_analytics_config: {
+ ...MOCK_DEFAULT_TEAM.customer_analytics_config,
+ default_pinned_properties: [{ kind: 'custom_property', id: customProperty.id }],
+ },
+ })
+ logic.mount()
+
+ await waitFor(() => expect(logic.values.definitionsLoadFailed).toBe(true))
+ logic.actions.openConfigurator()
+ logic.actions.setDraftPinnedPropertyKeys([])
+
+ expect(logic.values.canSave).toBe(false)
+ })
+})
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/defaultPinnedAccountPropertiesLogic.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/defaultPinnedAccountPropertiesLogic.ts
new file mode 100644
index 000000000000..de3df3c3bf24
--- /dev/null
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/defaultPinnedAccountPropertiesLogic.ts
@@ -0,0 +1,317 @@
+import { MakeLogicType, actions, connect, kea, listeners, path, reducers, selectors } from 'kea'
+
+import { teamLogic } from 'scenes/teamLogic'
+
+import type { CustomerAnalyticsConfig } from '~/queries/schema/schema-general'
+
+import type { PinnedAccountPropertyApi } from 'products/customer_analytics/frontend/generated/api.schemas'
+import {
+ configuratorKeysToPinnedProperties,
+ pinnedPropertyToConfiguratorKey,
+} from 'products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/accountSidebarConfigLogic'
+import type { AccountPropertyOption } from 'products/customer_analytics/frontend/scenes/CustomerAnalyticsAccountScene/components/accountPropertyTypes'
+
+import type { AccountRelationshipDefinitionApi, CustomPropertyDefinitionApi } from '../../../generated/api.schemas'
+import { customPropertyDefinitionsLogic } from './customPropertyDefinitionsLogic'
+import { relationshipDefinitionsLogic } from './relationshipDefinitionsLogic'
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface defaultPinnedAccountPropertiesLogicValues {
+ customPropertyDefinitions: CustomPropertyDefinitionApi[] // customPropertyDefinitionsLogic
+ customPropertyDefinitionsLoadFailed: boolean // customPropertyDefinitionsLogic
+ customPropertyDefinitionsLoading: boolean // customPropertyDefinitionsLogic
+ relationshipDefinitions: AccountRelationshipDefinitionApi[] // relationshipDefinitionsLogic
+ relationshipDefinitionsLoadFailed: boolean // relationshipDefinitionsLogic
+ relationshipDefinitionsLoading: boolean // relationshipDefinitionsLogic
+ customerAnalyticsConfig: CustomerAnalyticsConfig // teamLogic
+ canSave: boolean
+ defaultPinnedProperties: PinnedAccountPropertyApi[]
+ definitionsLoadFailed: boolean
+ definitionsLoading: boolean
+ draftPinnedPropertyKeys: string[]
+ isOpen: boolean
+ propertyOptions: AccountPropertyOption[]
+ resolvedPinnedPropertyKeys: string[]
+ saveFailed: boolean
+ saving: boolean
+ stalePinnedProperties: PinnedAccountPropertyApi[]
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface defaultPinnedAccountPropertiesLogicActions {
+ loadCustomPropertyDefinitions: () => any // customPropertyDefinitionsLogic
+ loadRelationshipDefinitions: () => any // relationshipDefinitionsLogic
+ updateCurrentTeam: (payload: Partial<import('~/types').TeamType>) => Partial<import('~/types').TeamType> // teamLogic
+ updateCurrentTeamFailure: (
+ error: string,
+ errorObject?: any
+ ) => {
+ error: string
+ errorObject?: any
+ } // teamLogic
+ updateCurrentTeamSuccess: (
+ currentTeam: import('~/types').TeamPublicType | import('~/types').TeamType,
+ payload?: Partial<import('~/types').TeamType> | undefined
+ ) => {
+ currentTeam: import('~/types').TeamPublicType | import('~/types').TeamType
+ payload?: Partial<import('~/types').TeamType>
+ } // teamLogic
+ closeConfigurator: () => {
+ value: true
+ }
+ openConfigurator: () => {
+ value: true
+ }
+ retryDefinitions: () => {
+ value: true
+ }
+ saveDefaultPinnedProperties: () => {
+ value: true
+ }
+ saveDefaultPinnedPropertiesFailure: () => {
+ value: true
+ }
+ saveDefaultPinnedPropertiesSuccess: () => {
+ value: true
+ }
+ setDraftPinnedPropertyKeys: (keys: string[]) => {
+ keys: string[]
+ }
+ startSaving: () => {
+ value: true
+ }
+}
+
+// Generated by kea-typegen. Update if you're an agent, ignore if you're human.
+export interface defaultPinnedAccountPropertiesLogicMeta {
+ __keaTypeGenInternalSelectorTypes: {
+ defaultPinnedProperties: (customerAnalyticsConfig: CustomerAnalyticsConfig) => PinnedAccountPropertyApi[]
+ propertyOptions: (
+ customPropertyDefinitions: CustomPropertyDefinitionApi[],
+ relationshipDefinitions: AccountRelationshipDefinitionApi[]
+ ) => AccountPropertyOption[]
+ resolvedPinnedPropertyKeys: (
+ defaultPinnedProperties: PinnedAccountPropertyApi[],
+ propertyOptions: AccountPropertyOption[]
+ ) => string[]
+ stalePinnedProperties: (
+ defaultPinnedProperties: PinnedAccountPropertyApi[],
+ propertyOptions: AccountPropertyOption[]
+ ) => PinnedAccountPropertyApi[]
+ definitionsLoading: (
+ customPropertyDefinitionsLoading: boolean,
+ relationshipDefinitionsLoading: boolean
+ ) => boolean
+ definitionsLoadFailed: (
+ customPropertyDefinitionsLoadFailed: boolean,
+ relationshipDefinitionsLoadFailed: boolean
+ ) => boolean
+ canSave: (
+ isOpen: boolean,
+ saving: boolean,
+ definitionsLoading: boolean,
+ definitionsLoadFailed: boolean,
+ draftPinnedPropertyKeys: string[],
+ defaultPinnedProperties: PinnedAccountPropertyApi[]
+ ) => boolean
+ }
+}
+
+export type defaultPinnedAccountPropertiesLogicType = MakeLogicType<
+ defaultPinnedAccountPropertiesLogicValues,
+ defaultPinnedAccountPropertiesLogicActions,
+ Record<string, any>,
+ defaultPinnedAccountPropertiesLogicMeta
+>
+
+export const defaultPinnedAccountPropertiesLogic = kea<defaultPinnedAccountPropertiesLogicType>([
+ path([
+ 'products',
+ 'customer_analytics',
+ 'frontend',
+ 'scenes',
+ 'CustomerAnalyticsConfigurationScene',
+ 'account',
+ 'defaultPinnedAccountPropertiesLogic',
+ ]),
+ connect(() => ({
+ values: [
+ teamLogic,
+ ['customerAnalyticsConfig'],
+ customPropertyDefinitionsLogic,
+ [
+ 'definitions as customPropertyDefinitions',
+ 'definitionsLoading as customPropertyDefinitionsLoading',
+ 'definitionsLoadFailed as customPropertyDefinitionsLoadFailed',
+ ],
+ relationshipDefinitionsLogic,
+ [
+ 'definitions as relationshipDefinitions',
+ 'definitionsLoading as relationshipDefinitionsLoading',
+ 'definitionsLoadFailed as relationshipDefinitionsLoadFailed',
+ ],
+ ],
+ actions: [
+ teamLogic,
+ ['updateCurrentTeam', 'updateCurrentTeamSuccess', 'updateCurrentTeamFailure'],
+ customPropertyDefinitionsLogic,
+ ['loadDefinitions as loadCustomPropertyDefinitions'],
+ relationshipDefinitionsLogic,
+ ['loadDefinitions as loadRelationshipDefinitions'],
+ ],
+ })),
+ actions({
+ openConfigurator: true,
+ closeConfigurator: true,
+ setDraftPinnedPropertyKeys: (keys: string[]) => ({ keys }),
+ saveDefaultPinnedProperties: true,
+ retryDefinitions: true,
+ startSaving: true,
+ saveDefaultPinnedPropertiesSuccess: true,
+ saveDefaultPinnedPropertiesFailure: true,
+ }),
+ reducers({
+ isOpen: [
+ false,
+ {
+ openConfigurator: () => true,
+ closeConfigurator: () => false,
+ saveDefaultPinnedPropertiesSuccess: () => false,
+ },
+ ],
+ draftPinnedPropertyKeys: [
+ [] as string[],
+ {
+ setDraftPinnedPropertyKeys: (_, { keys }) => keys,
+ },
+ ],
+ saving: [
+ false,
+ {
+ startSaving: () => true,
+ saveDefaultPinnedPropertiesSuccess: () => false,
+ saveDefaultPinnedPropertiesFailure: () => false,
+ },
+ ],
+ saveFailed: [
+ false,
+ {
+ openConfigurator: () => false,
+ startSaving: () => false,
+ saveDefaultPinnedPropertiesSuccess: () => false,
+ saveDefaultPinnedPropertiesFailure: () => true,
+ },
+ ],
+ }),
+ selectors({
+ defaultPinnedProperties: [
+ (s) => [s.customerAnalyticsConfig],
+ (config: CustomerAnalyticsConfig): PinnedAccountPropertyApi[] =>
+ (config.default_pinned_properties ?? []).map(({ kind, id }) => ({ kind, id })),
+ ],
+ propertyOptions: [
+ (s) => [s.customPropertyDefinitions, s.relationshipDefinitions],
+ (
+ customProperties: import('products/customer_analytics/frontend/generated/api.schemas').CustomPropertyDefinitionApi[],
+ relationships: import('products/customer_analytics/frontend/generated/api.schemas').AccountRelationshipDefinitionApi[]
+ ): AccountPropertyOption[] => [
+ ...customProperties
+ .filter(({ target_type }) => target_type === 'account')
+ .map((definition) => ({
+ key: pinnedPropertyToConfiguratorKey({ kind: 'custom_property', id: definition.id }),
+ label: definition.name,
+ kind: 'custom' as const,
+ })),
+ ...relationships.map((definition) => ({
+ key: pinnedPropertyToConfiguratorKey({ kind: 'relationship', id: definition.id }),
+ label: definition.name,
+ kind: 'relationship' as const,
+ })),
+ ],
+ ],
+ resolvedPinnedPropertyKeys: [
+ (s) => [s.defaultPinnedProperties, s.propertyOptions],
+ (references: PinnedAccountPropertyApi[], options: AccountPropertyOption[]): string[] => {
+ const availableKeys = new Set(options.map(({ key }) => key))
+ return references.map(pinnedPropertyToConfiguratorKey).filter((key) => availableKeys.has(key))
+ },
+ ],
+ stalePinnedProperties: [
+ (s) => [s.defaultPinnedProperties, s.propertyOptions],
+ (references: PinnedAccountPropertyApi[], options: AccountPropertyOption[]): PinnedAccountPropertyApi[] => {
+ const availableKeys = new Set(options.map(({ key }) => key))
+ return references.filter((reference) => !availableKeys.has(pinnedPropertyToConfiguratorKey(reference)))
+ },
+ ],
+ definitionsLoading: [
+ (s) => [s.customPropertyDefinitionsLoading, s.relationshipDefinitionsLoading],
+ (customPropertiesLoading: boolean, relationshipsLoading: boolean): boolean =>
+ customPropertiesLoading || relationshipsLoading,
+ ],
+ definitionsLoadFailed: [
+ (s) => [s.customPropertyDefinitionsLoadFailed, s.relationshipDefinitionsLoadFailed],
+ (customPropertiesLoadFailed: boolean, relationshipsLoadFailed: boolean): boolean =>
+ customPropertiesLoadFailed || relationshipsLoadFailed,
+ ],
+ canSave: [
+ (s) => [
+ s.isOpen,
+ s.saving,
+ s.definitionsLoading,
+ s.definitionsLoadFailed,
+ s.draftPinnedPropertyKeys,
+ s.defaultPinnedProperties,
+ ],
+ (
+ isOpen: boolean,
+ saving: boolean,
+ definitionsLoading: boolean,
+ definitionsLoadFailed: boolean,
+ draftKeys: string[],
+ savedReferences: PinnedAccountPropertyApi[]
+ ): boolean => {
+ const savedKeys = savedReferences.map(pinnedPropertyToConfiguratorKey)
+ return (
+ isOpen &&
+ !saving &&
+ !definitionsLoading &&
+ !definitionsLoadFailed &&
+ (draftKeys.length !== savedKeys.length || draftKeys.some((key, index) => key !== savedKeys[index]))
+ )
+ },
+ ],
+ }),
+ listeners(({ actions, values }) => ({
+ openConfigurator: () => {
+ actions.setDraftPinnedPropertyKeys(values.resolvedPinnedPropertyKeys)
+ },
+ closeConfigurator: () => {
+ actions.setDraftPinnedPropertyKeys(values.resolvedPinnedPropertyKeys)
+ },
+ retryDefinitions: () => {
+ actions.loadCustomPropertyDefinitions()
+ actions.loadRelationshipDefinitions()
+ },
+ saveDefaultPinnedProperties: () => {
+ if (!values.canSave) {
+ return
+ }
+ actions.startSaving()
+ actions.updateCurrentTeam({
+ customer_analytics_config: {
+ default_pinned_properties: configuratorKeysToPinnedProperties(values.draftPinnedPropertyKeys),
+ } as CustomerAnalyticsConfig,
+ })
+ },
+ updateCurrentTeamSuccess: ({ payload }) => {
+ if (payload?.customer_analytics_config?.default_pinned_properties !== undefined) {
+ actions.saveDefaultPinnedPropertiesSuccess()
+ }
+ },
+ updateCurrentTeamFailure: () => {
+ if (values.saving) {
+ actions.saveDefaultPinnedPropertiesFailure()
+ }
+ },
+ })),
+])
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/relationshipDefinitionsLogic.test.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/relationshipDefinitionsLogic.test.ts
index aa460629aab8..72cdb43d02ef 100644
--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/relationshipDefinitionsLogic.test.ts
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/relationshipDefinitionsLogic.test.ts
@@ -51,6 +51,30 @@ describe('relationshipDefinitionsLogic', () => {
.toMatchValues({ definitions: [expect.objectContaining({ id: 'def-1', name: 'CSM' })] })
})
+ it('loads relationship definitions beyond the first page', async () => {
+ const first = buildDefinition()
+ const second = buildDefinition({ id: 'def-2', name: 'Account owner' })
+ useMocks({
+ get: {
+ [DEFINITIONS_URL]: ({ request }) => {
+ const offset = Number(new URL(request.url).searchParams.get('offset') ?? 0)
+ return [
+ 200,
+ offset === 0
+ ? { count: 2, next: `${DEFINITIONS_URL}?offset=1`, results: [first] }
+ : { count: 2, next: null, results: [second] },
+ ]
+ },
+ },
+ })
+ mountLogic()
+ await expectLogic(logic)
+ .toDispatchActions(['loadDefinitionsSuccess'])
+ .toMatchValues({
+ definitions: [first, second],
+ })
+ })
+
it('creates a definition and reloads the list', async () => {
useMocks({
get: { [DEFINITIONS_URL]: { count: 0, results: [] } },
diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/relationshipDefinitionsLogic.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/relationshipDefinitionsLogic.ts
index c7d5bb465155..c3a1c9b745a8 100644
--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/relationshipDefinitionsLogic.ts
+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/relationshipDefinitionsLogic.ts
@@ -50,6 +50,7 @@ const handleNameConflict = (error: unknown, setManualErrors: (errors: { name: st
export interface relationshipDefinitionsLogicValues {
currentProjectId: number | null // projectLogic
definitions: AccountRelationshipDefinitionApi[]
+ definitionsLoadFailed: boolean
definitionsLoading: boolean
editingDefinition: AccountRelationshipDefinitionApi | null
isRelationshipDefinitionFormSubmitting: boolean
@@ -175,6 +176,14 @@ export const relationshipDefinitionsLogic = kea<relationshipDefinitionsLogicType
closeModal: true,
}),
reducers({
+ definitionsLoadFailed: [
+ false,
+ {
+ loadDefinitions: () => false,
+ loadDefinitionsSuccess: () => false,
+ loadDefinitionsFailure: () => true,
+ },
+ ],
modalVisible: [
false,
{
@@ -197,8 +206,18 @@ export const relationshipDefinitionsLogic = kea<relationshipDefinitionsLogicType
[] as AccountRelationshipDefinitionApi[],
{
loadDefinitions: async (): Promise<AccountRelationshipDefinitionApi[]> => {
- const response = await accountRelationshipDefinitionsList(String(values.currentProjectId))
- return response.results
+ const projectId = String(values.currentProjectId)
+ const definitions: AccountRelationshipDefinitionApi[] = []
+ let response = await accountRelationshipDefinitionsList(projectId)
+ definitions.push(...response.results)
+ while (response.next) {
+ if (response.results.length === 0) {
+ throw new Error('Relationship definitions page is empty despite a next page')
+ }
+ response = await accountRelationshipDefinitionsList(projectId, { offset: definitions.length })
+ definitions.push(...response.results)
+ }
+ return definitions
},
deleteDefinition: async ({ id }: { id: string }): Promise<AccountRelationshipDefinitionApi[]> => {
await accountRelationshipDefinitionsDestroy(String(values.currentProjectId), id)
diff --git a/products/experiments/frontend/generated/api.schemas.ts b/products/experiments/frontend/generated/api.schemas.ts
index 0810b760b2a2..e75008e6c5de 100644
--- a/products/experiments/frontend/generated/api.schemas.ts
+++ b/products/experiments/frontend/generated/api.schemas.ts
@@ -943,9 +943,9 @@ export interface ExperimentToSavedMetricApi {
readonly name: string
}
-export type Kind1Api = (typeof Kind1Api)[keyof typeof Kind1Api]
+export type Kind2Api = (typeof Kind2Api)[keyof typeof Kind2Api]
-export const Kind1Api = {
+export const Kind2Api = {
ExperimentEventExposureConfig: 'ExperimentEventExposureConfig',
ActionsNode: 'ActionsNode',
} as const
@@ -1281,7 +1281,7 @@ export interface ExperimentApiExposureConfigApi {
/** Action ID. Required when kind is 'ActionsNode'. */
id?: number | null
/** Defaults to 'ExperimentEventExposureConfig' when omitted. Pass 'ActionsNode' for an action-based exposure. */
- kind?: Kind1Api | null
+ kind?: Kind2Api | null
/** Property filters (event, person, and other supported types). Pass an empty array if no filters needed. */
properties: (
| EventPropertyFilterApi
@@ -1327,9 +1327,9 @@ export interface ExperimentApiExposureCriteriaApi {
multiple_variant_handling?: MultipleVariantHandlingApi | null
}
-export type KindApi = (typeof KindApi)[keyof typeof KindApi]
+export type Kind1Api = (typeof Kind1Api)[keyof typeof Kind1Api]
-export const KindApi = {
+export const Kind1Api = {
EventsNode: 'EventsNode',
ActionsNode: 'ActionsNode',
} as const
@@ -1363,7 +1363,7 @@ export interface ExperimentApiEventSourceApi {
event?: string | null
/** Action ID. Required for ActionsNode. */
id?: number | null
- kind: KindApi
+ kind: Kind1Api
/** How to aggregate this source. Defaults to 'total' (event count). Use 'sum' together with math_property to aggregate a numeric property — e.g. a ratio numerator of revenue per order. Other options: 'avg', 'min', 'max', 'unique_session', 'dau', 'unique_group', 'hogql'. */
math?: ExperimentMetricMathTypeApi | null
/** Group type index to aggregate over. Required when math is 'unique_group'. */
@@ -1420,9 +1420,9 @@ export const ExperimentMetricTypeApi = {
Retention: 'retention',
} as const
-export type Kind2Api = (typeof Kind2Api)[keyof typeof Kind2Api]
+export type Kind3Api = (typeof Kind3Api)[keyof typeof Kind3Api]
-export const Kind2Api = {
+export const Kind3Api = {
EventsNode: 'EventsNode',
ActionsNode: 'ActionsNode',
ExperimentExposureNode: 'ExperimentExposureNode',
@@ -1434,7 +1434,7 @@ export interface ExperimentApiRetentionStartApi {
/** Action ID. Required for ActionsNode. */
id?: number | null
/** Pass 'ExperimentExposureNode' to start retention from the experiment's own exposure event; the other fields then stay unset. */
- kind: Kind2Api
+ kind: Kind3Api
/** How to aggregate this source. Defaults to 'total' (event count). Use 'sum' together with math_property to aggregate a numeric property — e.g. a ratio numerator of revenue per order. Other options: 'avg', 'min', 'max', 'unique_session', 'dau', 'unique_group', 'hogql'. */
math?: ExperimentMetricMathTypeApi | null
/** Group type index to aggregate over. Required when math is 'unique_group'. */
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 1c13a1ecc93a..c9091ca0a394 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -1868,6 +1868,18 @@ export namespace Schemas {
account_ids: string[];
}
+ /**
+ * * `custom_property` - Custom property
+ * * `relationship` - Relationship
+ */
+ export type AccountPropertyPinKindEnum = typeof AccountPropertyPinKindEnum[keyof typeof AccountPropertyPinKindEnum];
+
+
+ export const AccountPropertyPinKindEnum = {
+ CustomProperty: 'custom_property',
+ Relationship: 'relationship',
+ } as const;
+
/**
* A team-defined account relationship type (CSM, Onboarding manager, ...).
*/
@@ -41421,10 +41433,10 @@ export namespace Schemas {
Product: 'product',
} as const;
- export type Kind1 = typeof Kind1[keyof typeof Kind1];
+ export type Kind2 = typeof Kind2[keyof typeof Kind2];
- export const Kind1 = {
+ export const Kind2 = {
ExperimentEventExposureConfig: 'ExperimentEventExposureConfig',
ActionsNode: 'ActionsNode',
} as const;
@@ -41435,7 +41447,7 @@ export namespace Schemas {
/** Action ID. Required when kind is 'ActionsNode'. */
id?: number | null;
/** Defaults to 'ExperimentEventExposureConfig' when omitted. Pass 'ActionsNode' for an action-based exposure. */
- kind?: Kind1 | null;
+ kind?: Kind2 | null;
/** Property filters (event, person, and other supported types). Pass an empty array if no filters needed. */
properties: (EventPropertyFilter | PersonPropertyFilter | PersonMetadataPropertyFilter | ElementPropertyFilter | EventMetadataPropertyFilter | SessionPropertyFilter | CohortPropertyFilter | RecordingPropertyFilter | LogEntryPropertyFilter | GroupPropertyFilter | FeaturePropertyFilter | FlagPropertyFilter | HogQLPropertyFilter | EmptyPropertyFilter | DataWarehousePropertyFilter | DataWarehousePersonPropertyFilter | ErrorTrackingIssueFilter | LogPropertyFilter | MetricPropertyFilter | SpanPropertyFilter | RevenueAnalyticsPropertyFilter | AccountCustomPropertyFilter | WorkflowVariablePropertyFilter | BehavioralPropertyFilter)[];
}
@@ -41449,10 +41461,10 @@ export namespace Schemas {
multiple_variant_handling?: MultipleVariantHandling | null;
}
- export type Kind = typeof Kind[keyof typeof Kind];
+ export type Kind1 = typeof Kind1[keyof typeof Kind1];
- export const Kind = {
+ export const Kind1 = {
EventsNode: 'EventsNode',
ActionsNode: 'ActionsNode',
} as const;
@@ -41462,7 +41474,7 @@ export namespace Schemas {
event?: string | null;
/** Action ID. Required for ActionsNode. */
id?: number | null;
- kind: Kind;
+ kind: Kind1;
/** How to aggregate this source. Defaults to 'total' (event count). Use 'sum' together with math_property to aggregate a numeric property — e.g. a ratio numerator of revenue per order. Other options: 'avg', 'min', 'max', 'unique_session', 'dau', 'unique_group', 'hogql'. */
math?: ExperimentMetricMathType | null;
/** Group type index to aggregate over. Required when math is 'unique_group'. */
@@ -41485,10 +41497,10 @@ export namespace Schemas {
Retention: 'retention',
} as const;
- export type Kind2 = typeof Kind2[keyof typeof Kind2];
+ export type Kind3 = typeof Kind3[keyof typeof Kind3];
- export const Kind2 = {
+ export const Kind3 = {
EventsNode: 'EventsNode',
ActionsNode: 'ActionsNode',
ExperimentExposureNode: 'ExperimentExposureNode',
@@ -41500,7 +41512,7 @@ export namespace Schemas {
/** Action ID. Required for ActionsNode. */
id?: number | null;
/** Pass 'ExperimentExposureNode' to start retention from the experiment's own exposure event; the other fields then stay unset. */
- kind: Kind2;
+ kind: Kind3;
/** How to aggregate this source. Defaults to 'total' (event count). Use 'sum' together with math_property to aggregate a numeric property — e.g. a ratio numerator of revenue per order. Other options: 'avg', 'min', 'max', 'unique_session', 'dau', 'unique_group', 'hogql'. */
math?: ExperimentMetricMathType | null;
/** Group type index to aggregate over. Required when math is 'unique_group'. */
@@ -78017,6 +78029,16 @@ export namespace Schemas {
campaign_field_preferences?: MarketingAnalyticsCampaignFieldPreferences;
}
+ export interface TeamCustomerAnalyticsPinnedAccountProperty {
+ /** Definition type for this default pinned account property.
+ *
+ * * `custom_property` - Custom property
+ * * `relationship` - Relationship */
+ kind: AccountPropertyPinKindEnum;
+ /** Project-scoped custom property or relationship definition UUID. */
+ id: string;
+ }
+
export interface TeamCustomerAnalyticsConfig {
/** Event used as the activity signal (DAU/WAU/MAU). */
activity_event?: unknown;
@@ -78033,6 +78055,8 @@ export namespace Schemas {
* @nullable
*/
account_group_type_index?: number | null;
+ /** Ordered account properties shown until a user saves a personal pinned-property selection. Pass an empty list to show no properties by default. */
+ default_pinned_properties?: TeamCustomerAnalyticsPinnedAccountProperty[];
}
export interface TeamWorkflowsConfig {
@@ -81470,24 +81494,12 @@ export namespace Schemas {
readonly requires_credential_review?: boolean;
}
- /**
- * * `custom_property` - Custom property
- * * `relationship` - Relationship
- */
- export type PinnedAccountPropertyKindEnum = typeof PinnedAccountPropertyKindEnum[keyof typeof PinnedAccountPropertyKindEnum];
-
-
- export const PinnedAccountPropertyKindEnum = {
- CustomProperty: 'custom_property',
- Relationship: 'relationship',
- } as const;
-
export interface PinnedAccountProperty {
/** Definition type for this pinned account property.
*
* * `custom_property` - Custom property
* * `relationship` - Relationship */
- kind: PinnedAccountPropertyKindEnum;
+ kind: AccountPropertyPinKindEnum;
/** Team-scoped custom property or relationship definition UUID. */
id: string;
}
diff --git a/services/mcp/src/generated/core/api.ts b/services/mcp/src/generated/core/api.ts
index 68f35bbfb3f7..de73416e4db5 100644
--- a/services/mcp/src/generated/core/api.ts
+++ b/services/mcp/src/generated/core/api.ts
@@ -2428,6 +2428,24 @@ export const OrganizationsProjectsCreateBody = () => zod
.describe(
'Index of the group type to treat as an Account in customer analytics. Must reference an existing group type configured for the project.'
),
+ default_pinned_properties: zod
+ .array(
+ zod.object({
+ kind: zod
+ .enum(['custom_property', 'relationship'])
+ .describe('\* `custom_property` - Custom property\n\* `relationship` - Relationship')
+ .describe(
+ 'Definition type for this default pinned account property.\n\n\* `custom_property` - Custom property\n\* `relationship` - Relationship'
+ ),
+ id: zod
+ .string()
+ .describe('Project-scoped custom property or relationship definition UUID.'),
+ })
+ )
+ .optional()
+ .describe(
+ 'Ordered account properties shown until a user saves a personal pinned-property selection. Pass an empty list to show no properties by default.'
+ ),
})
.optional(),
workflows_config: zod
@@ -5114,6 +5132,24 @@ export const OrganizationsProjectsPartialUpdateBody = () => zod
.describe(
'Index of the group type to treat as an Account in customer analytics. Must reference an existing group type configured for the project.'
),
+ default_pinned_properties: zod
+ .array(
+ zod.object({
+ kind: zod
+ .enum(['custom_property', 'relationship'])
+ .describe('\* `custom_property` - Custom property\n\* `relationship` - Relationship')
+ .describe(
+ 'Definition type for this default pinned account property.\n\n\* `custom_property` - Custom property\n\* `relationship` - Relationship'
+ ),
+ id: zod
+ .string()
+ .describe('Project-scoped custom property or relationship definition UUID.'),
+ })
+ )
+ .optional()
+ .describe(
+ 'Ordered account properties shown until a user saves a personal pinned-property selection. Pass an empty list to show no properties by default.'
+ ),
})
.optional(),
workflows_config: zod
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/project-settings-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/project-settings-update.json
index fbe14cb2e51c..f213f28db23a 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/project-settings-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/project-settings-update.json
@@ -321,6 +321,25 @@
"activity_event": {
"description": "Event used as the activity signal (DAU/WAU/MAU)."
},
+ "default_pinned_properties": {
+ "description": "Ordered account properties shown until a user saves a personal pinned-property selection. Pass an empty list to show no properties by default.",
+ "items": {
+ "properties": {
+ "id": {
+ "description": "Project-scoped custom property or relationship definition UUID.",
+ "type": "string"
+ },
+ "kind": {
+ "description": "Definition type for this default pinned account property.\n\n* `custom_property` - Custom property\n* `relationship` - Relationship",
+ "enum": ["custom_property", "relationship"],
+ "type": "string"
+ }
+ },
+ "required": ["kind", "id"],
+ "type": "object"
+ },
+ "type": "array"
+ },
"payment_event": {
"description": "Event used to count payments on dashboards."
},