Workflows: expose the active relationship assignment date on the external account payload
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 39.9k
- Forks
- 3.4k
- Avg merge
- 6h 51m
- Merged PRs (30d)
- 232
Description
TL;DR
AccountRelationship stores when a CSM/AE/owner assignment started, and the internal facade exposes that date. The external account payload that workflows consume collapses relationships to {definition_name: [{user_id, email}]} with no dates. A workflow cannot read when a role was assigned. Scope: add the active assignment's started_at to the external payload. Exposing full assignment history is out of scope.
What exists today
AccountRelationshipcarriesstarted_atandended_at(products/customer_analytics/backend/models/relationship.py:48-49).assign()closes the previous holder's row (ended_at = now()) and inserts a new one when the definition is single-holder (logic/relationships.py:28-53), sostarted_aton the active row is the date of the current assignment.- The internal contract exposes the date:
contracts.AccountRelationshiphasstarted_at: datetime(facade/contracts.py:55-63), returned bylist_account_relationships(facade/api.py:2800-2812). - The external wire shape drops it:
_to_external_account(facade/api.py:318-339) buildsrelationshipsas{definition_name: [{user_id, email}]}from active rows only (ended_at__isnull=True). This is the payload ofGET /api/customer_analytics/external/account?external_id=(presentation/views/external.py:188-197). - Workflows read account data through that payload: the "Get account" step (
template-posthog-get-account,nodejs/src/cdp/templates/_destinations/posthog_customer_analytics/posthog-get-account.template.ts) fetches it and maps response paths into workflow variables (#69417 addedcustom_propertiesto the payload the same way). Any field absent from the payload is not pickable as a variable.
Constraints
- The relationship table is a shadow of the JSON role keys (
csm,account_executive,account_owner) onAccount._properties. The JSON is authoritative, andsync_from_account_properties()keeps the table in step from every JSON writer (products/customer_analytics/backend/COMPROMISES.md:38-63). The table is the only place assignment dates exist. The JSON keys carry no dates. - The
_to_external_accountdocstring notes the payload was kept byte-identical to what the CDP worker consumed before the facade move (facade/api.py:319-324). Existing workflow output variables reference literal result paths intorelationships({definition_name: [{user_id, email}]}), so entry shape changes are visible to saved workflows.
Goal
A workflow can read the date the active relationship (for example CSM or AE) was assigned to an account, as a pickable output variable of the Get account step.
Open questions
- Relationships are keyed by definition name in the external payload. Is that keying stable enough for date fields, given result paths in workflow output variables reference it literally?
- Where does the date surface in the Get account step's variable picker: only via the response tree, or as a pre-populated output variable alongside the existing hardcoded relationship entries (
products/workflows/frontend/Workflows/hogflows/registry/actions/customer_analytics.ts)?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with _to_external_account and the external account view in facade/api.py and presentation/views/external.py, then inspect the Get account template and customer_analytics.ts registry. Trace how active AccountRelationship rows become workflow variables and how existing relationship result paths are preserved. Done means the active assignment date is available to workflows without removing or changing existing relationship fields.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, typescript
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100