:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(warehouse-sources): add concord approval, signature, version and metadata tables (#104386)
Tom Owersf643f80b6e5c
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.mdindex 1e9132a31745..471eae223703 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md@@ -1925,18 +1925,18 @@ Note: The full OpenAPI (292 paths) is published at commercetools/commercetools-a## Concord — gaps-Today (15): `agreement_activities`, `agreement_clauses`, `agreement_endclauses`, `agreement_fields`, `agreement_members`, `agreements`, `approvals`, `clauses`, `events`, `folders`, `groups`, `members`, `organizations`, `reports`, `tags`+Today (19): `agreement_activities`, `agreement_approval`, `agreement_clauses`, `agreement_endclauses`, `agreement_fields`, `agreement_members`, `agreement_metadata`, `agreement_signature`, `agreement_versions`, `agreements`, `approvals`, `clauses`, `events`, `folders`, `groups`, `members`, `organizations`, `reports`, `tags`Diffed against: <https://api.doc.concordnow.com/concord-openapi-bundled.yaml>- [x] `GET /organizations/{organizationId}/agreements/{agreementUid}/members` — agreement<->user junction: who has access, their permission and signer role (high)- [x] `GET /organizations/{organizationId}/agreements/{agreementUid}/summary/fields` — smart fields (contract value, renewal date, term) - the analytical dimensions of a contract (high)-- [ ] `GET /organizations/{organizationId}/agreements/{agreementUid}/signature` — signature state and signer slots per agreement; drives time-to-signature (high)-- [ ] `GET /organizations/{organizationId}/agreements/{agreementUid}/approval` — per-agreement approval state, joins the approvals table we already sync to its contract (high)+- [x] `GET /organizations/{organizationId}/agreements/{agreementUid}/signature` — signature state and signer slots per agreement; drives time-to-signature (high)+- [x] `GET /organizations/{organizationId}/agreements/{agreementUid}/approval` — per-agreement approval state, joins the approvals table we already sync to its contract (high)- [x] `GET /organizations/{organizationId}/agreements/{agreementUid}/activities` — per-agreement activity timeline (sent, viewed, signed) at finer grain than the org events feed (high)- [x] `GET /organizations/{organizationId}/agreements/{agreementUid}/summary` — clause instances per agreement - the junction to the clauses lookup table already synced (high). The listed `/summary/clauses` and `/summary/endclauses` paths are POST-only; the clause and end-clause arrays are only readable from `GET /summary`, which is what the `agreement_clauses` and `agreement_endclauses` tables sync.-- [ ] `GET /organizations/{organizationId}/agreements/{agreementUid}/versions` — contract version history for redline/negotiation-cycle analysis (medium)-- [ ] `GET /organizations/{organizationId}/agreements/{agreementUid}/metadata` — structured metadata fields beyond the agreement record (medium)+- [x] `GET /organizations/{organizationId}/agreements/{agreementUid}/versions` — contract version history for redline/negotiation-cycle analysis (medium)+- [x] `GET /organizations/{organizationId}/agreements/{agreementUid}/metadata` — structured metadata fields beyond the agreement record (medium)- [ ] `GET /organizations/{organizationId}/agreements/{agreementUid}/comments` — negotiation comment thread per agreement (medium)- [ ] `GET /organizations/{organizationId}/folders/{folderId}/agreements` — folder->agreement membership; resolves the folders table already synced to its contents (low)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/concord/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/concord/canonical_descriptions.pyindex 4a56f400ed02..ce6317e3c074 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/concord/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/concord/canonical_descriptions.py@@ -192,4 +192,65 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"nextEndClauseId": "Id of the end clause that replaced this one.",},},+ "agreement_approval": {+ "description": "Approval workflow governing each agreement, with its rules and overall status.",+ "docs_url": _DOCS_URL,+ "columns": {+ "agreement_uuid": "UID of the agreement. Joins to agreements.uuid.",+ "organizationApprovalId": "Id of the organization approval workflow template this approval is based on. Joins to approvals.id.",+ "organizationApprovalTitle": "Title of the organization approval workflow template.",+ "blockThirdPartySignature": "Whether external users are prevented from signing until every validation rule is satisfied.",+ "autoNotificationEnabled": "Whether Concord notifies approvers automatically when their approval is needed.",+ "rules": "Approval rules defining who must approve and in what order, each with its own validations and status.",+ "status": "Overall approval status: PENDING, APPROVED or REFUSED.",+ },+ },+ "agreement_signature": {+ "description": "Signature setup of each agreement, with one slot per signatory and the signature recorded in it.",+ "docs_url": _DOCS_URL,+ "columns": {+ "agreement_uuid": "UID of the agreement. Joins to agreements.uuid.",+ "enforceOrder": "Whether signers must sign in the configured order.",+ "autoRequest": "Whether signing triggers an automatic signature request to the remaining signers.",+ "signatureProvider": "Provider processing the signatures (CONCORD or DOCUSIGN).",+ "slots": "Signature slots, each with its reservation and, once signed, the signature date, type and signatory.",+ },+ },+ "agreement_versions": {+ "description": "Version history of each agreement, one row per uploaded or generated document version.",+ "docs_url": _DOCS_URL,+ "columns": {+ "agreement_uuid": "UID of the agreement. Joins to agreements.uuid.",+ "id": "Document id of the version within its agreement.",+ "date": "Version creation date as a Unix timestamp in milliseconds.",+ "version": "Version number.",+ "displayVersion": "Version as shown in Concord, in x.y form.",+ "comment": "Comment saved with the version.",+ "type": "Document format of the version (HTML, PDF, WORD_MODE, WORD_LIVE_EDITING or SIGNED).",+ "visibility": "Who can see the version (COMPANY or ALL).",+ "organization": "Organization the version was created under.",+ "user": "User who created the version.",+ },+ },+ "agreement_metadata": {+ "description": "Metadata of each agreement, covering its title, stage, tags and negotiation origin.",+ "docs_url": _DOCS_URL,+ "columns": {+ "agreement_uuid": "UID of the agreement. Joins to agreements.uuid.",+ "organization": "Organization that owns the agreement.",+ "title": "Agreement title.",+ "description": "Agreement description.",+ "status": "Lifecycle stage of the agreement (e.g. DRAFT, NEGOTIATION, CURRENT_CONTRACT).",+ "read": "Whether the account holder has read the agreement.",+ "inboxed": "Whether the agreement is in the account holder's inbox.",+ "bookmarked": "Whether the account holder bookmarked the agreement.",+ "accessFromRole": "Whether access comes from an organization role rather than a direct membership.",+ "trackChanges": "Whether track changes is turned on for the agreement.",+ "trashed": "Whether the agreement is in the trash.",+ "lastAccessAt": "When the agreement was last opened, as a Unix timestamp in milliseconds.",+ "tags": "Tags applied to the agreement. Joins to tags.id.",+ "signedNegotiation": "The negotiation the signed agreement came from, with its originator.",+ "source": "Where the agreement came from, including whether it was created from a template.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/concord/concord.posthog.com.md b/products/warehouse_sources/backend/temporal/data_imports/sources/concord/concord.posthog.com.mdindex 8f532bf48700..cce295017676 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/concord/concord.posthog.com.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/concord/concord.posthog.com.md@@ -18,7 +18,8 @@ import AlphaRelease from "../\_snippets/alpha-release.mdx"e-signatures, contract storage, negotiation, and approvals. This source syncs your agreements,folders, clauses, tags, reports, organization members, and audit events into the PostHog datawarehouse so you can join contract data with your product and revenue data. It also syncs-per-agreement detail: smart fields, clauses, members, and the activity timeline.+per-agreement detail: smart fields, clauses, members, metadata, approval and signature state,+version history, and the activity timeline.## Prerequisites@@ -52,8 +53,9 @@ filter for them.### Per-agreement tables-The `agreement_activities`, `agreement_clauses`, `agreement_endclauses`, `agreement_fields`, and-`agreement_members` tables describe one agreement at a time. Concord has no bulk endpoint for them,+The `agreement_activities`, `agreement_approval`, `agreement_clauses`, `agreement_endclauses`,+`agreement_fields`, `agreement_members`, `agreement_metadata`, `agreement_signature`, and+`agreement_versions` tables describe one agreement at a time. Concord has no bulk endpoint for them,so syncing one makes a request per agreement on every sync. They are **deselected by default** —turn on the ones you need. If an agreement is deleted or your API key can't read it, that agreementis skipped and the rest of the table still syncs.diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/concord/concord.py b/products/warehouse_sources/backend/temporal/data_imports/sources/concord/concord.pyindex cac25d51ed55..72c580bda19d 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/concord/concord.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/concord/concord.py@@ -158,12 +158,21 @@ def _select_rows(def _select_child_rows(- payload: Any, selector: str | None, logger: FilteringBoundLogger | None = None+ payload: Any,+ selector: str | None,+ logger: FilteringBoundLogger | None = None,+ single_object: bool = False,) -> list[dict[str, Any]]:"""Select the rows of a per-agreement child response.- `/members` answers with a bare JSON array; every other child endpoint wraps its rows in a key.+ `/approval`, `/signature` and `/metadata` answer with one object describing the agreement, which+ becomes a single row. `/members` and `/versions` answer with a bare JSON array; every other+ child endpoint wraps its rows in a key."""+ if single_object:+ # An agreement with nothing configured answers `{}`, which would seed a row holding only the+ # parent uid — drop it so the table carries a row only where Concord has something to say.+ return [payload] if isinstance(payload, dict) and payload else []if selector is None:return payload if isinstance(payload, list) else []return _select_rows(payload, selector, logger)@@ -386,7 +395,7 @@ def _fetch_child_rows(raisereturn [_normalize_child_row(config.name, row, agreement_uuid)- for row in _select_child_rows(payload, config.data_selector, logger)+ for row in _select_child_rows(payload, config.data_selector, logger, config.single_object_child)]diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/concord/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/concord/settings.pyindex 7240c7b04aba..802c4ff4a9ed 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/concord/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/concord/settings.py@@ -69,6 +69,9 @@ class ConcordEndpointConfig:# Extra query params a per-agreement child request always needs (e.g. the required `type` on# /activities). Only read by "agreement_fanout" endpoints.fanout_params: dict[str, str] = field(default_factory=dict)+ # A per-agreement endpoint answering with one object describing the agreement rather than a+ # collection, so it yields a single row keyed on the parent agreement.+ single_object_child: bool = Falsedescription: Optional[str] = None@@ -245,6 +248,45 @@ CONCORD_ENDPOINTS: dict[str, ConcordEndpointConfig] = {should_sync_default=False,description="Renewal and termination clauses on each agreement, with notice periods and auto-renewal terms. One request per agreement, so it is off by default.",),+ "agreement_approval": ConcordEndpointConfig(+ name="agreement_approval",+ path="/organizations/{organization_id}/agreements/{agreement_uid}/approval",+ pagination="agreement_fanout",+ single_object_child=True,+ primary_keys=["agreement_uuid"],+ should_sync_default=False,+ description="Approval workflow on each agreement, with its rules and current status. Joins agreements to the organization approvals library. One request per agreement, so it is off by default.",+ ),+ "agreement_signature": ConcordEndpointConfig(+ name="agreement_signature",+ path="/organizations/{organization_id}/agreements/{agreement_uid}/signature",+ pagination="agreement_fanout",+ single_object_child=True,+ primary_keys=["agreement_uuid"],+ should_sync_default=False,+ description="Signature setup and slots on each agreement, including who signed and when. One request per agreement, so it is off by default.",+ ),+ "agreement_versions": ConcordEndpointConfig(+ name="agreement_versions",+ path="/organizations/{organization_id}/agreements/{agreement_uid}/versions",+ pagination="agreement_fanout",+ # The response body is itself the array, with no wrapper key.+ data_selector=None,+ # Version ids are document ids, only documented as unique within their agreement.+ primary_keys=["agreement_uuid", "id"],+ partition_key="date",+ should_sync_default=False,+ description="Version history of each agreement, for redline and negotiation cycle analysis. One request per agreement, so it is off by default.",+ ),+ "agreement_metadata": ConcordEndpointConfig(+ name="agreement_metadata",+ path="/organizations/{organization_id}/agreements/{agreement_uid}/metadata",+ pagination="agreement_fanout",+ single_object_child=True,+ primary_keys=["agreement_uuid"],+ should_sync_default=False,+ description="Metadata on each agreement, such as its tags, track-changes setting and negotiation origin. One request per agreement, so it is off by default.",+ ),}ENDPOINTS = tuple(CONCORD_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/concord/tests/test_concord.py b/products/warehouse_sources/backend/temporal/data_imports/sources/concord/tests/test_concord.pyindex fcaae070fc16..fe1a3b2a57d0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/concord/tests/test_concord.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/concord/tests/test_concord.py@@ -456,6 +456,34 @@ class TestAgreementFanout:assert [r["id"] for r in endclauses] == [9]assert any(url.endswith("/agreements/A/summary") for url in clause_urls)+ def test_versions_read_a_bare_array_response(self):+ rows, urls, _ = self._run(+ "agreement_versions",+ agreements=[{"uuid": "A"}],+ child=[{"id": 1, "displayVersion": "1.0"}, {"id": 2, "displayVersion": "2.0"}],+ )+ assert [(r["agreement_uuid"], r["id"]) for r in rows] == [("A", 1), ("A", 2)]+ assert any(url.endswith("/agreements/A/versions") for url in urls)++ @parameterized.expand(+ [+ ("approval", "agreement_approval", {"status": "PENDING", "blockThirdPartySignature": True}),+ ("signature", "agreement_signature", {"enforceOrder": True, "signatureProvider": "CONCORD"}),+ ("metadata", "agreement_metadata", {"title": "NDA", "status": "DRAFT"}),+ ]+ )+ def test_single_object_child_becomes_one_row_per_agreement(self, _name, endpoint, child):+ rows, _urls, _ = self._run(endpoint, agreements=[{"uuid": "A"}, {"uuid": "B"}], child=child)+ assert [r["agreement_uuid"] for r in rows] == ["A", "B"]+ # the object's own fields land on the row alongside the parent uid+ assert set(child) <= set(rows[0])++ @parameterized.expand([("approval", "agreement_approval"), ("signature", "agreement_signature")])+ def test_single_object_child_skips_an_agreement_with_nothing_configured(self, _name, endpoint):+ rows, _urls, _ = self._run(endpoint, agreements=[{"uuid": "A"}], child={})+ # an empty body would otherwise seed a row carrying nothing but the parent uid+ assert rows == []+@parameterized.expand([("forbidden", 403), ("not_found", 404)])def test_skips_an_agreement_the_key_cannot_read(self, _name, status_code):def child(url):