: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): Decagon tags dimension table (#80185)
jake sciotto6c93781d7447
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/canonical_descriptions.pyindex 80da44caeb4b..e2801c62c762 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/canonical_descriptions.py@@ -66,4 +66,31 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {),"docs_url": "https://docs.decagon.ai/api-reference/getting-started",},+ "tags": {+ "description": (+ "A tag in Decagon's taxonomy, one row per tag across all hierarchies. Resolves the "+ "tag ids embedded in conversation rows to names, parents, and hierarchy positions."+ ),+ "docs_url": "https://docs.decagon.ai/api-reference/getting-started",+ "columns": {+ "id": "Unique identifier for the tag.",+ "parent_id": "Identifier of the parent tag. Null for root tags.",+ "name": "Name of the tag.",+ "depth": "Depth of the tag within its hierarchy.",+ "is_frozen": "Whether the tag is frozen against edits.",+ "is_outcome": "Whether the tag represents a conversation outcome.",+ "external_key": "External key assigned to the tag, if any.",+ "tag_hierarchy_id": "Identifier of the hierarchy the tag belongs to.",+ "description": "Description of the tag.",+ "config": "Configuration attached to the tag.",+ "human_count": (+ "Number of conversations tagged by a human, as of the most recent sync. A "+ "point-in-time aggregate, not a historical series."+ ),+ "total_count": (+ "Total number of tagged conversations, as of the most recent sync. A "+ "point-in-time aggregate, not a historical series."+ ),+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/settings.pyindex 69fb86e17af2..e683bde4f2b5 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/settings.py@@ -179,6 +179,20 @@ DECAGON_ENDPOINTS: dict[str, DecagonEndpointConfig] = {pagination="single",extra_params={"timezone": "UTC"},),+ # /tag/all returns the whole tag taxonomy in one unpaginated response: the dimension+ # table that resolves the tag ids embedded in conversation rows to names, parents,+ # and hierarchy positions. get_counts populates human_count/total_count, point-in-time+ # aggregates that change on every sync. Tags carry no timestamp, so the table is+ # unpartitioned and full refresh only.+ "tags": DecagonEndpointConfig(+ name="tags",+ path="/tag/all",+ data_key="tags",+ primary_keys=["id"],+ incremental_fields=[],+ pagination="single",+ extra_params={"get_counts": "true"},+ ),}ENDPOINTS = tuple(DECAGON_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/tests/test_decagon.py b/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/tests/test_decagon.pyindex f726a5f4fb68..292689d7aa6f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/tests/test_decagon.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/tests/test_decagon.py@@ -584,6 +584,32 @@ class TestArticleTables:assert response.partition_keys is None+class TestTags:+ def test_tags_is_a_single_request_with_counts(self) -> None:+ # get_counts populates human_count/total_count; dropping the param silently+ # empties both columns.+ manager = _fresh_manager()+ responses = [_make_response({"tags": [{"id": 1, "parent_id": None}, {"id": 2, "parent_id": 1}]})]+ sent_params, batches = _drive_rows(manager, responses, endpoint="tags")++ assert sent_params == [{"get_counts": "true"}]+ assert [[t["id"] for t in b] for b in batches] == [[1, 2]]+ manager.save_state.assert_not_called()++ def test_tags_response_is_unpartitioned_with_id_key(self) -> None:+ # Tags carry no timestamp; wiring the datetime partitioning every other stream+ # uses would fail the sync on a missing column.+ response = decagon_source(+ api_key="key",+ endpoint="tags",+ logger=MagicMock(),+ resumable_source_manager=MagicMock(spec=ResumableSourceManager),+ )+ assert response.primary_keys == ["id"]+ assert response.partition_mode is None+ assert response.partition_keys is None++class TestToEpochSeconds:# The pipeline hands the DateTime watermark back as a datetime, a date, or an epoch# number depending on how it round-tripped through storage; the request boundary mustdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/tests/test_decagon_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/tests/test_decagon_source.pyindex 31e9cd24b4ba..e1f232f12a89 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/tests/test_decagon_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/decagon/tests/test_decagon_source.py@@ -80,6 +80,11 @@ class TestDecagonSource:assert usage.supports_incremental is Falseassert usage.supports_append is False+ tags = next(s for s in schemas if s.name == "tags")+ # /tag/all has no server-side timestamp filter, so only full refresh is honest.+ assert tags.supports_incremental is False+ assert tags.supports_append is False+def test_get_schemas_filtered_by_names(self) -> None:assert [s.name for s in self.source.get_schemas(self.config, self.team_id, names=["conversations"])] == ["conversations"