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 Aha releases, requirements, idea_votes tables (#98106)

Tom Owersa557cd0f45f7
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 51e0bff5a0f3..6f2346e57b72 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
@@ -106,10 +106,10 @@ Today (8): `epics`, `features`, `goals`, `ideas`, `initiatives`, `products`, `to
Diffed against: <https://www.aha.io/api>
-- [ ] `releases (GET /api/v1/products/{id}/releases)` — core roadmap object that every synced feature belongs to; currently unresolvable (high)
-- [ ] `requirements (GET /api/v1/features/{id}/requirements)` — the child records under features, where most delivery detail lives (high)
+- [x] `releases (GET /api/v1/products/{id}/releases)` — core roadmap object that every synced feature belongs to; currently unresolvable (high)
+- [x] `requirements (GET /api/v1/features/{id}/requirements)` — the child records under features, where most delivery detail lives (high)
- [ ] `workflow_status_times (GET .../workflow_status_times for features, epics, ideas, releases, requirements, initiatives, key_results)` — state transition history - time in each workflow status, needed for cycle-time analysis (high)
-- [ ] `idea_votes (GET /api/v1/ideas/{id}/endorsements, /api/v1/idea_votes)` — the headline demand metric for ideas we already sync (high)
+- [x] `idea_votes (GET /api/v1/ideas/{id}/endorsements, /api/v1/idea_votes)` — the headline demand metric for ideas we already sync (high)
- [ ] `workflows (GET /api/v1/workflows)` — lookup table decoding the workflow_status IDs carried on features, epics, ideas and releases (high)
- [ ] `key_results (GET /api/v1/goals/{id}/key_results)` — the measurable targets under every synced goal (high)
- [ ] `comments (GET /api/v1/products/{id}/comments and per-record variants) plus idea_comments` — discussion activity across features, releases, goals and ideas (high)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aha/aha.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aha/aha.py
index c3b9e3a621d1..e690dd281354 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/aha/aha.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aha/aha.py
@@ -1,10 +1,12 @@
import re
-import dataclasses
+from collections.abc import Iterable
from datetime import UTC, date, datetime
-from typing import Any, Optional
+from typing import Any, Optional, cast
from requests import Response
+from posthog.dataclasses import frozen
+
from products.warehouse_sources.backend.temporal.data_imports.sources.aha.settings import (
AHA_ENDPOINTS,
PER_PAGE,
@@ -15,12 +17,19 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.res
RESTAPIConfig,
rest_api_resource,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (
+ build_dependent_resource,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.jsonpath_utils import (
find_values,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (
PageNumberPaginator,
)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import (
+ ClientConfig,
+ IncrementalConfig,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
from products.warehouse_sources.backend.temporal.data_imports.sources.common.source_helpers import validate_via_probe
from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse
@@ -32,10 +41,16 @@ AHA_API_PATH = "/api/v1"
_SUBDOMAIN_RE = re.compile(r"^[A-Za-z0-9]([A-Za-z0-9-]{0,61}[A-Za-z0-9])?$")
+@frozen
class AhaResumeConfig:
- # Next 1-indexed page to fetch. None means "start from page 1".
+ # Top-level endpoints resume from the next 1-indexed page. None means "start from page 1".
next_page: int | None = None
+ # Fan-out endpoints (releases, requirements) resume by parent: the parent paths already fully
+ # synced, the parent in progress, and that parent's paginator state — see
+ # `common.rest_source.__init__._make_paginate_dependent_resource`.
+ completed: list[str] | None = None
+ current: str | None = None
+ child_state: dict[str, Any] | None = None
def normalize_subdomain(subdomain: str) -> str:
@@ -103,32 +118,60 @@ class AhaPageNumberPaginator(PageNumberPaginator):
self._has_next_page = False
-def aha_source(
+def _client_config(subdomain: str, api_key: str) -> ClientConfig:
+ return {
+ "base_url": _base_url(subdomain),
+ # Auth (Bearer) goes through the framework auth config so its value is redacted from
+ # logs; only the non-secret accept header is set here.
+ "headers": {"Accept": "application/json"},
+ "auth": {"type": "bearer", "token": api_key},
+ "paginator": AhaPageNumberPaginator(
+ base_page=1,
+ page_param="page",
+ total_path="pagination.total_pages",
+ ),
+ }
+
+
+def _incremental_window(field_name: str) -> IncrementalConfig:
+ """Bind a fan-out child's cursor field to Aha!'s `updated_since` filter param."""
+ return {
+ "cursor_path": field_name,
+ "start_param": "updated_since",
+ "initial_value": "1970-01-01T00:00:00Z",
+ "convert": _format_updated_since,
+ }
+
+
+def _make_source_response(config: AhaEndpointConfig, items: Any, column_hints: Any = None) -> SourceResponse:
+ return SourceResponse(
+ name=config.name,
+ items=items,
+ primary_keys=config.primary_keys,
+ partition_count=1,
+ partition_size=1,
+ partition_mode="datetime" if config.partition_key else None,
+ partition_format="month" if config.partition_key else None,
+ partition_keys=[config.partition_key] if config.partition_key else None,
+ column_hints=column_hints,
+ )
+
+
+def _top_level_source(
+ config: AhaEndpointConfig,
subdomain: str,
api_key: str,
endpoint: str,
team_id: int,
job_id: str,
resumable_source_manager: ResumableSourceManager[AhaResumeConfig],
- should_use_incremental_field: bool = False,
- db_incremental_field_last_value: Optional[Any] = None,
+ should_use_incremental_field: bool,
+ db_incremental_field_last_value: Optional[Any],
) -> SourceResponse:
- config = AHA_ENDPOINTS[endpoint]
params = _build_initial_params(config, should_use_incremental_field, db_incremental_field_last_value)
rest_config: RESTAPIConfig = {
- "client": {
- "base_url": _base_url(subdomain),
- # Auth (Bearer) goes through the framework auth config so its value is redacted from
- # logs; only the non-secret accept header is set here.
- "headers": {"Accept": "application/json"},
- "auth": {"type": "bearer", "token": api_key},
- "paginator": AhaPageNumberPaginator(
- base_page=1,
- page_param="page",
- total_path="pagination.total_pages",
- ),
- },
+ "client": _client_config(subdomain, api_key),
"resource_defaults": {},
"resources": [
{
@@ -165,16 +208,107 @@ def aha_source(
initial_paginator_state=initial_paginator_state,
)
- return SourceResponse(
- name=endpoint,
- items=lambda: resource,
- primary_keys=config.primary_keys,
- partition_count=1,
- partition_size=1,
- partition_mode="datetime" if config.partition_key else None,
- partition_format="month" if config.partition_key else None,
- partition_keys=[config.partition_key] if config.partition_key else None,
- column_hints=resource.column_hints,
+ return _make_source_response(config, lambda: resource, column_hints=resource.column_hints)
+
+
+def _fanout_source(
+ config: AhaEndpointConfig,
+ subdomain: str,
+ api_key: str,
+ endpoint: str,
+ team_id: int,
+ job_id: str,
+ resumable_source_manager: ResumableSourceManager[AhaResumeConfig],
+ should_use_incremental_field: bool,
+ db_incremental_field_last_value: Optional[Any],
+ incremental_field: str | None,
+) -> SourceResponse:
+ assert config.fanout is not None
+ parent_config = AHA_ENDPOINTS[config.fanout.parent_name]
+
+ initial_state: Optional[dict[str, Any]] = None
+ if resumable_source_manager.can_resume():
+ resume = resumable_source_manager.load_state()
+ if resume is not None and (resume.completed or resume.current):
+ initial_state = {
+ "completed": resume.completed or [],
+ "current": resume.current,
+ "child_state": resume.child_state,
+ }
+
+ def save_checkpoint(state: Optional[dict[str, Any]]) -> None:
+ if state is not None:
+ resumable_source_manager.save_state(
+ AhaResumeConfig(
+ completed=state.get("completed"),
+ current=state.get("current"),
+ child_state=state.get("child_state"),
+ )
+ )
+
+ dependent_resource = cast(
+ Iterable[Any],
+ build_dependent_resource(
+ endpoint_configs=AHA_ENDPOINTS,
+ child_endpoint=endpoint,
+ fanout=config.fanout,
+ client_config=_client_config(subdomain, api_key),
+ path_format_values={},
+ team_id=team_id,
+ job_id=job_id,
+ db_incremental_field_last_value=db_incremental_field_last_value,
+ should_use_incremental_field=should_use_incremental_field,
+ incremental_field=incremental_field,
+ incremental_config_factory=_incremental_window,
+ # Aha! wraps every list response in a root key; select the array for parent and child.
+ parent_endpoint_extra={"data_selector": parent_config.response_key},
+ child_endpoint_extra={"data_selector": config.response_key},
+ page_size_param="per_page",
+ resume_hook=save_checkpoint,
+ initial_paginator_state=initial_state,
+ ),
+ )
+
+ return _make_source_response(config, lambda: dependent_resource)
+
+
+def aha_source(
+ subdomain: str,
+ api_key: str,
+ endpoint: str,
+ team_id: int,
+ job_id: str,
+ resumable_source_manager: ResumableSourceManager[AhaResumeConfig],
+ should_use_incremental_field: bool = False,
+ db_incremental_field_last_value: Optional[Any] = None,
+ incremental_field: str | None = None,
+) -> SourceResponse:
+ config = AHA_ENDPOINTS[endpoint]
+
+ if config.fanout is not None:
+ return _fanout_source(
+ config,
+ subdomain,
+ api_key,
+ endpoint,
+ team_id,
+ job_id,
+ resumable_source_manager,
+ should_use_incremental_field,
+ db_incremental_field_last_value,
+ incremental_field,
+ )
+
+ return _top_level_source(
+ config,
+ subdomain,
+ api_key,
+ endpoint,
+ team_id,
+ job_id,
+ resumable_source_manager,
+ should_use_incremental_field,
+ db_incremental_field_last_value,
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aha/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aha/canonical_descriptions.py
index 4b4f395755f8..f6ef7b543b37 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/aha/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aha/canonical_descriptions.py
@@ -122,4 +122,40 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"updated_at": "Time at which the user was last updated.",
},
},
+ "releases": {
+ "description": "A release in Aha! — a dated container of features and epics delivered together.",
+ "docs_url": "https://www.aha.io/api/resources/releases",
+ "columns": {
+ **_COMMON_COLUMNS,
+ "product_id": "Identifier of the product this release belongs to.",
+ "release_date": "Planned external release date.",
+ "development_started_on": "Date development on the release started.",
+ "released": "Whether the release has shipped.",
+ "parking_lot": "Whether the release is a parking lot for un-scheduled work.",
+ "workflow_status": "The release's current status in its workflow.",
+ },
+ },
+ "requirements": {
+ "description": "A requirement in Aha! — a child record under a feature capturing delivery detail.",
+ "docs_url": "https://www.aha.io/api/resources/requirements",
+ "columns": {
+ **_COMMON_COLUMNS,
+ "feature_id": "Identifier of the feature this requirement belongs to.",
+ "workflow_status": "The requirement's current status in its workflow.",
+ "assigned_to_user": "The user the requirement is assigned to.",
+ "description": "Description of the requirement.",
+ },
+ },
+ "idea_votes": {
+ "description": "A vote (endorsement) cast on an Aha! idea — the demand signal behind an idea.",
+ "docs_url": "https://www.aha.io/api/resources/idea_votes",
+ "columns": {
+ "id": "Unique identifier for the vote.",
+ "idea_id": "Identifier of the idea the vote was cast on.",
+ "weight": "Weight of the vote.",
+ "link": "URL of the idea the vote belongs to.",
+ "created_at": "Time at which the vote was cast.",
+ "updated_at": "Time at which the vote was last updated.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aha/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aha/settings.py
index c4caff49fdb4..78f1aa23812d 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/aha/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aha/settings.py
@@ -1,6 +1,9 @@
from dataclasses import dataclass, field
from typing import Optional
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (
+ DependentEndpointConfig,
+)
from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType
# Aha! caps `per_page` at 200 (default 30). Always request the max to minimise round trips.
@@ -20,7 +23,10 @@ def _updated_at_incremental_fields() -> list[IncrementalField]:
]
-@dataclass
+# Mutable by choice, not oversight: instances flow into `build_dependent_resource`'s
+# `endpoint_configs: Mapping[str, FanoutEndpointLike]`, and mypy treats a frozen dataclass's
+# fields as read-only, which is incompatible with that Protocol's plain (read-write) attributes.
+@dataclass(frozen=False)
class AhaEndpointConfig:
name: str
path: str # Path under /api/v1, e.g. "/features"
@@ -32,8 +38,14 @@ class AhaEndpointConfig:
# Stable creation-time field to partition by. None when the resource has no reliable created_at.
partition_key: Optional[str] = "created_at"
incremental_fields: list[IncrementalField] = field(default_factory=list)
+ # The cursor field the fan-out helper binds to `updated_since`. Only read for fan-out children.
+ default_incremental_field: Optional[str] = None
primary_keys: list[str] = field(default_factory=lambda: ["id"])
should_sync_default: bool = True
+ # Set for child resources that hang off a parent list endpoint (e.g. releases under a product).
+ fanout: Optional[DependentEndpointConfig] = None
+ # Page size the fan-out helper requests for this resource's list action; matches PER_PAGE.
+ page_size: int = PER_PAGE
AHA_ENDPOINTS: dict[str, AhaEndpointConfig] = {
@@ -93,6 +105,55 @@ AHA_ENDPOINTS: dict[str, AhaEndpointConfig] = {
# The Get users list action only documents an `email` filter — no time-based incremental.
supports_incremental=False,
),
+ # Idea votes are exposed under the `endorsements` path but returned under an `idea_votes`
+ # root key (Aha! names the web "votes" as API "endorsements"). The account-wide list action
+ # `/ideas/endorsements` supports `updated_since`, so this is a plain top-level endpoint.
+ "idea_votes": AhaEndpointConfig(
+ name="idea_votes",
+ path="/ideas/endorsements",
+ response_key="idea_votes",
+ supports_incremental=True,
+ incremental_fields=_updated_at_incremental_fields(),
+ default_incremental_field="updated_at",
+ ),
+ # Releases have no account-wide list action, only per-product. Fan out over the synced
+ # `products` table; `updated_since` filters each product's release list server-side.
+ "releases": AhaEndpointConfig(
+ name="releases",
+ path="/products/{product_id}/releases",
+ response_key="releases",
+ supports_incremental=True,
+ incremental_fields=_updated_at_incremental_fields(),
+ default_incremental_field="updated_at",
+ # Aha! record ids are globally unique, but keep the parent product id in the key so a
+ # duplicate can never span products even if that ever changes.
+ primary_keys=["id", "product_id"],
+ fanout=DependentEndpointConfig(
+ parent_name="products",
+ resolve_param="product_id",
+ resolve_field="id",
+ include_from_parent=["id"],
+ parent_field_renames={"id": "product_id"},
+ ),
+ ),
+ # Requirements have no account-wide list action, only per-feature. Fan out over the synced
+ # `features` table; `updated_since` filters each feature's requirement list server-side.
+ "requirements": AhaEndpointConfig(
+ name="requirements",
+ path="/features/{feature_id}/requirements",
+ response_key="requirements",
+ supports_incremental=True,
+ incremental_fields=_updated_at_incremental_fields(),
+ default_incremental_field="updated_at",
+ primary_keys=["id", "feature_id"],
+ fanout=DependentEndpointConfig(
+ parent_name="features",
+ resolve_param="feature_id",
+ resolve_field="id",
+ include_from_parent=["id"],
+ parent_field_renames={"id": "feature_id"},
+ ),
+ ),
}
ENDPOINTS = tuple(AHA_ENDPOINTS.keys())
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aha/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aha/source.py
index ae2003b11512..6e8fb1f49a4a 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/aha/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aha/source.py
@@ -146,4 +146,5 @@ Create an API key under **Settings → Personal → Developer → API keys** in
db_incremental_field_last_value=inputs.db_incremental_field_last_value
if inputs.should_use_incremental_field
else None,
+ incremental_field=inputs.incremental_field,
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aha/tests/test_aha.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aha/tests/test_aha.py
index 569232fb4ecf..386642e6b712 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/aha/tests/test_aha.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aha/tests/test_aha.py
@@ -1,6 +1,6 @@
import json
from datetime import UTC, date, datetime
-from typing import Any
+from typing import Any, cast
import pytest
from unittest import mock
@@ -12,6 +12,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.aha.aha im
AhaResumeConfig,
_build_initial_params,
_format_updated_since,
+ _incremental_window,
aha_source,
normalize_subdomain,
validate_credentials,
@@ -19,6 +20,13 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.aha.aha im
from products.warehouse_sources.backend.temporal.data_imports.sources.aha.settings import AHA_ENDPOINTS, PER_PAGE
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.auth import BearerTokenAuth
+FANOUT_REST_RESOURCES_PATCH = (
+ "products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout.rest_api_resources"
+)
+BUILD_DEPENDENT_RESOURCE_PATCH = (
+ "products.warehouse_sources.backend.temporal.data_imports.sources.aha.aha.build_dependent_resource"
+)
+
# RESTClient builds its session via make_tracked_session in the rest_client module.
CLIENT_SESSION_PATCH = "products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.rest_client.make_tracked_session"
# validate_credentials builds its own tracked session in the aha module.
@@ -289,6 +297,66 @@ class TestAhaSource:
assert session.send.call_count == 2
+class TestIncrementalWindow:
+ def test_binds_cursor_field_to_updated_since(self) -> None:
+ window = _incremental_window("updated_at")
+ assert window["cursor_path"] == "updated_at"
+ assert window["start_param"] == "updated_since"
+ convert = window["convert"]
+ assert convert is not None
+ # The convert hook must emit the trailing-Z UTC form Aha! accepts, not an isoformat offset.
+ assert convert(datetime(2026, 3, 4, 2, 58, 14, tzinfo=UTC)) == "2026-03-04T02:58:14Z"
+
+
+class _FakeDltResource:
+ """Stand-in for a DltResource returned by ``rest_api_resources``."""
+
+ def __init__(self, name: str, rows: list[dict[str, Any]]) -> None:
+ self.name = name
+ self._rows = rows
+
+ def add_map(self, mapper: Any) -> "_FakeDltResource":
+ self._rows = [mapper(dict(row)) for row in self._rows]
+ return self
+
+ def __iter__(self) -> Any:
+ return iter(self._rows)
+
+
+class TestAhaFanout:
+ @mock.patch(FANOUT_REST_RESOURCES_PATCH)
+ def test_releases_injects_product_id_from_parent(self, mock_rest_api_resources) -> None:
+ mock_rest_api_resources.return_value = [
+ _FakeDltResource("products", [{"id": "1000"}]),
+ _FakeDltResource("releases", [{"id": "R1", "_products_id": "1000"}]),
+ ]
+
+ resp = _source("releases", _make_manager())
+
+ rows = list(cast(Any, resp.items()))
+ assert rows == [{"id": "R1", "product_id": "1000"}]
+
+ @mock.patch(BUILD_DEPENDENT_RESOURCE_PATCH)
+ def test_requirements_fanout_selects_root_keys_and_incremental_param(self, mock_build) -> None:
+ mock_build.return_value = iter([])
+
+ _source(
+ "requirements",
+ _make_manager(),
+ should_use_incremental_field=True,
+ db_incremental_field_last_value=datetime(2026, 3, 4, 2, 58, 14, tzinfo=UTC),
+ incremental_field="updated_at",
+ )
+
+ _, kwargs = mock_build.call_args
+ # Aha! wraps list bodies in a root key; parent and child must select their own arrays.
+ assert kwargs["parent_endpoint_extra"] == {"data_selector": "features"}
+ assert kwargs["child_endpoint_extra"] == {"data_selector": "requirements"}
+ assert kwargs["page_size_param"] == "per_page"
+ assert kwargs["path_format_values"] == {}
+ assert kwargs["incremental_config_factory"] is _incremental_window
+
+
class TestValidateCredentials:
@mock.patch(AHA_SESSION_PATCH)
def test_ok(self, mock_session) -> None:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aha/tests/test_aha_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aha/tests/test_aha_source.py
index 24c06605eec3..6e7d7a840b50 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/aha/tests/test_aha_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aha/tests/test_aha_source.py
@@ -6,7 +6,17 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.aha.source
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.aha import AhaSourceConfig
# Endpoints whose Aha! list action exposes the server-side `updated_since` filter.
-_INCREMENTAL_ENDPOINTS = {"products", "features", "epics", "initiatives", "ideas", "todos"}
+_INCREMENTAL_ENDPOINTS = {
+ "products",
+ "features",
+ "epics",
+ "initiatives",
+ "ideas",
+ "todos",
+ "idea_votes",
+ "releases",
+ "requirements",
+}
_FULL_REFRESH_ENDPOINTS = {"goals", "users"}