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(warehouse-sources): add impact.com ads and promo codes tables (#122039)

Tom Owers25e202725e33
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 c9ca10b0f705..239fe4f87839 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
@@ -6208,10 +6208,10 @@ Today (8): `Actions`, `ActionUpdates`, `Campaigns`, `Contracts`, `InvoiceDetaile
Diffed against: <https://integrations.impact.com/llms-full.txt/4>
-- [ ] `Ads (GET /Advertisers/{AccountSID}/Ads)` — resolve AdId on actions to creative names, types, and landing pages (high)
-- [ ] `Click Export (GET /Advertisers/{AccountSID}/Programs/{ProgramId}/ClickExport)` — measure partner traffic and conversion rates, including clicks that produce no action (high)
-- [ ] `Action items (GET /Advertisers/{AccountSID}/Actions/{ActionId}/Items)` — analyze conversion revenue and commissions by product SKU and quantity (high)
-- [ ] `Promo Codes (GET /Advertisers/{AccountSID}/PromoCodes)` — resolve action promo codes to assigned partners, active dates, and credit policies (high)
+- [x] `Ads (GET /Advertisers/{AccountSID}/Ads)` — resolve AdId on actions to creative names, types, and landing pages (high). Added as `Ads`, incremental on `DateLastUpdated`.
+- [ ] `Click Export (GET /Advertisers/{AccountSID}/Programs/{ProgramId}/ClickExport)` — measure partner traffic and conversion rates, including clicks that produce no action (high); skipped, it is an asynchronous export job that covers one program and one day per request, and impact.com allows 10 ClickExport requests per day per account, so neither a backfill nor a daily sync across programs fits
+- [ ] `Action items (GET /Advertisers/{AccountSID}/Actions/{ActionId}/Items)` — analyze conversion revenue and commissions by product SKU and quantity (high); skipped, it takes one request per action, and the default limit of 1,000 requests per hour per account would stretch a sync of a busy program over days and starve the other impact.com tables
+- [x] `Promo Codes (GET /Advertisers/{AccountSID}/PromoCodes)` — resolve action promo codes to assigned partners, active dates, and credit policies (high). Added as `PromoCodes`, full refresh only.
- [ ] `Report Export (GET /Advertisers/{AccountSID}/ReportExport/{ReportId})` — import vendor performance reports with dimensions and metrics beyond raw conversion records (medium)
- [ ] `Partner Groups (GET /Advertisers/{AccountSID}/Campaigns/{CampaignId}/MediaPartnerGroups)` — segment existing partners into vendor groups and retain group membership (medium)
- [ ] `Action Inquiries (GET /Advertisers/{AccountSID}/ActionInquiries)` — analyze missing conversion claims, resolution status, and commission disputes (medium)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/impact/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/impact/canonical_descriptions.py
index c8504d7cf7f3..28aa84063405 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/impact/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/impact/canonical_descriptions.py
@@ -37,6 +37,48 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"TotalAmount": "Total invoice amount.",
},
},
+ "Ads": {
+ "description": "The ad creatives partners use to refer traffic to your properties, such as banners, text links, and coupons.",
+ "docs_url": "https://integrations.impact.com/brand-api-reference/reference/ads/ads",
+ "columns": {
+ "Id": "Unique identifier for the ad. Matches AdId on actions.",
+ "Name": "Name of the ad.",
+ "Description": "Description of the ad.",
+ "CampaignId": "Campaign (program) the ad belongs to.",
+ "CampaignName": "Name of the campaign the ad belongs to.",
+ "AdType": "Type of ad, e.g. BANNER, TEXT_LINK, or COUPON.",
+ "LandingPage": "URL the ad sends traffic to.",
+ "DateCreated": "When the ad was created.",
+ "DateLastUpdated": "When the ad was last updated.",
+ "DealId": "Deal the ad is linked to, if any.",
+ "DealName": "Name of the linked deal.",
+ "Labels": "Comma-separated key terms on the ad.",
+ "MobileReady": "Whether the ad is optimized for mobile.",
+ },
+ },
+ "PromoCodes": {
+ "description": "Promo codes that credit partners with actions, with their assignment, active dates, and linked deal.",
+ "docs_url": "https://integrations.impact.com/brand-api-reference/reference/promo-codes/promo-codes",
+ "columns": {
+ "Id": "Unique identifier for the promo code.",
+ "Code": "The promo code value. Matches PromoCode on actions.",
+ "Type": "Match type: LI for exact match, RE for regex.",
+ "CreditPolicy": "How credit is awarded for actions involving this code.",
+ "CampaignId": "Program (campaign) the promo code applies to.",
+ "CampaignName": "Name of the program the promo code applies to.",
+ "AssignedPartnerId": "Partner the promo code is assigned to.",
+ "AssignedPartnerName": "Name of the partner the promo code is assigned to.",
+ "CreatedDate": "When the promo code was created.",
+ "StartDate": "When the promo code becomes active.",
+ "EndDate": "When the promo code expires.",
+ "State": "Current state of the promo code: ACTIVE or INACTIVE.",
+ "DealId": "Deal the promo code is linked to, if any.",
+ "DealName": "Name of the linked deal.",
+ "DiscountType": "How the discount is calculated.",
+ "DiscountAmount": "Flat discount amount, when DiscountType is FIXED.",
+ "DiscountPercent": "Discount percentage, when DiscountType is PERCENT.",
+ },
+ },
"Actions": {
"description": "Conversion and commission records tracked against your campaigns.",
"docs_url": "https://integrations.impact.com/brand-api-reference/reference/actions/actions",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/impact/impact.py b/products/warehouse_sources/backend/temporal/data_imports/sources/impact/impact.py
index 66f81269e7a8..5f56cb8f8e88 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/impact/impact.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/impact/impact.py
@@ -214,6 +214,9 @@ def _get_rows_simple(
cursor = _to_datetime(db_incremental_field_last_value)
if cursor is not None:
params[config.incremental_start_param] = _format_datetime(cursor)
+ # Impact's date range filters can require both ends of the range.
+ if config.incremental_end_param:
+ params[config.incremental_end_param] = _format_datetime(datetime.now(UTC))
resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None
start_page = resume.page if resume and resume.page else 1
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/impact/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/impact/settings.py
index 9f277a040d1e..26d3ce528e32 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/impact/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/impact/settings.py
@@ -112,6 +112,36 @@ IMPACT_ENDPOINTS: dict[str, ImpactEndpointConfig] = {
primary_keys=["Id"],
description="Partner invoices, returned most recent first. Full refresh only.",
),
+ "Ads": ImpactEndpointConfig(
+ name="Ads",
+ path="/Ads",
+ data_key="Ads",
+ primary_keys=["Id"],
+ incremental_start_param="DateLastUpdatedStart",
+ incremental_end_param="DateLastUpdatedEnd",
+ incremental_fields=[
+ {
+ "label": "DateLastUpdated",
+ "type": IncrementalFieldType.DateTime,
+ "field": "DateLastUpdated",
+ "field_type": IncrementalFieldType.DateTime,
+ },
+ ],
+ description=(
+ "The ad creatives (banners, text links, coupons) across your campaigns, with their names, "
+ "types, and landing pages. Join on AdId to see which creative drove each action."
+ ),
+ ),
+ "PromoCodes": ImpactEndpointConfig(
+ name="PromoCodes",
+ path="/PromoCodes",
+ data_key="PromoCodes",
+ primary_keys=["Id"],
+ description=(
+ "Promo codes used to credit partners, with the assigned partner, active dates, credit policy, "
+ "and linked deal. Join on the action PromoCode to attribute coupon conversions. Full refresh only."
+ ),
+ ),
"Actions": ImpactEndpointConfig(
name="Actions",
path="/Actions",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/impact/tests/test_impact.py b/products/warehouse_sources/backend/temporal/data_imports/sources/impact/tests/test_impact.py
index b81cb7e510e0..e093e909e0d6 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/impact/tests/test_impact.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/impact/tests/test_impact.py
@@ -121,15 +121,28 @@ class TestGetRowsSimple:
assert result.params("Page") == ["1", "2"]
assert result.saved_states == [ImpactResumeConfig(page=1), ImpactResumeConfig(page=2)]
- def test_incremental_param_sent_when_using_incremental_field(self) -> None:
+ @parameterized.expand(
+ [
+ ("MediaPartners", "Partners", {"startDate": "2024-01-01T00:00:00Z"}),
+ (
+ "Ads",
+ "Ads",
+ {"DateLastUpdatedStart": "2024-01-01T00:00:00Z", "DateLastUpdatedEnd": "2024-06-01T00:00:00Z"},
+ ),
+ ]
+ )
+ @time_machine.travel("2024-06-01", tick=False)
+ def test_incremental_params_sent_when_using_incremental_field(
+ self, endpoint: str, data_key: str, expected_params: dict[str, str]
+ ) -> None:
result = _driver().run(
- "MediaPartners",
- [ScriptedResponse(json={"Partners": [], "@numpages": "1"})],
+ endpoint,
+ [ScriptedResponse(json={data_key: [], "@numpages": "1"})],
should_use_incremental_field=True,
db_incremental_field_last_value="2024-01-01T00:00:00",
)
assert result.raised is None
- assert result.requests[0].param("startDate") == "2024-01-01T00:00:00Z"
+ assert {name: result.requests[0].param(name) for name in expected_params} == expected_params
class TestGetRowsActions: