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(data-imports): unwrap Apitally Apps envelope in fan-out parent (#87780)

Tom Owers401cda7696bc
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/apitally/apitally.py b/products/warehouse_sources/backend/temporal/data_imports/sources/apitally/apitally.py
index e3f7d07e8ccf..489883a6492f 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/apitally/apitally.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/apitally/apitally.py
@@ -163,6 +163,9 @@ def apitally_source(
child_endpoint=endpoint,
fanout=endpoint_config.fanout,
client_config=client_config,
+ # The Apps list wraps its rows in a `data` envelope; the parent must unwrap it so
+ # the fan-out can bind each app's `id` to the child's `app_id` path param.
+ parent_endpoint_extra={"data_selector": "data"},
path_format_values={},
team_id=team_id,
job_id=job_id,
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/apitally/tests/test_apitally.py b/products/warehouse_sources/backend/temporal/data_imports/sources/apitally/tests/test_apitally.py
index ec266c7b3a62..d1f60b5d5ef8 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/apitally/tests/test_apitally.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/apitally/tests/test_apitally.py
@@ -206,6 +206,18 @@ class TestApitallyFanout:
assert kwargs["page_size_param"] is None
assert isinstance(kwargs["child_endpoint_extra"]["paginator"], SinglePagePaginator)
+ @parameterized.expand(["Consumers", "Endpoints", "Traffic", "RequestLogs"])
+ @patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.apitally.apitally.build_dependent_resource"
+ )
+ def test_fanout_unwraps_parent_data_envelope(self, endpoint, mock_build) -> None:
+ mock_build.return_value = iter([])
+
+ apitally_source(api_key="key", endpoint=endpoint, team_id=1, job_id="job-1")
+
+ _, kwargs = mock_build.call_args
+ assert kwargs["parent_endpoint_extra"] == {"data_selector": "data"}
+
@patch(
"products.warehouse_sources.backend.temporal.data_imports.sources.apitally.apitally.build_dependent_resource"
)