: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
from dataclasses import field
from products.warehouse_sources.sources.sdk import IncrementalField, frozen
DEFAULT_BASE_URL = "https://api.growthbook.io/api"
PAGE_SIZE = 100
@frozen
class GrowthBookEndpoint:
path: str
data_selector: str
primary_keys: tuple[str, ...] = ("id",)
partition_key: str | None = "dateCreated"
paginated: bool = True
params: dict[str, str] = field(default_factory=dict)
# GrowthBook only exposes v2 for features; the other entities retain their v1 routes.
ENDPOINTS: dict[str, GrowthBookEndpoint] = {
"features": GrowthBookEndpoint(
path="{api_version}/features", data_selector="features", params={"archived": "true"}
),
"experiments": GrowthBookEndpoint(path="v1/experiments", data_selector="experiments"),
"metrics": GrowthBookEndpoint(path="v1/metrics", data_selector="metrics", params={"includeArchived": "true"}),
"fact_tables": GrowthBookEndpoint(path="v1/fact-tables", data_selector="factTables"),
"fact_metrics": GrowthBookEndpoint(path="v1/fact-metrics", data_selector="factMetrics"),
"segments": GrowthBookEndpoint(path="v1/segments", data_selector="segments"),
"dimensions": GrowthBookEndpoint(path="v1/dimensions", data_selector="dimensions"),
"projects": GrowthBookEndpoint(path="v1/projects", data_selector="projects"),
"environments": GrowthBookEndpoint(
path="v1/environments", data_selector="environments", partition_key=None, paginated=False
),
"saved_groups": GrowthBookEndpoint(path="v1/saved-groups", data_selector="savedGroups"),
"data_sources": GrowthBookEndpoint(path="v1/data-sources", data_selector="dataSources"),
"members": GrowthBookEndpoint(path="v1/members", data_selector="members", partition_key=None),
"teams": GrowthBookEndpoint(path="v1/teams", data_selector="teams", paginated=False),
"namespaces": GrowthBookEndpoint(path="v1/namespaces", data_selector="namespaces", partition_key=None),
"holdouts": GrowthBookEndpoint(path="v1/holdouts", data_selector="holdouts", paginated=False),
# One row per experiment holding its latest non-dimension snapshot; pages can be empty while hasMore is true.
"experiment_results": GrowthBookEndpoint(
path="v1/experiments/results", data_selector="experimentResults", partition_key=None
),
}
# Timestamp fields in responses do not imply server-side timestamp filtering.
INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {}