Skip to content

: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.

feat(data-warehouse): add 2 missing tables to the Freshsales source (#119060)

Tom Owers8e9795c8218f
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.md
index 382507819d93..f2d870f9c3f9 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
@@ -4953,8 +4953,8 @@ Diffed against: <https://developers.freshworks.com/crm/api/>
- [x] `/api/selector/lifecycle_stages` — lookup resolving lifecycle_stage_id on contacts and accounts (high)
- [x] `/api/selector/lead_sources` — lookup resolving lead_source_id - the core attribution dimension (high). Added as `lead_sources`.
- [x] `/api/selector/sales_activity_types (+ /sales_activity_outcomes)` — lookups resolving type and outcome IDs on the sales_activities already synced (high). Added as `sales_activity_types` and `sales_activity_outcomes`.
-- [ ] `/api/selector/contact_statuses` — lookup resolving contact_status_id (medium)
-- [ ] `/api/selector/territories` — lookup resolving territory_id for regional breakdowns (medium)
+- [x] `/api/selector/contact_statuses` — lookup resolving contact_status_id (medium)
+- [x] `/api/selector/territories` — lookup resolving territory_id for regional breakdowns (medium)
- [x] `/api/lists (+ /lists/{id} contacts)` — marketing lists and their contact membership (medium). Added as `lists` and `list_contacts` (fan-out over `lists` to `/api/contacts/lists/{id}`).
- ~~`/api/cpq/products`~~ — not listable: the API reference documents create, view by id, update, delete and bulk actions on `/api/cpq/products`, but no endpoint that lists the catalog (medium)
- [ ] `/api/cpq/cpq_documents (+ /{id}/related_products)` — quotes/documents with their product line items - quoted vs won revenue (medium)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/freshsales/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/freshsales/canonical_descriptions.py
index 9c259d499ad8..16f8251271e1 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/freshsales/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/freshsales/canonical_descriptions.py
@@ -185,6 +185,22 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"contact_statuses": "Contact statuses that belong to the lifecycle stage.",
},
},
+ "contact_statuses": {
+ "description": "A contact status configured in the portal. Resolves the contact_status_id carried on contacts.",
+ "docs_url": "https://developers.freshworks.com/crm/api/#admin_configuration",
+ "columns": {
+ "id": "Unique identifier for the contact status.",
+ "name": "Name of the contact status.",
+ },
+ },
+ "territories": {
+ "description": "A sales territory configured in the portal. Resolves the territory_id carried on contacts, accounts and deals.",
+ "docs_url": "https://developers.freshworks.com/crm/api/#admin_configuration",
+ "columns": {
+ "id": "Unique identifier for the territory.",
+ "name": "Name of the territory.",
+ },
+ },
"lead_sources": {
"description": "A lead source configured in the portal. Resolves the lead_source_id carried on contacts and deals.",
"docs_url": "https://developers.freshworks.com/crm/api/#admin_configuration",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/freshsales/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/freshsales/settings.py
index b831f2999817..402196d1435a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/freshsales/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/freshsales/settings.py
@@ -150,6 +150,18 @@ FRESHSALES_ENDPOINTS: dict[str, FreshsalesEndpointConfig] = {
object_key="lifecycle_stages",
is_selector=True,
),
+ "contact_statuses": FreshsalesEndpointConfig(
+ name="contact_statuses",
+ resource="selector/contact_statuses",
+ object_key="contact_statuses",
+ is_selector=True,
+ ),
+ "territories": FreshsalesEndpointConfig(
+ name="territories",
+ resource="selector/territories",
+ object_key="territories",
+ is_selector=True,
+ ),
"lead_sources": FreshsalesEndpointConfig(
name="lead_sources",
resource="selector/lead_sources",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/freshsales/tests/test_freshsales.py b/products/warehouse_sources/backend/temporal/data_imports/sources/freshsales/tests/test_freshsales.py
index 280c4041d39e..dfc07315968b 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/freshsales/tests/test_freshsales.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/freshsales/tests/test_freshsales.py
@@ -12,6 +12,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.tes
scripted_network,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.freshsales.freshsales import (
+ DEFAULT_PAGE_SIZE,
FreshsalesResumeConfig,
_normalize_alias,
check_credentials,
@@ -121,13 +122,26 @@ class TestGetRows:
assert result.items == [[{"id": 1}]]
assert result.paths == ["/crm/sales/api/contacts/filters", "/crm/sales/api/contacts/view/3"]
- def test_selector_falls_back_to_the_only_list_in_the_envelope(self) -> None:
- # Freshsales doesn't publish selector response bodies; an unexpected envelope key must not
- # silently sync an empty table.
- result = _driver().run("owners", [ScriptedResponse(json={"portal_users": [{"id": 1, "name": "Ann"}]})])
+ @parameterized.expand(
+ [
+ # Freshsales doesn't publish selector response bodies; an unexpected envelope key must not
+ # silently sync an empty table.
+ ("owners_unexpected_key", "owners", "portal_users"),
+ ("contact_statuses", "contact_statuses", "contact_statuses"),
+ ("contact_statuses_unexpected_key", "contact_statuses", "statuses"),
+ ("territories", "territories", "territories"),
+ ]
+ )
+ def test_selector_reads_the_whole_collection_in_one_request(
+ self, _name: str, endpoint: str, envelope_key: str
+ ) -> None:
+ rows = [{"id": i, "name": f"Row {i}"} for i in range(DEFAULT_PAGE_SIZE)]
+ result = _driver().run(endpoint, always(ScriptedResponse(json={envelope_key: rows})))
assert result.raised is None
- assert result.items == [[{"id": 1, "name": "Ann"}]]
+ assert result.items == [rows]
+ assert result.paths == [f"/crm/sales/api/selector/{endpoint}"]
+ assert result.params("page") == [None]
def test_deal_stages_walks_every_pipeline(self) -> None:
# /selector/deal_stages covers the default pipeline only, so a single request would miss the