: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(eppo): sync the entity, fact and dimension definition tables (#107274)
Tom Owersf8c090f40ad4
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.mdindex dfbfc725a1a5..5f924fa030ba 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@@ -2878,14 +2878,14 @@ Note: env0 is now branded 'env zero'; docs.env0.com and docs.envzero.com serve t## Eppo — gaps-Today (10): `Audiences`, `Bandits`, `Environments`, `Experiments`, `FeatureFlags`, `Holdouts`, `MetricCollections`, `Metrics`, `Tags`, `Teams`+Today (13): `Audiences`, `Bandits`, `DimensionDefinitions`, `EntityDefinitions`, `Environments`, `Experiments`, `FactDefinitions`, `FeatureFlags`, `Holdouts`, `MetricCollections`, `Metrics`, `Tags`, `Teams`Diffed against: <https://eppo.cloud/api/docs-json>-- [ ] `/api/v1/definitions/facts` — fact (metric source) definitions — the lookup that explains what each synced metric is computed from (high)-- [ ] `/api/v1/definitions/entities` — entity lookup resolving the entity ids carried on metrics, experiments and assignments (high)-- [ ] `/api/v1/definitions/dimensions` — dimension definitions, the breakdown axes available on experiment analyses (high)-- [ ] `/api/v1/experiments/{experiment_id}/property-analysis` — experiment results broken down by metric and property — the actual analysis output, currently unavailable (high)+- [x] `/api/v1/definitions/facts` — fact (metric source) definitions — the lookup that explains what each synced metric is computed from (high)+- [x] `/api/v1/definitions/entities` — entity lookup resolving the entity ids carried on metrics, experiments and assignments (high)+- [x] `/api/v1/definitions/dimensions` — dimension definitions, the breakdown axes available on experiment analyses (high)+- [ ] `/api/v1/experiments/{experiment_id}/property-analysis` — experiment results broken down by metric and property — the actual analysis output, currently unavailable (high) — not syncable: `property_id`, `property_type` and `metric_id` are all required, with no way to enumerate the valid combinations per experiment, so a table would need a speculative experiments x metrics x properties cross product- [ ] `/api/v1/definitions/assignments` — assignment source definitions that tie experiments to their exposure data (medium)- [ ] `/api/v1/experiments/{id}/diagnostics` — experiment health checks (sample ratio mismatch, traffic issues) per experiment (medium)- [ ] `/api/v1/schedules` — experiment schedules, needed to reason about analysis cadence and experiment timelines (medium)@@ -2895,7 +2895,7 @@ Diffed against: <https://eppo.cloud/api/docs-json>- [ ] `/api/v1/definitions (combined definitions listing)` — single call returning all definition objects, a cheaper alternative to syncing each definitions sub-resource (low)- [ ] `/api/v1/protocols` — experiment protocol templates referenced by experiments (low)-Note: eppo.cloud/api/docs is a Swagger UI shell; the machine-readable spec is at /api/docs-json (also /api/docs-yaml). The entire /api/v1/definitions/\* family (facts, entities, dimensions, assignments, entry-points) is missing and is where most lookup value sits.+Note: eppo.cloud/api/docs is a Swagger UI shell; the machine-readable spec is at /api/docs-json (also /api/docs-yaml). The /api/v1/definitions/\* family is where most lookup value sits; facts, entities and dimensions are now synced, leaving assignments and entry-points.## Eventbrite — gapsdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/canonical_descriptions.pyindex 2b5dee9c83f0..07711cd5792e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/canonical_descriptions.py@@ -174,4 +174,46 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"created_at": "Time at which the environment was created.",},},+ "EntityDefinitions": {+ "description": "An entity definition: a unit of analysis (e.g. user, company) that metrics, experiments and assignments are attributed to.",+ "docs_url": _API_DOCS,+ "columns": {+ "id": "Unique identifier for the entity, as referenced by entity_id on metrics and experiments.",+ "name": "Human-readable name of the entity.",+ "creator_email": "Email of the user who created the entity source.",+ "last_updated_by_email": "Email of the user who last updated the entity source.",+ },+ },+ "FactDefinitions": {+ "description": "A fact source (metric source): the SQL-backed event table that metrics are computed from.",+ "docs_url": _API_DOCS,+ "columns": {+ "id": "Unique identifier for the fact source.",+ "name": "Human-readable name for this metric source.",+ "sql": "SQL associated with this definition.",+ "timestamp_column": "Name of the column used as the event timestamp.",+ "entity_ids": "Deprecated by Eppo in favour of the entities field.",+ "entities": "Entities associated with this source, each with the column used to join to that entity.",+ "measures": "Measures defined on this source, which metrics aggregate over.",+ "dimensions": "Dimensions configured on this metric event, available as breakdowns in analyses.",+ "force_full_refresh": "Whether metrics derived from this source always fully refresh instead of updating incrementally. Used for tables whose rows keep changing after insert, such as refunds.",+ "full_refresh_metrics_on_change": "Deprecated by Eppo in favour of force_full_refresh.",+ "certified": "Whether this fact source is certified, meaning it has been formally approved and validated.",+ "creator_email": "Email of the user who created the metric source.",+ "last_updated_by_email": "Email of the user who last updated the metric source.",+ },+ },+ "DimensionDefinitions": {+ "description": "A dimension source: a SQL-backed attribute table supplying the breakdown axes available on experiment analyses.",+ "docs_url": _API_DOCS,+ "columns": {+ "id": "Unique identifier for the dimension source.",+ "name": "Human-readable name for this dimension source.",+ "column": "Dimension source column the breakdown values are read from.",+ "sql": "SQL associated with this definition.",+ "entity_ids": "Identifiers of the entities this source supplies dimensions for.",+ "creator_email": "Email of the user who created the dimension source.",+ "last_updated_by_email": "Email of the user who last updated the dimension source.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/eppo.py b/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/eppo.pyindex 3a70fe8253f4..26c187a087e7 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/eppo.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/eppo.py@@ -35,6 +35,9 @@ _ENDPOINT_PATHS: dict[str, str] = {"Tags": "/tags","Audiences": "/audiences","Environments": "/environments",+ "EntityDefinitions": "/definitions/entities",+ "FactDefinitions": "/definitions/facts",+ "DimensionDefinitions": "/definitions/dimensions",}_ENDPOINT_STATIC_PARAMS: dict[str, dict[str, Any]] = {diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/settings.pyindex d1a33fea0d56..0edbac8cb8cc 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/settings.py@@ -15,6 +15,9 @@ ENDPOINTS = ("Tags","Audiences","Environments",+ "EntityDefinitions",+ "FactDefinitions",+ "DimensionDefinitions",)# Endpoints that document `offset`/`limit` query params (https://eppo.cloud/api/docs).@@ -62,10 +65,14 @@ PRIMARY_KEYS: dict[str, list[str]] = {"Tags": ["id"],"Audiences": ["id"],"Environments": ["id"],+ "EntityDefinitions": ["id"],+ "FactDefinitions": ["id"],+ "DimensionDefinitions": ["id"],}# A stable creation-time field to partition on, where the endpoint has one. `None` disables-# partitioning for endpoints with no such field (MetricCollections, Teams).+# partitioning for endpoints with no such field (MetricCollections, Teams, and the+# /definitions/* resources, none of which return a timestamp).PARTITION_KEYS: dict[str, str | None] = {"Experiments": "created_date","Metrics": "created_date",@@ -77,4 +84,7 @@ PARTITION_KEYS: dict[str, str | None] = {"Tags": "created_at","Audiences": "created_at","Environments": "created_at",+ "EntityDefinitions": None,+ "FactDefinitions": None,+ "DimensionDefinitions": None,}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/tests/test_eppo.py b/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/tests/test_eppo.pyindex ca55961c7caf..409966b7d85c 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/tests/test_eppo.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/tests/test_eppo.py@@ -168,19 +168,30 @@ class TestEppoSourcePagination:assert rows == []assert session.send.call_count == 1+ @parameterized.expand(+ [+ ("Tags", f"{BASE_URL}/tags"),+ ("EntityDefinitions", f"{BASE_URL}/definitions/entities"),+ ("FactDefinitions", f"{BASE_URL}/definitions/facts"),+ ("DimensionDefinitions", f"{BASE_URL}/definitions/dimensions"),+ ]+ )@mock.patch(CLIENT_SESSION_PATCH)- def test_unpaginated_endpoint_fetches_single_page_with_no_offset_params(self, MockSession) -> None:+ def test_unpaginated_endpoint_fetches_single_page_with_no_offset_params(+ self, endpoint: str, expected_url: str, MockSession+ ) -> None:session = MockSession.return_value- # A full-limit-sized page would normally imply another page exists, but Tags has no- # documented offset/limit — it must not be treated as paginated.+ # A full-limit-sized page would normally imply another page exists, but none of these+ # endpoints document offset/limit — they must not be treated as paginated. Eppo ignores+ # the params, so an offset paginator would re-fetch the same full page forever.snapshots = _wire(session, [_response([{"id": i} for i in range(PAGE_LIMIT)])])- rows = _rows(_source("Tags"))+ rows = _rows(_source(endpoint))assert len(rows) == PAGE_LIMITassert session.send.call_count == 1- assert "limit" not in snapshots[0]["params"]- assert "offset" not in snapshots[0]["params"]+ assert snapshots[0]["url"] == expected_url+ assert snapshots[0]["params"] == {}@mock.patch(CLIENT_SESSION_PATCH)def test_auth_is_framework_api_key(self, MockSession) -> None:@@ -247,6 +258,9 @@ class TestEppoSourcePagination:("Tags", ["id"]),("Audiences", ["id"]),("Environments", ["id"]),+ ("EntityDefinitions", ["id"]),+ ("FactDefinitions", ["id"]),+ ("DimensionDefinitions", ["id"]),])@mock.patch(CLIENT_SESSION_PATCH)@@ -270,6 +284,9 @@ class TestEppoSourcePagination:("Tags", "created_at"),("Audiences", "created_at"),("Environments", "created_at"),+ ("EntityDefinitions", None),+ ("FactDefinitions", None),+ ("DimensionDefinitions", None),])@mock.patch(CLIENT_SESSION_PATCH)