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 carts and custom costs tables to the hyros source (#122643)

Tom Owers221c94d56ddc
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 8259af668f71..42bb1ff638d3 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
@@ -6175,20 +6175,20 @@ Note: Enumerated the API reference from https://docs.hyperspell.com/llms.txt, th
## Hyros — gaps
-Today (14): `AdAccounts`, `Ads`, `CallConversionPaths`, `Calls`, `Keywords`, `LeadConversionPaths`, `Leads`, `Products`, `SaleConversionPaths`, `Sales`, `Sources`, `Stages`, `Subscriptions`, `Tags`
+Today (16): `AdAccounts`, `Ads`, `CallConversionPaths`, `Calls`, `Carts`, `CustomCosts`, `Keywords`, `LeadConversionPaths`, `Leads`, `Products`, `SaleConversionPaths`, `Sales`, `Sources`, `Stages`, `Subscriptions`, `Tags`
Diffed against: <https://api-docs.hyros.com/ai-context/rest-api.txt>
- [x] `Ad Accounts (GET /api/v1.0/ad-accounts)` — resolve adAccountId on sources and attribution records to account names and platforms (high)
- [x] `Ads (GET /api/v1.0/ads)` — resolve adSourceId on sources and attribution records to individual ads (high)
- [x] `Products (GET /api/v1.0/products)` — add product prices and cost of goods to sales for profit analysis, using their existing product IDs (high)
-- [ ] `Ads Attribution Report (GET /api/v1.0/attribution)` — produce vendor attribution metrics and ad spend across attribution models and reporting levels (high)
-- [ ] `ROAS (GET /api/v1.0/attribution/roas)` — measure collected revenue against ad spend using the vendor's fixed return calculation (high)
+- ~~`Ads Attribution Report (GET /api/v1.0/attribution)` — produce vendor attribution metrics and ad spend across attribution models and reporting levels (high)~~ — skipped: a parameterized report, not a list. Each call needs explicit ids at one platform-specific level, an attribution model, a metric list and a date window, and with an ad account id it can't group rows by day
+- ~~`ROAS (GET /api/v1.0/attribution/roas)` — measure collected revenue against ad spend using the vendor's fixed return calculation (high)~~ — skipped: a preset over `GET /attribution` that reports one entity id over one date window per call, so there is no list to sync
- [x] `Conversion Paths (GET /api/v1.0/conversion-paths)` — analyze ordered source touches for each conversion and calculate custom attribution models (high)
- [ ] `Lead Clicks (GET /api/v1.0/leads/clicks)` — analyze click histories behind attributed sales instead of only first and last touches (medium)
- [ ] `Leads Journey (GET /api/v1.0/leads/journey)` — measure stage changes, opt-ins, email activity, and other events across each lead's timeline (medium)
-- [ ] `Custom Costs (GET /api/v1.0/custom-costs)` — include recurring and one-time business costs in campaign profitability calculations (medium)
-- [ ] `Carts (GET /api/v1.0/carts)` — measure cart abandonment and connect purchase intent with attributed sales (medium)
+- [x] `Custom Costs (GET /api/v1.0/custom-costs)` — include recurring and one-time business costs in campaign profitability calculations (medium)
+- [x] `Carts (GET /api/v1.0/carts)` — measure cart abandonment and connect purchase intent with attributed sales (medium)
Note: Parsed the vendor's REST OpenAPI 3.1 YAML, linked from its llms.txt, and inspected source and sale schemas. Tags/count and stages already cover their current lookup endpoints. Clicks and journeys require lead IDs, while reports need explicit windows and attribution choices. Tracking configuration and write-status polling are excluded.
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hyros/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hyros/canonical_descriptions.py
index 9e5158e25719..3e193a486c63 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hyros/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hyros/canonical_descriptions.py
@@ -161,6 +161,34 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"category": "Name of the product category.",
},
},
+ "Carts": {
+ "description": "A shopping cart a lead started, with its products and first/last touch attribution. Carts with an `orderId` were purchased.",
+ "docs_url": "https://api-docs.hyros.com",
+ "columns": {
+ "id": "Unique identifier for the cart.",
+ "orderId": "Identifier of the order the cart was purchased in. Only present once the cart is purchased.",
+ "creationDate": "Date the cart was created, in UTC.",
+ "events": "Number of add-to-cart events recorded on the cart.",
+ "lead": "The lead that owns the cart.",
+ "provider": "The integration the cart came from.",
+ "products": "Products in the cart.",
+ "firstSource": "First attributed source of the cart.",
+ "lastSource": "Last attributed source of the cart.",
+ },
+ },
+ "CustomCosts": {
+ "description": "A recurring or one-time business cost assigned to source tags, counted in profit reporting.",
+ "docs_url": "https://api-docs.hyros.com",
+ "columns": {
+ "id": "Unique identifier for the custom cost.",
+ "name": "Descriptive label for the cost.",
+ "cost": "Amount of the cost, in the account currency.",
+ "frequency": "How often the cost applies: `DAILY`, `ONE_TIME` or `MONTHLY`.",
+ "startDate": "Date the cost starts applying, as a local date-time with no time zone.",
+ "endDate": "Date the cost stops applying, as a local date-time with no time zone. Null for an open-ended cost.",
+ "tags": "Source tags the cost is assigned to.",
+ },
+ },
"SaleConversionPaths": {
"description": "A sale with the ordered source touches it was attributed with, up to the sale date.",
"docs_url": "https://api-docs.hyros.com",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hyros/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hyros/settings.py
index d68fc1c2a841..33658594466f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hyros/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hyros/settings.py
@@ -122,6 +122,21 @@ HYROS_ENDPOINTS: dict[str, HyrosEndpointConfig] = {
path="/api/v1.0/products",
primary_keys=["id"],
),
+ "Carts": HyrosEndpointConfig(
+ name="Carts",
+ path="/api/v1.0/carts",
+ primary_keys=["id"],
+ # Full refresh only: `fromDate` filters on the creation date, but a cart gains its `orderId`
+ # when it is purchased later.
+ partition_key="creationDate",
+ ),
+ "CustomCosts": HyrosEndpointConfig(
+ name="CustomCosts",
+ path="/api/v1.0/custom-costs",
+ primary_keys=["id"],
+ # `fromDate` matches costs whose active range overlaps the window, not a change date, so it
+ # can't serve as an incremental cursor.
+ ),
**{
name: HyrosEndpointConfig(
name=name,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/hyros/tests/test_hyros.py b/products/warehouse_sources/backend/temporal/data_imports/sources/hyros/tests/test_hyros.py
index f6985a11a3ac..7412377a8b82 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/hyros/tests/test_hyros.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/hyros/tests/test_hyros.py
@@ -139,15 +139,23 @@ class TestHyrosSourcePagination:
assert result.raised is None
assert [(row["platform"], row["adSourceId"]) for row in result.rows] == [("FACEBOOK", "238"), (None, None)]
- def test_full_refresh_endpoint_never_filters_by_date(self) -> None:
+ @parameterized.expand(
+ [
+ ("Stages", "/v1/api/v1.0/stages"),
+ ("Carts", "/v1/api/v1.0/carts"),
+ ("CustomCosts", "/v1/api/v1.0/custom-costs"),
+ ]
+ )
+ def test_full_refresh_endpoint_never_filters_by_date(self, endpoint: str, path: str) -> None:
result = _driver().run(
- "Stages",
+ endpoint,
[_response([{"id": "1"}])],
should_use_incremental_field=True,
db_incremental_field_last_value=datetime(2026, 3, 4, tzinfo=UTC),
)
assert result.raised is None
+ assert result.paths == [path]
assert result.queries == [{"pageSize": ("250",)}]