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(workflows): split update account into tag and relationships actions (#69510)

Arthur Moreira de Deus0784425d837f
diff --git a/frontend/src/lib/components/CyclotronJob/customInputRenderers.ts b/frontend/src/lib/components/CyclotronJob/customInputRenderers.ts
index e936082fde02..f008e1af400b 100644
--- a/frontend/src/lib/components/CyclotronJob/customInputRenderers.ts
+++ b/frontend/src/lib/components/CyclotronJob/customInputRenderers.ts
@@ -29,4 +29,8 @@ export const CUSTOM_INPUT_RENDERERS: Record<
() =>
import('products/customer_analytics/frontend/components/AccountPropertiesInput/CyclotronJobInputAccountProperties')
),
+ customer_analytics_account_relationships: lazy(
+ () =>
+ import('products/customer_analytics/frontend/components/AccountRelationshipsInput/CyclotronJobInputAccountRelationships')
+ ),
}
diff --git a/frontend/src/types.ts b/frontend/src/types.ts
index cc62ed242f72..142fe1bdaead 100644
--- a/frontend/src/types.ts
+++ b/frontend/src/types.ts
@@ -6953,6 +6953,7 @@ export type CyclotronJobInputSchemaType = {
| 'posthog_business_hours'
| 'non_failure_status_codes'
| 'customer_analytics_account_properties'
+ | 'customer_analytics_account_relationships'
key: string
label: string
choices?: { value: string; label: string }[]
diff --git a/nodejs/src/cdp/schema/cyclotron.ts b/nodejs/src/cdp/schema/cyclotron.ts
index ab22c02ed39d..0a659754bf06 100644
--- a/nodejs/src/cdp/schema/cyclotron.ts
+++ b/nodejs/src/cdp/schema/cyclotron.ts
@@ -24,6 +24,7 @@ export const CyclotronJobInputSchemaTypeSchema = z.object({
'posthog_ticket_tags',
'posthog_business_hours',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
]),
key: z.string(),
label: z.string(),
diff --git a/nodejs/src/cdp/templates/_destinations/posthog_customer_analytics/posthog-accounts.template.test.ts b/nodejs/src/cdp/templates/_destinations/posthog_customer_analytics/posthog-accounts.template.test.ts
index 5004956ed441..76ff30697689 100644
--- a/nodejs/src/cdp/templates/_destinations/posthog_customer_analytics/posthog-accounts.template.test.ts
+++ b/nodejs/src/cdp/templates/_destinations/posthog_customer_analytics/posthog-accounts.template.test.ts
@@ -1,8 +1,14 @@
+import { parseJSON } from '~/common/utils/json-parse'
+
import { TemplateTester } from '../../test/test-helpers'
import { template as getAccountTemplate } from './posthog-get-account.template'
+import { template as tagAccountTemplate } from './posthog-tag-account.template'
import { template as updateAccountPropertyTemplate } from './posthog-update-account-property.template'
+import { template as updateAccountRelationshipsTemplate } from './posthog-update-account-relationships.template'
import { template as updateAccountTemplate } from './posthog-update-account.template'
+const REL_UUID = '0197f9f0-1111-0000-0000-000000000000'
+
describe('posthog customer analytics account templates', () => {
const cases = [
{
@@ -26,6 +32,20 @@ describe('posthog customer analytics account templates', () => {
failurePrefix: 'Failed to update account properties (400):',
successLog: 'Updated custom properties on account acme-1',
},
+ {
+ name: 'tag account',
+ template: tagAccountTemplate,
+ inputs: { external_id: 'acme-1', tags: ['vip'], tags_mode: 'add' },
+ failurePrefix: 'Failed to tag account (400):',
+ successLog: 'Tagged account acme-1',
+ },
+ {
+ name: 'update account relationships',
+ template: updateAccountRelationshipsTemplate,
+ inputs: { external_id: 'acme-1', relationships: { [REL_UUID]: { type: 'user', id: 42 } } },
+ failurePrefix: 'Failed to update account relationships (400):',
+ successLog: 'Updated relationships on account acme-1',
+ },
]
describe.each(cases)('$name', ({ template, inputs, failurePrefix, successLog }) => {
@@ -86,4 +106,25 @@ describe('posthog customer analytics account templates', () => {
expect(response.error).toEqual(expected)
})
})
+
+ describe('update account relationships queued fetch body', () => {
+ const tester = new TemplateTester(updateAccountRelationshipsTemplate)
+
+ beforeEach(async () => {
+ await tester.beforeEach()
+ })
+
+ it('sends relationship assignments keyed by UUID in the request body', async () => {
+ const response = await tester.invoke({
+ external_id: 'acme-1',
+ relationships: { [REL_UUID]: { type: 'user', id: 42 } },
+ })
+
+ expect(response.error).toBeUndefined()
+ expect(response.finished).toBe(false)
+
+ const body = parseJSON((response.invocation.queueParameters as any).body)
+ expect(body.relationships).toEqual({ [REL_UUID]: { type: 'user', id: 42 } })
+ })
+ })
})
diff --git a/nodejs/src/cdp/templates/_destinations/posthog_customer_analytics/posthog-tag-account.template.ts b/nodejs/src/cdp/templates/_destinations/posthog_customer_analytics/posthog-tag-account.template.ts
new file mode 100644
index 000000000000..22b59efe866b
--- /dev/null
+++ b/nodejs/src/cdp/templates/_destinations/posthog_customer_analytics/posthog-tag-account.template.ts
@@ -0,0 +1,75 @@
+import { HogFunctionTemplate } from '~/cdp/types'
+
+export const template: HogFunctionTemplate = {
+ free: true,
+ status: 'hidden',
+ type: 'destination',
+ id: 'template-posthog-tag-account',
+ name: 'Tag account',
+ description: 'Add, replace, or remove tags on a Customer analytics account.',
+ icon_url: '/static/posthog-icon.svg',
+ category: ['Custom'],
+ code_language: 'hog',
+ code: `
+if (empty(inputs.external_id)) {
+ throw Error('Account external ID is required')
+}
+
+if (empty(inputs.tags)) {
+ throw Error('At least one tag is required')
+}
+
+let response := postHogUpdateAccount({
+ 'external_id': inputs.external_id,
+ 'updates': {
+ 'tags': inputs.tags,
+ 'tags_mode': (not empty(inputs.tags_mode)) ? inputs.tags_mode : 'add'
+ }
+})
+
+if (response.status == 404) {
+ throw Error(f'Account not found: {inputs.external_id}')
+}
+
+if (response.status >= 400) {
+ throw Error(f'Failed to tag account ({response.status}): {response.body.error ?? response.body}')
+}
+
+print(f'Tagged account {inputs.external_id}')
+return response.body
+`,
+ inputs_schema: [
+ {
+ key: 'external_id',
+ type: 'string',
+ label: 'Account external ID',
+ secret: false,
+ required: true,
+ description:
+ 'The external ID of the account to tag — the group key the account is linked to. Available from trigger event or group properties.',
+ },
+ {
+ key: 'tags',
+ type: 'posthog_ticket_tags',
+ label: 'Tags',
+ secret: false,
+ required: true,
+ description: 'Tags to apply to the account.',
+ },
+ {
+ key: 'tags_mode',
+ type: 'choice',
+ label: 'Tag mode',
+ secret: false,
+ required: false,
+ default: 'add',
+ choices: [
+ { label: 'Add to existing tags', value: 'add' },
+ { label: 'Replace all tags', value: 'set' },
+ { label: 'Remove these tags', value: 'remove' },
+ ],
+ description:
+ 'How the tags above are applied. Add (default) is safe when multiple workflows tag the same account.',
+ },
+ ],
+}
diff --git a/nodejs/src/cdp/templates/_destinations/posthog_customer_analytics/posthog-update-account-relationships.template.ts b/nodejs/src/cdp/templates/_destinations/posthog_customer_analytics/posthog-update-account-relationships.template.ts
new file mode 100644
index 000000000000..4a2453b47de8
--- /dev/null
+++ b/nodejs/src/cdp/templates/_destinations/posthog_customer_analytics/posthog-update-account-relationships.template.ts
@@ -0,0 +1,60 @@
+import { HogFunctionTemplate } from '~/cdp/types'
+
+export const template: HogFunctionTemplate = {
+ free: true,
+ status: 'hidden',
+ type: 'destination',
+ id: 'template-posthog-update-account-relationships',
+ name: 'Update account relationships',
+ description: 'Assign users to relationship roles on a Customer analytics account.',
+ icon_url: '/static/posthog-icon.svg',
+ category: ['Custom'],
+ code_language: 'hog',
+ code: `
+if (empty(inputs.external_id)) {
+ throw Error('Account external ID is required')
+}
+
+if (empty(inputs.relationships)) {
+ throw Error('At least one relationship assignment is required')
+}
+
+let response := postHogUpdateAccount({
+ 'external_id': inputs.external_id,
+ 'updates': {
+ 'relationships': inputs.relationships
+ }
+})
+
+if (response.status == 404) {
+ throw Error(f'Account not found: {inputs.external_id}')
+}
+
+if (response.status >= 400) {
+ throw Error(f'Failed to update account relationships ({response.status}): {response.body.error ?? response.body}')
+}
+
+print(f'Updated relationships on account {inputs.external_id}')
+return response.body
+`,
+ inputs_schema: [
+ {
+ key: 'external_id',
+ type: 'string',
+ label: 'Account external ID',
+ secret: false,
+ required: true,
+ description:
+ 'The external ID of the account to update — the group key the account is linked to. Available from trigger event or group properties.',
+ },
+ {
+ key: 'relationships',
+ type: 'customer_analytics_account_relationships',
+ label: 'Relationship assignments',
+ secret: false,
+ required: true,
+ description:
+ 'Map each relationship definition to a user assignment. Set a user to assign them; set to "Clear assignment" to end the current assignment.',
+ },
+ ],
+}
diff --git a/nodejs/src/cdp/templates/index.ts b/nodejs/src/cdp/templates/index.ts
index 88cc6a1106d5..16b6925f4789 100644
--- a/nodejs/src/cdp/templates/index.ts
+++ b/nodejs/src/cdp/templates/index.ts
@@ -25,7 +25,9 @@ import { template as posthogUpdatePersonPropertiesTemplate } from './_destinatio
import { template as posthogGetTicketTemplate } from './_destinations/posthog_conversations/posthog-get-ticket.template'
import { template as posthogUpdateTicketTemplate } from './_destinations/posthog_conversations/posthog-update-ticket.template'
import { template as posthogGetAccountTemplate } from './_destinations/posthog_customer_analytics/posthog-get-account.template'
+import { template as posthogTagAccountTemplate } from './_destinations/posthog_customer_analytics/posthog-tag-account.template'
import { template as posthogUpdateAccountPropertyTemplate } from './_destinations/posthog_customer_analytics/posthog-update-account-property.template'
+import { template as posthogUpdateAccountRelationshipsTemplate } from './_destinations/posthog_customer_analytics/posthog-update-account-relationships.template'
import { template as posthogUpdateAccountTemplate } from './_destinations/posthog_customer_analytics/posthog-update-account.template'
import { template as posthogSetHogflowVariableTemplate } from './_destinations/posthog_workflows/posthog-set-variable.template'
import { template as redditAdsTemplate } from './_destinations/reddit_ads/reddit.template'
@@ -78,6 +80,8 @@ export const HOG_FUNCTION_TEMPLATES_DESTINATIONS: HogFunctionTemplate[] = [
posthogGetTicketTemplate,
posthogUpdateTicketTemplate,
posthogGetAccountTemplate,
+ posthogTagAccountTemplate,
+ posthogUpdateAccountRelationshipsTemplate,
posthogUpdateAccountTemplate,
posthogUpdateAccountPropertyTemplate,
hubspotCompanyTemplate,
diff --git a/nodejs/src/cdp/types.ts b/nodejs/src/cdp/types.ts
index a925e64d6f17..a0821fe0ff43 100644
--- a/nodejs/src/cdp/types.ts
+++ b/nodejs/src/cdp/types.ts
@@ -408,6 +408,7 @@ export type HogFunctionInputSchemaType = {
| 'posthog_business_hours'
| 'non_failure_status_codes'
| 'customer_analytics_account_properties'
+ | 'customer_analytics_account_relationships'
key: string
label?: string
choices?: { value: string; label: string }[]
diff --git a/posthog/cdp/test/test_validation.py b/posthog/cdp/test/test_validation.py
index 657c82b1523b..0d017b5a33c9 100644
--- a/posthog/cdp/test/test_validation.py
+++ b/posthog/cdp/test/test_validation.py
@@ -733,6 +733,16 @@ class TestHogFunctionValidation(ClickhouseTestMixin, APIBaseTest, QueryMatchingT
assert validated["properties"].get("bytecode") is not None
+ def test_customer_analytics_account_relationships_validates_assignment_dict(self):
+ # Guards the type's registration in InputsSchemaItemSerializer's ChoiceField —
+ # without it, publishing a workflow with the relationships node 400s.
+ inputs_schema = [{"key": "relationships", "type": "customer_analytics_account_relationships", "required": True}]
+ inputs = {"relationships": {"value": {"0197f9f0-1111-0000-0000-000000000000": {"type": "user", "id": 42}}}}
+
+ validated = validate_inputs(inputs_schema, inputs)
+
+ assert validated["relationships"].get("bytecode") is not None
+
@parameterized.expand(
[
# Reproduces the original user report: a mixed literal prefix plus a workflow variable.
diff --git a/posthog/cdp/validation.py b/posthog/cdp/validation.py
index 7a5d66f85a38..9436e63ff4f4 100644
--- a/posthog/cdp/validation.py
+++ b/posthog/cdp/validation.py
@@ -248,6 +248,7 @@ class InputsSchemaItemSerializer(serializers.Serializer):
"posthog_business_hours",
"non_failure_status_codes",
"customer_analytics_account_properties",
+ "customer_analytics_account_relationships",
]
)
key = serializers.CharField()
@@ -325,7 +326,11 @@ class InputsItemSerializer(serializers.Serializer):
else:
if not isinstance(value, bool):
raise serializers.ValidationError({"input": f"Value must be a boolean."})
- elif item_type in ("dictionary", "customer_analytics_account_properties"):
+ elif item_type in (
+ "dictionary",
+ "customer_analytics_account_properties",
+ "customer_analytics_account_relationships",
+ ):
if not isinstance(value, dict):
raise serializers.ValidationError({"input": f"Value must be a dictionary."})
elif item_type == "integration":
@@ -372,6 +377,7 @@ class InputsItemSerializer(serializers.Serializer):
"native_email",
"posthog_ticket_tags",
"customer_analytics_account_properties",
+ "customer_analytics_account_relationships",
] or (item_type == "boolean" and isinstance(value, str))
if value_is_transpiled:
if item_type in ("email", "native_email") and isinstance(value, dict):
diff --git a/products/cdp/frontend/generated/api.schemas.ts b/products/cdp/frontend/generated/api.schemas.ts
index 641d534d380a..c63f3fde1cc2 100644
--- a/products/cdp/frontend/generated/api.schemas.ts
+++ b/products/cdp/frontend/generated/api.schemas.ts
@@ -270,6 +270,7 @@ export const HogFunctionTypeEnumApi = {
* * `posthog_business_hours` - posthog_business_hours
* * `non_failure_status_codes` - non_failure_status_codes
* * `customer_analytics_account_properties` - customer_analytics_account_properties
+ * * `customer_analytics_account_relationships` - customer_analytics_account_relationships
*/
export type InputsSchemaItemTypeEnumApi = (typeof InputsSchemaItemTypeEnumApi)[keyof typeof InputsSchemaItemTypeEnumApi]
@@ -289,6 +290,7 @@ export const InputsSchemaItemTypeEnumApi = {
PosthogBusinessHours: 'posthog_business_hours',
NonFailureStatusCodes: 'non_failure_status_codes',
CustomerAnalyticsAccountProperties: 'customer_analytics_account_properties',
+ CustomerAnalyticsAccountRelationships: 'customer_analytics_account_relationships',
} as const
export type InputsSchemaItemApiChoicesItem = { [key: string]: unknown }
diff --git a/products/cdp/frontend/generated/api.zod.ts b/products/cdp/frontend/generated/api.zod.ts
index a64571edc31c..da6f074aafc3 100644
--- a/products/cdp/frontend/generated/api.zod.ts
+++ b/products/cdp/frontend/generated/api.zod.ts
@@ -77,9 +77,10 @@ export const HogFunctionsCreateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
@@ -175,9 +176,10 @@ export const HogFunctionsCreateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
@@ -323,9 +325,10 @@ export const HogFunctionsUpdateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
@@ -421,9 +424,10 @@ export const HogFunctionsUpdateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
@@ -569,9 +573,10 @@ export const HogFunctionsPartialUpdateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
@@ -667,9 +672,10 @@ export const HogFunctionsPartialUpdateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
@@ -819,9 +825,10 @@ export const HogFunctionsEnableBackfillsCreateBody = /* @__PURE__ */ zod.object(
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
@@ -917,9 +924,10 @@ export const HogFunctionsEnableBackfillsCreateBody = /* @__PURE__ */ zod.object(
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
@@ -1139,9 +1147,10 @@ export const HogFunctionsInvocationsCreateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
@@ -1246,9 +1255,10 @@ export const HogFunctionsInvocationsCreateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '\* `string` - string\n\* `number` - number\n\* `boolean` - boolean\n\* `dictionary` - dictionary\n\* `choice` - choice\n\* `json` - json\n\* `integration` - integration\n\* `integration_field` - integration_field\n\* `email` - email\n\* `native_email` - native_email\n\* `posthog_assignee` - posthog_assignee\n\* `posthog_ticket_tags` - posthog_ticket_tags\n\* `posthog_business_hours` - posthog_business_hours\n\* `non_failure_status_codes` - non_failure_status_codes\n\* `customer_analytics_account_properties` - customer_analytics_account_properties\n\* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
diff --git a/products/customer_analytics/backend/facade/api.py b/products/customer_analytics/backend/facade/api.py
index 50f11e311fb4..f3ac4ea0c297 100644
--- a/products/customer_analytics/backend/facade/api.py
+++ b/products/customer_analytics/backend/facade/api.py
@@ -308,25 +308,36 @@ def _apply_external_tags(account: Account, tags: list[str], mode: str) -> None:
def _apply_external_relationship_assignments(
account: Account, assignments: dict[str, int | None]
) -> contracts.ExternalAccountUpdateResult | None:
- """Apply provided relationship assignments, keyed by definition name (None ends the
+ """Apply provided relationship assignments, keyed by definition UUID (None ends the
active assignment). Each non-None user id is resolved against an
``OrganizationMembership`` in the account's org so assignees are always trusted.
Everything is validated before the first write — the caller's ``atomic()`` block
returns (commits) on an error result rather than rolling back.
"""
+ keys_to_ids: dict[str, UUID] = {}
+ for key in assignments:
+ try:
+ keys_to_ids[key] = UUID(key)
+ except ValueError:
+ return contracts.ExternalAccountUpdateResult(
+ error=contracts.ExternalAccountUpdateError.RELATIONSHIP_DEFINITION_NOT_FOUND,
+ error_field=key,
+ )
+
definitions = {
- definition.name: definition
+ definition.id: definition
for definition in AccountRelationshipDefinition.objects.for_team(account.team_id).filter(
- name__in=assignments.keys()
+ id__in=keys_to_ids.values()
)
}
+
resolved: list[tuple[AccountRelationshipDefinition, User | None]] = []
- for name, user_id in assignments.items():
- definition = definitions.get(name)
+ for key, user_id in assignments.items():
+ definition = definitions.get(keys_to_ids[key])
if definition is None:
return contracts.ExternalAccountUpdateResult(
error=contracts.ExternalAccountUpdateError.RELATIONSHIP_DEFINITION_NOT_FOUND,
- error_field=name,
+ error_field=key,
)
if user_id is None:
resolved.append((definition, None))
@@ -339,7 +350,7 @@ def _apply_external_relationship_assignments(
if membership is None:
return contracts.ExternalAccountUpdateResult(
error=contracts.ExternalAccountUpdateError.USER_NOT_IN_ORGANIZATION,
- error_field=name,
+ error_field=key,
)
resolved.append((definition, membership.user))
diff --git a/products/customer_analytics/backend/presentation/views/external.py b/products/customer_analytics/backend/presentation/views/external.py
index 3accbb04899f..77b7cd665537 100644
--- a/products/customer_analytics/backend/presentation/views/external.py
+++ b/products/customer_analytics/backend/presentation/views/external.py
@@ -124,7 +124,7 @@ def _update_error_response(result: contracts.ExternalAccountUpdateResult) -> Res
)
if result.error == contracts.ExternalAccountUpdateError.RELATIONSHIP_DEFINITION_NOT_FOUND:
return Response(
- {"error": f"{result.error_field}: no relationship definition with this name"},
+ {"error": f"{result.error_field}: no relationship definition with this ID"},
status=status.HTTP_400_BAD_REQUEST,
)
assert result.error is not None
@@ -142,9 +142,9 @@ class ExternalAccountUpdateSerializer(serializers.Serializer):
child=serializers.JSONField(allow_null=True),
required=False,
help_text=(
- "Relationship assignments keyed by definition name (e.g. 'CSM'). Each value is an "
- "assignee object `{type: 'user', id}` or null to end the active assignment. Only the "
- "named definitions are changed."
+ "Relationship assignments keyed by definition UUID. Each value is an assignee object "
+ "`{type: 'user', id}` or null to end the active assignment. Only the supplied "
+ "definitions are changed."
),
)
tags = serializers.ListField(
diff --git a/products/customer_analytics/backend/test/test_external.py b/products/customer_analytics/backend/test/test_external.py
index a2beb7f1cc4e..54c749c0889e 100644
--- a/products/customer_analytics/backend/test/test_external.py
+++ b/products/customer_analytics/backend/test/test_external.py
@@ -31,6 +31,7 @@ class TestExternalAccountAPI(APIBaseTest):
self.csm_definition = AccountRelationshipDefinition.objects.for_team(self.team.id).create(
team_id=self.team.id, name="CSM"
)
+ self.csm_key = str(self.csm_definition.id)
self.url = "/api/customer_analytics/external/account"
csp_enabled = patch(
"products.customer_analytics.backend.presentation.views.external.posthoganalytics.feature_enabled",
@@ -148,7 +149,7 @@ class TestExternalAccountAPI(APIBaseTest):
def test_patch_assigns_relationship_and_returns_it(self):
response = self._patch(
- {"external_id": "acme-1", "relationships": {"CSM": {"type": "user", "id": self.user.id}}}
+ {"external_id": "acme-1", "relationships": {self.csm_key: {"type": "user", "id": self.user.id}}}
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(
@@ -160,7 +161,7 @@ class TestExternalAccountAPI(APIBaseTest):
def test_patch_null_ends_active_assignment(self):
self._assign_csm(self.user)
- response = self._patch({"external_id": "acme-1", "relationships": {"CSM": None}})
+ response = self._patch({"external_id": "acme-1", "relationships": {self.csm_key: None}})
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json()["relationships"], {})
self.assertEqual(self._active_csm_user_ids(), [])
@@ -170,7 +171,7 @@ class TestExternalAccountAPI(APIBaseTest):
self.account.save(update_fields=["_properties"])
response = self._patch(
- {"external_id": "acme-1", "relationships": {"CSM": {"type": "user", "id": self.user.id}}}
+ {"external_id": "acme-1", "relationships": {self.csm_key: {"type": "user", "id": self.user.id}}}
)
self.assertEqual(response.status_code, status.HTTP_200_OK)
self.assertEqual(response.json()["properties"]["stripe_customer_id"], "cus_123")
@@ -183,21 +184,23 @@ class TestExternalAccountAPI(APIBaseTest):
]
)
def test_patch_rejects_invalid_assignee(self, _name, assignee):
- response = self._patch({"external_id": "acme-1", "relationships": {"CSM": assignee}})
+ response = self._patch({"external_id": "acme-1", "relationships": {self.csm_key: assignee}})
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
self.assertEqual(self._active_csm_user_ids(), [])
- def test_patch_rejects_unknown_definition_name(self):
+ def test_patch_rejects_non_uuid_key(self):
response = self._patch({"external_id": "acme-1", "relationships": {"AE": {"type": "user", "id": self.user.id}}})
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
- self.assertEqual(response.json()["error"], "AE: no relationship definition with this name")
+ self.assertEqual(response.json()["error"], "AE: no relationship definition with this ID")
def test_patch_rejects_non_member_user(self):
other_org = Organization.objects.create(name="Outsiders")
outsider = User.objects.create_and_join(other_org, "[email protected]", None)
- response = self._patch({"external_id": "acme-1", "relationships": {"CSM": {"type": "user", "id": outsider.id}}})
+ response = self._patch(
+ {"external_id": "acme-1", "relationships": {self.csm_key: {"type": "user", "id": outsider.id}}}
+ )
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
- self.assertEqual(response.json()["error"], "CSM: user is not a member of this organization")
+ self.assertEqual(response.json()["error"], f"{self.csm_key}: user is not a member of this organization")
self.assertEqual(self._active_csm_user_ids(), [])
def test_patch_adds_tags_by_default(self):
@@ -234,7 +237,7 @@ class TestExternalAccountAPI(APIBaseTest):
response = self._patch(
{
"external_id": "acme-1",
- "relationships": {"CSM": {"type": "user", "id": self.user.id}},
+ "relationships": {self.csm_key: {"type": "user", "id": self.user.id}},
"tags": ["enterprise"],
}
)
@@ -273,6 +276,14 @@ class TestExternalAccountAPI(APIBaseTest):
self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
mock_capture.assert_not_called()
+ def test_patch_rejects_unknown_uuid_key(self):
+ unknown_uuid = "00000000-0000-0000-0000-000000000099"
+ response = self._patch(
+ {"external_id": "acme-1", "relationships": {unknown_uuid: {"type": "user", "id": self.user.id}}}
+ )
+ self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)
+ self.assertIn(unknown_uuid, response.json()["error"])
+
class TestExternalAccountCustomPropertiesAPI(APIBaseTest):
def setUp(self):
diff --git a/products/customer_analytics/backend/test/test_facade.py b/products/customer_analytics/backend/test/test_facade.py
index c0e958e9d553..f64f96c7787d 100644
--- a/products/customer_analytics/backend/test/test_facade.py
+++ b/products/customer_analytics/backend/test/test_facade.py
@@ -179,11 +179,15 @@ class TestCustomerAnalyticsFacade(BaseTest):
return AccountRelationship.objects.for_team(self.team.id).filter(account_id=account.id, ended_at__isnull=True)
def test_update_external_account_assigns_relationship_and_resolves_email(self):
- self._create_csm_definition()
+ definition = self._create_csm_definition()
account = create_account(team_id=self.team.id, name="Acme Corp", external_id="acme-1")
result = facade.update_external_account(
- self.team.id, "acme-1", relationship_assignments={"CSM": self.user.id}, tags=None, tags_mode="add"
+ self.team.id,
+ "acme-1",
+ relationship_assignments={str(definition.id): self.user.id},
+ tags=None,
+ tags_mode="add",
)
assert result.error is None
@@ -199,7 +203,7 @@ class TestCustomerAnalyticsFacade(BaseTest):
)
result = facade.update_external_account(
- self.team.id, "acme-1", relationship_assignments={"CSM": None}, tags=None, tags_mode="add"
+ self.team.id, "acme-1", relationship_assignments={str(definition.id): None}, tags=None, tags_mode="add"
)
assert result.account is not None
@@ -207,7 +211,7 @@ class TestCustomerAnalyticsFacade(BaseTest):
assert self._active_relationships(account).count() == 0
def test_update_external_account_does_not_touch_properties(self):
- self._create_csm_definition()
+ definition = self._create_csm_definition()
account = create_account(
team_id=self.team.id,
name="Acme Corp",
@@ -216,7 +220,11 @@ class TestCustomerAnalyticsFacade(BaseTest):
)
facade.update_external_account(
- self.team.id, "acme-1", relationship_assignments={"CSM": self.user.id}, tags=None, tags_mode="add"
+ self.team.id,
+ "acme-1",
+ relationship_assignments={str(definition.id): self.user.id},
+ tags=None,
+ tags_mode="add",
)
account.refresh_from_db()
@@ -224,17 +232,21 @@ class TestCustomerAnalyticsFacade(BaseTest):
assert account.properties.csm is None
def test_update_external_account_rejects_non_member(self):
- self._create_csm_definition()
+ definition = self._create_csm_definition()
account = create_account(team_id=self.team.id, name="Acme Corp", external_id="acme-1")
outsider = User.objects.create_and_join(Organization.objects.create(name="Outsiders"), "[email protected]", None)
result = facade.update_external_account(
- self.team.id, "acme-1", relationship_assignments={"CSM": outsider.id}, tags=None, tags_mode="add"
+ self.team.id,
+ "acme-1",
+ relationship_assignments={str(definition.id): outsider.id},
+ tags=None,
+ tags_mode="add",
)
assert result.account is None
assert result.error == contracts.ExternalAccountUpdateError.USER_NOT_IN_ORGANIZATION
- assert result.error_field == "CSM"
+ assert result.error_field == str(definition.id)
assert self._active_relationships(account).count() == 0
def test_update_external_account_invalid_properties(self):
@@ -276,7 +288,7 @@ class TestCustomerAnalyticsFacade(BaseTest):
assert removed.account is not None and removed.account.tags == []
def test_update_external_account_rolls_back_relationship_when_tags_fail(self):
- self._create_csm_definition()
+ definition = self._create_csm_definition()
account = create_account(team_id=self.team.id, name="Acme Corp", external_id="acme-1")
with patch(
@@ -286,7 +298,7 @@ class TestCustomerAnalyticsFacade(BaseTest):
result = facade.update_external_account(
self.team.id,
"acme-1",
- relationship_assignments={"CSM": self.user.id},
+ relationship_assignments={str(definition.id): self.user.id},
tags=["enterprise"],
tags_mode="add",
)
diff --git a/products/customer_analytics/backend/test/test_relationships.py b/products/customer_analytics/backend/test/test_relationships.py
index 4ddf2530689e..f2d81c1e0e84 100644
--- a/products/customer_analytics/backend/test/test_relationships.py
+++ b/products/customer_analytics/backend/test/test_relationships.py
@@ -338,7 +338,9 @@ class TestRelationshipFacade(BaseTest):
class TestWritePathSync(BaseTest):
def setUp(self):
super().setUp()
- AccountRelationshipDefinition.objects.for_team(self.team.id).create(team_id=self.team.id, name="CSM")
+ self.csm_definition = AccountRelationshipDefinition.objects.for_team(self.team.id).create(
+ team_id=self.team.id, name="CSM"
+ )
def _active_rows(self, account):
return AccountRelationship.objects.for_team(self.team.id).filter(account=account, ended_at__isnull=True)
@@ -384,7 +386,11 @@ class TestWritePathSync(BaseTest):
def test_update_external_account_syncs_roles(self):
account = Account.objects.create_account(team=self.team, name="Acme", external_id="acme-1")
result = facade.update_external_account(
- self.team.id, "acme-1", relationship_assignments={"CSM": self.user.id}, tags=None, tags_mode="add"
+ self.team.id,
+ "acme-1",
+ relationship_assignments={str(self.csm_definition.id): self.user.id},
+ tags=None,
+ tags_mode="add",
)
assert result.error is None
rows = self._active_rows(account)
diff --git a/products/customer_analytics/frontend/components/AccountRelationshipsInput/CyclotronJobInputAccountRelationships.tsx b/products/customer_analytics/frontend/components/AccountRelationshipsInput/CyclotronJobInputAccountRelationships.tsx
new file mode 100644
index 000000000000..cde9a1e7ce2c
--- /dev/null
+++ b/products/customer_analytics/frontend/components/AccountRelationshipsInput/CyclotronJobInputAccountRelationships.tsx
@@ -0,0 +1,137 @@
+import { useActions, useValues } from 'kea'
+import { useRef, useState } from 'react'
+
+import { IconPlus, IconX } from '@posthog/icons'
+import { LemonButton } from '@posthog/lemon-ui'
+
+import type { CustomInputRendererProps } from 'lib/components/CyclotronJob/customInputRenderers'
+import { MemberSelect } from 'lib/components/MemberSelect'
+import { Combobox, ComboboxContent, ComboboxEmpty, ComboboxInput, ComboboxItem, ComboboxList } from 'lib/ui/quill'
+import { fullName } from 'lib/utils/strings'
+
+import type { AccountRelationshipDefinitionApi } from 'products/customer_analytics/frontend/generated/api.schemas'
+
+import { accountRelationshipsInputLogic } from './accountRelationshipsInputLogic'
+
+type RelationshipAssignment = { type: 'user'; id: number } | null
+
+export default function CyclotronJobInputAccountRelationships({
+ value,
+ onChange,
+}: CustomInputRendererProps): JSX.Element {
+ const { definitions, definitionsLoading, pendingDefinitionIds } = useValues(accountRelationshipsInputLogic)
+ const { addPendingDefinition, removePendingDefinition } = useActions(accountRelationshipsInputLogic)
+
+ const assignmentsByDefinitionId: Record<string, RelationshipAssignment> = value ?? {}
+ const rows: [string, RelationshipAssignment | undefined][] = [
+ ...Object.entries(assignmentsByDefinitionId),
+ ...pendingDefinitionIds
+ .filter((definitionId) => !(definitionId in assignmentsByDefinitionId))
+ .map((definitionId): [string, undefined] => [definitionId, undefined]),
+ ]
+ const selectedIds = new Set(rows.map(([definitionId]) => definitionId))
+ const available = definitions.filter((d) => !selectedIds.has(d.id))
+
+ const setAssignment = (definitionId: string, assignment: RelationshipAssignment): void => {
+ removePendingDefinition(definitionId)
+ onChange({ ...assignmentsByDefinitionId, [definitionId]: assignment })
+ }
+ const removeDefinition = (definitionId: string): void => {
+ removePendingDefinition(definitionId)
+ if (definitionId in assignmentsByDefinitionId) {
+ const next = { ...assignmentsByDefinitionId }
+ delete next[definitionId]
+ onChange(next)
+ }
+ }
+
+ return (
+ <div className="flex flex-col gap-2">
+ {rows.map(([definitionId, assignment]) => {
+ const definition = definitions.find((d) => d.id === definitionId)
+ const isPending = assignment === undefined
+ return (
+ <div className="flex gap-2 items-center" key={definitionId}>
+ <div className="flex-1 min-w-50 font-medium truncate" title={definition?.name ?? definitionId}>
+ {definition?.name ?? <span className="text-secondary italic">Unknown relationship</span>}
+ </div>
+ <MemberSelect
+ value={assignment?.id ?? null}
+ allowNone
+ defaultLabel="Clear assignment"
+ onChange={(user) =>
+ setAssignment(definitionId, user ? { type: 'user', id: user.id } : null)
+ }
+ >
+ {(selectedUser) => (
+ <LemonButton size="small" type="secondary">
+ {selectedUser ? (
+ fullName(selectedUser)
+ ) : isPending ? (
+ <span className="text-secondary">Select member</span>
+ ) : (
+ 'Clear assignment'
+ )}
+ </LemonButton>
+ )}
+ </MemberSelect>
+ <LemonButton icon={<IconX />} size="small" onClick={() => removeDefinition(definitionId)} />
+ </div>
+ )
+ })}
+ <AddDefinitionDropdown available={available} onSelect={addPendingDefinition} loading={definitionsLoading} />
+ </div>
+ )
+}
+
+function AddDefinitionDropdown({
+ available,
+ onSelect,
+ loading,
+}: {
+ available: AccountRelationshipDefinitionApi[]
+ onSelect: (id: string) => void
+ loading: boolean
+}): JSX.Element {
+ const [open, setOpen] = useState(false)
+ const triggerRef = useRef<HTMLButtonElement>(null)
+
+ return (
+ <Combobox
+ items={available}
+ itemToStringValue={(d: AccountRelationshipDefinitionApi) => d.name}
+ open={open}
+ onOpenChange={setOpen}
+ value={null}
+ onValueChange={(d: AccountRelationshipDefinitionApi | null) => {
+ if (d) {
+ onSelect(d.id)
+ }
+ setOpen(false)
+ }}
+ >
+ <LemonButton
+ ref={triggerRef}
+ type="secondary"
+ size="small"
+ icon={<IconPlus />}
+ loading={loading}
+ disabledReason={loading ? 'Loading relationship definitions…' : undefined}
+ onClick={() => setOpen(true)}
+ >
+ Add relationship
+ </LemonButton>
+ <ComboboxContent anchor={triggerRef}>
+ <ComboboxInput placeholder="Search relationships" showTrigger={false} />
+ <ComboboxEmpty>No relationships found</ComboboxEmpty>
+ <ComboboxList>
+ {(d: AccountRelationshipDefinitionApi) => (
+ <ComboboxItem key={d.id} value={d}>
+ {d.name}
+ </ComboboxItem>
+ )}
+ </ComboboxList>
+ </ComboboxContent>
+ </Combobox>
+ )
+}
diff --git a/products/customer_analytics/frontend/components/AccountRelationshipsInput/accountRelationshipsInputLogic.ts b/products/customer_analytics/frontend/components/AccountRelationshipsInput/accountRelationshipsInputLogic.ts
new file mode 100644
index 000000000000..af8f70f849cb
--- /dev/null
+++ b/products/customer_analytics/frontend/components/AccountRelationshipsInput/accountRelationshipsInputLogic.ts
@@ -0,0 +1,68 @@
+import { actions, afterMount, connect, kea, listeners, path, reducers } from 'kea'
+import { loaders } from 'kea-loaders'
+import posthog from 'posthog-js'
+
+import { projectLogic } from 'scenes/projectLogic'
+
+import { accountRelationshipDefinitionsList } from 'products/customer_analytics/frontend/generated/api'
+import type { AccountRelationshipDefinitionApi } from 'products/customer_analytics/frontend/generated/api.schemas'
+
+import type { accountRelationshipsInputLogicType } from './accountRelationshipsInputLogicType'
+
+export const accountRelationshipsInputLogic = kea<accountRelationshipsInputLogicType>([
+ path([
+ 'products',
+ 'customer_analytics',
+ 'frontend',
+ 'components',
+ 'AccountRelationshipsInput',
+ 'accountRelationshipsInputLogic',
+ ]),
+ connect(() => ({
+ values: [projectLogic, ['currentProjectId']],
+ })),
+ actions({
+ addPendingDefinition: (definitionId: string) => ({ definitionId }),
+ removePendingDefinition: (definitionId: string) => ({ definitionId }),
+ }),
+ reducers({
+ // Rows the user added but hasn't assigned yet. They stay out of the input value because
+ // a null assignment ends the account's active assignment when the workflow runs.
+ pendingDefinitionIds: [
+ [] as string[],
+ {
+ addPendingDefinition: (state, { definitionId }) => [...state, definitionId],
+ removePendingDefinition: (state, { definitionId }) => state.filter((id) => id !== definitionId),
+ },
+ ],
+ }),
+ loaders(({ values }) => ({
+ definitions: [
+ [] as AccountRelationshipDefinitionApi[],
+ {
+ loadDefinitions: async (): Promise<AccountRelationshipDefinitionApi[]> => {
+ const results: AccountRelationshipDefinitionApi[] = []
+ let offset = 0
+ let response
+ do {
+ response = await accountRelationshipDefinitionsList(String(values.currentProjectId), {
+ limit: 100,
+ offset,
+ })
+ results.push(...response.results)
+ offset += response.results.length
+ } while (response.next && response.results.length > 0)
+ return results
+ },
+ },
+ ],
+ })),
+ listeners({
+ loadDefinitionsFailure: ({ error }) => {
+ posthog.captureException(error, { scope: 'accountRelationshipsInputLogic.load' })
+ },
+ }),
+ afterMount(({ actions }) => {
+ actions.loadDefinitions()
+ }),
+])
diff --git a/products/workflows/frontend/Workflows/hogflows/registry/actions/customer_analytics.test.ts b/products/workflows/frontend/Workflows/hogflows/registry/actions/customer_analytics.test.ts
index f0924a1822ba..e8eff545f124 100644
--- a/products/workflows/frontend/Workflows/hogflows/registry/actions/customer_analytics.test.ts
+++ b/products/workflows/frontend/Workflows/hogflows/registry/actions/customer_analytics.test.ts
@@ -60,19 +60,35 @@ describe('customer analytics action registry', () => {
])
})
- it('wires the Update account node to its hog function template', () => {
+ it('does not include the old Update account node in the picker', () => {
const node = getCategory().nodes.find((n) => n.name === 'Update account')
+ expect(node).toBeUndefined()
+ })
+
+ it('wires the Tag account node to its hog function template', () => {
+ const node = getCategory().nodes.find((n) => n.name === 'Tag account')
expect(node).toMatchObject({
type: 'function',
- config: { template_id: 'template-posthog-update-account' },
+ config: { template_id: 'template-posthog-tag-account' },
})
})
- it.each(['Get account', 'Update account'])('gives %s a dynamic external_id default resolver', (name) => {
- const node = getCategory().nodes.find((n) => n.name === name)
- expect(typeof node?.getDefaultInputs).toBe('function')
+ it('wires the Update account relationships node to its hog function template', () => {
+ const node = getCategory().nodes.find((n) => n.name === 'Update account relationships')
+ expect(node).toMatchObject({
+ type: 'function',
+ config: { template_id: 'template-posthog-update-account-relationships' },
+ })
})
+ it.each(['Get account', 'Tag account', 'Update account relationships'])(
+ 'gives %s a dynamic external_id default resolver',
+ (name) => {
+ const node = getCategory().nodes.find((n) => n.name === name)
+ expect(typeof node?.getDefaultInputs).toBe('function')
+ }
+ )
+
describe('buildAccountExternalIdInputs', () => {
it('builds a name-based group key expression from the account group type index', () => {
const inputs = buildAccountExternalIdInputs(2, groupTypesMap([0, 'project'], [2, 'organization']))
diff --git a/products/workflows/frontend/Workflows/hogflows/registry/actions/customer_analytics.ts b/products/workflows/frontend/Workflows/hogflows/registry/actions/customer_analytics.ts
index d3da1e2800a2..75edfbf92fdd 100644
--- a/products/workflows/frontend/Workflows/hogflows/registry/actions/customer_analytics.ts
+++ b/products/workflows/frontend/Workflows/hogflows/registry/actions/customer_analytics.ts
@@ -66,9 +66,17 @@ registerActionNodeCategory({
},
{
type: 'function',
- name: 'Update account',
- description: 'Assign role contacts or tag a Customer analytics account.',
- config: { template_id: 'template-posthog-update-account', inputs: {} },
+ name: 'Tag account',
+ description: 'Add, replace, or remove tags on a Customer analytics account.',
+ config: { template_id: 'template-posthog-tag-account', inputs: {} },
+ getDefaultInputs: getAccountExternalIdDefaultInputs,
+ output_variable: { key: 'account', result_path: null },
+ },
+ {
+ type: 'function',
+ name: 'Update account relationships',
+ description: 'Assign users to relationship roles on a Customer analytics account.',
+ config: { template_id: 'template-posthog-update-account-relationships', inputs: {} },
getDefaultInputs: getAccountExternalIdDefaultInputs,
output_variable: { key: 'account', result_path: null },
},
diff --git a/products/workflows/frontend/Workflows/hogflows/steps/types.ts b/products/workflows/frontend/Workflows/hogflows/steps/types.ts
index b5fd25895801..a3c757df93a8 100644
--- a/products/workflows/frontend/Workflows/hogflows/steps/types.ts
+++ b/products/workflows/frontend/Workflows/hogflows/steps/types.ts
@@ -89,6 +89,7 @@ export const CyclotronJobInputSchemaTypeSchema = z.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
]),
key: z.string(),
label: z.string(),
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index 278146aeb8b0..c76fc1a528a5 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -26698,6 +26698,7 @@ export namespace Schemas {
* * `posthog_business_hours` - posthog_business_hours
* * `non_failure_status_codes` - non_failure_status_codes
* * `customer_analytics_account_properties` - customer_analytics_account_properties
+ * * `customer_analytics_account_relationships` - customer_analytics_account_relationships
*/
export type InputsSchemaItemTypeEnum = typeof InputsSchemaItemTypeEnum[keyof typeof InputsSchemaItemTypeEnum];
@@ -26718,6 +26719,7 @@ export namespace Schemas {
PosthogBusinessHours: 'posthog_business_hours',
NonFailureStatusCodes: 'non_failure_status_codes',
CustomerAnalyticsAccountProperties: 'customer_analytics_account_properties',
+ CustomerAnalyticsAccountRelationships: 'customer_analytics_account_relationships',
} as const;
export type InputsSchemaItemChoicesItem = { [key: string]: unknown };
diff --git a/services/mcp/src/generated/cdp_functions/api.ts b/services/mcp/src/generated/cdp_functions/api.ts
index a20712877bf7..b7d2502cc53a 100644
--- a/services/mcp/src/generated/cdp_functions/api.ts
+++ b/services/mcp/src/generated/cdp_functions/api.ts
@@ -102,9 +102,10 @@ export const HogFunctionsCreateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
@@ -195,9 +196,10 @@ export const HogFunctionsCreateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
@@ -351,9 +353,10 @@ export const HogFunctionsPartialUpdateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
@@ -444,9 +447,10 @@ export const HogFunctionsPartialUpdateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
@@ -674,9 +678,10 @@ export const HogFunctionsInvocationsCreateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
@@ -781,9 +786,10 @@ export const HogFunctionsInvocationsCreateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
diff --git a/services/mcp/src/generated/error_tracking_alerts/api.ts b/services/mcp/src/generated/error_tracking_alerts/api.ts
index 6088fe07b3e1..445944584877 100644
--- a/services/mcp/src/generated/error_tracking_alerts/api.ts
+++ b/services/mcp/src/generated/error_tracking_alerts/api.ts
@@ -102,9 +102,10 @@ export const HogFunctionsCreateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
@@ -195,9 +196,10 @@ export const HogFunctionsCreateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
@@ -342,9 +344,10 @@ export const HogFunctionsPartialUpdateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
@@ -435,9 +438,10 @@ export const HogFunctionsPartialUpdateBody = /* @__PURE__ */ zod.object({
'posthog_business_hours',
'non_failure_status_codes',
'customer_analytics_account_properties',
+ 'customer_analytics_account_relationships',
])
.describe(
- '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties'
+ '* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships'
),
key: zod.string(),
label: zod.string().optional(),
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-create.json
index 7da453ac3fd2..e039b9bf76ba 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-create.json
@@ -174,7 +174,7 @@
]
},
"type": {
- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties",
+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships",
"enum": [
"string",
"number",
@@ -190,7 +190,8 @@
"posthog_ticket_tags",
"posthog_business_hours",
"non_failure_status_codes",
- "customer_analytics_account_properties"
+ "customer_analytics_account_properties",
+ "customer_analytics_account_relationships"
],
"type": "string"
}
@@ -334,7 +335,7 @@
]
},
"type": {
- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties",
+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships",
"enum": [
"string",
"number",
@@ -350,7 +351,8 @@
"posthog_ticket_tags",
"posthog_business_hours",
"non_failure_status_codes",
- "customer_analytics_account_properties"
+ "customer_analytics_account_properties",
+ "customer_analytics_account_relationships"
],
"type": "string"
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-invocations-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-invocations-create.json
index 5f5b919b276c..3042b99f7b81 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-invocations-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-invocations-create.json
@@ -312,7 +312,7 @@
]
},
"type": {
- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties",
+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships",
"enum": [
"string",
"number",
@@ -328,7 +328,8 @@
"posthog_ticket_tags",
"posthog_business_hours",
"non_failure_status_codes",
- "customer_analytics_account_properties"
+ "customer_analytics_account_properties",
+ "customer_analytics_account_relationships"
],
"type": "string"
}
@@ -492,7 +493,7 @@
]
},
"type": {
- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties",
+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships",
"enum": [
"string",
"number",
@@ -508,7 +509,8 @@
"posthog_ticket_tags",
"posthog_business_hours",
"non_failure_status_codes",
- "customer_analytics_account_properties"
+ "customer_analytics_account_properties",
+ "customer_analytics_account_relationships"
],
"type": "string"
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-partial-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-partial-update.json
index af3c7e1882f4..12fa68751a4b 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-partial-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/cdp-functions-partial-update.json
@@ -178,7 +178,7 @@
]
},
"type": {
- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties",
+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships",
"enum": [
"string",
"number",
@@ -194,7 +194,8 @@
"posthog_ticket_tags",
"posthog_business_hours",
"non_failure_status_codes",
- "customer_analytics_account_properties"
+ "customer_analytics_account_properties",
+ "customer_analytics_account_relationships"
],
"type": "string"
}
@@ -338,7 +339,7 @@
]
},
"type": {
- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties",
+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships",
"enum": [
"string",
"number",
@@ -354,7 +355,8 @@
"posthog_ticket_tags",
"posthog_business_hours",
"non_failure_status_codes",
- "customer_analytics_account_properties"
+ "customer_analytics_account_properties",
+ "customer_analytics_account_relationships"
],
"type": "string"
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-create.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-create.json
index 17c6f4717f2c..2ab4dc8fc255 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-create.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-create.json
@@ -174,7 +174,7 @@
]
},
"type": {
- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties",
+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships",
"enum": [
"string",
"number",
@@ -190,7 +190,8 @@
"posthog_ticket_tags",
"posthog_business_hours",
"non_failure_status_codes",
- "customer_analytics_account_properties"
+ "customer_analytics_account_properties",
+ "customer_analytics_account_relationships"
],
"type": "string"
}
@@ -334,7 +335,7 @@
]
},
"type": {
- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties",
+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships",
"enum": [
"string",
"number",
@@ -350,7 +351,8 @@
"posthog_ticket_tags",
"posthog_business_hours",
"non_failure_status_codes",
- "customer_analytics_account_properties"
+ "customer_analytics_account_properties",
+ "customer_analytics_account_relationships"
],
"type": "string"
}
diff --git a/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-partial-update.json b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-partial-update.json
index 217322a88281..229d0479d8da 100644
--- a/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-partial-update.json
+++ b/services/mcp/tests/unit/__snapshots__/tool-schemas/error-tracking-alerts-partial-update.json
@@ -178,7 +178,7 @@
]
},
"type": {
- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties",
+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships",
"enum": [
"string",
"number",
@@ -194,7 +194,8 @@
"posthog_ticket_tags",
"posthog_business_hours",
"non_failure_status_codes",
- "customer_analytics_account_properties"
+ "customer_analytics_account_properties",
+ "customer_analytics_account_relationships"
],
"type": "string"
}
@@ -338,7 +339,7 @@
]
},
"type": {
- "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties",
+ "description": "* `string` - string\n* `number` - number\n* `boolean` - boolean\n* `dictionary` - dictionary\n* `choice` - choice\n* `json` - json\n* `integration` - integration\n* `integration_field` - integration_field\n* `email` - email\n* `native_email` - native_email\n* `posthog_assignee` - posthog_assignee\n* `posthog_ticket_tags` - posthog_ticket_tags\n* `posthog_business_hours` - posthog_business_hours\n* `non_failure_status_codes` - non_failure_status_codes\n* `customer_analytics_account_properties` - customer_analytics_account_properties\n* `customer_analytics_account_relationships` - customer_analytics_account_relationships",
"enum": [
"string",
"number",
@@ -354,7 +355,8 @@
"posthog_ticket_tags",
"posthog_business_hours",
"non_failure_status_codes",
- "customer_analytics_account_properties"
+ "customer_analytics_account_properties",
+ "customer_analytics_account_relationships"
],
"type": "string"
}