: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): sync Gong call summaries as a calls_content table (#88000)
Simon Fisherab466dedffd4
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gong/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gong/canonical_descriptions.pyindex 583817a9b525..ce274119a41b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gong/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gong/canonical_descriptions.py@@ -48,6 +48,25 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"context": "CRM associations for the call — linked objects (e.g. Salesforce/HubSpot Account, Opportunity, Contact) and their field values.",},},+ "calls_content": {+ "description": "Gong's Call Spotlight summary of a recorded call, sourced from the /v2/calls/extensive endpoint. Gong only generates a summary for calls longer than 30 seconds whose transcript runs to at least 100 words, so shorter calls sync with an empty `content`.",+ "docs_url": "https://gong.app.gong.io/settings/api/documentation#post-/v2/calls/extensive",+ "columns": {+ "id": "Unique identifier for the call. Join to `calls` or `calls_extensive` on this.",+ "title": "Title of the call.",+ "url": "URL of the call within the Gong web app.",+ "started": "Time at which the call started (ISO 8601).",+ "duration": "Duration of the call in seconds.",+ "direction": "Direction of the call (Inbound, Outbound, Conference, or Unknown).",+ "scope": "Whether the call was internal or external.",+ "media": "Media type of the call (Audio or Video).",+ "language": "Detected primary language of the call.",+ "workspaceId": "Identifier of the workspace the call belongs to.",+ "primaryUserId": "Identifier of the main Gong user (host) on the call.",+ "scheduled": "Scheduled start time of the call, if applicable.",+ "content": "Gong's AI-generated summary of the call — the Spotlight `brief`, `keyPoints`, `highlights`, `callOutcome`, and `outline`. For the verbatim conversation rather than the summary, see `transcripts`.",+ },+ },"transcripts": {"description": "The transcript of a recorded Gong call — what each speaker said, grouped into monologues and sentences.","docs_url": "https://gong.app.gong.io/settings/api/documentation#post-/v2/calls/transcript",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gong/gong.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gong/gong.pyindex de27930b005d..199652f90ecd 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gong/gong.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gong/gong.py@@ -105,41 +105,40 @@ def _build_url(path: str, params: dict[str, Any]) -> str:return f"{GONG_BASE_URL}{path}?{urlencode(params)}"-def _extensive_body(window_start: datetime, window_end: datetime, cursor: Optional[str]) -> dict[str, Any]:+def _extensive_body(+ config: GongEndpointConfig, window_start: datetime, window_end: datetime, cursor: Optional[str]+) -> dict[str, Any]:"""Request body for `POST /v2/calls/extensive`.- `contentSelector.context = "Extended"` asks Gong to return each call's CRM associations- (linked Salesforce/HubSpot objects and their fields); `exposedFields.parties = true` returns- the participants (name, email address, affiliation). Neither is available from the basic- `/v2/calls` list endpoint. The pagination cursor travels in the body, not the query string.+ Gong returns only the enrichment blocks named in `contentSelector`, so each extensive table+ supplies its own — CRM associations and participants for `calls_extensive`, Spotlight+ summaries for `calls_content`. None of it is available from the basic `/v2/calls` list+ endpoint. The pagination cursor travels in the body, not the query string."""body: dict[str, Any] = {"filter": {"fromDateTime": _format_datetime(window_start),"toDateTime": _format_datetime(window_end),},- "contentSelector": {- "context": "Extended",- "exposedFields": {"parties": True},- },+ "contentSelector": config.extensive_content_selector,}if cursor:body["cursor"] = cursorreturn body-def _flatten_extensive_call(call: dict[str, Any]) -> dict[str, Any]:+def _flatten_extensive_call(call: dict[str, Any], row_keys: tuple[str, ...]) -> dict[str, Any]:"""Lift the `metaData` block of an extensive call row to the top level.- `/v2/calls/extensive` nests the core call fields under `metaData` and returns `parties`- and CRM `context` as siblings. Flattening `metaData` up keeps `id` and `started` available- at the top level for primary-key merge and datetime partitioning, while preserving the- enrichment as nested `parties`/`context` columns.+ `/v2/calls/extensive` nests the core call fields under `metaData` and returns the requested+ enrichment blocks as siblings. Flattening `metaData` up keeps `id` and `started` available at+ the top level for primary-key merge and datetime partitioning, while preserving each+ enrichment block as a nested column."""meta = call.get("metaData") or {}flattened = dict(meta)- flattened["parties"] = call.get("parties")- flattened["context"] = call.get("context")+ for key in row_keys:+ flattened[key] = call.get(key)return flattened@@ -265,9 +264,11 @@ def _iter_call_rows(if config.uses_extensive:data = fetch_page(_build_url(config.path, {}),- json_body=_extensive_body(window_start, window_end, cursor),+ json_body=_extensive_body(config, window_start, window_end, cursor),)- rows = [_flatten_extensive_call(row) for row in data.get(config.response_key, [])]+ rows = [+ _flatten_extensive_call(row, config.extensive_row_keys) for row in data.get(config.response_key, [])+ ]else:params: dict[str, Any] = {"fromDateTime": _format_datetime(window_start),diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gong/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gong/settings.pyindex 9a567b231b78..376507dd29b9 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gong/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gong/settings.py@@ -1,5 +1,5 @@from dataclasses import field-from typing import Optional+from typing import Any, Optionalfrom posthog.dataclasses import frozen@@ -23,9 +23,15 @@ class GongEndpointConfig:uses_date_window: bool = False# `/v2/calls/extensive` is a POST endpoint whose filter, content selector, and pagination# cursor live in a JSON body, and whose rows wrap the call fields in a `metaData` object- # alongside `parties` (participants) and CRM `context`. Requires the broader+ # alongside the enrichment blocks the content selector asked for. Requires the broader# `api:calls:read:extensive` scope.uses_extensive: bool = False+ # `contentSelector` sent to `/v2/calls/extensive`. Gong omits every enrichment block that is+ # not explicitly requested here, so this decides which sibling keys of `metaData` come back.+ extensive_content_selector: Optional[dict[str, Any]] = None+ # Sibling keys of `metaData` to keep as nested columns on the flattened row. Must line up with+ # what `extensive_content_selector` requests, or the columns arrive permanently null.+ extensive_row_keys: tuple[str, ...] = ()# `POST /v2/calls/transcript` answers with `callId` and `transcript` and nothing else. Endpoints# that set this are driven off the `/v2/calls` list for the same window instead: each page of# calls supplies the `callIds` filter for one transcript request, and the call's `started`@@ -42,6 +48,10 @@ class GongEndpointConfig:# Rows-per-chunk override for endpoints whose rows are whole documents. None keeps the# pipeline's default.chunk_size: Optional[int] = None+ # Whether one-shot source setup and new-schema auto-sync enable this endpoint without the+ # administrator picking it. False for endpoints carrying content sensitive enough that syncing+ # it into the warehouse should be a deliberate choice.+ should_sync_default: bool = TrueGONG_ENDPOINTS: dict[str, GongEndpointConfig] = {@@ -76,6 +86,52 @@ GONG_ENDPOINTS: dict[str, GongEndpointConfig] = {uses_date_window=True,uses_extensive=True,capture_http_samples=False,+ extensive_content_selector={+ "context": "Extended",+ "exposedFields": {"parties": True},+ },+ extensive_row_keys=("parties", "context"),+ incremental_fields=[+ {+ "label": "started",+ "type": IncrementalFieldType.DateTime,+ "field": "started",+ "field_type": IncrementalFieldType.DateTime,+ },+ ],+ ),+ # Gong's Call Spotlight summaries, from the same `/v2/calls/extensive` endpoint under the same+ # scope as `calls_extensive` but with the `content` block of the selector requested instead of+ # participants and CRM links. Kept as its own default-off table because a call's AI-generated+ # summary is far more sensitive than the metadata in the other call tables: syncing it puts+ # what was said on every call in reach of anyone who can query the warehouse, so it takes a+ # deliberate pick rather than arriving with the rest of the source.+ "calls_content": GongEndpointConfig(+ name="calls_content",+ path="/v2/calls/extensive",+ response_key="calls",+ primary_key="id",+ partition_key="started",+ supports_incremental=True,+ uses_date_window=True,+ uses_extensive=True,+ capture_http_samples=False,+ should_sync_default=False,+ extensive_content_selector={+ # No CRM context or participants — `calls_extensive` already covers those, and asking+ # for them again would double the payload for data this table does not expose.+ "context": "None",+ "exposedFields": {+ "content": {+ "brief": True,+ "keyPoints": True,+ "highlights": True,+ "callOutcome": True,+ "outline": True,+ }+ },+ },+ extensive_row_keys=("content",),incremental_fields=[{"label": "started",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gong/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gong/source.pyindex 7c21260605be..238928a8b961 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gong/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gong/source.py@@ -56,7 +56,7 @@ Grant the following read scopes so the connected endpoints can sync:- `api:settings:scorecards:read`- `api:workspaces:read`-To also sync the `calls_extensive` table (call participants and CRM associations), additionally grant:+To also sync the `calls_extensive` table (call participants and CRM associations) and the `calls_content` table (Gong's Call Spotlight summaries), additionally grant:- `api:calls:read:extensive`To also sync the `transcripts` table (what was said on each call), additionally grant:@@ -110,6 +110,7 @@ To also sync the `transcripts` table (what was said on each call), additionallysupports_append=endpoint_config.supports_incremental,incremental_fields=endpoint_config.incremental_fields,default_incremental_lookback_seconds=endpoint_config.default_incremental_lookback_seconds,+ should_sync_default=endpoint_config.should_sync_default,description="Only syncs the last 365 days on initial sync"if endpoint_config.uses_date_windowelse None,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gong/tests/test_gong.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gong/tests/test_gong.pyindex f2f21567f5fa..1b5a7bc49aa8 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gong/tests/test_gong.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gong/tests/test_gong.py@@ -348,6 +348,7 @@ class TestGongSource:assert set(GONG_ENDPOINTS) == {"calls","calls_extensive",+ "calls_content","transcripts","users","scorecards",@@ -356,7 +357,55 @@ class TestGongSource:class TestExtensiveCalls:- def test_posts_extensive_body_and_flattens_metadata(self) -> None:+ # Gong returns only the enrichment blocks the selector names, so a table whose selector and+ # kept row keys disagree syncs null columns and no data at all.+ @parameterized.expand(+ [+ (+ "calls_extensive_requests_parties_and_crm_context",+ "calls_extensive",+ {+ "parties": [{"emailAddress": "[email protected]", "affiliation": "External"}],+ "context": [{"system": "Salesforce", "objects": [{"objectType": "Account"}]}],+ "content": {"brief": "should be dropped — not a column on this table"},+ },+ {"context": "Extended", "exposedFields": {"parties": True}},+ {+ "parties": [{"emailAddress": "[email protected]", "affiliation": "External"}],+ "context": [{"system": "Salesforce", "objects": [{"objectType": "Account"}]}],+ },+ ),+ (+ "calls_content_requests_spotlight_summary_only",+ "calls_content",+ {+ "content": {"brief": "Buyer wants SSO.", "keyPoints": [{"text": "Asked about SSO"}]},+ "parties": [{"emailAddress": "[email protected]"}],+ },+ {+ "context": "None",+ "exposedFields": {+ "content": {+ "brief": True,+ "keyPoints": True,+ "highlights": True,+ "callOutcome": True,+ "outline": True,+ }+ },+ },+ {"content": {"brief": "Buyer wants SSO.", "keyPoints": [{"text": "Asked about SSO"}]}},+ ),+ ]+ )+ def test_posts_selector_and_flattens_metadata(+ self,+ _name: str,+ endpoint: str,+ siblings: dict[str, Any],+ expected_selector: dict[str, Any],+ expected_columns: dict[str, Any],+ ) -> None:last_value = datetime.now(UTC) - timedelta(days=5)session = _FakeSession([@@ -365,8 +414,7 @@ class TestExtensiveCalls:"calls": [{"metaData": {"id": "c1", "title": "Discovery", "started": "2026-03-01T00:00:00Z"},- "parties": [{"emailAddress": "[email protected]", "affiliation": "External"}],- "context": [{"system": "Salesforce", "objects": [{"objectType": "Account"}]}],+ **siblings,}]}@@ -383,7 +431,7 @@ class TestExtensiveCalls:get_rows("key","secret",- "calls_extensive",+ endpoint,mock.MagicMock(),manager,should_use_incremental_field=True,@@ -391,23 +439,13 @@ class TestExtensiveCalls:))- # metaData is lifted to the top level; parties and CRM context ride along as columns.- assert batches == [- [- {- "id": "c1",- "title": "Discovery",- "started": "2026-03-01T00:00:00Z",- "parties": [{"emailAddress": "[email protected]", "affiliation": "External"}],- "context": [{"system": "Salesforce", "objects": [{"objectType": "Account"}]}],- }- ]- ]+ # metaData is lifted to the top level; only the blocks this table asked for ride along.+ assert batches == [[{"id": "c1", "title": "Discovery", "started": "2026-03-01T00:00:00Z", **expected_columns}]]# A single POST to the extensive endpoint with no query string.assert session.requested_urls == [f"{GONG_BASE_URL}/v2/calls/extensive"]body = session.posted_bodies[0]assert body is not None- assert body["contentSelector"] == {"context": "Extended", "exposedFields": {"parties": True}}+ assert body["contentSelector"] == expected_selectorassert body["filter"]["fromDateTime"] == _format_datetime(last_value)assert "cursor" not in bodydiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/gong/tests/test_gong_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/gong/tests/test_gong_source.pyindex 3c5aed81c4bb..394fc09974fb 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/gong/tests/test_gong_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/gong/tests/test_gong_source.py@@ -20,7 +20,7 @@ class TestGongSource:schemas = {schema.name: schema for schema in self.source.get_schemas(self.config, self.team_id)}# Only the call-date-filtered endpoints expose a server-side timestamp filter.- for name in ("calls", "calls_extensive", "transcripts"):+ for name in ("calls", "calls_extensive", "calls_content", "transcripts"):assert schemas[name].supports_incremental is Trueassert schemas[name].supports_append is Trueassert any(f["field"] == "started" for f in schemas[name].incremental_fields)@@ -33,6 +33,18 @@ class TestGongSource:assert schemas[name].supports_incremental is Falseassert schemas[name].supports_append is False+ def test_only_call_content_is_default_off(self):+ schemas = {schema.name: schema for schema in self.source.get_schemas(self.config, self.team_id)}++ # Call summaries reach the warehouse only when an admin picks them, so one-shot setup and+ # new-schema auto-sync must leave this table alone.+ assert schemas["calls_content"].should_sync_default is False++ # Derived from ENDPOINTS rather than a fixed list, so a table added later is covered here+ # without editing this test.+ for name in set(ENDPOINTS) - {"calls_content"}:+ assert schemas[name].should_sync_default is True+def test_get_schemas_filtered_by_names(self):schemas = self.source.get_schemas(self.config, self.team_id, names=["calls"])