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.

fix(appsflyer): stop selecting Protect360 tables a new source can't sync (#104907)

Tom Owers9b973f5a50bf
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/appsflyer/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/appsflyer/settings.py
index 85fb04f16a5f..6f4f519a945e 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/appsflyer/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/appsflyer/settings.py
@@ -106,6 +106,9 @@ class AppsFlyerEndpointConfig:
partition_format: PartitionFormat = "month"
# Query params sent on every request for this report, on top of the date window.
extra_params: dict[str, str] = field(default_factory=dict)
+ # Reports behind an AppsFlyer add-on the account may not have start unselected, so a new
+ # source doesn't queue a sync that can only fail.
+ should_sync_default: bool = True
# AppsFlyer's aggregate Pull API returns CSV per date window (max ~1000 days);
@@ -198,6 +201,7 @@ APPSFLYER_ENDPOINTS: dict[str, AppsFlyerEndpointConfig] = {
partition_key="event_time",
partition_format="day",
extra_params={"additional_fields": ",".join(_BLOCKED_ADDITIONAL_FIELDS)},
+ should_sync_default=False,
),
"blocked_in_app_events": AppsFlyerEndpointConfig(
name="blocked_in_app_events",
@@ -208,6 +212,7 @@ APPSFLYER_ENDPOINTS: dict[str, AppsFlyerEndpointConfig] = {
partition_key="event_time",
partition_format="day",
extra_params={"additional_fields": ",".join(_BLOCKED_ADDITIONAL_FIELDS)},
+ should_sync_default=False,
),
"post_attribution_installs": AppsFlyerEndpointConfig(
name="post_attribution_installs",
@@ -222,6 +227,7 @@ APPSFLYER_ENDPOINTS: dict[str, AppsFlyerEndpointConfig] = {
partition_key="event_time",
partition_format="day",
extra_params={"additional_fields": ",".join(_POST_ATTRIBUTION_ADDITIONAL_FIELDS)},
+ should_sync_default=False,
),
"ad_revenue": AppsFlyerEndpointConfig(
name="ad_revenue",
@@ -271,3 +277,9 @@ ENDPOINTS = tuple(APPSFLYER_ENDPOINTS.keys())
INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {
name: config.incremental_fields for name, config in APPSFLYER_ENDPOINTS.items() if config.incremental_fields
}
+
+# The Protect360 fraud reports need the Protect360 add-on, which most accounts don't buy, so they
+# start unselected instead of failing on the first sync of every new source.
+SHOULD_SYNC_DEFAULT: dict[str, bool] = {
+ name: config.should_sync_default for name, config in APPSFLYER_ENDPOINTS.items()
+}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/appsflyer/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/appsflyer/source.py
index 55498ddfc317..07eb01c8bc3f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/appsflyer/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/appsflyer/source.py
@@ -18,6 +18,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.appsflyer.
from products.warehouse_sources.backend.temporal.data_imports.sources.appsflyer.settings import (
ENDPOINTS,
INCREMENTAL_FIELDS,
+ SHOULD_SYNC_DEFAULT,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, SimpleSource
from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
@@ -122,7 +123,7 @@ Raw data tables (installs, in-app events, uninstalls, retargeting conversions, a
force_refresh: bool = False,
api_version: str | None = None,
) -> list[SourceSchema]:
- return build_endpoint_schemas(ENDPOINTS, INCREMENTAL_FIELDS, names)
+ return build_endpoint_schemas(ENDPOINTS, INCREMENTAL_FIELDS, names, should_sync_default=SHOULD_SYNC_DEFAULT)
def validate_credentials(
self,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/appsflyer/tests/test_appsflyer_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/appsflyer/tests/test_appsflyer_source.py
index d81574577c97..d0655deaefaa 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/appsflyer/tests/test_appsflyer_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/appsflyer/tests/test_appsflyer_source.py
@@ -62,6 +62,13 @@ class TestAppsFlyerSource:
full_refresh_only = {"post_attribution_installs"}
assert {schema.name for schema in schemas if not schema.supports_incremental} == full_refresh_only
assert {schema.name for schema in schemas if not schema.supports_append} == full_refresh_only
+ # The Protect360 reports need an add-on most accounts don't have, so selecting them by
+ # default fails the first sync of every new source.
+ assert {schema.name for schema in schemas if not schema.should_sync_default} == {
+ "blocked_installs",
+ "blocked_in_app_events",
+ "post_attribution_installs",
+ }
@mock.patch(
"products.warehouse_sources.backend.temporal.data_imports.sources.appsflyer.source.validate_appsflyer_credentials"