:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(customer-analytics): add relationship definitions management UI (#68723)
Arthur Moreira de Deus2a3db4ca2ade
diff --git a/products/customer_analytics/backend/facade/api.py b/products/customer_analytics/backend/facade/api.pyindex bb4aa33bb4fc..b6f4559db5c2 100644--- a/products/customer_analytics/backend/facade/api.py+++ b/products/customer_analytics/backend/facade/api.py@@ -1718,11 +1718,13 @@ def _to_account_relationship(relationship: AccountRelationship) -> contracts.Acc)-def list_account_relationship_definitions(team_id: int) -> list[contracts.AccountRelationshipDefinition]:- return [- _to_account_relationship_definition(definition)- for definition in AccountRelationshipDefinition.objects.for_team(team_id).order_by("name")- ]+def list_account_relationship_definitions(+ team_id: int, offset: int = 0, limit: int = 100+) -> tuple[list[contracts.AccountRelationshipDefinition], int]:+ queryset = AccountRelationshipDefinition.objects.for_team(team_id).order_by("name")+ total_count = queryset.count()+ page = queryset[offset : offset + limit]+ return [_to_account_relationship_definition(definition) for definition in page], total_countdef create_account_relationship_definition(@@ -1748,6 +1750,32 @@ def create_account_relationship_definition(return _to_account_relationship_definition(definition)+def get_account_relationship_definition(+ team_id: int, definition_id: str | UUID+) -> contracts.AccountRelationshipDefinition | None:+ definition = AccountRelationshipDefinition.objects.for_team(team_id).filter(id=definition_id).first()+ if definition is None:+ return None+ return _to_account_relationship_definition(definition)+++def update_account_relationship_definition(+ *, team_id: int, definition_id: str | UUID, fields: dict[str, Any]+) -> contracts.AccountRelationshipDefinition | None:+ definition = AccountRelationshipDefinition.objects.for_team(team_id).filter(id=definition_id).first()+ if definition is None:+ return None+ for attr, value in fields.items():+ setattr(definition, attr, value)+ try:+ definition.save()+ except IntegrityError:+ raise AccountRelationshipDefinitionConflictError(+ "A relationship definition with this name already exists for this team."+ )+ return _to_account_relationship_definition(definition)++def delete_account_relationship_definition(*, team_id: int, definition_id: str | UUID) -> bool:"""Hard-deletes the definition and (by cascade) its assignment history. Returns False whenno definition matches the id for this team (→ 404)."""diff --git a/products/customer_analytics/backend/facade/contracts.py b/products/customer_analytics/backend/facade/contracts.pyindex fd143978715c..23a761c7665a 100644--- a/products/customer_analytics/backend/facade/contracts.py+++ b/products/customer_analytics/backend/facade/contracts.py@@ -30,14 +30,18 @@ class AccountAssignment:email: str-@dataclass(frozen=True)+@stdlib_dataclass(frozen=True)class AccountRelationshipDefinition:- """A team-defined account relationship type (CSM, Onboarding manager, ...)."""+ """A team-defined account relationship type (CSM, Onboarding manager, ...).- id: UUID- name: str- description: str | None- is_single_holder: bool+ Stdlib dataclass with defaults so the wrapping ``DataclassSerializer`` can construct it+ from partial request bodies (see :class:`CustomPropertyDefinitionView`).+ """++ id: UUID | None = None+ name: str = ""+ description: str | None = None+ is_single_holder: bool = True@dataclass(frozen=True)diff --git a/products/customer_analytics/backend/presentation/views/serializers.py b/products/customer_analytics/backend/presentation/views/serializers.pyindex 554f2f25238b..8f4965ae69d3 100644--- a/products/customer_analytics/backend/presentation/views/serializers.py+++ b/products/customer_analytics/backend/presentation/views/serializers.py@@ -34,6 +34,7 @@ from products.customer_analytics.backend.facade.constants import (from products.customer_analytics.backend.facade.contracts import (AccountNotebookView,AccountNoteView,+ AccountRelationshipDefinition,AccountView,CustomerJourneyView,CustomerProfileConfigView,@@ -512,3 +513,28 @@ class CustomPropertyValueSerializer(serializers.Serializer):created_by_id = serializers.IntegerField(read_only=True, allow_null=True, help_text="Id of the user who set this value, if known.")+++class AccountRelationshipDefinitionSerializer(DataclassSerializer):+ """A team-defined account relationship type (CSM, Onboarding manager, ...)."""++ id = serializers.UUIDField(read_only=True, help_text="Relationship definition UUID.")+ name = serializers.CharField(+ max_length=400, help_text="Human-readable name of the relationship. Unique within the team."+ )+ description = serializers.CharField(+ required=False,+ allow_null=True,+ allow_blank=True,+ help_text="What this relationship means, e.g. 'The customer success manager responsible for this account'.",+ )+ is_single_holder = serializers.BooleanField(+ required=False,+ default=True,+ help_text="Whether only one user can hold this relationship per account at a time, e.g. a single CSM per account.",+ )++ class Meta:+ dataclass = AccountRelationshipDefinition+ ref_name = "AccountRelationshipDefinition"+ fields = ["id", "name", "description", "is_single_holder"]diff --git a/products/customer_analytics/backend/presentation/views/views.py b/products/customer_analytics/backend/presentation/views/views.pyindex a965a339b0e2..a743a088c008 100644--- a/products/customer_analytics/backend/presentation/views/views.py+++ b/products/customer_analytics/backend/presentation/views/views.py@@ -36,6 +36,7 @@ from products.customer_analytics.backend.facade import api, contractsfrom products.customer_analytics.backend.presentation.views.serializers import (AccountNotebookSerializer,AccountNoteSerializer,+ AccountRelationshipDefinitionSerializer,AccountSerializer,CustomerJourneySerializer,CustomerProfileConfigSerializer,@@ -303,6 +304,84 @@ def _custom_property_option_dicts(options) -> list[dict] | None:return [asdict(option) for option in options]+class AccountRelationshipDefinitionViewSet(+ TeamAndOrgViewSetMixin,+ AccessControlViewSetMixin,+ _FacadePaginationMixin,+ viewsets.ModelViewSet,+):+ scope_object = "account"+ serializer_class = AccountRelationshipDefinitionSerializer+ queryset = None # data is reached through the facade; declared for router/schema only++ def list(self, request: Request, *args, **kwargs) -> Response:+ return self._paginate_via_facade(+ request,+ lambda offset, limit: api.list_account_relationship_definitions(self.team_id, offset=offset, limit=limit),+ AccountRelationshipDefinitionSerializer,+ )++ def retrieve(self, request: Request, *args, **kwargs) -> Response:+ definition = api.get_account_relationship_definition(self.team_id, self.kwargs["pk"])+ if definition is None:+ return Response({"detail": "Not found."}, status=status.HTTP_404_NOT_FOUND)+ return Response(AccountRelationshipDefinitionSerializer(instance=definition).data)++ def create(self, request: Request, *args, **kwargs) -> Response:+ serializer = AccountRelationshipDefinitionSerializer(data=request.data)+ serializer.is_valid(raise_exception=True)+ data = serializer.validated_data+ try:+ definition = api.create_account_relationship_definition(+ team_id=self.team_id,+ name=data.name,+ description=data.description,+ is_single_holder=data.is_single_holder,+ created_by=cast(User, request.user),+ )+ except api.AccountRelationshipDefinitionConflictError as e:+ raise Conflict(str(e))+ return Response(+ AccountRelationshipDefinitionSerializer(instance=definition).data, status=status.HTTP_201_CREATED+ )++ def update(self, request: Request, *args, **kwargs) -> Response:+ partial = kwargs.pop("partial", False)+ serializer = AccountRelationshipDefinitionSerializer(data=request.data, partial=partial)+ serializer.is_valid(raise_exception=True)+ try:+ definition = api.update_account_relationship_definition(+ team_id=self.team_id,+ definition_id=self.kwargs["pk"],+ fields=_account_relationship_definition_write_fields(serializer.validated_data, request.data),+ )+ except api.AccountRelationshipDefinitionConflictError as e:+ raise Conflict(str(e))+ if definition is None:+ return Response({"detail": "Not found."}, status=status.HTTP_404_NOT_FOUND)+ return Response(AccountRelationshipDefinitionSerializer(instance=definition).data)++ def partial_update(self, request: Request, *args, **kwargs) -> Response:+ kwargs["partial"] = True+ return self.update(request, *args, **kwargs)++ def destroy(self, request: Request, *args, **kwargs) -> Response:+ if not api.delete_account_relationship_definition(team_id=self.team_id, definition_id=self.kwargs["pk"]):+ return Response({"detail": "Not found."}, status=status.HTTP_404_NOT_FOUND)+ return Response(status=status.HTTP_204_NO_CONTENT)+++def _account_relationship_definition_write_fields(validated, raw_data: dict) -> dict:+ fields: dict = {}+ if "name" in raw_data:+ fields["name"] = validated.name+ if "description" in raw_data:+ fields["description"] = validated.description+ if "is_single_holder" in raw_data:+ fields["is_single_holder"] = validated.is_single_holder+ return fields++class CustomPropertySourceViewSet(TeamAndOrgViewSetMixin,AccessControlViewSetMixin,diff --git a/products/customer_analytics/backend/routes.py b/products/customer_analytics/backend/routes.pyindex 6f0d007f5a5a..a75c62dfd537 100644--- a/products/customer_analytics/backend/routes.py+++ b/products/customer_analytics/backend/routes.py@@ -6,6 +6,7 @@ from products.customer_analytics.backend.presentation.views.organization_membersfrom products.customer_analytics.backend.presentation.views.views import (AccountNotebookViewSet,AccountNotesViewSet,+ AccountRelationshipDefinitionViewSet,AccountViewSet,CustomerJourneyViewSet,CustomerProfileConfigViewSet,@@ -43,6 +44,12 @@ def register_routes(routers: RouterRegistry) -> None:"project_custom_property_sources",["team_id"],)+ routers.projects.register(+ r"account_relationship_definitions",+ AccountRelationshipDefinitionViewSet,+ "project_account_relationship_definitions",+ ["team_id"],+ )routers.projects.register(r"account_notes",AccountNotesViewSet,diff --git a/products/customer_analytics/backend/test/test_relationships.py b/products/customer_analytics/backend/test/test_relationships.pyindex f28c5a5c70c2..771bec0ce78a 100644--- a/products/customer_analytics/backend/test/test_relationships.py+++ b/products/customer_analytics/backend/test/test_relationships.py@@ -163,11 +163,45 @@ class TestRelationshipFacade(BaseTest):created = facade.create_account_relationship_definition(team_id=self.team.id, name="Onboarding manager", description="Runs onboarding", created_by=self.user)- listed = facade.list_account_relationship_definitions(self.team.id)+ listed, total = facade.list_account_relationship_definitions(self.team.id)+ assert total == 1assert [d.id for d in listed] == [created.id]assert listed[0].description == "Runs onboarding"assert listed[0].is_single_holder is True+ def test_update_definition_renames_and_toggles_cardinality(self):+ definition = facade.create_account_relationship_definition(+ team_id=self.team.id, name="FDE", created_by=self.user+ )+ assert definition.id is not None+ updated = facade.update_account_relationship_definition(+ team_id=self.team.id,+ definition_id=definition.id,+ fields={"name": "Field engineer", "is_single_holder": False},+ )+ assert updated is not None+ assert updated.name == "Field engineer"+ assert updated.is_single_holder is False++ def test_update_definition_name_collision_raises_conflict(self):+ facade.create_account_relationship_definition(team_id=self.team.id, name="CSM", created_by=self.user)+ definition = facade.create_account_relationship_definition(+ team_id=self.team.id, name="FDE", created_by=self.user+ )+ assert definition.id is not None+ with self.assertRaises(facade.AccountRelationshipDefinitionConflictError):+ facade.update_account_relationship_definition(+ team_id=self.team.id, definition_id=definition.id, fields={"name": "CSM"}+ )++ def test_update_definition_unknown_id_returns_none(self):+ assert (+ facade.update_account_relationship_definition(+ team_id=self.team.id, definition_id="00000000-0000-0000-0000-000000000000", fields={"name": "X"}+ )+ is None+ )+def test_create_duplicate_definition_name_raises_conflict(self):facade.create_account_relationship_definition(team_id=self.team.id, name="CSM", created_by=self.user)with self.assertRaises(facade.AccountRelationshipDefinitionConflictError):@@ -177,6 +211,7 @@ class TestRelationshipFacade(BaseTest):definition = facade.create_account_relationship_definition(team_id=self.team.id, name="CSM", created_by=self.user)+ assert definition.id is not Nonemodel_definition = AccountRelationshipDefinition.objects.for_team(self.team.id).get(id=definition.id)relationships.assign(team_id=self.team.id,@@ -192,6 +227,7 @@ class TestRelationshipFacade(BaseTest):definition = facade.create_account_relationship_definition(team_id=self.team.id, name="CSM", created_by=self.user)+ assert definition.id is not Nonemodel_definition = AccountRelationshipDefinition.objects.for_team(self.team.id).get(id=definition.id)rel = relationships.assign(team_id=self.team.id,@@ -215,7 +251,8 @@ class TestRelationshipFacade(BaseTest):definition = facade.create_account_relationship_definition(team_id=self.team.id, name="CSM", created_by=self.user)- assert facade.list_account_relationship_definitions(other_team.id) == []+ assert definition.id is not None+ assert facade.list_account_relationship_definitions(other_team.id) == ([], 0)assert facade.list_account_relationships(team_id=other_team.id, account_id=self.account.id) == []assert not facade.delete_account_relationship_definition(team_id=other_team.id, definition_id=definition.id)diff --git a/products/customer_analytics/backend/test/test_views.py b/products/customer_analytics/backend/test/test_views.pyindex ef18db5e2f98..88d2b86ef17a 100644--- a/products/customer_analytics/backend/test/test_views.py+++ b/products/customer_analytics/backend/test/test_views.py@@ -18,8 +18,11 @@ from posthog.models.organization import OrganizationMembershipfrom posthog.models.team import Teamfrom posthog.models.user import User+from products.customer_analytics.backend.logic import relationships as relationships_logicfrom products.customer_analytics.backend.models import (Account,+ AccountRelationship,+ AccountRelationshipDefinition,CustomerJourney,CustomerProfileConfig,CustomPropertyDefinition,@@ -2109,3 +2112,102 @@ class TestAccountNotesViewSet(APIBaseTest):self.assertEqual(status.HTTP_200_OK, response.status_code, response.json())short_ids = [n["short_id"] for n in response.json()["results"]]self.assertEqual(short_ids, [visible.short_id])+++class TestAccountRelationshipDefinitionViewSet(APIBaseTest):+ def setUp(self):+ super().setUp()+ self.endpoint_base = f"/api/projects/{self.team.id}/account_relationship_definitions/"++ def _create(self, **overrides):+ payload = {"name": "CSM", "description": "Customer success manager"}+ payload.update(overrides)+ return self.client.post(self.endpoint_base, payload, format="json")++ def test_create_and_list_roundtrip(self):+ response = self._create()++ self.assertEqual(status.HTTP_201_CREATED, response.status_code, response.json())+ data = response.json()+ self.assertEqual(data["name"], "CSM")+ self.assertEqual(data["description"], "Customer success manager")+ self.assertTrue(data["is_single_holder"])++ # nosemgrep: idor-lookup-without-team (test assertion)+ definition = AccountRelationshipDefinition.objects.unscoped().get(id=data["id"])+ self.assertEqual(definition.team, self.team)+ self.assertEqual(definition.created_by, self.user)++ listed = self.client.get(self.endpoint_base)+ self.assertEqual(status.HTTP_200_OK, listed.status_code, listed.json())+ self.assertEqual([d["id"] for d in listed.json()["results"]], [data["id"]])++ def test_create_duplicate_name_returns_conflict(self):+ self._create()+ response = self._create()++ self.assertEqual(status.HTTP_409_CONFLICT, response.status_code, response.json())++ def test_patch_renames_and_toggles_cardinality(self):+ definition_id = self._create(name="FDE").json()["id"]++ response = self.client.patch(+ f"{self.endpoint_base}{definition_id}/",+ {"name": "Field engineer", "is_single_holder": False},+ format="json",+ )++ self.assertEqual(status.HTTP_200_OK, response.status_code, response.json())+ self.assertEqual(response.json()["name"], "Field engineer")+ self.assertFalse(response.json()["is_single_holder"])++ def test_retrieve_returns_definition_and_404_for_unknown(self):+ definition_id = self._create().json()["id"]++ response = self.client.get(f"{self.endpoint_base}{definition_id}/")+ self.assertEqual(status.HTTP_200_OK, response.status_code, response.json())+ self.assertEqual(response.json()["name"], "CSM")++ missing = self.client.get(f"{self.endpoint_base}00000000-0000-0000-0000-000000000000/")+ self.assertEqual(status.HTTP_404_NOT_FOUND, missing.status_code)++ def test_patch_unknown_id_returns_404(self):+ response = self.client.patch(+ f"{self.endpoint_base}00000000-0000-0000-0000-000000000000/", {"name": "X"}, format="json"+ )++ self.assertEqual(status.HTTP_404_NOT_FOUND, response.status_code)++ def test_delete_removes_definition_and_cascades_history(self):+ definition_id = self._create().json()["id"]+ account = create_account(team_id=self.team.id, name="Acme")+ # nosemgrep: idor-lookup-without-team (test setup)+ definition = AccountRelationshipDefinition.objects.unscoped().get(id=definition_id)+ relationships_logic.assign(+ team_id=self.team.id, account=account, definition=definition, user=self.user, created_by=self.user+ )++ response = self.client.delete(f"{self.endpoint_base}{definition_id}/")++ self.assertEqual(status.HTTP_204_NO_CONTENT, response.status_code)+ self.assertFalse(AccountRelationshipDefinition.objects.unscoped().filter(id=definition_id).exists())+ self.assertFalse(AccountRelationship.objects.unscoped().filter(definition_id=definition_id).exists())++ def test_viewer_access_can_list_but_not_write(self):+ self.organization.available_product_features = [+ {"key": AvailableFeature.ACCESS_CONTROL, "name": AvailableFeature.ACCESS_CONTROL},+ {"key": AvailableFeature.ROLE_BASED_ACCESS, "name": AvailableFeature.ROLE_BASED_ACCESS},+ ]+ self.organization.save()+ viewer = User.objects.create_and_join(self.organization, "[email protected]", "testtest")+ AccessControl.objects.create(+ team=self.team,+ resource="customer_analytics",+ resource_id=None,+ access_level="viewer",+ organization_member=OrganizationMembership.objects.get(user=viewer, organization=self.organization),+ )+ self.client.force_login(viewer)++ self.assertEqual(self.client.get(self.endpoint_base).status_code, status.HTTP_200_OK)+ self.assertEqual(self._create().status_code, status.HTTP_403_FORBIDDEN)diff --git a/products/customer_analytics/frontend/generated/api.schemas.ts b/products/customer_analytics/frontend/generated/api.schemas.tsindex d9f3a3d78389..7d2326ff10e1 100644--- a/products/customer_analytics/frontend/generated/api.schemas.ts+++ b/products/customer_analytics/frontend/generated/api.schemas.ts@@ -94,6 +94,55 @@ export interface PaginatedAccountNoteListApi {results: AccountNoteApi[]}+/**+ * A team-defined account relationship type (CSM, Onboarding manager, ...).+ */+export interface AccountRelationshipDefinitionApi {+ /** Relationship definition UUID. */+ readonly id: string+ /**+ * Human-readable name of the relationship. Unique within the team.+ * @maxLength 400+ */+ name: string+ /**+ * What this relationship means, e.g. 'The customer success manager responsible for this account'.+ * @nullable+ */+ description?: string | null+ /** Whether only one user can hold this relationship per account at a time, e.g. a single CSM per account. */+ is_single_holder?: boolean+}++export interface PaginatedAccountRelationshipDefinitionListApi {+ count: number+ /** @nullable */+ next?: string | null+ /** @nullable */+ previous?: string | null+ results: AccountRelationshipDefinitionApi[]+}++/**+ * A team-defined account relationship type (CSM, Onboarding manager, ...).+ */+export interface PatchedAccountRelationshipDefinitionApi {+ /** Relationship definition UUID. */+ readonly id?: string+ /**+ * Human-readable name of the relationship. Unique within the team.+ * @maxLength 400+ */+ name?: string+ /**+ * What this relationship means, e.g. 'The customer success manager responsible for this account'.+ * @nullable+ */+ description?: string | null+ /** Whether only one user can hold this relationship per account at a time, e.g. a single CSM per account. */+ is_single_holder?: boolean+}+/*** Typed account properties: assignment fields (csm, account_executive, account_owner) and external system identifiers (stripe_customer_id, hubspot_deal_id, billing_id, sfdc_id, zendesk_id, slack_channel_id, usage_dashboard_link). Defaults to an empty object. Unknown keys are rejected.* @nullable@@ -835,6 +884,17 @@ export type AccountNotesListParams = {search?: string}+export type AccountRelationshipDefinitionsListParams = {+ /**+ * Number of results to return per page.+ */+ limit?: number+ /**+ * The initial index from which to return the results.+ */+ offset?: number+}+export type AccountsListParams = {/*** Filter by account executive. Use 'unassigned' or an integer user id.diff --git a/products/customer_analytics/frontend/generated/api.ts b/products/customer_analytics/frontend/generated/api.tsindex eac479f3a5c8..2df1c335aec5 100644--- a/products/customer_analytics/frontend/generated/api.ts+++ b/products/customer_analytics/frontend/generated/api.ts@@ -12,6 +12,8 @@ import type {AccountApi,AccountNotebookApi,AccountNotesListParams,+ AccountRelationshipDefinitionApi,+ AccountRelationshipDefinitionsListParams,AccountsListParams,AccountsNotebooksListParams,CustomPropertyDefinitionApi,@@ -30,12 +32,14 @@ import type {PaginatedAccountListApi,PaginatedAccountNoteListApi,PaginatedAccountNotebookListApi,+ PaginatedAccountRelationshipDefinitionListApi,PaginatedCustomPropertyDefinitionListApi,PaginatedCustomPropertySourceListApi,PaginatedCustomerJourneyListApi,PaginatedCustomerProfileConfigListApi,PaginatedGroupUsageMetricListApi,PatchedAccountApi,+ PatchedAccountRelationshipDefinitionApi,PatchedCustomPropertyDefinitionApi,PatchedCustomPropertySourceUpdateApi,PatchedCustomerJourneyApi,@@ -87,6 +91,125 @@ export const accountNotesList = async (})}+export const getAccountRelationshipDefinitionsListUrl = (+ projectId: string,+ params?: AccountRelationshipDefinitionsListParams+) => {+ const normalizedParams = new URLSearchParams()++ Object.entries(params || {}).forEach(([key, value]) => {+ if (value !== undefined) {+ normalizedParams.append(key, value === null ? 'null' : String(value))+ }+ })++ const stringifiedParams = normalizedParams.toString()++ return stringifiedParams.length > 0+ ? `/api/projects/${projectId}/account_relationship_definitions/?${stringifiedParams}`+ : `/api/projects/${projectId}/account_relationship_definitions/`+}++export const accountRelationshipDefinitionsList = async (+ projectId: string,+ params?: AccountRelationshipDefinitionsListParams,+ options?: RequestInit+): Promise<PaginatedAccountRelationshipDefinitionListApi> => {+ return apiMutator<PaginatedAccountRelationshipDefinitionListApi>(+ getAccountRelationshipDefinitionsListUrl(projectId, params),+ {+ ...options,+ method: 'GET',+ }+ )+}++export const getAccountRelationshipDefinitionsCreateUrl = (projectId: string) => {+ return `/api/projects/${projectId}/account_relationship_definitions/`+}++export const accountRelationshipDefinitionsCreate = async (+ projectId: string,+ accountRelationshipDefinitionApi: NonReadonly<AccountRelationshipDefinitionApi>,+ options?: RequestInit+): Promise<AccountRelationshipDefinitionApi> => {+ return apiMutator<AccountRelationshipDefinitionApi>(getAccountRelationshipDefinitionsCreateUrl(projectId), {+ ...options,+ method: 'POST',+ headers: { 'Content-Type': 'application/json', ...options?.headers },+ body: JSON.stringify(accountRelationshipDefinitionApi),+ })+}++export const getAccountRelationshipDefinitionsRetrieveUrl = (projectId: string, id: string) => {+ return `/api/projects/${projectId}/account_relationship_definitions/${id}/`+}++export const accountRelationshipDefinitionsRetrieve = async (+ projectId: string,+ id: string,+ options?: RequestInit+): Promise<AccountRelationshipDefinitionApi> => {+ return apiMutator<AccountRelationshipDefinitionApi>(getAccountRelationshipDefinitionsRetrieveUrl(projectId, id), {+ ...options,+ method: 'GET',+ })+}++export const getAccountRelationshipDefinitionsUpdateUrl = (projectId: string, id: string) => {+ return `/api/projects/${projectId}/account_relationship_definitions/${id}/`+}++export const accountRelationshipDefinitionsUpdate = async (+ projectId: string,+ id: string,+ accountRelationshipDefinitionApi: NonReadonly<AccountRelationshipDefinitionApi>,+ options?: RequestInit+): Promise<AccountRelationshipDefinitionApi> => {+ return apiMutator<AccountRelationshipDefinitionApi>(getAccountRelationshipDefinitionsUpdateUrl(projectId, id), {+ ...options,+ method: 'PUT',+ headers: { 'Content-Type': 'application/json', ...options?.headers },+ body: JSON.stringify(accountRelationshipDefinitionApi),+ })+}++export const getAccountRelationshipDefinitionsPartialUpdateUrl = (projectId: string, id: string) => {+ return `/api/projects/${projectId}/account_relationship_definitions/${id}/`+}++export const accountRelationshipDefinitionsPartialUpdate = async (+ projectId: string,+ id: string,+ patchedAccountRelationshipDefinitionApi?: NonReadonly<PatchedAccountRelationshipDefinitionApi>,+ options?: RequestInit+): Promise<AccountRelationshipDefinitionApi> => {+ return apiMutator<AccountRelationshipDefinitionApi>(+ getAccountRelationshipDefinitionsPartialUpdateUrl(projectId, id),+ {+ ...options,+ method: 'PATCH',+ headers: { 'Content-Type': 'application/json', ...options?.headers },+ body: JSON.stringify(patchedAccountRelationshipDefinitionApi),+ }+ )+}++export const getAccountRelationshipDefinitionsDestroyUrl = (projectId: string, id: string) => {+ return `/api/projects/${projectId}/account_relationship_definitions/${id}/`+}++export const accountRelationshipDefinitionsDestroy = async (+ projectId: string,+ id: string,+ options?: RequestInit+): Promise<void> => {+ return apiMutator<void>(getAccountRelationshipDefinitionsDestroyUrl(projectId, id), {+ ...options,+ method: 'DELETE',+ })+}+export const getAccountsListUrl = (projectId: string, params?: AccountsListParams) => {const normalizedParams = new URLSearchParams()diff --git a/products/customer_analytics/frontend/generated/api.zod.ts b/products/customer_analytics/frontend/generated/api.zod.tsindex 62fd50a436a2..054eced9f790 100644--- a/products/customer_analytics/frontend/generated/api.zod.ts+++ b/products/customer_analytics/frontend/generated/api.zod.ts@@ -9,6 +9,82 @@*/import * as zod from 'zod'+export const accountRelationshipDefinitionsCreateBodyNameMax = 400++export const accountRelationshipDefinitionsCreateBodyIsSingleHolderDefault = true++export const AccountRelationshipDefinitionsCreateBody = /* @__PURE__ */ zod+ .object({+ name: zod+ .string()+ .max(accountRelationshipDefinitionsCreateBodyNameMax)+ .describe('Human-readable name of the relationship. Unique within the team.'),+ description: zod+ .string()+ .nullish()+ .describe(+ "What this relationship means, e.g. 'The customer success manager responsible for this account'."+ ),+ is_single_holder: zod+ .boolean()+ .default(accountRelationshipDefinitionsCreateBodyIsSingleHolderDefault)+ .describe(+ 'Whether only one user can hold this relationship per account at a time, e.g. a single CSM per account.'+ ),+ })+ .describe('A team-defined account relationship type (CSM, Onboarding manager, ...).')++export const accountRelationshipDefinitionsUpdateBodyNameMax = 400++export const accountRelationshipDefinitionsUpdateBodyIsSingleHolderDefault = true++export const AccountRelationshipDefinitionsUpdateBody = /* @__PURE__ */ zod+ .object({+ name: zod+ .string()+ .max(accountRelationshipDefinitionsUpdateBodyNameMax)+ .describe('Human-readable name of the relationship. Unique within the team.'),+ description: zod+ .string()+ .nullish()+ .describe(+ "What this relationship means, e.g. 'The customer success manager responsible for this account'."+ ),+ is_single_holder: zod+ .boolean()+ .default(accountRelationshipDefinitionsUpdateBodyIsSingleHolderDefault)+ .describe(+ 'Whether only one user can hold this relationship per account at a time, e.g. a single CSM per account.'+ ),+ })+ .describe('A team-defined account relationship type (CSM, Onboarding manager, ...).')++export const accountRelationshipDefinitionsPartialUpdateBodyNameMax = 400++export const accountRelationshipDefinitionsPartialUpdateBodyIsSingleHolderDefault = true++export const AccountRelationshipDefinitionsPartialUpdateBody = /* @__PURE__ */ zod+ .object({+ name: zod+ .string()+ .max(accountRelationshipDefinitionsPartialUpdateBodyNameMax)+ .optional()+ .describe('Human-readable name of the relationship. Unique within the team.'),+ description: zod+ .string()+ .nullish()+ .describe(+ "What this relationship means, e.g. 'The customer success manager responsible for this account'."+ ),+ is_single_holder: zod+ .boolean()+ .default(accountRelationshipDefinitionsPartialUpdateBodyIsSingleHolderDefault)+ .describe(+ 'Whether only one user can hold this relationship per account at a time, e.g. a single CSM per account.'+ ),+ })+ .describe('A team-defined account relationship type (CSM, Onboarding manager, ...).')+export const accountsCreateBodyNameMax = 400export const accountsCreateBodyExternalIdMax = 400diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomerAnalyticsAccountConfig.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomerAnalyticsAccountConfig.tsxindex d025a1646001..56560be1b3b2 100644--- a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomerAnalyticsAccountConfig.tsx+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/CustomerAnalyticsAccountConfig.tsx@@ -13,6 +13,7 @@ import { groupsModel } from '~/models/groupsModel'import { CustomerAnalyticsConfig } from '~/queries/schema/schema-general'import { CustomPropertiesConfig } from './CustomPropertiesConfig'+import { RelationshipsConfig } from './RelationshipsConfig'const NO_ACCOUNT_GROUP = -1@@ -59,6 +60,8 @@ export function CustomerAnalyticsAccountConfig(): JSX.Element {/><LemonDivider /><CustomPropertiesConfig />+ <LemonDivider />+ <RelationshipsConfig /></div>)}diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/RelationshipDefinitionModal.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/RelationshipDefinitionModal.tsxnew file mode 100644index 000000000000..8c0a26a6e1bf--- /dev/null+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/RelationshipDefinitionModal.tsx@@ -0,0 +1,53 @@+import { useActions, useValues } from 'kea'+import { Form } from 'kea-forms'++import { LemonButton, LemonInput, LemonModal, LemonTextArea } from '@posthog/lemon-ui'++import { LemonField } from 'lib/lemon-ui/LemonField'++import { relationshipDefinitionsLogic } from './relationshipDefinitionsLogic'++export function RelationshipDefinitionModal(): JSX.Element {+ const { modalVisible, editingDefinition, isRelationshipDefinitionFormSubmitting } =+ useValues(relationshipDefinitionsLogic)+ const { closeModal, submitRelationshipDefinitionForm } = useActions(relationshipDefinitionsLogic)++ return (+ <LemonModal+ isOpen={modalVisible}+ onClose={closeModal}+ title={editingDefinition ? 'Edit relationship' : 'New relationship'}+ footer={+ <>+ <LemonButton type="secondary" onClick={closeModal}>+ Cancel+ </LemonButton>+ <LemonButton+ type="primary"+ onClick={submitRelationshipDefinitionForm}+ loading={isRelationshipDefinitionFormSubmitting}+ >+ {editingDefinition ? 'Save' : 'Create'}+ </LemonButton>+ </>+ }+ >+ <Form+ logic={relationshipDefinitionsLogic}+ formKey="relationshipDefinitionForm"+ enableFormOnSubmit+ className="flex flex-col gap-4"+ >+ <LemonField name="name" label="Name">+ <LemonInput placeholder="e.g. Onboarding manager" autoFocus fullWidth />+ </LemonField>+ <LemonField name="description" label="Description" showOptional>+ <LemonTextArea+ placeholder="What this relationship means, e.g. 'Runs onboarding for this account'"+ minRows={2}+ />+ </LemonField>+ </Form>+ </LemonModal>+ )+}diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/RelationshipsConfig.tsx b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/RelationshipsConfig.tsxnew file mode 100644index 000000000000..289c02357737--- /dev/null+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/RelationshipsConfig.tsx@@ -0,0 +1,96 @@+import { useActions, useValues } from 'kea'++import { IconPencil, IconTrash } from '@posthog/icons'+import { LemonButton, LemonTable, LemonTableColumns } from '@posthog/lemon-ui'++import { RestrictionScope, useRestrictedArea } from 'lib/components/RestrictedArea'+import { TeamMembershipLevel } from 'lib/constants'+import { LemonDialog } from 'lib/lemon-ui/LemonDialog'++import type { AccountRelationshipDefinitionApi } from 'products/customer_analytics/frontend/generated/api.schemas'++import { RelationshipDefinitionModal } from './RelationshipDefinitionModal'+import { relationshipDefinitionsLogic } from './relationshipDefinitionsLogic'++export function RelationshipsConfig(): JSX.Element {+ const { definitions, definitionsLoading } = useValues(relationshipDefinitionsLogic)+ const { openCreateModal, openEditModal, deleteDefinition } = useActions(relationshipDefinitionsLogic)+ const restrictionReason = useRestrictedArea({+ scope: RestrictionScope.Project,+ minimumAccessLevel: TeamMembershipLevel.Admin,+ })++ const confirmDelete = (definition: AccountRelationshipDefinitionApi): void => {+ LemonDialog.open({+ title: `Delete ${definition.name}?`,+ description: `Deleting ${definition.name} also deletes its entire assignment history on all accounts. This can't be undone.`,+ primaryButton: {+ children: 'Delete',+ status: 'danger',+ onClick: () => deleteDefinition({ id: definition.id }),+ },+ secondaryButton: { children: 'Cancel' },+ })+ }++ const columns: LemonTableColumns<AccountRelationshipDefinitionApi> = [+ {+ title: 'Name',+ dataIndex: 'name',+ render: (_, definition) => <span className="font-semibold">{definition.name}</span>,+ },+ {+ title: 'Description',+ dataIndex: 'description',+ render: (_, definition) =>+ definition.description ? definition.description : <span className="text-secondary">—</span>,+ },+ {+ title: '',+ width: 0,+ render: (_, definition) => (+ <div className="flex gap-1 justify-end">+ <LemonButton+ size="small"+ icon={<IconPencil />}+ tooltip="Edit"+ onClick={() => openEditModal(definition)}+ disabledReason={restrictionReason}+ />+ <LemonButton+ size="small"+ status="danger"+ icon={<IconTrash />}+ tooltip="Delete"+ onClick={() => confirmDelete(definition)}+ disabledReason={restrictionReason}+ />+ </div>+ ),+ },+ ]++ return (+ <div className="flex flex-col gap-2">+ <div className="flex items-center justify-between gap-2">+ <div>+ <h3 className="mb-0">Relationships</h3>+ <p className="text-secondary mb-0">+ Define the roles your team holds on accounts, like CSM or Onboarding manager.+ </p>+ </div>+ <LemonButton type="primary" onClick={openCreateModal} disabledReason={restrictionReason}>+ New relationship+ </LemonButton>+ </div>+ <LemonTable+ columns={columns}+ dataSource={definitions}+ loading={definitionsLoading}+ rowKey="id"+ emptyState="No relationships yet. Create one to get started."+ />+ <RelationshipDefinitionModal />+ </div>+ )+}diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/relationshipDefinitionsLogic.test.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/relationshipDefinitionsLogic.test.tsnew file mode 100644index 000000000000..54e9fe8af631--- /dev/null+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/relationshipDefinitionsLogic.test.ts@@ -0,0 +1,115 @@+import { MOCK_DEFAULT_TEAM, MOCK_DEFAULT_USER } from '~/lib/api.mock'++import { expectLogic } from 'kea-test-utils'++import { userLogic } from 'scenes/userLogic'++import { useMocks } from '~/mocks/jest'+import { initKeaTests } from '~/test/init'++import type { AccountRelationshipDefinitionApi } from 'products/customer_analytics/frontend/generated/api.schemas'++import { relationshipDefinitionsLogic } from './relationshipDefinitionsLogic'++const DEFINITIONS_URL = '/api/projects/:team_id/account_relationship_definitions/'+const DEFINITION_URL = '/api/projects/:team_id/account_relationship_definitions/:id/'++const buildDefinition = (+ overrides: Partial<AccountRelationshipDefinitionApi> = {}+): AccountRelationshipDefinitionApi => ({+ id: 'def-1',+ name: 'CSM',+ description: null,+ is_single_holder: true,+ ...overrides,+})++describe('relationshipDefinitionsLogic', () => {+ let logic: ReturnType<typeof relationshipDefinitionsLogic.build>++ const mountLogic = (): void => {+ logic = relationshipDefinitionsLogic()+ logic.mount()+ }++ beforeEach(() => {+ window.POSTHOG_APP_CONTEXT = {+ ...window.POSTHOG_APP_CONTEXT,+ current_team: MOCK_DEFAULT_TEAM,+ current_user: MOCK_DEFAULT_USER,+ } as any+ initKeaTests()+ userLogic.mount()+ })++ it('loads definitions on mount', async () => {+ useMocks({ get: { [DEFINITIONS_URL]: { count: 1, results: [buildDefinition()] } } })+ mountLogic()+ await expectLogic(logic)+ .toDispatchActions(['loadDefinitions', 'loadDefinitionsSuccess'])+ .toMatchValues({ definitions: [expect.objectContaining({ id: 'def-1', name: 'CSM' })] })+ })++ it('creates a definition and reloads the list', async () => {+ useMocks({+ get: { [DEFINITIONS_URL]: { count: 0, results: [] } },+ post: { [DEFINITIONS_URL]: buildDefinition({ id: 'def-2', name: 'FDE', is_single_holder: false }) },+ })+ mountLogic()+ logic.actions.openCreateModal()+ logic.actions.setRelationshipDefinitionFormValues({ name: 'FDE' })++ await expectLogic(logic, () => logic.actions.submitRelationshipDefinitionForm()).toDispatchActions([+ 'submitRelationshipDefinitionFormSuccess',+ 'loadDefinitions',+ 'closeModal',+ ])+ expect(logic.values.modalVisible).toBe(false)+ })++ it('maps a 409 to a name form error and keeps the modal open', async () => {+ useMocks({+ get: { [DEFINITIONS_URL]: { count: 0, results: [] } },+ post: { [DEFINITIONS_URL]: () => [409, { detail: 'duplicate' }] },+ })+ mountLogic()+ logic.actions.openCreateModal()+ logic.actions.setRelationshipDefinitionFormValues({ name: 'CSM' })++ await expectLogic(logic, () => logic.actions.submitRelationshipDefinitionForm()).toDispatchActions([+ 'submitRelationshipDefinitionFormFailure',+ ])+ expect(logic.values.modalVisible).toBe(true)+ expect(logic.values.relationshipDefinitionFormManualErrors).toEqual({+ name: 'A relationship with this name already exists.',+ })+ })++ it('hydrates the form when editing', async () => {+ useMocks({ get: { [DEFINITIONS_URL]: { count: 0, results: [] } } })+ mountLogic()+ const definition = buildDefinition({ description: 'Runs onboarding' })++ logic.actions.openEditModal(definition)++ expect(logic.values.editingDefinition).toEqual(definition)+ expect(logic.values.relationshipDefinitionForm).toEqual({+ name: 'CSM',+ description: 'Runs onboarding',+ })+ })++ it('removes a deleted definition from the list', async () => {+ useMocks({+ get: { [DEFINITIONS_URL]: { count: 1, results: [buildDefinition()] } },+ delete: { [DEFINITION_URL]: {} },+ })+ mountLogic()+ await expectLogic(logic).toDispatchActions(['loadDefinitionsSuccess'])++ await expectLogic(logic, () => logic.actions.deleteDefinition({ id: 'def-1' })).toDispatchActions([+ 'deleteDefinitionSuccess',+ ])+ expect(logic.values.definitions).toEqual([])+ })+})diff --git a/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/relationshipDefinitionsLogic.ts b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/relationshipDefinitionsLogic.tsnew file mode 100644index 000000000000..64717e1875d2--- /dev/null+++ b/products/customer_analytics/frontend/scenes/CustomerAnalyticsConfigurationScene/account/relationshipDefinitionsLogic.ts@@ -0,0 +1,156 @@+import { actions, afterMount, connect, kea, listeners, path, reducers } from 'kea'+import { forms } from 'kea-forms'+import { loaders } from 'kea-loaders'+import posthog from 'posthog-js'++import { lemonToast } from 'lib/lemon-ui/LemonToast/LemonToast'+import { projectLogic } from 'scenes/projectLogic'++import {+ accountRelationshipDefinitionsCreate,+ accountRelationshipDefinitionsDestroy,+ accountRelationshipDefinitionsList,+ accountRelationshipDefinitionsPartialUpdate,+} from 'products/customer_analytics/frontend/generated/api'+import type { AccountRelationshipDefinitionApi } from 'products/customer_analytics/frontend/generated/api.schemas'++import type { relationshipDefinitionsLogicType } from './relationshipDefinitionsLogicType'++export interface RelationshipDefinitionFormValues {+ name: string+ description: string+}++const DEFAULT_FORM_VALUES: RelationshipDefinitionFormValues = {+ name: '',+ description: '',+}++// Cardinality is not exposed in the UI for now — every relationship is single-holder+// (the API default), though the schema already supports multi-holder definitions.+const serializeDefinition = ({+ name,+ description,+}: RelationshipDefinitionFormValues): {+ name: string+ description: string | null+} => ({+ name: name.trim(),+ description: description?.trim() || null,+})++const handleNameConflict = (error: unknown, setManualErrors: (errors: { name: string }) => void): boolean => {+ if ((error as { status?: number })?.status !== 409) {+ return false+ }+ setManualErrors({ name: 'A relationship with this name already exists.' })+ return true+}++export const relationshipDefinitionsLogic = kea<relationshipDefinitionsLogicType>([+ path([+ 'products',+ 'customer_analytics',+ 'frontend',+ 'scenes',+ 'CustomerAnalyticsConfigurationScene',+ 'account',+ 'relationshipDefinitionsLogic',+ ]),+ connect(() => ({+ values: [projectLogic, ['currentProjectId']],+ })),+ actions({+ openCreateModal: true,+ openEditModal: (definition: AccountRelationshipDefinitionApi) => ({ definition }),+ closeModal: true,+ }),+ reducers({+ modalVisible: [+ false,+ {+ openCreateModal: () => true,+ openEditModal: () => true,+ closeModal: () => false,+ },+ ],+ editingDefinition: [+ null as AccountRelationshipDefinitionApi | null,+ {+ openCreateModal: () => null,+ openEditModal: (_, { definition }) => definition,+ closeModal: () => null,+ },+ ],+ }),+ loaders(({ values }) => ({+ definitions: [+ [] as AccountRelationshipDefinitionApi[],+ {+ loadDefinitions: async (): Promise<AccountRelationshipDefinitionApi[]> => {+ const response = await accountRelationshipDefinitionsList(String(values.currentProjectId))+ return response.results+ },+ deleteDefinition: async ({ id }: { id: string }): Promise<AccountRelationshipDefinitionApi[]> => {+ await accountRelationshipDefinitionsDestroy(String(values.currentProjectId), id)+ return values.definitions.filter((definition) => definition.id !== id)+ },+ },+ ],+ })),+ forms(({ values }) => ({+ relationshipDefinitionForm: {+ defaults: DEFAULT_FORM_VALUES,+ errors: ({ name }: RelationshipDefinitionFormValues) => ({+ name: !name?.trim() ? 'Name is required' : undefined,+ }),+ submit: async (formValues: RelationshipDefinitionFormValues) => {+ const projectId = String(values.currentProjectId)+ const body = serializeDefinition(formValues)+ if (values.editingDefinition) {+ await accountRelationshipDefinitionsPartialUpdate(projectId, values.editingDefinition.id, body)+ } else {+ await accountRelationshipDefinitionsCreate(projectId, body)+ }+ },+ },+ })),+ listeners(({ actions }) => ({+ openCreateModal: () => {+ actions.resetRelationshipDefinitionForm()+ },+ openEditModal: ({ definition }) => {+ actions.setRelationshipDefinitionFormValues({+ name: definition.name,+ description: definition.description ?? '',+ })+ },+ submitRelationshipDefinitionFormSuccess: () => {+ lemonToast.success('Relationship saved')+ actions.loadDefinitions()+ actions.closeModal()+ },+ submitRelationshipDefinitionFormFailure: ({ error }) => {+ // A name conflict is expected validation feedback, not an exception worth capturing.+ if (handleNameConflict(error, actions.setRelationshipDefinitionFormManualErrors)) {+ return+ }+ posthog.captureException(error, { scope: 'relationshipDefinitionsLogic.submit' })+ lemonToast.error('Failed to save relationship')+ },+ deleteDefinitionSuccess: () => {+ lemonToast.success('Relationship deleted')+ },+ deleteDefinitionFailure: ({ error }) => {+ posthog.captureException(error, { scope: 'relationshipDefinitionsLogic.delete' })+ lemonToast.error('Failed to delete relationship')+ },+ loadDefinitionsFailure: ({ error }) => {+ posthog.captureException(error, { scope: 'relationshipDefinitionsLogic.load' })+ lemonToast.error('Failed to load relationships')+ },+ })),+ afterMount(({ actions }) => {+ actions.loadDefinitions()+ }),+])diff --git a/products/customer_analytics/mcp/tools.yaml b/products/customer_analytics/mcp/tools.yamlindex 8e7fa5cf1a3a..59c449310308 100644--- a/products/customer_analytics/mcp/tools.yaml+++ b/products/customer_analytics/mcp/tools.yaml@@ -12,6 +12,24 @@ tools:account-notes-list:operation: account_notes_listenabled: false+ account-relationship-definitions-create:+ operation: account_relationship_definitions_create+ enabled: false+ account-relationship-definitions-destroy:+ operation: account_relationship_definitions_destroy+ enabled: false+ account-relationship-definitions-list:+ operation: account_relationship_definitions_list+ enabled: false+ account-relationship-definitions-partial-update:+ operation: account_relationship_definitions_partial_update+ enabled: false+ account-relationship-definitions-retrieve:+ operation: account_relationship_definitions_retrieve+ enabled: false+ account-relationship-definitions-update:+ operation: account_relationship_definitions_update+ enabled: falseaccounts-create:operation: accounts_createenabled: truediff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.tsindex 3ba57bd10509..dc2bed505f79 100644--- a/services/mcp/src/api/generated.ts+++ b/services/mcp/src/api/generated.ts@@ -258,6 +258,26 @@ export namespace Schemas {readonly last_modified_by: UserBasic;}+ /**+ * A team-defined account relationship type (CSM, Onboarding manager, ...).+ */+ export interface AccountRelationshipDefinition {+ /** Relationship definition UUID. */+ readonly id: string;+ /**+ * Human-readable name of the relationship. Unique within the team.+ * @maxLength 400+ */+ name: string;+ /**+ * What this relationship means, e.g. 'The customer success manager responsible for this account'.+ * @nullable+ */+ description?: string | null;+ /** Whether only one user can hold this relationship per account at a time, e.g. a single CSM per account. */+ is_single_holder?: boolean;+ }+export type BounceRatePageViewMode = typeof BounceRatePageViewMode[keyof typeof BounceRatePageViewMode];@@ -31707,6 +31727,15 @@ export namespace Schemas {results: AccountNotebook[];}+ export interface PaginatedAccountRelationshipDefinitionList {+ count: number;+ /** @nullable */+ next?: string | null;+ /** @nullable */+ previous?: string | null;+ results: AccountRelationshipDefinition[];+ }+export interface PaginatedActionList {count: number;/** @nullable */@@ -36471,6 +36500,26 @@ export namespace Schemas {readonly updated_at?: string | null;}+ /**+ * A team-defined account relationship type (CSM, Onboarding manager, ...).+ */+ export interface PatchedAccountRelationshipDefinition {+ /** Relationship definition UUID. */+ readonly id?: string;+ /**+ * Human-readable name of the relationship. Unique within the team.+ * @maxLength 400+ */+ name?: string;+ /**+ * What this relationship means, e.g. 'The customer success manager responsible for this account'.+ * @nullable+ */+ description?: string | null;+ /** Whether only one user can hold this relationship per account at a time, e.g. a single CSM per account. */+ is_single_holder?: boolean;+ }+/*** Serializer mixin that handles tags for objects.*/@@ -61518,6 +61567,17 @@ export namespace Schemas {search?: string;};+ export type AccountRelationshipDefinitionsListParams = {+ /**+ * Number of results to return per page.+ */+ limit?: number;+ /**+ * The initial index from which to return the results.+ */+ offset?: number;+ };+export type AccountsListParams = {/*** Filter by account executive. Use 'unassigned' or an integer user id.