: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 CoinGecko insights table (#90076)
Tom Owers08bfe64fbd24
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 aa40070baeff..75b4dbee5537 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@@ -1784,7 +1784,7 @@ Note: docs.coinapi.io is behind a Cloudflare interstitial and returns 403 to cur## CoinGecko — gaps-Today (7): `asset_platforms`, `coins_categories`, `coins_categories_list`, `coins_list`, `coins_markets`, `exchanges`, `exchanges_list`+Today (8): `asset_platforms`, `coins_categories`, `coins_categories_list`, `coins_list`, `coins_markets`, `exchanges`, `exchanges_list`, `insights`Diffed against: <https://docs.coingecko.com/llms.txt>@@ -1800,6 +1800,7 @@ Diffed against: <https://docs.coingecko.com/llms.txt>- [ ] `/exchange_rates` — BTC-to-currency rates, the standard normaliser for cross-currency reporting (medium)- [ ] `/derivatives/exchanges and /derivatives/tickers` — derivatives venues and open interest, entirely absent from current coverage (medium)- [ ] `/nfts/markets` — NFT collections with floor price, market cap and volume - a whole product surface with no table today (medium)+- [ ] `/coins/{id}/supply_breakdown` — per-coin circulating/non-circulating supply split with non-circulating wallet detail (Pro, Analyst plan and above); needs per-coin fan-out over the full coin universe, which this top-level-only source has no plumbing for (medium)Note: docs.coingecko.com/reference/\* pages are client-rendered and unparseable by curl, but llms.txt enumerates every reference page (Demo and Pro) with descriptions, and any single page can be fetched by appending .md. The onchain/GeckoTerminal family (networks, dexes, pools, token holders, pool trades) is a further ~35 endpoints with zero coverage; treated as a separate product rather than listed individually here.diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/coingecko/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/coingecko/canonical_descriptions.pyindex 4643a409a6d7..751366523932 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/coingecko/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/coingecko/canonical_descriptions.py@@ -93,4 +93,14 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"native_coin_id": "CoinGecko coin id of the platform's native token.",},},+ "insights": {+ "description": "Latest coin insights published on CoinGecko. Requires a Pro/Enterprise API key.",+ "docs_url": "https://docs.coingecko.com/reference/insights",+ "columns": {+ "title": "Insight title.",+ "description": "Insight body text.",+ "related_coin_ids": "CoinGecko coin ids the insight relates to.",+ "posted_at": "Timestamp the insight was posted, in ISO 8601 format.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/coingecko/coingecko.py b/products/warehouse_sources/backend/temporal/data_imports/sources/coingecko/coingecko.pyindex 857115d875dc..dcafe5bc2ae4 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/coingecko/coingecko.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/coingecko/coingecko.py@@ -62,10 +62,13 @@ class CoinGeckoPagePaginator(PageNumberPaginator):"""CoinGecko paginates with ``page``/``per_page``. A short page (fewer than ``per_page`` items) oran empty page is the last one — stop without paying an extra empty-page request, since the freetier's tight rate limits make sparing that request worthwhile. Resume replays the last full page- (merge dedupes on the primary key)."""+ (merge dedupes on the primary key).- def __init__(self, page_size: int) -> None:- super().__init__(base_page=1, page_param="page")+ ``max_pages`` caps the page number for endpoints the API refuses to page past (e.g. /insights+ rejects page > 20); the base class stops once the next page would exceed it."""++ def __init__(self, page_size: int, max_pages: Optional[int] = None) -> None:+ super().__init__(base_page=1, page_param="page", maximum_page=max_pages)self._page_size = page_sizedef update_state(self, response: Response, data: Optional[list[Any]] = None) -> None:@@ -85,9 +88,10 @@ def coingecko_source() -> SourceResponse:config = COINGECKO_ENDPOINTS[endpoint]+ page_size = config.page_size or PAGE_SIZEparams: dict[str, Any] = dict(config.extra_params)if config.paginated:- params["per_page"] = PAGE_SIZE+ params["per_page"] = page_sizerest_config: RESTAPIConfig = {"client": {@@ -112,7 +116,9 @@ def coingecko_source(# Bare-array bodies. A non-list body means the response shape changed (or an# unexpected error envelope) — fail loud rather than syncing a garbage row."data_selector_required": True,- "paginator": CoinGeckoPagePaginator(PAGE_SIZE) if config.paginated else SinglePagePaginator(),+ "paginator": CoinGeckoPagePaginator(page_size, config.max_pages)+ if config.paginated+ else SinglePagePaginator(),# The keyless/demo tier reports rate limiting inside a success-status body; the# client retries on status only, so promote that in-body signal to a retry."response_actions": [{"content": marker, "action": "retry"} for marker in RATE_LIMIT_BODY_MARKERS],diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/coingecko/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/coingecko/settings.pyindex 28ded0ea472e..58db2936cd6f 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/coingecko/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/coingecko/settings.py@@ -1,9 +1,11 @@-from dataclasses import dataclass, field+from dataclasses import field++from posthog.dataclasses import frozenfrom products.warehouse_sources.backend.types import IncrementalField-@dataclass+@frozenclass CoinGeckoEndpointConfig:name: strpath: str@@ -13,6 +15,12 @@ class CoinGeckoEndpointConfig:# Whether the endpoint supports page/per_page pagination. Reference endpoints (e.g. /coins/list)# return the whole collection in one response and ignore pagination params.paginated: bool = False+ # per_page value to request. None means the source default (250). Some endpoints cap it lower+ # (e.g. /insights allows at most 20), so it is overridable per endpoint.+ page_size: int | None = None+ # Hard cap on the page number to request, for endpoints the API refuses to page past+ # (e.g. /insights rejects page > 20). None means walk until a short/empty page.+ max_pages: int | None = None# Extra static query params (e.g. vs_currency for /coins/markets).extra_params: dict[str, str] = field(default_factory=dict)should_sync_default: bool = True@@ -59,6 +67,16 @@ COINGECKO_ENDPOINTS: dict[str, CoinGeckoEndpointConfig] = {name="asset_platforms",path="/asset_platforms",),+ # Latest coin insights published on CoinGecko (Pro/Enterprise). Paginated, but the API caps both+ # per_page and page at 20. Insight rows carry no id, so key on title + posted_at.+ "insights": CoinGeckoEndpointConfig(+ name="insights",+ path="/insights",+ paginated=True,+ page_size=20,+ max_pages=20,+ primary_keys=["title", "posted_at"],+ ),}ENDPOINTS = tuple(COINGECKO_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/coingecko/tests/test_coingecko.py b/products/warehouse_sources/backend/temporal/data_imports/sources/coingecko/tests/test_coingecko.pyindex da4cf5a8b8c6..ac6473f2fb95 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/coingecko/tests/test_coingecko.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/coingecko/tests/test_coingecko.py@@ -191,6 +191,26 @@ class TestPagination:_rows(_source(PLAN_DEMO, "key", "coins_markets", _manager()))assert snaps[0]["params"]["vs_currency"] == "usd"+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_insights_requests_capped_per_page(self, MockSession) -> None:+ session = MockSession.return_value+ # CoinGecko caps /insights per_page at 20, so the source must not send the default 250.+ snaps = _wire(session, [_response([{"title": "t", "posted_at": "2026-01-01T00:00:00Z"}])])++ _rows(_source(PLAN_PRO, "key", "insights", _manager()))+ assert snaps[0]["params"]["per_page"] == 20++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_insights_stops_at_max_page_cap(self, MockSession) -> None:+ session = MockSession.return_value+ # 20 full pages back to back would normally trigger a 21st request, but CoinGecko rejects+ # page > 20 for /insights, so the cap must stop paging without that doomed request.+ full_page = [{"title": f"t{i}", "posted_at": "2026-01-01T00:00:00Z"} for i in range(20)]+ _wire(session, [_response(full_page) for _ in range(20)])++ _rows(_source(PLAN_PRO, "key", "insights", _manager()))+ assert session.send.call_count == 20+class TestRateLimitAndErrors:@parameterized.expand([("compact", True), ("spaced", False)])