: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(data-warehouse): add 7 missing Intercom tables (#77271)
Tom Owersf39948ffdb3d
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 58951efb6520..68f86d2f326d 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@@ -651,16 +651,25 @@ tables dynamically at sync time, so message coverage is better than the static c- [ ] User groups, team info, emoji.- [ ] Admin analytics (member and channel activity).-### Intercom — needs confirmation--Fourteen tables and solid coverage.--- [ ] `data_events` — user event stream.-- [ ] Help center collections and sections (we have `articles` but not their structure).-- [ ] Subscription types.-- [ ] `visitors`.-- [ ] Conversation ratings.-- [ ] News items, ticket types, macros / saved replies.+### Intercom — spec-verified++Diffed 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.++- [ ] `data_events` — user event stream. (skipped: `GET /events` is not listable. It requires a+ single-contact filter plus `type=user` and only serves the last 90 days, so it would fan out to+ one request per contact against a per-workspace rate limit.)+- [x] Help center collections and sections — shipped as `collections` and `help_centers`. Sections are+ nested collections (`parent_id`), so the collections table covers both.+- [x] Subscription types — shipped as `subscription_types`.+- [ ] `visitors` — (skipped: `GET /visitors` requires a `user_id` and returns a single visitor; there is+ no list endpoint.)+- [ ] Conversation ratings — (skipped: no endpoint. `conversation_rating` is a field on the conversation+ object, 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.### Webflow, WordPress, Calendly, ActiveCampaign, Pipedrivediff --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 3c60d8f0a1c8..e2026bfc143d 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@@ -235,4 +235,116 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"updated_at": "Time at which the segment was last updated, as a Unix timestamp.",},},+ "help_centers": {+ "description": "A Help Center site in the workspace. Help Centers contain the collections that group articles.",+ "docs_url": "https://developers.intercom.com/docs/references/rest-api/api.intercom.io/help-center/listallhelpcenters",+ "columns": {+ "id": "Unique identifier for the Help Center.",+ "type": "The object type, always 'help_center'.",+ "workspace_id": "Identifier of the workspace the Help Center belongs to.",+ "identifier": "The identifier of the Help Center, used in its URL.",+ "display_name": "The display name of the Help Center, only seen by teammates.",+ "url": "The URL of the Help Center, using the custom domain when one is configured.",+ "custom_domain": "Custom domain configured for the Help Center.",+ "website_turned_on": "Whether the Help Center site is turned on.",+ "default": "Whether this Help Center is the workspace default.",+ "locales": "The locales the Help Center is available in.",+ "created_at": "Time at which the Help Center was created, as a Unix timestamp.",+ "updated_at": "Time at which the Help Center was last updated, as a Unix timestamp.",+ },+ },+ "collections": {+ "description": "A Help Center collection, the top level container that groups articles.",+ "docs_url": "https://developers.intercom.com/docs/references/rest-api/api.intercom.io/help-center/listallcollections",+ "columns": {+ "id": "Unique identifier for the collection.",+ "workspace_id": "Identifier of the workspace the collection belongs to.",+ "name": "The name of the collection. For multilingual collections this is the default language's name.",+ "description": "The description of the collection, in the default language.",+ "url": "The URL of the collection, in the default language.",+ "icon": "The icon of the collection.",+ "order": "The position of the collection relative to others, starting at 0.",+ "default_locale": "The default locale of the Help Center. Only returned for multilingual Help Centers.",+ "translated_content": "The collection's name and description in each configured locale.",+ "parent_id": "Identifier of the parent collection, or null when this is a top level collection.",+ "help_center_id": "Identifier of the Help Center the collection belongs to.",+ "created_at": "Time at which the collection was created, as a Unix timestamp.",+ "updated_at": "Time at which the collection was last updated, as a Unix timestamp.",+ },+ },+ "ticket_types": {+ "description": "A ticket type, defining the category and data fields captured on tickets of that type.",+ "docs_url": "https://developers.intercom.com/docs/references/rest-api/api.intercom.io/tickets/listtickettypes",+ "columns": {+ "id": "Unique identifier for the ticket type.",+ "type": "The object type, always 'ticket_type'.",+ "name": "The name of the ticket type.",+ "description": "The description of the ticket type.",+ "category": "Category of the ticket type: Customer, Back-office, or Tracker.",+ "icon": "The icon of the ticket type.",+ "workspace_id": "Identifier of the workspace the ticket type belongs to.",+ "ticket_type_attributes": "The attributes captured on tickets of this type.",+ "ticket_states": "The ticket states available to tickets of this type.",+ "archived": "Whether the ticket type has been archived.",+ "created_at": "Time at which the ticket type was created, as a Unix timestamp.",+ "updated_at": "Time at which the ticket type was last updated, as a Unix timestamp.",+ },+ },+ "ticket_states": {+ "description": "A ticket state, defining a stage a ticket can be in and how that stage is labelled.",+ "docs_url": "https://developers.intercom.com/docs/references/rest-api/api.intercom.io/tickets/listticketstates",+ "columns": {+ "id": "Unique identifier for the ticket state.",+ "type": "The object type, always 'ticket_state'.",+ "category": "The category of the state: submitted, in_progress, waiting_on_customer, or resolved.",+ "internal_label": "The state in human readable form, visible to teammates in Intercom.",+ "external_label": "The state in human readable form, visible to customers.",+ "archived": "Whether the ticket state has been archived.",+ "ticket_types": "The ticket types this state is available to.",+ },+ },+ "subscription_types": {+ "description": "A subscription type customers can opt in or out of, letting them mute non-essential messages.",+ "docs_url": "https://developers.intercom.com/docs/references/rest-api/api.intercom.io/subscription-types/listsubscriptiontypes",+ "columns": {+ "id": "Unique identifier for the subscription type.",+ "type": "The object type, always 'subscription'.",+ "state": "The state of the subscription type: live, draft, or archived.",+ "consent_type": "Whether consent is opt_in or opt_out.",+ "content_types": "The message types the subscription covers, such as email or sms_message.",+ "default_translation": "The subscription type's name and description in the default locale.",+ "translations": "The subscription type's name and description in each configured locale.",+ },+ },+ "news_items": {+ "description": "A news item, used to announce product updates, company news, promotions, and events to customers.",+ "docs_url": "https://developers.intercom.com/docs/references/rest-api/api.intercom.io/news/listnewsitems",+ "columns": {+ "id": "Unique identifier for the news item.",+ "type": "The object type, always 'news-item'.",+ "workspace_id": "Identifier of the workspace the news item belongs to.",+ "title": "The title of the news item.",+ "body": "The body of the news item, which may contain HTML.",+ "sender_id": "Identifier of the teammate sending the news item.",+ "state": "Whether the news item is a draft or live. Drafts are not visible to customers.",+ "newsfeed_assignments": "The newsfeeds the news item is assigned to, with their publish times.",+ "labels": "Label names shown to customers to categorize the news item.",+ "cover_image_url": "URL of the image used as the news item's cover.",+ "reactions": "The emoji reactions offered on the news item. Empty when reactions are disabled.",+ "deliver_silently": "Whether the news item appears in the newsfeed without a notification badge.",+ "created_at": "Time at which the news item was created, as a Unix timestamp.",+ "updated_at": "Time at which the news item was last updated, as a Unix timestamp.",+ },+ },+ "newsfeeds": {+ "description": "A newsfeed, the collection of news items shown to a targeted audience.",+ "docs_url": "https://developers.intercom.com/docs/references/rest-api/api.intercom.io/news/listnewsfeeds",+ "columns": {+ "id": "Unique identifier for the newsfeed.",+ "type": "The object type, always 'newsfeed'.",+ "name": "The name of the newsfeed. Never visible to customers.",+ "created_at": "Time at which the newsfeed was created, as a Unix timestamp.",+ "updated_at": "Time at which the newsfeed was last updated, as a Unix timestamp.",+ },+ },}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 0dbc79735941..99b56d9b7a27 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@@ -16,6 +16,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.resrest_api_resource,)from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (+ BaseNextUrlPaginator,BasePaginator,JSONResponseCursorPaginator,JSONResponsePaginator,@@ -162,6 +163,59 @@ class IntercomSearchPaginator(BasePaginator):pagination["starting_after"] = self._next_cursor+class IntercomPagesPaginator(BaseNextUrlPaginator):+ """Paginator for Intercom list endpoints whose ``pages.next`` shape varies.++ Intercom's OpenAPI description types ``pages.next`` as a+ ``{"starting_after": ...}`` object for the Help Center and News lists, but the+ live Help Center endpoints return a plain next-page URL there instead — which+ is why ``articles`` ships on ``JSONResponsePaginator``. Rather than bet on one+ shape per endpoint, accept both: a string is followed as the next URL, an+ object's ``starting_after`` is sent back as a query param.+ """++ def __init__(self) -> None:+ super().__init__()+ self._cursor: Optional[str] = None++ def update_state(self, response: Response, data: Optional[list[Any]] = None) -> None:+ try:+ payload = response.json()+ except Exception:+ payload = None+ pages = payload.get("pages") if isinstance(payload, dict) else None+ next_block = pages.get("next") if isinstance(pages, dict) else None++ if isinstance(next_block, str):+ self._cursor = None+ self._advance_to(next_block)+ return++ # Clear any URL from a previous page so `update_request` can't reuse it.+ self._next_url = None+ cursor = next_block.get("starting_after") if isinstance(next_block, dict) else None+ if cursor and cursor == self._cursor:+ # Same guard as the base class applies to a repeated next URL: a cursor that+ # doesn't advance would re-fetch the same page until the activity times out.+ logger.warning("intercom_pagination_not_advancing", paginator=str(self))+ self._has_next_page = False+ return+ self._cursor = cursor or None+ self._has_next_page = bool(cursor)++ def update_request(self, request: Request) -> None:+ if self._next_url is not None:+ super().update_request(request)+ return+ if self._cursor is not None:+ if request.params is None:+ request.params = {}+ request.params["starting_after"] = self._cursor++ def __str__(self) -> str:+ return "IntercomPagesPaginator()"++def _build_search_body(cfg: IntercomEndpointConfig,incremental_field: str,@@ -193,6 +247,8 @@ def _build_paginator(cfg: IntercomEndpointConfig) -> BasePaginator:)if cfg.paginator_kind == "next_url":return JSONResponsePaginator(next_url_path="pages.next")+ if cfg.paginator_kind == "pages":+ return IntercomPagesPaginator()return SinglePagePaginator()@@ -218,7 +274,7 @@ 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"):+ elif cfg.paginator_kind in ("cursor", "next_url", "pages"):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 defaultdiff --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 7cacdf11490e..128f6f8e0504 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@@ -4,7 +4,7 @@ from typing import Literalfrom 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", "search", "substream", "scroll"]+PaginatorKind = Literal["single", "cursor", "next_url", "pages", "search", "substream", "scroll"]PartitionMode = Literal["md5", "datetime"]HttpMethod = Literal["GET", "POST"]SortMode = Literal["asc", "desc"]@@ -195,6 +195,82 @@ INTERCOM_ENDPOINTS: dict[str, IntercomEndpointConfig] = {partition_key="created_at",coerce_string_fields=["waiting_since"],),+ "help_centers": IntercomEndpointConfig(+ # `GET /help_center/help_centers` — one row per Help Center site. A workspace+ # has a handful at most and the response carries no `pages` block, so it's a+ # single-page read. Decodes `collections.help_center_id`.+ name="help_centers",+ path="/help_center/help_centers",+ data_selector="data",+ paginator_kind="single",+ partition_key="id",+ partition_mode="md5",+ partition_format=None,+ ),+ "collections": IntercomEndpointConfig(+ # `GET /help_center/collections` — the Help Center structure behind the+ # `articles` table (articles carry `parent_id`, collections carry+ # `parent_id`/`help_center_id`). Intercom documents the order as descending+ # on `updated_at` and offers no server-side timestamp filter, so this is+ # full refresh.+ name="collections",+ path="/help_center/collections",+ data_selector="data",+ paginator_kind="pages",+ sort_mode="desc",+ ),+ "ticket_types": IntercomEndpointConfig(+ # `GET /ticket_types` — decodes the `ticket_type` id carried on `tickets`.+ # Workspace-level config list with no `pages` block.+ name="ticket_types",+ path="/ticket_types",+ data_selector="data",+ paginator_kind="single",+ partition_key="id",+ partition_mode="md5",+ partition_format=None,+ ),+ "ticket_states": IntercomEndpointConfig(+ # `GET /ticket_states` — decodes the ticket state id carried on `tickets`,+ # and carries the customer-facing vs internal labels for each state.+ name="ticket_states",+ path="/ticket_states",+ data_selector="data",+ paginator_kind="single",+ partition_key="id",+ partition_mode="md5",+ partition_format=None,+ ),+ "subscription_types": IntercomEndpointConfig(+ # `GET /subscription_types` — the consent/subscription types a contact can+ # opt in or out of. Rows have no timestamps, so partition on the id.+ name="subscription_types",+ path="/subscription_types",+ data_selector="data",+ paginator_kind="single",+ partition_key="id",+ partition_mode="md5",+ partition_format=None,+ ),+ "news_items": IntercomEndpointConfig(+ # `GET /news/news_items` — product announcements published to newsfeeds.+ # No server-side timestamp filter, so full refresh.+ name="news_items",+ path="/news/news_items",+ data_selector="data",+ paginator_kind="pages",+ ),+ "newsfeeds": IntercomEndpointConfig(+ # `GET /news/newsfeeds` — the feeds news items are assigned to. A workspace+ # has very few, so partition on the id rather than by week.+ name="newsfeeds",+ path="/news/newsfeeds",+ data_selector="data",+ paginator_kind="pages",+ partition_key="id",+ partition_mode="md5",+ partition_format=None,+ ),"company_segments": IntercomEndpointConfig(# Substream of `companies`. Intercom doesn't expose a server-side# filter on either parent or child, so this is full-refresh (matchesdiff --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 be5ea503a11e..915875f0c9e3 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@@ -17,6 +17,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.resfrom products.warehouse_sources.backend.temporal.data_imports.sources.intercom import intercom as intercom_modulefrom products.warehouse_sources.backend.temporal.data_imports.sources.intercom.intercom import (INTERCOM_API_BASE,+ IntercomPagesPaginator,IntercomSearchPaginator,_build_paginator,_build_search_body,@@ -172,6 +173,7 @@ class TestBuildPaginator:("search", IntercomSearchPaginator),("cursor", JSONResponseCursorPaginator),("next_url", JSONResponsePaginator),+ ("pages", IntercomPagesPaginator),("single", SinglePagePaginator),],)@@ -181,6 +183,87 @@ class TestBuildPaginator:assert isinstance(_build_paginator(cfg), expected_type)+PAGES_ENDPOINTS = [name for name, cfg in INTERCOM_ENDPOINTS.items() if cfg.paginator_kind == "pages"]+++class TestPagesPaginator:+ # Intercom's OpenAPI description types `pages.next` on the Help Center and News lists+ # as a `{"starting_after": ...}` object, but the live Help Center endpoints return a+ # plain next-page URL there. Guessing wrong either way is a real failure: treating a+ # cursor object as a URL puts a dict on `request.url`, and treating a URL as a cursor+ # silently truncates the table to its first page.+ def test_follows_next_url_when_next_is_a_string(self):+ paginator = IntercomPagesPaginator()+ paginator.update_state(_make_response({"pages": {"next": "https://api.intercom.io/x?page=2"}}))++ request = Request(method="GET", url=f"{INTERCOM_API_BASE}/x", params={"per_page": 150})+ paginator.update_request(request)++ assert paginator.has_next_page is True+ assert request.url == "https://api.intercom.io/x?page=2"+ assert request.params == {}++ def test_sends_starting_after_when_next_is_a_cursor_object(self):+ paginator = IntercomPagesPaginator()+ paginator.update_state(_make_response({"pages": {"next": {"starting_after": "cursor-1"}}}))++ request = Request(method="GET", url=f"{INTERCOM_API_BASE}/x", params={"per_page": 150})+ paginator.update_request(request)++ assert paginator.has_next_page is True+ assert request.url == f"{INTERCOM_API_BASE}/x"+ assert request.params == {"per_page": 150, "starting_after": "cursor-1"}++ def test_cursor_page_does_not_reuse_a_previous_next_url(self):+ # An endpoint that switches shapes mid-walk must not keep pointing at the URL+ # from the earlier page, which would refetch it forever.+ paginator = IntercomPagesPaginator()+ paginator.update_state(_make_response({"pages": {"next": "https://api.intercom.io/x?page=2"}}))+ paginator.update_state(_make_response({"pages": {"next": {"starting_after": "cursor-2"}}}))++ request = Request(method="GET", url=f"{INTERCOM_API_BASE}/x", params={})+ paginator.update_request(request)++ assert request.url == f"{INTERCOM_API_BASE}/x"+ assert request.params == {"starting_after": "cursor-2"}++ @pytest.mark.parametrize(+ "body",+ [+ # Last page of a paginated endpoint.+ {"pages": {"next": None}},+ {"pages": {"next": {"starting_after": None}}},+ {"pages": {"page": 1, "total_pages": 1}},+ # Endpoints that return no pagination block at all.+ {"pages": None},+ {"data": []},+ ],+ )+ def test_terminates_without_a_next_page(self, body: Any):+ paginator = IntercomPagesPaginator()+ paginator.update_state(_make_response(body))++ assert paginator.has_next_page is False++ def test_terminates_on_non_json_body(self):+ paginator = IntercomPagesPaginator()+ paginator.update_state(_make_response(None, text="<html>bad gateway</html>"))++ assert paginator.has_next_page is False++ def test_stops_when_the_cursor_stops_advancing(self):+ # A repeated cursor would refetch the same page until the Temporal activity+ # times out, which for these tables is a very long time to spend on one page.+ paginator = IntercomPagesPaginator()+ body = {"pages": {"next": {"starting_after": "cursor-1"}}}++ paginator.update_state(_make_response(body))+ assert paginator.has_next_page is True++ paginator.update_state(_make_response(body))+ assert paginator.has_next_page is False++NON_SUBSTREAM_ENDPOINTS = [name for name, cfg in INTERCOM_ENDPOINTS.items() if cfg.paginator_kind != "substream"]@@ -243,6 +326,25 @@ class TestGetResource:assert _endpoint(resource)["params"] == {"model": expected_model}+ @pytest.mark.parametrize("name", PAGES_ENDPOINTS)+ def test_pages_endpoints_stay_full_refresh(self, name: str):+ # These endpoints expose no server-side timestamp filter, so they declare no+ # incremental fields. Even if the pipeline were to pass an incremental field+ # through, they must keep paging with plain `per_page` and stay on `replace` —+ # merge-upserting a table with no cursor would silently freeze deletions.+ resource = get_resource(+ name,+ should_use_incremental_field=True,+ incremental_field="updated_at",+ db_incremental_field_last_value="1700000000",+ )++ assert resource["write_disposition"] == "replace"+ endpoint = _endpoint(resource)+ assert endpoint["params"] == {"per_page": INTERCOM_ENDPOINTS[name].page_size}+ assert "json" not in endpoint+ assert isinstance(endpoint["paginator"], IntercomPagesPaginator)+def test_single_endpoint_without_params(self):resource = get_resource("admins", should_use_incremental_field=False, incremental_field=None, db_incremental_field_last_value=Nonediff --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 ea3f70429c61..ad4fb5024600 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@@ -118,6 +118,17 @@ class TestIntercomSource:assert schema.supports_incremental is expected, nameassert schema.supports_append is expected, name+ def test_canonical_descriptions_cover_every_endpoint(self):+ # Endpoints missing from the curated map fall back to LLM enrichment, which is+ # both slower and less accurate than the vendor's own docs. Adding a table+ # without its description is the easy thing to forget.+ descriptions = self.source.get_canonical_descriptions()++ assert set(descriptions) == set(INTERCOM_ENDPOINTS)+ for name, entry in descriptions.items():+ assert entry.get("description"), name+ assert entry.get("columns"), name+def test_get_schemas_names_filter(self):schemas = self.source.get_schemas(self.config, self.team_id, names=["contacts", "companies"])