: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 dropbox sign team, bulk send job and fax tables (#106635)
Tom Owersf77ca290260a
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.mdindex 7310434026d7..1bdeec2cea86 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@@ -2670,15 +2670,16 @@ Today (4): `account`, `api_apps`, `signature_requests`, `templates`Diffed against: <https://raw.githubusercontent.com/hellosign/hellosign-openapi/main/openapi.yaml>-- [ ] `GET /team/members/{team_id} (teamMembers)` — member roster that resolves the account IDs carried on signature_requests and templates (high)-- [ ] `GET /bulk_send_job/list + /bulk_send_job/{id} (bulkSendJobList)` — bulk send batches and their per-batch signature request status (medium)-- [ ] `GET /team and /team/info (teamGet, teamInfo)` — team/org record with seat and usage counts to join members against (medium)+- [x] `GET /team/members/{team_id} (teamMembers)` — member roster that resolves the account IDs carried on signature_requests and templates (high) — added as `team_members`. The path takes a team id, resolved from `/team/info` at sync time.+- [x] `GET /bulk_send_job/list + /bulk_send_job/{id} (bulkSendJobList)` — bulk send batches and their per-batch signature request status (medium) — added as `bulk_send_jobs` from the list endpoint. `/bulk_send_job/{id}` is not synced: it returns the batch's signature requests, which the `signature_requests` table already holds, and every row there carries `bulk_send_job_id` to join on.+- [x] `GET /team and /team/info (teamGet, teamInfo)` — team/org record with seat and usage counts to join members against (medium) — added as `team`, from `/team/info`, which carries the team id, name and the member and sub-team counts. `/team` is not used: its payload has no id field to key a row on, and its `accounts` array repeats `team_members`.- [ ] `GET /team/sub_teams/{team_id} (teamSubTeams)` — team hierarchy lookup for rolling member activity up to parent teams (low)- [ ] `GET /team/invites (teamInvites)` — pending invites for onboarding/seat funnel analysis (low)-- [ ] `GET /fax/list (faxList)` — sent/received fax transactions for accounts using the fax product (low)+- [x] `GET /fax/list (faxList)` — sent/received fax transactions for accounts using the fax product (low) — added as `faxes`, off by default since faxing is a separate product most accounts do not use.- [ ] `GET /fax_line/list (faxLineList)` — fax line lookup that resolves the line a fax was sent on (low)Note: Spec has 36 paths; the only other GETs are file downloads, embedded URL generators and OAuth. /report/create is POST-only and emails a CSV, so it is not warehouse-queryable.+The team endpoints 404 for an account that belongs to no team, which the source treats as an empty table rather than a failed sync.## Dub — gapsdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/canonical_descriptions.pyindex 403ff9093f48..689d3c9bbcbd 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/canonical_descriptions.py@@ -69,6 +69,53 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"created_at": "Unix timestamp at which the API app was created.",},},+ "bulk_send_jobs": {+ "description": "A batch of signature requests sent together from a single template.",+ "docs_url": "https://developers.hellosign.com/api/reference/operation/bulkSendJobList/",+ "columns": {+ "bulk_send_job_id": "Unique identifier for the bulk send job. Signature requests created by the job carry the same id.",+ "total": "The total number of signature requests queued for sending by the job.",+ "is_creator": "Whether the connected account owns the job, rather than a team member sharing it.",+ "created_at": "Unix timestamp at which the bulk send job was created.",+ },+ },+ "faxes": {+ "description": "A fax sent or received on one of the account's fax lines.",+ "docs_url": "https://developers.hellosign.com/api/reference/operation/faxList/",+ "columns": {+ "fax_id": "Unique identifier for the fax.",+ "title": "The fax's title.",+ "original_title": "The title used when the fax was originally created.",+ "subject": "The fax's subject line.",+ "message": "The message included with the fax.",+ "sender": "Email address of the sender.",+ "files_url": "URL the fax's files can be downloaded from.",+ "final_copy_uri": "Path the completed document can be downloaded from.",+ "transmissions": "One entry per send or receive attempt, with the recipient number and status.",+ "metadata": "Custom metadata attached to the fax.",+ "created_at": "Unix timestamp at which the fax was created.",+ },+ },+ "team": {+ "description": "The team the connected account belongs to, with its seat and sub-team counts. Empty when the account is not on a team.",+ "docs_url": "https://developers.hellosign.com/api/reference/operation/teamInfo/",+ "columns": {+ "team_id": "Unique identifier for the team. Matches the team_id on the account table.",+ "team_parent": "The parent team, when this team is a sub-team.",+ "name": "The team's name.",+ "num_members": "Number of members in the team.",+ "num_sub_teams": "Number of sub-teams under the team.",+ },+ },+ "team_members": {+ "description": "The members of the connected account's team and the role each one holds. Empty when the account is not on a team.",+ "docs_url": "https://developers.hellosign.com/api/reference/operation/teamMembers/",+ "columns": {+ "account_id": "Unique identifier for the member's account. Resolves the account ids carried on other tables.",+ "email_address": "The member's email address.",+ "role": "The role the member holds on the team.",+ },+ },"account": {"description": "The Dropbox Sign account connected via the API key.","docs_url": "https://developers.hellosign.com/api/reference/operation/accountGet/",diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/dropbox_sign.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/dropbox_sign.pyindex 0d7052cabc0f..9c7ff9d482af 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/dropbox_sign.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/dropbox_sign.py@@ -62,7 +62,8 @@ def _fetch_page(headers: dict[str, str],params: dict[str, Any],logger: FilteringBoundLogger,-) -> dict:+ empty_on_404: bool = False,+) -> dict | None:response = session.get(url, headers=headers, params=params, timeout=60)# Dropbox Sign returns 429 when a rate-limit window is exceeded (10-100 req/min depending on@@ -70,6 +71,11 @@ def _fetch_page(if response.status_code == 429 or response.status_code >= 500:raise DropboxSignRetryableError(f"Dropbox Sign API error (retryable): status={response.status_code}, url={url}")+ # The /team endpoints 404 for an account that belongs to no team. An empty table is the right+ # answer there, so it must not be logged as an error or fail the sync.+ if empty_on_404 and response.status_code == 404:+ return None+if not response.ok:logger.error(f"Dropbox Sign API error: status={response.status_code}, body={response.text}, url={url}")response.raise_for_status()@@ -95,6 +101,19 @@ def _redact(item: Any, paths: list[str]) -> Any:return item+def _resolve_team_id(+ session: requests.Session,+ headers: dict[str, str],+ logger: FilteringBoundLogger,+) -> str | None:+ """Resolve the connected account's team id, which team-scoped paths take as a path parameter.+ Returns None when the account belongs to no team."""+ data = _fetch_page(session, f"{DROPBOX_SIGN_BASE_URL}/team/info", headers, {}, logger, empty_on_404=True)+ if data is None:+ return None+ return (data.get("team") or {}).get("team_id")++def get_rows(api_key: str,endpoint: str,@@ -106,11 +125,18 @@ def get_rows(batcher = Batcher(logger=logger, chunk_size=2000, chunk_size_bytes=100 * 1024 * 1024)# One session reused across every page so urllib3 keeps the connection alive.session = make_tracked_session()- url = f"{DROPBOX_SIGN_BASE_URL}{config.path}"++ path = config.path+ if config.requires_team_id:+ team_id = _resolve_team_id(session, headers, logger)+ if team_id is None:+ return+ path = path.format(team_id=team_id)+ url = f"{DROPBOX_SIGN_BASE_URL}{path}"if config.is_single_object:- data = _fetch_page(session, url, headers, {}, logger)- obj = data.get(config.data_key)+ data = _fetch_page(session, url, headers, {}, logger, empty_on_404=config.empty_on_404)+ obj = data.get(config.data_key) if data else Noneif obj:batcher.batch(_redact(obj, config.redact_paths))while batcher.should_yield(include_incomplete_chunk=True):@@ -121,7 +147,11 @@ def get_rows(page = resume.page if resume is not None else 1while True:- data = _fetch_page(session, url, headers, {"page": page, "page_size": PAGE_SIZE}, logger)+ data = _fetch_page(+ session, url, headers, {"page": page, "page_size": PAGE_SIZE}, logger, empty_on_404=config.empty_on_404+ )+ if data is None:+ breakitems = data.get(config.data_key) or []num_pages = (data.get("list_info") or {}).get("num_pages") or 1diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/settings.pyindex ccb1c5034320..a9b19e222fa7 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/settings.py@@ -1,10 +1,12 @@-from dataclasses import dataclass, field+from dataclasses import fieldfrom typing import Optional+from posthog.dataclasses import frozen+from products.warehouse_sources.backend.types import IncrementalField-@dataclass+@frozenclass DropboxSignEndpointConfig:name: str# Path under the v3 base URL (https://api.hellosign.com/v3).@@ -16,6 +18,12 @@ class DropboxSignEndpointConfig:primary_keys: list[str] = field(default_factory=lambda: ["id"])# When True the endpoint returns a single object with no `list_info` / pagination.is_single_object: bool = False+ # When True the path carries a `{team_id}` placeholder resolved from /team/info at sync time.+ requires_team_id: bool = False+ # When True a 404 from this endpoint means the table is empty rather than the sync failed.+ # Only /team/info qualifies: it 404s when the connected account belongs to no team. A 404 from+ # a paginated endpoint would truncate the table silently, so those must keep failing.+ empty_on_404: bool = False# Stable creation timestamp used for datetime partitioning. Dropbox Sign returns these as Unix# timestamps (ints), which the pipeline's datetime partitioner handles natively. None disables# partitioning for the endpoint (e.g. templates expose no creation timestamp).@@ -61,6 +69,37 @@ DROPBOX_SIGN_ENDPOINTS: dict[str, DropboxSignEndpointConfig] = {primary_keys=["account_id"],is_single_object=True,),+ "bulk_send_jobs": DropboxSignEndpointConfig(+ name="bulk_send_jobs",+ path="/bulk_send_job/list",+ data_key="bulk_send_jobs",+ primary_keys=["bulk_send_job_id"],+ partition_key="created_at",+ ),+ "faxes": DropboxSignEndpointConfig(+ name="faxes",+ path="/fax/list",+ data_key="faxes",+ primary_keys=["fax_id"],+ partition_key="created_at",+ # Faxing is a separate Dropbox Sign product, so most accounts have nothing here.+ should_sync_default=False,+ ),+ "team": DropboxSignEndpointConfig(+ name="team",+ path="/team/info",+ data_key="team",+ primary_keys=["team_id"],+ is_single_object=True,+ empty_on_404=True,+ ),+ "team_members": DropboxSignEndpointConfig(+ name="team_members",+ path="/team/members/{team_id}",+ data_key="team_members",+ primary_keys=["account_id"],+ requires_team_id=True,+ ),}ENDPOINTS = tuple(DROPBOX_SIGN_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/test_dropbox_sign.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/test_dropbox_sign.pyindex 3fff819d4c17..76aa207f7204 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/test_dropbox_sign.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/test_dropbox_sign.py@@ -62,7 +62,14 @@ class TestGetRows:"""Drive ``get_rows`` with ``_fetch_page`` faked to serve responses by requested page."""sent_params: list[dict[str, Any]] = []- def fake_fetch(session: Any, url: str, headers: dict[str, str], params: dict[str, Any], logger: Any) -> dict:+ def fake_fetch(+ session: Any,+ url: str,+ headers: dict[str, str],+ params: dict[str, Any],+ logger: Any,+ empty_on_404: bool = False,+ ) -> dict:sent_params.append(dict(params))page = params.get("page", 1)return pages_by_page_number[page]@@ -144,7 +151,14 @@ class TestGetRows:def test_single_object_endpoint_yields_one_row_without_pagination(self, monkeypatch: Any) -> None:captured: list[dict[str, Any]] = []- def fake_fetch(session: Any, url: str, headers: dict[str, str], params: dict[str, Any], logger: Any) -> dict:+ def fake_fetch(+ session: Any,+ url: str,+ headers: dict[str, str],+ params: dict[str, Any],+ logger: Any,+ empty_on_404: bool = False,+ ) -> dict:captured.append(dict(params))return {"account": {"account_id": "acc_1", "email_address": "[email protected]"}}@@ -164,6 +178,61 @@ class TestGetRows:assert captured == [{}]+class TestEndpointSettings:+ def test_only_single_object_endpoints_treat_404_as_empty(self) -> None:+ # A 404 part way through pagination would end the walk and publish a truncated table, so+ # only an endpoint that fetches one object may read a 404 as an empty result.+ paginated = [c.name for c in DROPBOX_SIGN_ENDPOINTS.values() if c.empty_on_404 and not c.is_single_object]+ assert paginated == []+++class TestTeamEndpoints:+ @staticmethod+ def _run(endpoint: str, monkeypatch: Any, bodies: dict[str, Any]) -> tuple[list[dict], list[str]]:+ urls: list[str] = []++ def fake_fetch(+ session: Any,+ url: str,+ headers: dict[str, str],+ params: dict[str, Any],+ logger: Any,+ empty_on_404: bool = False,+ ) -> dict | None:+ urls.append(url)+ return bodies[url]++ monkeypatch.setattr(dropbox_sign, "_fetch_page", fake_fetch)++ rows: list[dict] = []+ for table in get_rows(+ api_key="key",+ endpoint=endpoint,+ logger=MagicMock(),+ resumable_source_manager=_FakeResumableManager(), # type: ignore[arg-type]+ ):+ rows.extend(table.to_pylist())+ return rows, urls++ def test_team_members_path_takes_the_resolved_team_id(self, monkeypatch: Any) -> None:+ bodies = {+ f"{DROPBOX_SIGN_BASE_URL}/team/info": {"team": {"team_id": "T1", "name": "Acme"}},+ f"{DROPBOX_SIGN_BASE_URL}/team/members/T1": _page_body(+ "team_members", [{"account_id": "a1", "role": "Admin"}], page=1, num_pages=1+ ),+ }+ rows, urls = self._run("team_members", monkeypatch, bodies)+ assert rows == [{"account_id": "a1", "role": "Admin"}]+ assert urls == [f"{DROPBOX_SIGN_BASE_URL}/team/info", f"{DROPBOX_SIGN_BASE_URL}/team/members/T1"]++ @pytest.mark.parametrize("endpoint", ["team", "team_members"])+ def test_no_team_yields_no_rows(self, monkeypatch: Any, endpoint: str) -> None:+ # `_fetch_page` returns None for the 404 Dropbox Sign sends when the account has no team.+ rows, urls = self._run(endpoint, monkeypatch, {f"{DROPBOX_SIGN_BASE_URL}/team/info": None})+ assert rows == []+ assert urls == [f"{DROPBOX_SIGN_BASE_URL}/team/info"]++class TestResumeStateSaving:"""The resume page is saved AFTER a batch is yielded, and only while a later page remains."""@@ -179,7 +248,14 @@ class TestResumeStateSaving:monkeypatch.setattr(dropbox_sign, "Batcher", small_batcher)- def fake_fetch(session: Any, url: str, headers: dict[str, str], params: dict[str, Any], logger: Any) -> dict:+ def fake_fetch(+ session: Any,+ url: str,+ headers: dict[str, str],+ params: dict[str, Any],+ logger: Any,+ empty_on_404: bool = False,+ ) -> dict:page = params.get("page", 1)items = [{"signature_request_id": f"p{page}-{i}"} for i in range(items_per_page)]return _page_body("signature_requests", items, page=page, num_pages=num_pages)@@ -243,8 +319,12 @@ class TestSourceResponse:[("signature_requests", True),("api_apps", True),+ ("bulk_send_jobs", True),+ ("faxes", True),("templates", False),("account", False),+ ("team", False),+ ("team_members", False),])def test_partitioning_only_when_endpoint_has_partition_key(self, endpoint: str, partitioned: bool) -> None:@@ -280,6 +360,31 @@ class TestRetryClassification:# would still retry; instead assert the classification directly.cast(Any, dropbox_sign._fetch_page).__wrapped__(session, "http://x", {}, {}, MagicMock())+ @staticmethod+ def _session_returning_404() -> Any:+ response = MagicMock()+ response.status_code = 404+ response.ok = False+ response.raise_for_status.side_effect = requests.HTTPError("404", response=cast(requests.Response, response))+ session = MagicMock()+ session.get.return_value = response+ return session++ def test_404_is_empty_for_an_endpoint_that_opts_in(self) -> None:+ logger = MagicMock()+ result = cast(Any, dropbox_sign._fetch_page).__wrapped__(+ self._session_returning_404(), "http://x", {}, {}, logger, empty_on_404=True+ )+ assert result is None+ # An expected 404 must not reach the error log.+ logger.error.assert_not_called()++ def test_404_raises_for_an_endpoint_that_does_not_opt_in(self) -> None:+ with pytest.raises(requests.HTTPError):+ cast(Any, dropbox_sign._fetch_page).__wrapped__(+ self._session_returning_404(), "http://x", {}, {}, MagicMock()+ )+def test_client_error_raises_http_error(self) -> None:response = MagicMock()response.status_code = 400diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/test_dropbox_sign_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/test_dropbox_sign_source.pyindex 0134be0fe947..4406cd470ad5 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/test_dropbox_sign_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/dropbox_sign/test_dropbox_sign_source.py@@ -50,6 +50,12 @@ class TestSchemas:assert schema.supports_append is Falseassert schema.incremental_fields == []+ def test_faxes_is_not_selected_by_default(self) -> None:+ # Faxing is a separate Dropbox Sign product, so the table stays off unless the user picks it.+ schemas = {s.name: s for s in DropboxSignSource().get_schemas(MagicMock(), team_id=1)}+ assert schemas["faxes"].should_sync_default is False+ assert schemas["signature_requests"].should_sync_default is True+def test_names_filter(self) -> None:schemas = DropboxSignSource().get_schemas(MagicMock(), team_id=1, names=["templates"])assert [s.name for s in schemas] == ["templates"]