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(data-warehouse): add Eppo source (#73210)

Tom Owers82489cc99b86
diff --git a/frontend/public/services/eppo.png b/frontend/public/services/eppo.png
index ba563ea17a58..0778f7d1aebf 100644
Binary files a/frontend/public/services/eppo.png and b/frontend/public/services/eppo.png differ
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md
index 5bb771a74a55..32cfdc114b41 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md
@@ -197,6 +197,7 @@ the row lists both.
| easypost | HTTP | requests | ✅ |
| easypromos | HTTP | requests | ✅ |
| elevenlabs | HTTP | requests | ✅ |
+| eppo | HTTP | requests + `rest_source.RESTClient` | ✅ |
| freshcaller | HTTP | requests | ✅ |
| freshchat | HTTP | requests | ✅ |
| freshdesk | HTTP | requests | ✅ |
@@ -893,7 +894,6 @@ doesn't conflict with concurrent PRs.
- employment_hero
- encharge
- entsoe
-- eppo
- etsy
- eurostat
- expensify
diff --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.py
new file mode 100644
index 000000000000..2b5dee9c83f0
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/canonical_descriptions.py
@@ -0,0 +1,177 @@
+"""Canonical, documentation-sourced descriptions for Eppo endpoints and columns.
+
+Sourced from the official Eppo public API reference (https://eppo.cloud/api/docs). Keyed by the
+resource names in `settings.py` `ENDPOINTS`, which match the `ExternalDataSchema.name` of a synced
+Eppo table. Columns absent here fall back to LLM enrichment.
+"""
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
+ CanonicalDescriptions,
+)
+
+_API_DOCS = "https://eppo.cloud/api/docs"
+
+CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
+ "Experiments": {
+ "description": "An Eppo experiment or holdout: its configuration, variations, metrics, and status.",
+ "docs_url": _API_DOCS,
+ "columns": {
+ "id": "Unique identifier for the experiment.",
+ "status": "Current status of the experiment (e.g. running, stopped, not_started).",
+ "name": "Human-readable name of the experiment.",
+ "assignments_start_date": "Date from which assignments to this experiment began.",
+ "entity_id": "Identifier of the entity (unit of analysis) the experiment is run on.",
+ "hypothesis": "Hypothesis being tested by the experiment.",
+ "assignments_end_date": "Date after which no new assignments are made to this experiment.",
+ "events_start_date": "Start of the date range used to include events in analysis.",
+ "events_end_date": "End of the date range used to include events in analysis.",
+ "experiment_key": "Unique key used to reference the experiment in code (e.g. SDK assignment calls).",
+ "traffic_allocation": "Percentage of eligible traffic allocated to the experiment.",
+ "results_url": "URL to view the experiment's results in the Eppo UI.",
+ "progress_percent": "Percentage of the experiment's planned duration or sample size completed.",
+ "results_last_updated": "Time the experiment's analysis results were last recalculated.",
+ "winning_variant_key": "Key of the variation Eppo has determined to be winning, if any.",
+ "outcome": "Recorded outcome of the experiment once concluded.",
+ "decision_reason": "Reason recorded for the experiment's concluding decision.",
+ "team_id": "Identifier of the team that owns the experiment.",
+ "schedule_id": "Identifier of the schedule driving this experiment's automated runs, if any.",
+ "holdout_id": "Identifier of the holdout this experiment belongs to, if any.",
+ "is_holdout_analysis": "Whether this experiment represents a holdout analysis.",
+ "is_traffic_imbalanced": "Whether observed traffic across variations deviates materially from the configured split.",
+ "created_date": "Time at which the experiment was created.",
+ "concluded_date": "Time at which the experiment was concluded, if applicable.",
+ "deleted_date": "Time at which the experiment was deleted, if applicable.",
+ "key_takeaways": "Free-text summary of the experiment's key takeaways.",
+ },
+ },
+ "Metrics": {
+ "description": "A metric definition used to analyze experiments (e.g. conversion rate, revenue per user).",
+ "docs_url": _API_DOCS,
+ "columns": {
+ "id": "Unique identifier for the metric.",
+ "name": "Human-readable name of the metric.",
+ "type": "Type of the metric (e.g. simple, ratio, funnel).",
+ "description": "Description of what the metric measures.",
+ "minimum_detectable_effect": "Minimum effect size the metric is configured to reliably detect.",
+ "entity_id": "Identifier of the entity (unit of analysis) the metric is computed over.",
+ "guardrail_cutoff": "Threshold beyond which the metric is flagged as a guardrail concern.",
+ "display_style": "How the metric's value is formatted for display (e.g. percentage, currency).",
+ "certified": "Whether the metric has been marked as certified/trusted by the team.",
+ "created_date": "Time at which the metric was created.",
+ "updated_date": "Time at which the metric was last updated.",
+ "creator_email": "Email of the user who created the metric.",
+ "last_updated_by_email": "Email of the user who last updated the metric.",
+ "desired_change": "Direction of change considered desirable for this metric (increase or decrease).",
+ "team_id": "Identifier of the team that owns the metric.",
+ },
+ },
+ "MetricCollections": {
+ "description": "A named grouping of metrics (e.g. a guardrail metric set) reusable across experiments.",
+ "docs_url": _API_DOCS,
+ "columns": {
+ "id": "Unique identifier for the metric collection.",
+ "name": "Human-readable name of the metric collection.",
+ "description": "Description of the metric collection's purpose.",
+ "is_guardrail": "Whether this collection is used as a guardrail metric set.",
+ "entity_id": "Identifier of the entity (unit of analysis) the collection applies to.",
+ "creator_email": "Email of the user who created the collection.",
+ "last_updated_by_email": "Email of the user who last updated the collection.",
+ },
+ },
+ "FeatureFlags": {
+ "description": "A feature flag, its variations, allocations, and per-environment configuration.",
+ "docs_url": _API_DOCS,
+ "columns": {
+ "id": "Unique identifier for the feature flag.",
+ "name": "Human-readable name of the feature flag.",
+ "description": "Description of the feature flag's purpose.",
+ "key": "Unique key used to reference the flag in code (SDK evaluation calls).",
+ "is_archived": "Whether the feature flag has been archived.",
+ "updated_at": "Time at which the feature flag was last updated.",
+ "created_at": "Time at which the feature flag was created.",
+ "entity_id": "Identifier of the entity (unit of analysis) the feature flag targets.",
+ },
+ },
+ "Bandits": {
+ "description": "A contextual multi-armed bandit that dynamically allocates traffic across variations.",
+ "docs_url": _API_DOCS,
+ "columns": {
+ "id": "Unique identifier for the bandit.",
+ "name": "Human-readable name of the bandit.",
+ "key": "Unique key used to reference the bandit in code (SDK evaluation calls).",
+ "updated_at": "Time at which the bandit was last updated.",
+ "created_at": "Time at which the bandit was created.",
+ "model_version": "Version identifier of the bandit's underlying model.",
+ "training_frequency_hours": "How often, in hours, the bandit's model is retrained.",
+ "response_window_minutes": "Window, in minutes, within which a reward is attributed to an assignment.",
+ "lookback_window_days": "Number of days of historical data used to train the bandit's model.",
+ "exploitation_temperature": "Parameter controlling the bandit's exploration-versus-exploitation tradeoff.",
+ },
+ },
+ "Holdouts": {
+ "description": "A holdout group excluded from one or more experiments for a period, to measure long-run impact.",
+ "docs_url": _API_DOCS,
+ "columns": {
+ "id": "Unique identifier for the holdout.",
+ "name": "Human-readable name of the holdout.",
+ "key": "Unique key used to reference the holdout.",
+ "assignments_start_date": "Date from which assignments to the holdout began.",
+ "assignments_end_date": "Date after which no new assignments are made to the holdout.",
+ "experiment_id": "Identifier of the experiment associated with this holdout, if any.",
+ "traffic_allocation": "Percentage of eligible traffic allocated to the holdout group.",
+ "archived_at": "Time at which the holdout was archived, if applicable.",
+ "updated_at": "Time at which the holdout was last updated.",
+ "created_at": "Time at which the holdout was created.",
+ },
+ },
+ "Teams": {
+ "description": "A team used to group ownership of experiments, metrics, and feature flags.",
+ "docs_url": _API_DOCS,
+ "columns": {
+ "id": "Unique identifier for the team.",
+ "name": "Human-readable name of the team.",
+ "archived_at": "Time at which the team was archived, if applicable.",
+ },
+ },
+ "Tags": {
+ "description": "A tag used to label and filter experiments and feature flags.",
+ "docs_url": _API_DOCS,
+ "columns": {
+ "id": "Unique identifier for the tag.",
+ "name": "Name of the tag.",
+ "description": "Description of the tag's purpose.",
+ "created_at": "Time at which the tag was created.",
+ "updated_at": "Time at which the tag was last updated.",
+ },
+ },
+ "Audiences": {
+ "description": "A saved audience definition (targeting rule set) reusable across feature flags and experiments.",
+ "docs_url": _API_DOCS,
+ "columns": {
+ "id": "Unique identifier for the audience.",
+ "name": "Human-readable name of the audience.",
+ "description": "Description of the audience's purpose.",
+ "team": "Identifier of the team the audience belongs to.",
+ "creator_email": "Email of the user who created the audience.",
+ "last_edited_by_email": "Email of the user who last edited the audience.",
+ "allocation_count": "Number of allocations currently using this audience.",
+ "updated_at": "Time at which the audience was last updated.",
+ "created_at": "Time at which the audience was created.",
+ "archived_at": "Time at which the audience was archived, if applicable.",
+ "is_archived": "Whether the audience has been archived.",
+ },
+ },
+ "Environments": {
+ "description": "A deployment environment (e.g. production, staging) feature flags can be configured per.",
+ "docs_url": _API_DOCS,
+ "columns": {
+ "id": "Unique identifier for the environment.",
+ "name": "Human-readable name of the environment.",
+ "is_production": "Whether this environment is marked as production.",
+ "sdk_key_count": "Number of SDK keys provisioned for this environment.",
+ "client_token_count": "Number of client tokens provisioned for this environment.",
+ "updated_at": "Time at which the environment was last updated.",
+ "created_at": "Time at which the environment was created.",
+ },
+ },
+}
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.py
new file mode 100644
index 000000000000..7e33b51408ae
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/eppo.py
@@ -0,0 +1,161 @@
+from datetime import UTC, date, datetime
+from typing import Any, Optional
+
+from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import SourceResponse
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source import (
+ RESTAPIConfig,
+ rest_api_resource,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import (
+ EndpointResource,
+ PaginatorConfig,
+)
+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.eppo.settings import (
+ INCREMENTAL_QUERY_PARAM,
+ PAGE_LIMIT,
+ PAGINATED_ENDPOINTS,
+ PARTITION_KEYS,
+ PRIMARY_KEYS,
+)
+
+BASE_URL = "https://eppo.cloud/api/v1"
+
+# Path + static (non-pagination) params per endpoint. Every response is a bare JSON array, so
+# no `data_selector` override is needed (the framework default `"$"` selects the array root).
+_ENDPOINT_PATHS: dict[str, str] = {
+ "Experiments": "/experiments",
+ "Metrics": "/metrics",
+ "MetricCollections": "/metrics/collections",
+ "FeatureFlags": "/feature-flags",
+ "Bandits": "/bandits",
+ "Holdouts": "/holdouts",
+ "Teams": "/teams",
+ "Tags": "/tags",
+ "Audiences": "/audiences",
+ "Environments": "/environments",
+}
+
+_ENDPOINT_STATIC_PARAMS: dict[str, dict[str, Any]] = {
+ # Archived flags/teams are excluded by default; pull the full history instead.
+ "FeatureFlags": {"include_archived": "true"},
+ "Teams": {"include_archived": "true"},
+ "Audiences": {"status": "all"},
+}
+
+
+def _format_since(value: Any) -> str:
+ """Format an incremental cursor as the ISO 8601 UTC string Eppo's `_since` filters expect."""
+ if isinstance(value, datetime):
+ aware = value if value.tzinfo is not None else value.replace(tzinfo=UTC)
+ return aware.astimezone(UTC).strftime("%Y-%m-%dT%H:%M:%SZ")
+ if isinstance(value, date):
+ return datetime.combine(value, datetime.min.time(), tzinfo=UTC).strftime("%Y-%m-%dT%H:%M:%SZ")
+ return str(value)
+
+
+def _build_params(
+ endpoint: str,
+ incremental_field: Optional[str],
+ should_use_incremental_field: bool,
+ db_incremental_field_last_value: Optional[Any],
+) -> dict[str, Any]:
+ params: dict[str, Any] = dict(_ENDPOINT_STATIC_PARAMS.get(endpoint, {}))
+
+ query_param = INCREMENTAL_QUERY_PARAM.get(incremental_field or "")
+ if should_use_incremental_field and query_param and db_incremental_field_last_value is not None:
+ params[query_param] = _format_since(db_incremental_field_last_value)
+
+ return params
+
+
+def _get_resource(
+ endpoint: str,
+ incremental_field: Optional[str],
+ should_use_incremental_field: bool,
+ db_incremental_field_last_value: Optional[Any],
+) -> EndpointResource:
+ params = _build_params(endpoint, incremental_field, should_use_incremental_field, db_incremental_field_last_value)
+
+ if endpoint in PAGINATED_ENDPOINTS:
+ params["limit"] = PAGE_LIMIT
+
+ return {
+ "name": endpoint,
+ "table_name": endpoint,
+ "write_disposition": "merge" if should_use_incremental_field else "replace",
+ "endpoint": {
+ "path": _ENDPOINT_PATHS[endpoint],
+ "params": params,
+ },
+ "table_format": "delta",
+ }
+
+
+def eppo_source(
+ api_key: str,
+ endpoint: str,
+ team_id: int,
+ job_id: str,
+ incremental_field: Optional[str],
+ should_use_incremental_field: bool,
+ db_incremental_field_last_value: Optional[Any],
+) -> SourceResponse:
+ paginator: PaginatorConfig = (
+ {"type": "offset", "limit": PAGE_LIMIT, "total_path": None}
+ if endpoint in PAGINATED_ENDPOINTS
+ else "single_page"
+ )
+
+ config: RESTAPIConfig = {
+ "client": {
+ "base_url": BASE_URL,
+ "auth": {
+ "type": "api_key",
+ "api_key": api_key,
+ "name": "X-Eppo-Token",
+ "location": "header",
+ },
+ "paginator": paginator,
+ # Pin every request (including paginator next-page links) to the Eppo origin and never
+ # follow redirects, so the `X-Eppo-Token` credential can't be replayed off-host.
+ "allowed_hosts": [],
+ "allow_redirects": False,
+ },
+ "resources": [
+ _get_resource(endpoint, incremental_field, should_use_incremental_field, db_incremental_field_last_value)
+ ],
+ }
+
+ resource = rest_api_resource(
+ config,
+ team_id,
+ job_id,
+ db_incremental_field_last_value if should_use_incremental_field else None,
+ )
+
+ partition_key = PARTITION_KEYS.get(endpoint)
+
+ return SourceResponse(
+ name=endpoint,
+ items=lambda: resource,
+ primary_keys=PRIMARY_KEYS[endpoint],
+ partition_count=1 if partition_key else None,
+ partition_size=1 if partition_key else None,
+ partition_mode="datetime" if partition_key else None,
+ partition_format="month" if partition_key else None,
+ partition_keys=[partition_key] if partition_key else None,
+ column_hints=resource.column_hints,
+ )
+
+
+def validate_credentials(api_key: str) -> tuple[bool, int | None]:
+ """Probe the experiments list endpoint to confirm the API key is genuine."""
+ return validate_via_probe(
+ # `allow_redirects=False` pins the credential to the validated Eppo host, so a redirect
+ # from the probe endpoint can't replay `X-Eppo-Token` to an attacker-controlled origin.
+ lambda: make_tracked_session(redact_values=(api_key,), allow_redirects=False),
+ f"{BASE_URL}/experiments?limit=1",
+ headers={"X-Eppo-Token": api_key},
+ )
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.py
new file mode 100644
index 000000000000..d1a33fea0d56
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/settings.py
@@ -0,0 +1,80 @@
+from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType
+
+# Eppo's public API (https://eppo.cloud/api/v1) returns a plain JSON array for every list
+# endpoint below (no envelope, no total count). Endpoints with a documented "limit"/"offset"
+# pair are paginated with the offset paginator; endpoints with no such params return
+# everything in a single page.
+ENDPOINTS = (
+ "Experiments",
+ "Metrics",
+ "MetricCollections",
+ "FeatureFlags",
+ "Bandits",
+ "Holdouts",
+ "Teams",
+ "Tags",
+ "Audiences",
+ "Environments",
+)
+
+# Endpoints that document `offset`/`limit` query params (https://eppo.cloud/api/docs).
+# Everything else has no pagination and returns its full list in one response.
+PAGINATED_ENDPOINTS = frozenset(
+ {
+ "Experiments",
+ "Metrics",
+ "FeatureFlags",
+ "Holdouts",
+ }
+)
+
+PAGE_LIMIT = 100
+
+# Only "Experiments" documents a server-side timestamp filter (`created_since`/`updated_since`,
+# both ISO 8601). We map to `created_since` — `created_date` is a field the response actually
+# returns, so the synced watermark is verifiable, unlike `updated_since` which has no matching
+# output column. Every other endpoint has no documented filter, so it stays full refresh.
+INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {
+ "Experiments": [
+ {
+ "label": "created_date",
+ "type": IncrementalFieldType.DateTime,
+ "field": "created_date",
+ "field_type": IncrementalFieldType.DateTime,
+ },
+ ],
+}
+
+# Maps an incremental field name to the query param Eppo expects it as.
+INCREMENTAL_QUERY_PARAM: dict[str, str] = {
+ "created_date": "created_since",
+}
+
+# Primary keys are a numeric `id`, unique per endpoint (no fan-out/parent-child endpoints here).
+PRIMARY_KEYS: dict[str, list[str]] = {
+ "Experiments": ["id"],
+ "Metrics": ["id"],
+ "MetricCollections": ["id"],
+ "FeatureFlags": ["id"],
+ "Bandits": ["id"],
+ "Holdouts": ["id"],
+ "Teams": ["id"],
+ "Tags": ["id"],
+ "Audiences": ["id"],
+ "Environments": ["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).
+PARTITION_KEYS: dict[str, str | None] = {
+ "Experiments": "created_date",
+ "Metrics": "created_date",
+ "MetricCollections": None,
+ "FeatureFlags": "created_at",
+ "Bandits": "created_at",
+ "Holdouts": "created_at",
+ "Teams": None,
+ "Tags": "created_at",
+ "Audiences": "created_at",
+ "Environments": "created_at",
+}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/source.py
index df0b08d28469..ebc80f3c1c28 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/source.py
@@ -1,30 +1,121 @@
-from typing import cast
+from typing import Optional, cast
from posthog.schema import (
DataWarehouseSourceCategory,
ExternalDataSourceType as SchemaExternalDataSourceType,
+ ReleaseStatus,
SourceConfig,
+ SourceFieldInputConfig,
+ SourceFieldInputConfigType,
)
+from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import (
+ SourceInputs,
+ SourceResponse,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, SimpleSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
+ CanonicalDescriptions,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.registry import SourceRegistry
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import (
+ SourceSchema,
+ build_endpoint_schemas,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.eppo.eppo import (
+ eppo_source,
+ validate_credentials as validate_eppo_credentials,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.eppo.settings import ENDPOINTS, INCREMENTAL_FIELDS
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.eppo import EppoSourceConfig
from products.warehouse_sources.backend.types import ExternalDataSourceType
@SourceRegistry.register
class EppoSource(SimpleSource[EppoSourceConfig]):
+ # Every endpoint here is a static entry in ENDPOINTS with no I/O — safe for public docs.
+ lists_tables_without_credentials = True
+ # Eppo's public API has no versioned path/header — https://eppo.cloud/api/v1/ is the only
+ # documented base, and it has never changed.
+ api_docs_url = "https://eppo.cloud/api/docs"
+
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.EPPO
+ def get_non_retryable_errors(self) -> dict[str, str | None]:
+ return {
+ "401 Client Error": "Eppo authentication failed. Please check your API key.",
+ "403 Client Error": "Eppo authentication failed. Please check your API key and its permissions.",
+ }
+
+ def get_canonical_descriptions(self) -> CanonicalDescriptions:
+ from products.warehouse_sources.backend.temporal.data_imports.sources.eppo.canonical_descriptions import (
+ CANONICAL_DESCRIPTIONS,
+ )
+
+ return CANONICAL_DESCRIPTIONS
+
+ def get_schemas(
+ self,
+ config: EppoSourceConfig,
+ team_id: int,
+ with_counts: bool = False,
+ names: list[str] | None = None,
+ force_refresh: bool = False,
+ api_version: str | None = None,
+ ) -> list[SourceSchema]:
+ return build_endpoint_schemas(ENDPOINTS, INCREMENTAL_FIELDS, names)
+
+ def validate_credentials(
+ self,
+ config: EppoSourceConfig,
+ team_id: int,
+ schema_name: Optional[str] = None,
+ api_version: str | None = None,
+ ) -> tuple[bool, str | None]:
+ ok, status_code = validate_eppo_credentials(config.api_key)
+ if ok:
+ return True, None
+ if status_code == 403 and schema_name is None:
+ # A valid key may legitimately lack scope for some resources — only block source
+ # create on outright rejection, not on a per-table permission gap.
+ return True, None
+ return False, "Invalid Eppo API key"
+
+ def source_for_pipeline(self, config: EppoSourceConfig, inputs: SourceInputs) -> SourceResponse:
+ return eppo_source(
+ api_key=config.api_key,
+ endpoint=inputs.schema_name,
+ team_id=inputs.team_id,
+ job_id=inputs.job_id,
+ incremental_field=inputs.incremental_field,
+ should_use_incremental_field=inputs.should_use_incremental_field,
+ db_incremental_field_last_value=inputs.db_incremental_field_last_value,
+ )
+
@property
def get_source_config(self) -> SourceConfig:
return SourceConfig(
name=SchemaExternalDataSourceType.EPPO,
category=DataWarehouseSourceCategory.ANALYTICS,
label="Eppo (Datadog)",
+ caption="Sync experiment, metric, and feature flag metadata from Eppo. "
+ "Create an API key under Admin > API Keys in Eppo (distinct from SDK/client keys).",
+ docsUrl="https://posthog.com/docs/cdp/sources/eppo",
iconPath="/static/services/eppo.png",
- fields=cast(list[FieldType], []),
- unreleasedSource=True,
+ releaseStatus=ReleaseStatus.ALPHA,
+ fields=cast(
+ list[FieldType],
+ [
+ SourceFieldInputConfig(
+ name="api_key",
+ label="API key",
+ type=SourceFieldInputConfigType.PASSWORD,
+ required=True,
+ placeholder="",
+ secret=True,
+ ),
+ ],
+ ),
)
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.py
new file mode 100644
index 000000000000..ca55961c7caf
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/tests/test_eppo.py
@@ -0,0 +1,320 @@
+import json
+from datetime import UTC, date, datetime
+from typing import Any
+
+import pytest
+from unittest import mock
+
+from parameterized import parameterized
+from requests import Response
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.auth import APIKeyAuth
+from products.warehouse_sources.backend.temporal.data_imports.sources.eppo.eppo import (
+ BASE_URL,
+ _build_params,
+ _format_since,
+ eppo_source,
+ validate_credentials,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.eppo.settings import PAGE_LIMIT
+
+# 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 eppo module.
+EPPO_SESSION_PATCH = "products.warehouse_sources.backend.temporal.data_imports.sources.eppo.eppo.make_tracked_session"
+
+
+class TestFormatSince:
+ @parameterized.expand(
+ [
+ ("utc_datetime", datetime(2026, 3, 4, 2, 58, 14, tzinfo=UTC), "2026-03-04T02:58:14Z"),
+ ("naive_datetime", datetime(2026, 3, 4, 2, 58, 14), "2026-03-04T02:58:14Z"),
+ ("date_value", date(2026, 3, 4), "2026-03-04T00:00:00Z"),
+ ("string_passthrough", "2026-03-04T02:58:14Z", "2026-03-04T02:58:14Z"),
+ ]
+ )
+ def test_format(self, _name: str, value: Any, expected: str) -> None:
+ result = _format_since(value)
+ assert result == expected
+ assert "+00:00" not in result
+
+
+class TestBuildParams:
+ def test_incremental_endpoint_with_cursor_adds_created_since(self) -> None:
+ params = _build_params(
+ "Experiments",
+ incremental_field="created_date",
+ should_use_incremental_field=True,
+ db_incremental_field_last_value=datetime(2026, 3, 4, 2, 58, 14, tzinfo=UTC),
+ )
+ assert params == {"created_since": "2026-03-04T02:58:14Z"}
+
+ def test_incremental_endpoint_without_cursor_omits_created_since(self) -> None:
+ params = _build_params(
+ "Experiments",
+ incremental_field="created_date",
+ should_use_incremental_field=True,
+ db_incremental_field_last_value=None,
+ )
+ assert params == {}
+
+ def test_full_refresh_endpoint_never_filters(self) -> None:
+ # Metrics has no server-side timestamp filter; a cursor must not leak into the request.
+ params = _build_params(
+ "Metrics",
+ incremental_field=None,
+ should_use_incremental_field=True,
+ db_incremental_field_last_value=datetime(2026, 3, 4, tzinfo=UTC),
+ )
+ assert params == {}
+
+ def test_static_params_carried_for_feature_flags(self) -> None:
+ params = _build_params(
+ "FeatureFlags",
+ incremental_field=None,
+ should_use_incremental_field=False,
+ db_incremental_field_last_value=None,
+ )
+ assert params == {"include_archived": "true"}
+
+ def test_static_params_carried_for_audiences(self) -> None:
+ params = _build_params(
+ "Audiences",
+ incremental_field=None,
+ should_use_incremental_field=False,
+ db_incremental_field_last_value=None,
+ )
+ assert params == {"status": "all"}
+
+
+def _response(items: list[dict[str, Any]]) -> Response:
+ resp = Response()
+ resp.status_code = 200
+ resp._content = json.dumps(items).encode()
+ return resp
+
+
+def _redirect_response(location: str) -> Response:
+ resp = Response()
+ resp.status_code = 302
+ resp.headers["Location"] = location
+ resp._content = b""
+ return resp
+
+
+def _wire(session: mock.MagicMock, responses: list[Response]) -> list[dict[str, Any]]:
+ """Wire a mock session and return a list that captures each request AT SEND TIME.
+
+ ``request.params`` is a single dict mutated in place across pages, so inspecting it after the
+ run shows only the final state — snapshot a copy when each request is prepared instead.
+ """
+ session.headers = {}
+ snapshots: list[dict[str, Any]] = []
+
+ def _prepare(request: Any) -> mock.MagicMock:
+ snapshots.append({"url": request.url, "params": dict(request.params or {}), "auth": request.auth})
+ # Carry the real URL onto the prepared request so the client's host-pinning check
+ # (allowed_hosts) sees the Eppo origin rather than a MagicMock.
+ prepared = mock.MagicMock()
+ prepared.url = request.url
+ return prepared
+
+ session.prepare_request.side_effect = _prepare
+ session.send.side_effect = responses
+ return snapshots
+
+
+def _source(endpoint: str, **kwargs: Any):
+ defaults: dict[str, Any] = {
+ "incremental_field": None,
+ "should_use_incremental_field": False,
+ "db_incremental_field_last_value": None,
+ }
+ defaults.update(kwargs)
+ return eppo_source(api_key="key", endpoint=endpoint, team_id=1, job_id="j", **defaults)
+
+
+def _rows(source_response) -> list[dict[str, Any]]:
+ return [row for page in source_response.items() for row in page]
+
+
+class TestEppoSourcePagination:
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_paginated_endpoint_stops_on_short_page(self, MockSession) -> None:
+ session = MockSession.return_value
+ snapshots = _wire(
+ session,
+ [
+ _response([{"id": i} for i in range(PAGE_LIMIT)]),
+ _response([{"id": PAGE_LIMIT}]),
+ ],
+ )
+
+ rows = _rows(_source("Experiments"))
+
+ assert len(rows) == PAGE_LIMIT + 1
+ assert session.send.call_count == 2
+ assert snapshots[0]["url"] == f"{BASE_URL}/experiments"
+ assert snapshots[0]["params"] == {"limit": PAGE_LIMIT, "offset": 0}
+ assert snapshots[1]["params"] == {"limit": PAGE_LIMIT, "offset": PAGE_LIMIT}
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_paginated_endpoint_stops_on_empty_page(self, MockSession) -> None:
+ session = MockSession.return_value
+ _wire(session, [_response([])])
+
+ rows = _rows(_source("Holdouts"))
+
+ assert rows == []
+ assert session.send.call_count == 1
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_unpaginated_endpoint_fetches_single_page_with_no_offset_params(self, 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.
+ snapshots = _wire(session, [_response([{"id": i} for i in range(PAGE_LIMIT)])])
+
+ rows = _rows(_source("Tags"))
+
+ assert len(rows) == PAGE_LIMIT
+ assert session.send.call_count == 1
+ assert "limit" not in snapshots[0]["params"]
+ assert "offset" not in snapshots[0]["params"]
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_auth_is_framework_api_key(self, MockSession) -> None:
+ session = MockSession.return_value
+ snapshots = _wire(session, [_response([{"id": 1}])])
+
+ _rows(_source("Environments"))
+
+ auth = snapshots[0]["auth"]
+ assert isinstance(auth, APIKeyAuth)
+ assert auth.api_key == "key"
+ assert auth.name == "X-Eppo-Token"
+ assert auth.location == "header"
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_sync_client_refuses_off_origin_redirect(self, MockSession) -> None:
+ # A 3xx from the Eppo API must not be followed — otherwise the X-Eppo-Token header would be
+ # replayed to the redirect target. The client is pinned with allow_redirects=False.
+ session = MockSession.return_value
+ _wire(session, [_redirect_response("https://evil.example/steal")])
+
+ with pytest.raises(ValueError, match="refusing to follow"):
+ _rows(_source("Experiments"))
+
+ assert session.send.call_args.kwargs["allow_redirects"] is False
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_incremental_cursor_added_to_request(self, MockSession) -> None:
+ session = MockSession.return_value
+ snapshots = _wire(session, [_response([{"id": 1}])])
+
+ _rows(
+ _source(
+ "Experiments",
+ incremental_field="created_date",
+ should_use_incremental_field=True,
+ db_incremental_field_last_value=datetime(2026, 3, 4, 2, 58, 14, tzinfo=UTC),
+ )
+ )
+
+ assert snapshots[0]["params"]["created_since"] == "2026-03-04T02:58:14Z"
+
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_static_params_present_for_feature_flags_and_audiences(self, MockSession) -> None:
+ session = MockSession.return_value
+ snapshots = _wire(session, [_response([{"id": 1}])])
+ _rows(_source("FeatureFlags"))
+ assert snapshots[0]["params"]["include_archived"] == "true"
+
+ session2 = MockSession.return_value
+ snapshots2 = _wire(session2, [_response([{"id": 1}])])
+ _rows(_source("Audiences"))
+ assert snapshots2[-1]["params"]["status"] == "all"
+
+ @parameterized.expand(
+ [
+ ("Experiments", ["id"]),
+ ("Metrics", ["id"]),
+ ("MetricCollections", ["id"]),
+ ("FeatureFlags", ["id"]),
+ ("Bandits", ["id"]),
+ ("Holdouts", ["id"]),
+ ("Teams", ["id"]),
+ ("Tags", ["id"]),
+ ("Audiences", ["id"]),
+ ("Environments", ["id"]),
+ ]
+ )
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_primary_keys_per_endpoint(self, endpoint: str, expected_keys: list[str], MockSession) -> None:
+ session = MockSession.return_value
+ _wire(session, [_response([{"id": 1}])])
+
+ response = _source(endpoint)
+
+ assert response.primary_keys == expected_keys
+
+ @parameterized.expand(
+ [
+ ("Experiments", "created_date"),
+ ("Metrics", "created_date"),
+ ("MetricCollections", None),
+ ("FeatureFlags", "created_at"),
+ ("Bandits", "created_at"),
+ ("Holdouts", "created_at"),
+ ("Teams", None),
+ ("Tags", "created_at"),
+ ("Audiences", "created_at"),
+ ("Environments", "created_at"),
+ ]
+ )
+ @mock.patch(CLIENT_SESSION_PATCH)
+ def test_partition_keys_per_endpoint(self, endpoint: str, expected_partition: str | None, MockSession) -> None:
+ session = MockSession.return_value
+ _wire(session, [_response([{"id": 1}])])
+
+ response = _source(endpoint)
+
+ if expected_partition is None:
+ assert response.partition_keys is None
+ assert response.partition_mode is None
+ else:
+ assert response.partition_keys == [expected_partition]
+ assert response.partition_mode == "datetime"
+
+
+class TestValidateCredentials:
+ @mock.patch(EPPO_SESSION_PATCH)
+ def test_ok(self, mock_session) -> None:
+ mock_session.return_value.get.return_value = mock.MagicMock(status_code=200)
+ assert validate_credentials("key") == (True, 200)
+
+ @mock.patch(EPPO_SESSION_PATCH)
+ def test_unauthorized(self, mock_session) -> None:
+ mock_session.return_value.get.return_value = mock.MagicMock(status_code=401)
+ assert validate_credentials("key") == (False, 401)
+
+ @mock.patch(EPPO_SESSION_PATCH)
+ def test_swallows_transport_errors(self, mock_session) -> None:
+ mock_session.return_value.get.side_effect = Exception("boom")
+ assert validate_credentials("key") == (False, None)
+
+ @mock.patch(EPPO_SESSION_PATCH)
+ def test_probes_experiments_endpoint_with_token_header(self, mock_session) -> None:
+ mock_session.return_value.get.return_value = mock.MagicMock(status_code=200)
+ validate_credentials("key")
+
+ call = mock_session.return_value.get.call_args
+ assert call.args[0] == f"{BASE_URL}/experiments?limit=1"
+ assert call.kwargs["headers"]["X-Eppo-Token"] == "key"
+
+ @mock.patch(EPPO_SESSION_PATCH)
+ def test_probe_session_disables_redirects(self, mock_session) -> None:
+ # The probe carries the token; a redirect must not be followed off the validated Eppo host.
+ mock_session.return_value.get.return_value = mock.MagicMock(status_code=200)
+ validate_credentials("key")
+ assert mock_session.call_args.kwargs["allow_redirects"] is False
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/tests/test_eppo_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/tests/test_eppo_source.py
new file mode 100644
index 000000000000..33ae2f26cbcc
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eppo/tests/test_eppo_source.py
@@ -0,0 +1,146 @@
+import pytest
+from unittest import mock
+
+from posthog.schema import ReleaseStatus, SourceFieldInputConfig, SourceFieldInputConfigType
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.eppo.settings import ENDPOINTS
+from products.warehouse_sources.backend.temporal.data_imports.sources.eppo.source import EppoSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.eppo import EppoSourceConfig
+from products.warehouse_sources.backend.types import ExternalDataSourceType
+
+# Only "Experiments" documents a server-side timestamp filter (created_since/updated_since).
+_INCREMENTAL_ENDPOINTS = {"Experiments"}
+_FULL_REFRESH_ENDPOINTS = set(ENDPOINTS) - _INCREMENTAL_ENDPOINTS
+
+
+class TestEppoSource:
+ def setup_method(self):
+ self.source = EppoSource()
+ self.team_id = 123
+ self.config = EppoSourceConfig(api_key="key")
+
+ def test_source_type(self):
+ assert self.source.source_type == ExternalDataSourceType.EPPO
+
+ def test_get_source_config(self):
+ config = self.source.get_source_config
+
+ assert config.name.value == "Eppo"
+ assert config.label == "Eppo (Datadog)"
+ assert config.releaseStatus == ReleaseStatus.ALPHA
+ assert config.unreleasedSource is None
+ assert config.iconPath == "/static/services/eppo.png"
+ assert config.docsUrl == "https://posthog.com/docs/cdp/sources/eppo"
+
+ field_names = [f.name for f in config.fields if isinstance(f, SourceFieldInputConfig)]
+ assert field_names == ["api_key"]
+
+ def test_api_key_field_is_secret_password(self):
+ config = self.source.get_source_config
+ api_key_field = next(f for f in config.fields if isinstance(f, SourceFieldInputConfig) and f.name == "api_key")
+ assert api_key_field.type == SourceFieldInputConfigType.PASSWORD
+ assert api_key_field.secret is True
+ assert api_key_field.required is True
+
+ def test_api_docs_url_is_set(self):
+ assert self.source.api_docs_url == "https://eppo.cloud/api/docs"
+
+ @pytest.mark.parametrize(
+ "observed_error",
+ [
+ "401 Client Error: Unauthorized for url: https://eppo.cloud/api/v1/experiments?limit=100",
+ "403 Client Error: Forbidden for url: https://eppo.cloud/api/v1/experiments?limit=100",
+ ],
+ )
+ def test_non_retryable_errors_match_auth_failures(self, observed_error):
+ non_retryable_errors = self.source.get_non_retryable_errors()
+ assert any(key in observed_error for key in non_retryable_errors)
+
+ @pytest.mark.parametrize(
+ "other_error",
+ [
+ "429 Client Error: Too Many Requests for url: https://eppo.cloud/api/v1/experiments",
+ "500 Server Error: Internal Server Error for url: https://eppo.cloud/api/v1/experiments",
+ "HTTPSConnectionPool(host='eppo.cloud', port=443): Read timed out.",
+ ],
+ )
+ def test_non_retryable_errors_do_not_match_transient(self, other_error):
+ non_retryable_errors = self.source.get_non_retryable_errors()
+ assert not any(key in other_error for key in non_retryable_errors)
+
+ def test_get_schemas_match_endpoints_with_correct_sync_modes(self):
+ schemas = {schema.name: schema for schema in self.source.get_schemas(self.config, self.team_id)}
+
+ assert set(schemas) == set(ENDPOINTS)
+ for name in _INCREMENTAL_ENDPOINTS:
+ assert schemas[name].supports_incremental is True
+ assert schemas[name].supports_append is True
+ assert [f["field"] for f in schemas[name].incremental_fields] == ["created_date"]
+ for name in _FULL_REFRESH_ENDPOINTS:
+ assert schemas[name].supports_incremental is False
+ assert schemas[name].supports_append is False
+ assert schemas[name].incremental_fields == []
+
+ def test_get_schemas_filtered_by_names(self):
+ schemas = self.source.get_schemas(self.config, self.team_id, names=["Metrics"])
+ assert len(schemas) == 1
+ assert schemas[0].name == "Metrics"
+
+ def test_get_schemas_filtered_unknown_name_returns_empty(self):
+ assert self.source.get_schemas(self.config, self.team_id, names=["nope"]) == []
+
+ def test_lists_tables_without_credentials_publishes_catalog(self):
+ # Static endpoint catalog (no I/O) — the public docs table list should render.
+ assert self.source.lists_tables_without_credentials is True
+ documented = self.source.get_documented_tables()
+ assert {table["name"] for table in documented} == set(ENDPOINTS)
+
+ def test_canonical_descriptions_cover_every_endpoint(self):
+ canonical = self.source.get_canonical_descriptions()
+ assert set(canonical) == set(ENDPOINTS)
+
+ @pytest.mark.parametrize(
+ "mock_return, schema_name, expected_valid, expected_message",
+ [
+ ((True, 200), None, True, None),
+ ((False, 401), None, False, "Invalid Eppo API key"),
+ # A valid key that lacks scope for one resource must not block source-create.
+ ((False, 403), None, True, None),
+ # ...but a per-table scope check on a specific schema should still surface it.
+ ((False, 403), "Experiments", False, "Invalid Eppo API key"),
+ ((False, None), None, False, "Invalid Eppo API key"),
+ ],
+ )
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.eppo.source.validate_eppo_credentials"
+ )
+ def test_validate_credentials(self, mock_validate, mock_return, schema_name, expected_valid, expected_message):
+ mock_validate.return_value = mock_return
+
+ is_valid, error_message = self.source.validate_credentials(self.config, self.team_id, schema_name=schema_name)
+
+ assert is_valid is expected_valid
+ assert error_message == expected_message
+ mock_validate.assert_called_once_with("key")
+
+ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.eppo.source.eppo_source")
+ def test_source_for_pipeline_plumbs_arguments(self, mock_eppo_source):
+ inputs = mock.MagicMock()
+ inputs.schema_name = "Experiments"
+ inputs.team_id = self.team_id
+ inputs.job_id = "job-1"
+ inputs.incremental_field = "created_date"
+ inputs.should_use_incremental_field = True
+ inputs.db_incremental_field_last_value = "2026-01-01T00:00:00Z"
+
+ self.source.source_for_pipeline(self.config, inputs)
+
+ mock_eppo_source.assert_called_once_with(
+ api_key="key",
+ endpoint="Experiments",
+ team_id=self.team_id,
+ job_id="job-1",
+ incremental_field="created_date",
+ should_use_incremental_field=True,
+ db_incremental_field_last_value="2026-01-01T00:00:00Z",
+ )
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/eppo.py b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/eppo.py
index 6cdd1d1d90cf..b7e911f043e1 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/eppo.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/eppo.py
@@ -6,4 +6,4 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common imp
@config.config
class EppoSourceConfig(config.Config):
- pass
+ api_key: str