: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 2 missing tables to the Salesflare source (#125286)
Tom Owersdefc321e966c
diff --git a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt b/posthog/test/repo_invariants/dataclass_frozen_baseline.txtindex c547dd5dec09..01094a71325b 100644--- a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt+++ b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt@@ -943,7 +943,6 @@1 products/warehouse_sources/backend/temporal/data_imports/sources/sage_hr/sage_hr.py1 products/warehouse_sources/backend/temporal/data_imports/sources/sage_hr/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/salesflare.py-1 products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/salesforce/salesforce.py1 products/warehouse_sources/backend/temporal/data_imports/sources/salesloft/salesloft.py1 products/warehouse_sources/backend/temporal/data_imports/sources/salesloft/settings.pydiff --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 54f55c4728a6..66583ba07b2d 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@@ -10521,8 +10521,8 @@ Today (7): `accounts`, `contacts`, `opportunities`, `pipelines`, `tags`, `tasks`Diffed against: <https://api.salesflare.com/openapi.json>-- [ ] `stages (GET /stages)` — lookup resolving the stage id on every opportunity already synced (high)-- [ ] `users (GET /users)` — lookup resolving owner/assignee ids on accounts, contacts, opportunities and tasks (high)+- [x] `stages (GET /stages)` — lookup resolving the stage id on every opportunity already synced (high)+- [x] `users (GET /users)` — lookup resolving owner/assignee ids on accounts, contacts, opportunities and tasks (high)- [ ] `persons (GET /persons)` — the full people directory, broader than the contacts table (medium)- [ ] `accounts/{id}/feed` — per-account activity timeline (the interaction history behind the CRM) (medium)- [ ] `accounts/{id}/messages` — email/message log per account for engagement analysis (medium)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/canonical_descriptions.pyindex 2251fbab0406..92bc556a6b01 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/canonical_descriptions.py@@ -52,6 +52,15 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"name": "The name of the pipeline.",},},+ "stages": {+ "description": "A stage within a sales pipeline that opportunities move through.",+ "docs_url": "https://api.salesflare.com/docs",+ "columns": {+ "id": "The unique ID of the stage.",+ "name": "The name of the stage.",+ "pipeline": "The pipeline the stage belongs to.",+ },+ },"tasks": {"description": "A to-do or reminder linked to a contact, account, or opportunity.","docs_url": "https://api.salesflare.com/docs",@@ -70,6 +79,15 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"name": "The tag name.",},},+ "users": {+ "description": "A Salesflare user (team member) who can own or be assigned to records.",+ "docs_url": "https://api.salesflare.com/docs",+ "columns": {+ "id": "The unique ID of the user.",+ "name": "The user's full name.",+ "email": "The user's email address.",+ },+ },"workflows": {"description": "An automated email workflow (campaign) configured in Salesflare.","docs_url": "https://api.salesflare.com/docs",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/salesflare.py b/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/salesflare.pyindex 30a3fe4c9911..bf088370d601 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/salesflare.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/salesflare.py@@ -8,7 +8,9 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.res)from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (OffsetPaginator,+ SinglePagePaginator,)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import Endpointfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManagerfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponsefrom products.warehouse_sources.backend.temporal.data_imports.sources.salesflare.settings import SALESFLARE_ENDPOINTS@@ -42,6 +44,17 @@ def salesflare_source() -> SourceResponse:config = SALESFLARE_ENDPOINTS[endpoint]+ endpoint_config: Endpoint = {+ "path": config.path,+ # Salesflare list endpoints return a bare JSON array. A 200 body that isn't a list+ # is treated as a transient malformed payload and retried (as the old source did).+ "data_selector_malformed_retryable": True,+ }+ if config.paginated:+ endpoint_config["params"] = {"limit": PAGE_SIZE}+ else:+ endpoint_config["paginator"] = SinglePagePaginator()+rest_config: RESTAPIConfig = {"client": {"base_url": SALESFLARE_BASE_URL,@@ -57,13 +70,7 @@ def salesflare_source("resources": [{"name": endpoint,- "endpoint": {- "path": config.path,- "params": {"limit": PAGE_SIZE},- # Salesflare list endpoints return a bare JSON array. A 200 body that isn't a list- # is treated as a transient malformed payload and retried (as the old source did).- "data_selector_malformed_retryable": True,- },+ "endpoint": endpoint_config,}],}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/settings.pyindex ea608554e48d..1d2dc8727856 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/settings.py@@ -1,13 +1,17 @@-from dataclasses import dataclass, field+from dataclasses import field++from posthog.dataclasses import frozenfrom products.warehouse_sources.backend.types import IncrementalField-@dataclass+@frozenclass SalesflareEndpointConfig:path: str# Salesflare object IDs are globally unique within an account, so `id` is a safe primary key.primary_keys: list[str] = field(default_factory=lambda: ["id"])+ # Some list endpoints (e.g. /stages) declare no `limit`/`offset` params and return every row at once.+ paginated: bool = True# Salesflare Core API list endpoints. All are full-refresh only: while a few objects expose a@@ -22,6 +26,8 @@ SALESFLARE_ENDPOINTS: dict[str, SalesflareEndpointConfig] = {"tasks": SalesflareEndpointConfig(path="/tasks"),"tags": SalesflareEndpointConfig(path="/tags"),"workflows": SalesflareEndpointConfig(path="/workflows"),+ "stages": SalesflareEndpointConfig(path="/stages", paginated=False),+ "users": SalesflareEndpointConfig(path="/users"),}ENDPOINTS = tuple(SALESFLARE_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/source.pyindex ef199449c3c2..82b9f05a5de2 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/source.py@@ -55,7 +55,7 @@ class SalesflareSource(ResumableSource[SalesflareSourceConfig, SalesflareResumeCreleaseStatus=ReleaseStatus.BETA,caption="""Enter your Salesflare API key to pull your CRM data into the PostHog Data warehouse.-You can create an API key under **Settings → API keys** in [Salesflare](https://app.salesflare.com/#/settings/apikeys). The key grants read access to your contacts, accounts, opportunities, pipelines, tasks, tags, and workflows.+You can create an API key under **Settings → API keys** in [Salesflare](https://app.salesflare.com/#/settings/apikeys). The key grants read access to your contacts, accounts, opportunities, pipelines, stages, tasks, tags, users, and workflows.""",iconPath="/static/services/salesflare.png",docsUrl="https://posthog.com/docs/cdp/sources/salesflare",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/tests/test_salesflare.py b/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/tests/test_salesflare.pyindex 579e8b1c9124..4b7ec2b8c50e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/tests/test_salesflare.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/salesflare/tests/test_salesflare.py@@ -60,6 +60,18 @@ class TestPagination:assert result.urls[0].split("?")[0] == f"{salesflare.SALESFLARE_BASE_URL}{SALESFLARE_ENDPOINTS[endpoint].path}"+ @parameterized.expand([(e, SALESFLARE_ENDPOINTS[e].paginated) for e in ENDPOINTS])+ def test_only_paginated_endpoints_send_page_params(self, endpoint: str, paginated: bool) -> None:+ result = _driver().run(endpoint, [_response(_full_page(0)), _response([])])++ if paginated:+ assert result.params("offset") == ["0", str(PAGE_SIZE)]+ assert result.params("limit")[0] == str(PAGE_SIZE)+ else:+ assert len(result.requests) == 1+ assert result.urls[0] == f"{salesflare.SALESFLARE_BASE_URL}{SALESFLARE_ENDPOINTS[endpoint].path}"+ assert len(result.rows) == PAGE_SIZE+class TestErrorHandling:@parameterized.expand([("rate_limited", 429), ("server_error", 500), ("bad_gateway", 503)])