: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 intercom 2.16 tables (#113310)
Tom Owers2fafacac766a
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS.mdindex a7cbddfa8047..20aee45d3708 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS.md@@ -770,7 +770,7 @@ tables dynamically at sync time, so message coverage is better than the static cDiffed 2026-08-04 against [Intercom's published OpenAPI description](https://github.com/intercom/Intercom-OpenAPI)for every API version this source supports (2.13, 2.15, 2.16).-Twenty-one tables.+Twenty-five tables, four of them only on 2.16.- [ ] `data_events` — user event stream. (skipped: `GET /events` is not listable. It requires asingle-contact filter plus `type=user` and only serves the last 90 days, so it would fan out to@@ -783,8 +783,8 @@ Twenty-one tables.- [ ] Conversation ratings — (skipped: no endpoint. `conversation_rating` is a field on the conversationobject, already synced by `conversations`.)- [x] News items, ticket types — shipped as `news_items`, `newsfeeds`, `ticket_types` and `ticket_states`.- Macros / saved replies skipped: `GET /macros` only exists in 2.16, so sources pinned to 2.13 or- 2.15 would 404 on it.+- [x] Macros / saved replies — shipped as `macros`. `GET /macros` only exists in 2.16, so the table only+ shows for sources pinned to 2.16. The other 2.16 additions are in the appendix.### Webflow, WordPress, Calendly, ActiveCampaign, Pipedrivediff --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 3b688afe9dc8..d2bf2ab54ac0 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@@ -4399,6 +4399,19 @@ Diffed against: <https://instatus.com/help/api>Note: Existing 'team' table maps to the teammates endpoint (GET /v1/{page_id}/team) and 'pages' to GET /v2/pages, so those are covered. Metric data points are POST/DELETE only — there is no GET for metric datapoints, so metric time series is not fetchable. escalation-policies, monitors, on-call-schedules, routing-rules and monitoring-integrations doc pages expose no GET list endpoints.+## Intercom — gaps++Today (25): `activity_logs`, `admins`, `articles`, `audiences`, `collections`, `companies`, `company_attributes`, `company_segments`, `contact_attributes`, `contacts`, `content_snippets`, `conversation_attributes`, `conversation_parts`, `conversations`, `help_centers`, `macros`, `news_items`, `newsfeeds`, `segments`, `subscription_types`, `tags`, `teams`, `ticket_states`, `ticket_types`, `tickets`++Diffed against: <https://github.com/intercom/Intercom-OpenAPI/blob/main/descriptions/2.16/api.intercom.io.yaml>++The main spec-verified diff is in [COVERAGE_GAPS.md](COVERAGE_GAPS.md#intercom--spec-verified). These endpoints were announced in the 2.16 changelog and are not in the 2.13 or 2.15 descriptions, so the tables only show for sources pinned to 2.16.++- [x] `GET /conversations/attributes` — conversation attribute definitions with list options, which decode the custom attribute values on `conversations` (medium). Added as `conversation_attributes`, including archived attributes.+- [x] `GET /macros` — saved replies teammates use in the inbox (medium). Added as `macros`, incremental on `updated_at` through the `updated_since` filter.+- [x] `GET /audiences` — saved audience definitions that content and messages target (low). Added as `audiences`.+- [x] `GET /content_snippets` — snippets that feed Fin and Copilot answers (medium). Added as `content_snippets`.+## Intruder — adequateToday (7): `fixed_occurrences`, `issues`, `occurrences`, `scan_schedules`, `scans`, `tags`, `targets`diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/canonical_descriptions.pyindex e2026bfc143d..db2af17cd350 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/canonical_descriptions.py@@ -347,4 +347,73 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"updated_at": "Time at which the newsfeed was last updated, as a Unix timestamp.",},},+ "conversation_attributes": {+ "description": "A custom data attribute defined on conversations, including archived ones.",+ "docs_url": "https://developers.intercom.com/docs/references/rest-api/api.intercom.io/conversations-attributes/listconversationattributes",+ "columns": {+ "id": "Unique identifier for the conversation attribute.",+ "type": "The object type, always 'conversation_attribute'.",+ "name": "The name of the attribute.",+ "description": "A readable description of the attribute.",+ "data_type": "The data type of the attribute: string, integer, list, decimal, boolean, datetime, relationship, or files.",+ "required": "Whether the attribute is required.",+ "visible_to_team_ids": "Identifiers of the teams that can see the attribute. Empty means all teams.",+ "archived": "Whether the attribute is archived.",+ "created_at": "Time at which the attribute was created, as a Unix timestamp.",+ "updated_at": "Time at which the attribute was last updated, as a Unix timestamp.",+ "admin_id": "Identifier of the admin who created the attribute.",+ "multiline": "For string attributes, whether the value can span multiple lines.",+ "options": "For list attributes, the options a teammate can pick, each with an id, label, and archived flag.",+ "reference": "For relationship attributes, the related custom object type and the relationship cardinality.",+ },+ },+ "macros": {+ "description": "A macro (saved reply) that teammates use to answer conversations.",+ "docs_url": "https://developers.intercom.com/docs/references/rest-api/api.intercom.io/macros/listmacros",+ "columns": {+ "id": "Unique identifier for the macro.",+ "type": "The object type, always 'macro'.",+ "name": "The name of the macro.",+ "body": "The body of the macro in HTML, with placeholders in an XML-like attribute format.",+ "body_text": "The plain text body of the macro, with placeholders in Intercom's original format.",+ "created_at": "Time at which the macro was created, as an ISO 8601 string.",+ "updated_at": "Time at which the macro was last updated, as an ISO 8601 string.",+ "visible_to": "Who can view the macro, such as everyone or specific_teams.",+ "visible_to_team_ids": "Identifiers of the teams that can view the macro when visible_to is specific_teams.",+ "available_on": "Where the macro is available for use, such as inbox or messenger.",+ },+ },+ "audiences": {+ "description": "A saved audience: rules that define which contacts a message or piece of content targets.",+ "docs_url": "https://developers.intercom.com/docs/references/rest-api/api.intercom.io/audiences/listaudiences",+ "columns": {+ "id": "Unique identifier for the audience.",+ "type": "The object type, always 'audience'.",+ "name": "The name of the audience.",+ "predicates": "The attribute predicates that decide which contacts belong to the audience.",+ "role_predicates": "Role predicates that further filter audience membership by contact role.",+ "created_at": "Time at which the audience was created, as a Unix timestamp.",+ "updated_at": "Time at which the audience was last updated, as a Unix timestamp.",+ },+ },+ "content_snippets": {+ "description": "A content snippet: a short piece of knowledge that Fin and Copilot use to answer questions.",+ "docs_url": "https://developers.intercom.com/docs/references/rest-api/api.intercom.io/content-snippets/listcontentsnippets",+ "columns": {+ "id": "Unique identifier for the content snippet.",+ "type": "The object type, always 'content_snippet'.",+ "title": "The title of the content snippet.",+ "locale": "The locale of the content snippet.",+ "json_blocks": "The content blocks that make up the body of the snippet.",+ "body_markdown": "The body of the content snippet in Markdown.",+ "chatbot_availability": "Deprecated. Use ai_chatbot_availability.",+ "copilot_availability": "Deprecated. Use ai_copilot_availability.",+ "ai_chatbot_availability": "Whether the snippet is available to Fin, the AI chatbot.",+ "ai_copilot_availability": "Whether the snippet is available to Copilot.",+ "ai_sales_agent_availability": "Whether the snippet is available to the AI sales agent.",+ "created_at": "Time at which the snippet was created, as a Unix timestamp.",+ "updated_at": "Time at which the snippet was last updated, as a Unix timestamp.",+ "audience_ids": "Identifiers of the audiences the snippet targets.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/intercom.py b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/intercom.pyindex 2793e80ff3c9..ce4b9436be7d 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/intercom.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/intercom.py@@ -1,6 +1,7 @@import timeimport dataclassesfrom collections.abc import AsyncIterable, Callable, Iterable, Iterator+from datetime import UTC, datetimefrom typing import Any, Optional, castimport structlog@@ -21,6 +22,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.resBasePaginator,JSONResponseCursorPaginator,JSONResponsePaginator,+ PageNumberPaginator,SinglePagePaginator,)from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import (@@ -56,6 +58,8 @@ class IntercomResumeConfig:completed_conversation_ids: list[str] = dataclasses.field(default_factory=list)# company_segments: every company id that sorts at or before this one is already yielded.last_company_id: str | None = None+ # Page-number list endpoints: the next page to fetch.+ page: int | None = Nonedef _load_resume_state(@@ -293,6 +297,19 @@ class IntercomPagesPaginator(BaseNextUrlPaginator):return "IntercomPagesPaginator()"+def _to_unix_seconds(value: Any) -> int:+ """Coerce a watermark to the Unix seconds Intercom's query-param filters expect.++ Most Intercom timestamps are epoch integers, but macros carry ISO 8601 strings, so their+ watermark arrives as a datetime.+ """+ if isinstance(value, datetime):+ return int((value if value.tzinfo else value.replace(tzinfo=UTC)).timestamp())+ if isinstance(value, str) and not value.lstrip("-").isdigit():+ return _to_unix_seconds(datetime.fromisoformat(value.replace("Z", "+00:00")))+ return int(value)++def _build_search_body(cfg: IntercomEndpointConfig,incremental_field: str,@@ -326,6 +343,8 @@ def _build_paginator(cfg: IntercomEndpointConfig) -> BasePaginator:return JSONResponsePaginator(next_url_path="pages.next")if cfg.paginator_kind == "pages":return IntercomPagesPaginator()+ if cfg.paginator_kind == "page_number":+ return PageNumberPaginator(base_page=1, total_path="total_pages")return SinglePagePaginator()@@ -351,14 +370,14 @@ def get_resource(# `value: 0` matches every record. Default to "updated_at" (the only# cursor Intercom search endpoints support) when no field is passed.endpoint["json"] = _build_search_body(cfg, incremental_field or "updated_at", db_incremental_field_last_value)- elif cfg.paginator_kind in ("cursor", "next_url", "pages"):+ elif cfg.paginator_kind in ("cursor", "next_url", "pages", "page_number"):params: dict[str, Any] = {"per_page": cfg.page_size, **cfg.extra_params}if cfg.incremental_query_param:# Intercom's `/admins/activity_logs` returns a much smaller default# window when called without `created_at_after`, so we always set# the param. `0` matches every record (Unix epoch start).if should_use_incremental_field and db_incremental_field_last_value is not None:- params[cfg.incremental_query_param] = int(db_incremental_field_last_value)+ params[cfg.incremental_query_param] = _to_unix_seconds(db_incremental_field_last_value)else:params[cfg.incremental_query_param] = 0endpoint["params"] = params@@ -763,6 +782,8 @@ def _rest_resume_state(cfg: IntercomEndpointConfig, resume: IntercomResumeConfigreturn {"next_url": resume.next_url}if resume.cursor is not None:return {"cursor": resume.cursor}+ if cfg.paginator_kind == "page_number" and resume.page is not None:+ return {"page": resume.page}return None@@ -778,6 +799,11 @@ def intercom_source(db_incremental_field_last_value: Optional[Any] = None,) -> SourceResponse:cfg = INTERCOM_ENDPOINTS[endpoint]+ if cfg.api_versions is not None and api_version not in cfg.api_versions:+ raise ValueError(+ f"Intercom table {endpoint} requires Intercom API version {', '.join(cfg.api_versions)}, "+ f"but this source is pinned to {api_version}"+ )items: Callable[[], Iterable[Any] | AsyncIterable[Any]]supports_resume = True@@ -832,6 +858,8 @@ def intercom_source(resumable_source_manager.save_state(IntercomResumeConfig(cursor=state["cursor"], query_value=query_value))+ elif state.get("page"):+ resumable_source_manager.save_state(IntercomResumeConfig(page=state["page"]))config: RESTAPIConfig = {"client": {diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/settings.pyindex 19332e21003d..94d568076af8 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/settings.py@@ -6,7 +6,7 @@ from posthog.dataclasses import frozenfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import PartitionFormatfrom products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType-PaginatorKind = Literal["single", "cursor", "next_url", "pages", "search", "substream", "scroll"]+PaginatorKind = Literal["single", "cursor", "next_url", "pages", "page_number", "search", "substream", "scroll"]PartitionMode = Literal["md5", "datetime"]HttpMethod = Literal["GET", "POST"]SortMode = Literal["asc", "desc"]@@ -33,14 +33,18 @@ class IntercomEndpointConfig:incremental_query_param: str | None = None# Substream wiring — when set, this endpoint is fetched per-row of `parent_endpoint`.parent_endpoint: str | None = None+ # Intercom versions that serve this endpoint. `None` means every version the source supports.+ api_versions: tuple[str, ...] | None = None# Endpoint contracts validated against the live Intercom REST API (version 2.13).# Selectors, pagination shape, and partition keys reflect what the API actually# returns — not the docs.+# The endpoints with `api_versions=("2.16",)` exist only on 2.16 and follow+# Intercom's published 2.16 OpenAPI description.## Real-incremental endpoints (server-side filter honored): contacts, conversations,-# tickets, activity_logs, conversation_parts (via parent). Everything else is+# tickets, activity_logs, macros, conversation_parts (via parent). Everything else is# full-refresh because Intercom either has no server filter (companies, segments,# company_segments — Airbyte/Stitch sync these "incrementally" but actually walk# every page each run) or no timestamp at all (data_attributes).@@ -269,6 +273,53 @@ INTERCOM_ENDPOINTS: dict[str, IntercomEndpointConfig] = {partition_mode="md5",partition_format=None,),+ "conversation_attributes": IntercomEndpointConfig(+ # `GET /conversations/attributes?include_archived=true` — the conversation data+ # attribute definitions, with list options and relationship references. Archived+ # attributes are included because older conversations still carry their values.+ name="conversation_attributes",+ path="/conversations/attributes",+ data_selector="data",+ paginator_kind="single",+ partition_key="id",+ partition_mode="md5",+ partition_format=None,+ extra_params={"include_archived": "true"},+ api_versions=("2.16",),+ ),+ "macros": IntercomEndpointConfig(+ # `GET /macros` — saved replies. Paged by a `pages.next.starting_after` cursor,+ # sorted descending on `updated_at`, and filtered server-side by `updated_since`+ # (Unix seconds), so `sort_mode="desc"` like `activity_logs`. Unlike most+ # Intercom objects, `created_at`/`updated_at` are ISO 8601 strings here.+ name="macros",+ path="/macros",+ data_selector="data",+ paginator_kind="pages",+ sort_mode="desc",+ incremental_query_param="updated_since",+ api_versions=("2.16",),+ ),+ "audiences": IntercomEndpointConfig(+ # `GET /audiences` — saved audience definitions (targeting predicates). Paged by+ # `page`/`per_page` (max 50) with a top-level `total_pages`, no timestamp filter.+ name="audiences",+ path="/audiences",+ data_selector="data",+ paginator_kind="page_number",+ page_size=50,+ api_versions=("2.16",),+ ),+ "content_snippets": IntercomEndpointConfig(+ # `GET /content_snippets` — snippets that feed Fin and Copilot answers. Same+ # `page`/`per_page` (max 50) shape as `audiences`, no timestamp filter.+ name="content_snippets",+ path="/content_snippets",+ data_selector="data",+ paginator_kind="page_number",+ page_size=50,+ api_versions=("2.16",),+ ),}ENDPOINTS = tuple(INTERCOM_ENDPOINTS.keys())@@ -279,6 +330,7 @@ ENDPOINTS = tuple(INTERCOM_ENDPOINTS.keys())# - contacts/conversations/tickets: POST /<resource>/search accepts# `{"field":"updated_at","operator":">","value":<unix_ts>}` in the body.# - activity_logs: GET /admins/activity_logs?created_at_after=<unix_ts>.+# - macros: GET /macros?updated_since=<unix_ts>.# - conversation_parts: child of conversations; the parent's `updated_at >`# filter is server-honored, so parents whose timestamp didn't advance# aren't refetched.@@ -287,7 +339,8 @@ ENDPOINTS = tuple(INTERCOM_ENDPOINTS.keys())# list endpoints don't accept a timestamp filter, and a "client-side cursor"# that walks every page each run is identical in API cost to a full refresh.#-# `field_type=Integer` because Intercom returns Unix epoch seconds, not ISO.+# `field_type=Integer` because Intercom returns Unix epoch seconds, not ISO —+# except on macros, which return ISO 8601 strings.INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {"contacts": [{@@ -329,4 +382,12 @@ INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {"field_type": IncrementalFieldType.Integer,}],+ "macros": [+ {+ "label": "updated_at",+ "type": IncrementalFieldType.DateTime,+ "field": "updated_at",+ "field_type": IncrementalFieldType.DateTime,+ }+ ],}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/source.pyindex b8cd7680fbd8..1dc1881a6a35 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/source.py@@ -58,6 +58,8 @@ class IntercomSource(ResumableSource[IntercomSourceConfig, IntercomResumeConfig]"Missing integration ID": "Intercom integration ID is not configured. Please reconnect your Intercom account.","Integration not found": "The linked Intercom integration no longer exists. Please reconnect your Intercom account.","Intercom access token not found": "Intercom OAuth access token is missing. Please reconnect your Intercom account.",+ # Raised by intercom_source for a table Intercom only serves on a newer API version.+ "requires Intercom API version": "This table needs a newer Intercom API version. Upgrade the source's API version, then sync again.",}def resume_covers_run(@@ -127,8 +129,11 @@ class IntercomSource(ResumableSource[IntercomSourceConfig, IntercomResumeConfig]force_refresh: bool = False,api_version: str | None = None,) -> list[SourceSchema]:+ resolved_version = self.resolve_api_version(api_version)schemas = []for endpoint_config in INTERCOM_ENDPOINTS.values():+ if endpoint_config.api_versions is not None and resolved_version not in endpoint_config.api_versions:+ continueincremental_fields = INCREMENTAL_FIELDS.get(endpoint_config.name, [])supports_incremental = bool(incremental_fields)schemas.append(diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/tests/test_intercom.py b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/tests/test_intercom.pyindex 7e1a218547b8..3e7ba1976a9f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/tests/test_intercom.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/tests/test_intercom.py@@ -1,5 +1,6 @@import jsonfrom collections.abc import Iterable+from datetime import UTC, datetimefrom typing import Any, castimport pytest@@ -12,6 +13,7 @@ from requests.exceptions import HTTPErrorfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (JSONResponseCursorPaginator,JSONResponsePaginator,+ PageNumberPaginator,SinglePagePaginator,)from products.warehouse_sources.backend.temporal.data_imports.sources.intercom import intercom as intercom_module@@ -33,6 +35,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.intercom.i_make_intercom_session,_rate_limit_backoff_seconds,_substream_items,+ _to_unix_seconds,get_resource,intercom_source,validate_credentials,@@ -186,6 +189,7 @@ class TestBuildPaginator:("cursor", JSONResponseCursorPaginator),("next_url", JSONResponsePaginator),("pages", IntercomPagesPaginator),+ ("page_number", PageNumberPaginator),("single", SinglePagePaginator),],)@@ -195,7 +199,11 @@ class TestBuildPaginator:assert isinstance(_build_paginator(cfg), expected_type)-PAGES_ENDPOINTS = [name for name, cfg in INTERCOM_ENDPOINTS.items() if cfg.paginator_kind == "pages"]+PAGES_ENDPOINTS = [+ name+ for name, cfg in INTERCOM_ENDPOINTS.items()+ if cfg.paginator_kind == "pages" and cfg.incremental_query_param is None+]class TestPagesPaginator:@@ -324,6 +332,32 @@ class TestGetResource:assert _endpoint(resource)["params"]["created_at_after"] == expected_cursorassert resource["write_disposition"] == expected_disposition+ @pytest.mark.parametrize(+ "should_use_incremental,last_value,expected_disposition,expected_since",+ [+ # Macro timestamps are ISO strings, so the watermark arrives as a datetime.+ (+ True,+ datetime(2023, 11, 14, 22, 13, 20, tzinfo=UTC),+ {"disposition": "merge", "strategy": "upsert"},+ 1700000000,+ ),+ (False, None, "replace", 0),+ ],+ )+ def test_macros_send_the_watermark_as_unix_seconds(+ self, should_use_incremental: bool, last_value: Any, expected_disposition: Any, expected_since: int+ ):+ resource = get_resource(+ "macros",+ should_use_incremental_field=should_use_incremental,+ incremental_field="updated_at" if should_use_incremental else None,+ db_incremental_field_last_value=last_value,+ )++ assert _endpoint(resource)["params"]["updated_since"] == expected_since+ assert resource["write_disposition"] == expected_disposition+@pytest.mark.parametrize("endpoint_name,expected_model",[("company_attributes", "company"), ("contact_attributes", "contact")],@@ -374,6 +408,20 @@ class TestGetResource:assert resource["table_format"] == "delta"+ "value,expected",+ [+ (1700000000, 1700000000),+ ("1700000000", 1700000000),+ (datetime(2023, 11, 14, 22, 13, 20, tzinfo=UTC), 1700000000),+ (datetime(2023, 11, 14, 22, 13, 20), 1700000000),+ ("2023-11-14T22:13:20.000Z", 1700000000),+ ],+)+def test_to_unix_seconds(value: Any, expected: int):+ assert _to_unix_seconds(value) == expected++class TestNoSourceLevelTypeCoercion:# Type flips (Intercom returning a field as an int on some rows and a string on others)# are stabilized generically when batches are built, not by naming fields per endpoint.@@ -834,7 +882,7 @@ class TestIntercomSource:endpoint=endpoint,team_id=1,job_id="job-1",- api_version="2.15",+ api_version="2.16",resumable_source_manager=_manager(),)@@ -845,6 +893,20 @@ class TestIntercomSource:# A companies scroll expires within a minute and cannot restart mid-walk.assert response.supports_resume is (cfg.paginator_kind != "scroll")+ @pytest.mark.parametrize(+ "endpoint", [name for name, cfg in INTERCOM_ENDPOINTS.items() if cfg.api_versions is not None]+ )+ def test_endpoint_unavailable_on_the_pinned_version_raises(self, endpoint: str):+ with pytest.raises(ValueError, match="requires Intercom API version"):+ intercom_source(+ access_token="token",+ endpoint=endpoint,+ team_id=1,+ job_id="job-1",+ api_version="2.13",+ resumable_source_manager=_manager(),+ )+def test_companies_routes_through_scroll_api(self):# `companies` must walk the un-capped Scroll API, never `POST /companies/list`# (capped at 10,000 — paging past it returns `400 page limit reached`). This@@ -1113,6 +1175,33 @@ class TestResumableRestEndpoints:assert sent[0]["params"] == expected_params+def _numbered_page(ids: list[int], page: int, total_pages: int) -> Response:+ return _make_response(+ {"type": "list", "data": [{"id": i} for i in ids], "page": page, "per_page": 50, "total_pages": total_pages}+ )+++class TestPageNumberEndpoints:+ @pytest.mark.parametrize("endpoint", ["audiences", "content_snippets"])+ def test_fresh_run_walks_every_page_and_stops_at_total_pages(self, endpoint: str):+ manager = _manager()+ responses = [_numbered_page([1], 1, 2), _numbered_page([2], 2, 2)]++ rows, sent = _run_rest(endpoint, manager, responses)++ assert rows == [1, 2]+ # The last page is known from `total_pages`, so no trailing empty-page request goes out.+ assert [req["params"] for req in sent] == [{"per_page": 50, "page": 1}, {"per_page": 50, "page": 2}]+ assert _staged(manager) == [IntercomResumeConfig(page=2)]++ def test_resumed_run_starts_at_the_saved_page(self):+ rows, sent = _run_rest("audiences", _manager(IntercomResumeConfig(page=3)), [_numbered_page([7], 3, 3)])++ assert rows == [7]+ assert len(sent) == 1+ assert sent[0]["params"] == {"per_page": 50, "page": 3}++def _segments_session(scroll_ids: list[str], segments: dict[str, Any]) -> mock.MagicMock:responses: dict[str, Any] = {f"/companies/{cid}/segments": body for cid, body in segments.items()}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/tests/test_intercom_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/tests/test_intercom_source.pyindex bf84326490ea..84aa87417167 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/tests/test_intercom_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/intercom/tests/test_intercom_source.py@@ -7,7 +7,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.generated_from products.warehouse_sources.backend.temporal.data_imports.sources.intercom.settings import INTERCOM_ENDPOINTSfrom products.warehouse_sources.backend.temporal.data_imports.sources.intercom.source import IntercomSource-INCREMENTAL_ENDPOINTS = {"contacts", "conversations", "tickets", "activity_logs", "conversation_parts"}+INCREMENTAL_ENDPOINTS = {"contacts", "conversations", "tickets", "activity_logs", "conversation_parts", "macros"}class TestIntercomSource:@@ -132,6 +132,13 @@ class TestIntercomSource:assert entry.get("description"), nameassert entry.get("columns"), name+ @pytest.mark.parametrize("pin", ["2.13", "2.15"])+ def test_get_schemas_hides_tables_the_pinned_version_does_not_serve(self, pin: str):+ names = {s.name for s in self.source.get_schemas(self.config, self.team_id, api_version=pin)}++ assert names == {name for name, cfg in INTERCOM_ENDPOINTS.items() if cfg.api_versions is None}+ assert "macros" not in names+def test_get_schemas_names_filter(self):schemas = self.source.get_schemas(self.config, self.team_id, names=["contacts", "companies"])