: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.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(warehouse-sources): add aha ideas products, users and workflow tables (#116119)
Tom Owers278ae3107023
diff --git a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt b/posthog/test/repo_invariants/dataclass_frozen_baseline.txtindex be55b6fc78e9..17d63327349f 100644--- a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt+++ b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt@@ -226,7 +226,6 @@1 products/warehouse_sources/backend/temporal/data_imports/sources/aha/aha.py1 products/warehouse_sources/backend/temporal/data_imports/sources/aha/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/aha_ideas.py-1 products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/airbrake/airbrake.py1 products/warehouse_sources/backend/temporal/data_imports/sources/airbrake/settings.py1 products/warehouse_sources/backend/temporal/data_imports/sources/aircall/aircall.pydiff --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.mdindex 729129fb2f4f..3ee21aa7049d 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@@ -272,10 +272,10 @@ Today (7): `idea_comments`, `idea_endorsements`, `idea_organizations`, `idea_porDiffed against: <https://www.aha.io/openapi.json>-- [ ] `Products (GET /api/v1/products)` — resolves product IDs on ideas for reports by workspace (high)-- [ ] `Workflows (GET /api/v1/products/{product_id}/workflows)` — provides status names, order, and completion categories for idea workflows (high)-- [ ] `Users (GET /api/v1/users)` — provides staff identities for idea assignment and ownership reports (high)-- [ ] `Workflow status times (GET /api/v1/ideas/{idea_id}/workflow_status_times)` — measures time spent in each status and delays in idea delivery (high)+- [x] `Products (GET /api/v1/products)` — resolves product IDs on ideas for reports by workspace (high)+- [x] `Workflows (GET /api/v1/products/{product_id}/workflows)` — provides status names, order, and completion categories for idea workflows (high)+- [x] `Users (GET /api/v1/users)` — provides staff identities for idea assignment and ownership reports (high)+- [x] `Workflow status times (GET /api/v1/ideas/{idea_id}/workflow_status_times)` — measures time spent in each status and delays in idea delivery (high)- [ ] `Idea categories (GET /api/v1/products/{product_id}/idea_categories)` — provides the category hierarchy for grouping customer demand (medium)- [ ] `Ideas portal users (GET /api/v1/portal_users)` — links portal membership to idea users and portal engagement (medium)- [ ] `Idea subscriptions (GET /api/v1/ideas/{idea_id}/subscriptions)` — identifies followers of each idea for customer interest reports (medium)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/aha_ideas.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/aha_ideas.pyindex ed829d8a76c9..bfabc90e929c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/aha_ideas.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/aha_ideas.py@@ -24,7 +24,10 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.resfrom 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+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import (+ ClientConfig,+ Endpoint,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManagerfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.source_helpers import validate_via_probefrom products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse@@ -81,7 +84,7 @@ def _build_initial_params(should_use_incremental_field: bool,db_incremental_field_last_value: Any,) -> dict[str, Any]:- params: dict[str, Any] = {"per_page": config.page_size}+ params: dict[str, Any] = {"per_page": config.page_size, **config.params}# Only Aha!'s `updated_since`-capable endpoints filter server-side; everything else is full refresh.if config.supports_incremental and should_use_incremental_field and db_incremental_field_last_value:params["updated_since"] = _format_updated_since(db_incremental_field_last_value)@@ -113,6 +116,17 @@ class AhaIdeasPageNumberPaginator(PageNumberPaginator):self._has_next_page = False+def _explode_idea_nested_rows(record: dict[str, Any], nested_field: str) -> list[dict[str, Any]]:+ nested = record.get(nested_field)+ if not isinstance(nested, list):+ return []+ return [+ {**row, "idea_id": record.get("id"), "idea_updated_at": record.get("updated_at")}+ for row in nested+ if isinstance(row, dict)+ ]++def _client_config(subdomain: str, api_key: str, page_size: int) -> ClientConfig:return {"base_url": _base_url(subdomain),@@ -173,6 +187,9 @@ def _non_fanout_source(resume_hook=save_checkpoint,initial_paginator_state=initial_paginator_state,)+ nested_field = config.nested_rows_field+ if nested_field is not None:+ resource.add_map(lambda record: _explode_idea_nested_rows(record, nested_field))return SourceResponse(name=endpoint,@@ -197,6 +214,10 @@ def _fanout_source(config = AHA_IDEAS_ENDPOINTS[endpoint]assert config.fanout is not None+ child_endpoint_extra: Endpoint = {"data_selector": config.response_key}+ if not config.paginated:+ child_endpoint_extra["paginator"] = "single_page"+dependent_resource = cast(Iterable[Any],build_dependent_resource(@@ -213,7 +234,7 @@ def _fanout_source(should_use_incremental_field=False,page_size_param="per_page",parent_endpoint_extra={"data_selector": AHA_IDEAS_ENDPOINTS[config.fanout.parent_name].response_key},- child_endpoint_extra={"data_selector": config.response_key},+ child_endpoint_extra=child_endpoint_extra,),)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/canonical_descriptions.pyindex 9832605c04e1..f7dce4bab799 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/canonical_descriptions.py@@ -96,4 +96,55 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"idea_commenter_user": "The user who wrote the comment.",},},+ "products": {+ "description": "A workspace (product) in your Aha! account. Ideas belong to a workspace through `product_id`.",+ "docs_url": "https://www.aha.io/api/resources/products/list_products_in_the_account",+ "columns": {+ "id": "Unique identifier for the workspace.",+ "reference_prefix": "Prefix used in the reference numbers of the workspace's records.",+ "name": "The workspace's name.",+ "product_line": "Whether this record is a workspace line that groups other workspaces.",+ "workspace_type": "The kind of workspace (e.g. product_workspace).",+ "created_at": "Time at which the workspace was created.",+ "url": "URL of the workspace in the Aha! web app.",+ },+ },+ "users": {+ "description": "A member of your Aha! account, such as an idea assignee or creator.",+ "docs_url": "https://www.aha.io/api/resources/users/list_users",+ "columns": {+ "id": "Unique identifier for the user.",+ "name": "The user's full name.",+ "email": "The user's email address.",+ "created_at": "Time at which the user was created.",+ "updated_at": "Time at which the user was last updated.",+ "accessed_at": "Time at which the user last accessed Aha!.",+ "enabled": "Whether the user can sign in to the account.",+ "product_roles": "The user's role in each workspace.",+ },+ },+ "workflows": {+ "description": "A workflow used by a workspace, with its ordered statuses. Decodes the workflow statuses on ideas.",+ "docs_url": "https://www.aha.io/api/resources/workflows/list_workflows",+ "columns": {+ "id": "Unique identifier for the workflow.",+ "product_id": "Identifier of the workspace this workflow was listed for.",+ "name": "The workflow's name.",+ "statusable_type": "The record type that uses this workflow (e.g. Idea, Feature).",+ "transitions_only": "Whether records can only move between statuses through defined transitions.",+ "workflow_statuses": "The workflow's statuses, with name, position, completion flag and status category.",+ },+ },+ "workflow_status_times": {+ "description": "A period an idea spent in one workflow status. Use it to measure time in status.",+ "docs_url": "https://www.aha.io/api/resources/workflow_status_times/list_workflow_status_times_for_an_idea",+ "columns": {+ "idea_id": "Identifier of the idea.",+ "idea_updated_at": "Time at which the idea was last updated.",+ "status_id": "Identifier of the workflow status.",+ "status_name": "Name of the workflow status.",+ "started_at": "Time at which the idea entered the status.",+ "ended_at": "Time at which the idea left the status. Empty while the idea is still in it.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/settings.pyindex 002820af1a37..8ff76502693c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/settings.py@@ -1,5 +1,5 @@from dataclasses import dataclass, field-from typing import Optional+from typing import Any, Optionalfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (DependentEndpointConfig,@@ -10,21 +10,21 @@ from products.warehouse_sources.backend.types import IncrementalField, IncrementPER_PAGE = 200-def _updated_at_incremental_fields() -> list[IncrementalField]:+def _updated_at_incremental_fields(column: str = "updated_at") -> list[IncrementalField]:# Every incremental-capable Aha! Ideas endpoint filters server-side with `updated_since`,# which keys off `updated_at`. Advertising just `updated_at` keeps the user's chosen cursor# aligned with what the API actually filters on.return [{- "label": "updated_at",+ "label": column,"type": IncrementalFieldType.DateTime,- "field": "updated_at",+ "field": column,"field_type": IncrementalFieldType.DateTime,},]-@dataclass+@dataclass(frozen=True)class AhaIdeasEndpointConfig:name: strpath: str # Path under /api/v1, e.g. "/ideas"@@ -40,6 +40,11 @@ class AhaIdeasEndpointConfig:primary_keys: list[str] = field(default_factory=lambda: ["id"])should_sync_default: bool = Truepage_size: int = PER_PAGE+ # False for list actions that document no `page`/`per_page` and return everything in one response.+ paginated: bool = True+ params: dict[str, Any] = field(default_factory=dict)+ # Emit one row per element of this array field on each listed record instead of the record itself.+ nested_rows_field: str | None = Nonefanout: DependentEndpointConfig | None = None@@ -107,6 +112,54 @@ AHA_IDEAS_ENDPOINTS: dict[str, AhaIdeasEndpointConfig] = {include_from_parent=[],),),+ "products": AhaIdeasEndpointConfig(+ name="products",+ path="/products",+ response_key="products",+ # "List products" documents only `page`/`per_page`/`include_teams`/`with_idea_portals`.+ supports_incremental=False,+ ),+ "users": AhaIdeasEndpointConfig(+ name="users",+ path="/users",+ response_key="users",+ # "List users" documents only `page`/`per_page`.+ supports_incremental=False,+ ),+ "workflows": AhaIdeasEndpointConfig(+ name="workflows",+ path="/products/{product_id}/workflows",+ response_key="workflows",+ supports_incremental=False,+ paginated=False,+ partition_key=None,+ # Workflows are account-level and shared between workspaces, so one workflow id is listed+ # under every product that uses it.+ 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"},+ ),+ ),+ # The per-idea `/ideas/{idea_id}/workflow_status_times` action needs Aha! support to enable it+ # on the account and costs one request per idea. Aha! documents `fields=workflow_status_times`+ # on the list action as the way to read status history, which also keeps `updated_since`.+ "workflow_status_times": AhaIdeasEndpointConfig(+ name="workflow_status_times",+ path="/ideas",+ response_key="ideas",+ supports_incremental=True,+ incremental_fields=_updated_at_incremental_fields("idea_updated_at"),+ params={"fields": "id,updated_at,workflow_status_times"},+ nested_rows_field="workflow_status_times",+ # Embedded status times carry no id. An idea can re-enter a status, so `started_at` is+ # part of the key.+ primary_keys=["idea_id", "status_id", "started_at"],+ partition_key="started_at",+ ),}ENDPOINTS = tuple(AHA_IDEAS_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/tests/test_aha_ideas.py b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/tests/test_aha_ideas.pyindex e987b333fc7d..630f9b0ef179 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/tests/test_aha_ideas.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/aha_ideas/tests/test_aha_ideas.py@@ -162,6 +162,59 @@ class TestAhaIdeasSourceFanout:assert result.response.partition_keys == ["created_at"]+class TestAhaIdeasWorkflowStatusTimes:+ def test_explodes_status_times_per_idea(self) -> None:+ result = _driver().run(+ "workflow_status_times",+ [+ _response(+ "ideas",+ [+ {+ "id": "idea_1",+ "updated_at": "2026-03-04T00:00:00Z",+ "workflow_status_times": [+ {"status_id": "s1", "status_name": "New", "started_at": "2026-01-01T00:00:00Z"},+ {"status_id": "s2", "status_name": "Shipped", "started_at": "2026-02-01T00:00:00Z"},+ ],+ },+ {"id": "idea_2", "updated_at": "2026-03-05T00:00:00Z", "workflow_status_times": None},+ {"id": "idea_3", "updated_at": "2026-03-06T00:00:00Z"},+ ],+ total_pages=1,+ )+ ],+ should_use_incremental_field=True,+ db_incremental_field_last_value=datetime(2026, 3, 1, tzinfo=UTC),+ )++ assert result.raised is None+ assert [(row["idea_id"], row["status_id"], row["idea_updated_at"]) for row in result.rows] == [+ ("idea_1", "s1", "2026-03-04T00:00:00Z"),+ ("idea_1", "s2", "2026-03-04T00:00:00Z"),+ ]+ assert result.paths == ["/api/v1/ideas"]+ assert result.params("fields") == ["id,updated_at,workflow_status_times"]+ assert result.params("updated_since") == ["2026-03-01T00:00:00Z"]+++class TestAhaIdeasWorkflows:+ def test_workflows_fan_out_over_products_without_paging(self) -> None:+ result = _driver().run(+ "workflows",+ [+ _response("products", [{"id": "p1"}, {"id": "p2"}], total_pages=1),+ _response("workflows", [{"id": 10, "name": "Idea workflow"}]),+ _response("workflows", [{"id": 10, "name": "Idea workflow"}]),+ ],+ )++ assert result.raised is None+ assert [(row["id"], row["product_id"]) for row in result.rows] == [(10, "p1"), (10, "p2")]+ assert result.paths == ["/api/v1/products", "/api/v1/products/p1/workflows", "/api/v1/products/p2/workflows"]+ assert result.params("page") == ["1", None, None]++class TestValidateCredentials:def test_ok(self) -> None:with scripted_network([ScriptedResponse(status=200)]) as network: