: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 11 Algolia Analytics tables (#99223)
Tom Owers46e60aa90329
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 6947c161b765..8871ce9a3ebd 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@@ -196,7 +196,7 @@ Note: Static schema list (no dynamic discovery). Coverage of the org/billing obj## Algolia — gaps-Today (9): `ab_tests`, `indices`, `records`, `rules`, `searches_no_clicks`, `searches_no_results`, `synonyms`, `top_hits`, `top_searches`+Today (20): `ab_tests`, `add_to_cart_rate`, `average_click_position`, `click_positions`, `click_through_rate`, `conversion_rate`, `indices`, `purchase_rate`, `records`, `revenue`, `rules`, `searches_no_clicks`, `searches_no_results`, `synonyms`, `top_countries`, `top_filter_values`, `top_filters`, `top_hits`, `top_searches`, `users_count`Diffed against: <https://raw.githubusercontent.com/algolia/api-clients-automation/main/specs/bundled/analytics.yml>@@ -204,16 +204,16 @@ Diffed against: <https://raw.githubusercontent.com/algolia/api-clients-automatio- [x] `GET /2/hits (Analytics API)` — top results per query with click and conversion counts, the record-level performance table (high) → `top_hits`- [x] `GET /2/searches/noResults and /2/searches/noClicks` — zero-result and zero-click queries, the core relevance-debugging tables (high) → `searches_no_results`, `searches_no_clicks`- [x] `GET /2/abtests (A/B Testing API)` — A/B test definitions and per-variant results (high) → `ab_tests` (implemented against the GA `GET /3/abtests`; the audited `/2/abtests` listing is deprecated in favour of v3)-- [ ] `GET /2/conversions/conversionRate, /2/conversions/revenue, /2/conversions/addToCartRate, /2/conversions/purchaseRate` — conversion and revenue time series per index (high)-- [ ] `GET /2/clicks/clickThroughRate, /2/clicks/averageClickPosition, /2/clicks/positions` — click-through and click-position time series (medium)-- [ ] `GET /2/filters and /2/filters/{attribute}` — facet/filter usage breakdown dimension (medium)-- [ ] `GET /2/countries and /2/users/count` — geography breakdown and unique-user counts for search traffic (medium)+- [x] `GET /2/conversions/conversionRate, /2/conversions/revenue, /2/conversions/addToCartRate, /2/conversions/purchaseRate` — conversion and revenue time series per index (high) → `conversion_rate`, `revenue`, `add_to_cart_rate`, `purchase_rate` (one row per day, synced incrementally from the `startDate` filter)+- [x] `GET /2/clicks/clickThroughRate, /2/clicks/averageClickPosition, /2/clicks/positions` — click-through and click-position time series (medium) → `click_through_rate`, `average_click_position` (daily, incremental) and `click_positions` (a 12-bucket distribution with no date column, so full refresh)+- [x] `GET /2/filters and /2/filters/{attribute}` — facet/filter usage breakdown dimension (medium) → `top_filters`, `top_filter_values` (fan-out over `top_filters`, since the attribute is a path param)+- [x] `GET /2/countries and /2/users/count` — geography breakdown and unique-user counts for search traffic (medium) → `top_countries` (a top-N snapshot, full refresh) and `users_count` (daily, incremental)- [ ] `GET /1/runs and /1/runs/{runID}/events (Ingestion API)` — connector run history and per-run events for pipeline reliability reporting (medium)- [ ] `GET /1/logs (Search API)` — raw API request log including query, timing and errors (medium)- [ ] `GET /1/incidents, /1/latency/{clusters}, /1/indexing/{clusters} (Monitoring API)` — cluster latency, indexing time and incident history (low)- [ ] `GET /1/logs/{indexName} (Query Suggestions API)` — query-suggestions build logs per index (low)-Note: Static schema list, no dynamic index discovery. The headline Analytics tables (top searches, top hits, zero-result and zero-click searches) and A/B tests (via the GA `/3/abtests`) are now covered; the remaining Analytics time-series (conversions, clicks, filters, countries) and the Ingestion, Monitoring, and raw-log APIs are still absent. Also diffed against the bundled abtesting.yml, insights.yml, monitoring.yml, ingestion.yml and search.yml specs in the same repo.+Note: Static schema list, no dynamic index discovery. The Analytics API is now covered end to end — the headline tables (top searches, top hits, zero-result and zero-click searches), the daily conversion/revenue/click/user time series, and the filter and country breakdowns — alongside A/B tests (via the GA `/3/abtests`). The Ingestion, Monitoring, and raw-log APIs are still absent. Also diffed against the bundled abtesting.yml, insights.yml, monitoring.yml, ingestion.yml and search.yml specs in the same repo.## Alguna — gapsdiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/algolia.py b/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/algolia.pyindex 9ce1dea0027c..8f94e33c4f53 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/algolia.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/algolia.py@@ -1,4 +1,7 @@import re+import dataclasses+from collections.abc import Iterable+from datetime import date, datetime, timedeltafrom typing import Any, Optional, castfrom urllib.parse import quote@@ -9,24 +12,33 @@ from posthog.dataclasses import frozenfrom products.warehouse_sources.backend.temporal.data_imports.sources.algolia.settings import (ALGOLIA_ENDPOINTS,+ ANALYTICS_LOOKBACK_DAYS,AlgoliaApi,AlgoliaEndpointConfig,PaginationStyle,)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.datetime_utils import parse_datetime_valuefrom products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_sessionfrom 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.fanout import (+ DependentEndpointConfig,+ build_dependent_resource,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (BasePaginator,JSONResponseCursorPaginator,OffsetPaginator,PageNumberPaginator,+ SinglePagePaginator,)from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import (+ ClientConfig,Endpoint,HTTPMethodBasic,+ IncrementalConfig,)from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManagerfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse@@ -68,6 +80,8 @@ class AlgoliaResumeConfig:page: int | None = None# Row offset for the offset-paginated analytics / A-B testing endpoints.offset: int | None = None+ # Fan-out progress, in the shape the shared fan-out builder checkpoints.+ fanout: dict[str, Any] | None = Nonedef _base_url(application_id: str) -> str:@@ -144,6 +158,8 @@ class AlgoliaPageNumberPaginator(PageNumberPaginator):def _build_paginator(config: AlgoliaEndpointConfig) -> BasePaginator:+ if config.pagination == PaginationStyle.SINGLE:+ return SinglePagePaginator()if config.pagination == PaginationStyle.CURSOR:# Browse pages via an opaque cursor carried in the POST body; a missing cursor in the# response signals end of index.@@ -167,19 +183,111 @@ def _build_paginator(config: AlgoliaEndpointConfig) -> BasePaginator:)-def algolia_source(- endpoint: str,+def _analytics_params(config: AlgoliaEndpointConfig, index_name: str | None) -> dict[str, Any]:+ params: dict[str, Any] = {}+ if config.requires_index and index_name:+ params["index"] = index_name+ if config.click_analytics:+ params["clickAnalytics"] = "true"+ return params+++def _to_start_date(value: Any) -> str | None:+ """Format an incremental watermark as Algolia's `startDate`, floored by the lookback window.++ None (the first incremental sync, before a watermark exists) drops the param so Algolia+ applies its own default period, which every plan's analytics retention covers. An+ unparseable watermark degrades the same way rather than asking for a window Algolia rejects.+ """+ if value is None:+ return None+ if isinstance(value, datetime):+ day = value.date()+ elif isinstance(value, date):+ day = value+ else:+ parsed = parse_datetime_value(value)+ if parsed is None:+ return None+ day = parsed.date()+ return (day - timedelta(days=ANALYTICS_LOOKBACK_DAYS)).isoformat()+++def _client_config(+ application_id: str,+ api_key: str,+ config: AlgoliaEndpointConfig,+ region: str,+) -> ClientConfig:+ return {+ "base_url": _base_url_for(config, application_id, region),+ # The API key is supplied via the framework auth config so its value is redacted from+ # logs; only the non-secret application ID / content headers are set here.+ "headers": {+ "X-Algolia-Application-Id": application_id,+ "Accept": "application/json",+ "Content-Type": "application/json",+ },+ "auth": {"type": "api_key", "api_key": api_key, "name": "X-Algolia-API-Key", "location": "header"},+ }+++def _fanout_items(+ config: AlgoliaEndpointConfig,+ fanout_config: DependentEndpointConfig,application_id: str,api_key: str,index_name: str | None,team_id: int,job_id: str,manager: ResumableSourceManager[AlgoliaResumeConfig],- region: str = "us",-) -> SourceResponse:- config = ALGOLIA_ENDPOINTS[endpoint]- is_cursor = config.pagination == PaginationStyle.CURSOR+ region: str,+) -> Iterable[Any]:+ parent_config = ALGOLIA_ENDPOINTS[fanout_config.parent_name]+ # The index is required on both requests but only known at run time, so it is bound here+ # rather than in the static endpoint catalog.+ fanout = dataclasses.replace(fanout_config, parent_params=_analytics_params(parent_config, index_name))++ resume = manager.load_state() if manager.can_resume() else None++ def save_checkpoint(state: Optional[dict[str, Any]]) -> None:+ if state:+ manager.save_state(AlgoliaResumeConfig(fanout=state))++ return build_dependent_resource(+ endpoint_configs=ALGOLIA_ENDPOINTS,+ child_endpoint=config.name,+ fanout=fanout,+ client_config=_client_config(application_id, api_key, config, region),+ path_format_values={},+ team_id=team_id,+ job_id=job_id,+ db_incremental_field_last_value=None,+ # A facet attribute name is a record attribute path, so percent-encode it before the+ # builder binds it into the path with `str.format`, which escapes nothing.+ parent_data_map=lambda row: {**row, "attribute": quote(str(row.get("attribute", "")), safe="")},+ parent_endpoint_extra={+ "data_selector": parent_config.data_selector,+ "paginator": _build_paginator(parent_config),+ },+ child_endpoint_extra={+ "data_selector": config.data_selector,+ "paginator": _build_paginator(config),+ },+ child_params_extra=_analytics_params(config, index_name),+ # The paginators supply `limit` themselves; adding a page-size param would duplicate it.+ page_size_param=None,+ resume_hook=save_checkpoint,+ initial_paginator_state=resume.fanout if resume is not None else None,+ )++def _endpoint_config(+ config: AlgoliaEndpointConfig,+ index_name: str | None,+ should_use_incremental_field: bool,+ incremental_field: str | None,+) -> Endpoint:endpoint_config: Endpoint = {"path": _endpoint_path(config, index_name),"method": cast(HTTPMethodBasic, config.method),@@ -189,76 +297,111 @@ def algolia_source(if config.api == AlgoliaApi.ANALYTICS:# The paginator supplies `offset`/`limit`; the index (when the endpoint is index-scoped)# and the click-analytics toggle travel as static query params alongside it.- params: dict[str, Any] = {}- if config.requires_index and index_name:- params["index"] = index_name- if config.click_analytics:- params["clickAnalytics"] = "true"- endpoint_config["params"] = params+ endpoint_config["params"] = _analytics_params(config, index_name)+ if should_use_incremental_field and config.start_param:+ incremental: IncrementalConfig = {+ "start_param": config.start_param,+ "cursor_path": incremental_field or config.default_incremental_field or "date",+ "convert": _to_start_date,+ }+ endpoint_config["incremental"] = incrementalelif config.method == "POST":# Rows requested per page (`hitsPerPage`) travel where the page token does: in the POST body# for browse/search, in the query string for the GET indices listing.endpoint_config["json"] = {"hitsPerPage": config.page_size}else:endpoint_config["params"] = {"hitsPerPage": config.page_size}+ return endpoint_config- rest_config: RESTAPIConfig = {- "client": {- "base_url": _base_url_for(config, application_id, region),- # The API key is supplied via the framework auth config so its value is redacted from- # logs; only the non-secret application ID / content headers are set here.- "headers": {- "X-Algolia-Application-Id": application_id,- "Accept": "application/json",- "Content-Type": "application/json",- },- "auth": {"type": "api_key", "api_key": api_key, "name": "X-Algolia-API-Key", "location": "header"},- },- "resource_defaults": {},- "resources": [{"name": endpoint, "endpoint": endpoint_config}],- }- initial_paginator_state: Optional[dict[str, Any]] = None- if manager.can_resume():- resume = manager.load_state()- if resume is not None:- if is_cursor and resume.cursor is not None:- initial_paginator_state = {"cursor": resume.cursor}- elif config.pagination == PaginationStyle.OFFSET and resume.offset is not None:- initial_paginator_state = {"offset": resume.offset}- elif config.pagination == PaginationStyle.PAGE and resume.page is not None:- initial_paginator_state = {"page": resume.page}+def _resume_state(+ config: AlgoliaEndpointConfig,+ manager: ResumableSourceManager[AlgoliaResumeConfig],+) -> Optional[dict[str, Any]]:+ """Seed the paginator from saved state, in whichever token the endpoint pages by."""+ if not manager.can_resume():+ return None+ resume = manager.load_state()+ if resume is None:+ return None+ if config.pagination == PaginationStyle.CURSOR and resume.cursor is not None:+ return {"cursor": resume.cursor}+ if config.pagination == PaginationStyle.OFFSET and resume.offset is not None:+ return {"offset": resume.offset}+ if config.pagination == PaginationStyle.PAGE and resume.page is not None:+ return {"page": resume.page}+ return None+++def _save_resume_state(+ config: AlgoliaEndpointConfig,+ manager: ResumableSourceManager[AlgoliaResumeConfig],+ state: Optional[dict[str, Any]],+) -> None:+ # Persist only when a next page remains; the framework calls this AFTER a page is yielded so a+ # crash re-yields the last page (merge dedupes on the primary key) rather than skipping it.+ if not state:+ return+ if config.pagination == PaginationStyle.CURSOR:+ if state.get("cursor") is not None:+ manager.save_state(AlgoliaResumeConfig(cursor=state["cursor"]))+ elif config.pagination == PaginationStyle.OFFSET:+ if state.get("offset") is not None:+ manager.save_state(AlgoliaResumeConfig(offset=int(state["offset"])))+ elif state.get("page") is not None:+ manager.save_state(AlgoliaResumeConfig(page=int(state["page"])))- def save_checkpoint(state: Optional[dict[str, Any]]) -> None:- # Persist only when a next page remains; the hook fires AFTER a page is yielded so a crash- # re-yields the last page (merge dedupes on the primary key) rather than skipping it.- if not state:- return- if is_cursor:- if state.get("cursor") is not None:- manager.save_state(AlgoliaResumeConfig(cursor=state["cursor"]))- elif config.pagination == PaginationStyle.OFFSET:- if state.get("offset") is not None:- manager.save_state(AlgoliaResumeConfig(offset=int(state["offset"])))- elif state.get("page") is not None:- manager.save_state(AlgoliaResumeConfig(page=int(state["page"])))-- resource = rest_api_resource(- rest_config,- team_id,- job_id,- None,- resume_hook=save_checkpoint,- initial_paginator_state=initial_paginator_state,- )++def algolia_source(+ endpoint: str,+ application_id: str,+ api_key: str,+ index_name: str | None,+ team_id: int,+ job_id: str,+ manager: ResumableSourceManager[AlgoliaResumeConfig],+ region: str = "us",+ should_use_incremental_field: bool = False,+ db_incremental_field_last_value: Any = None,+ incremental_field: str | None = None,+) -> SourceResponse:+ config = ALGOLIA_ENDPOINTS[endpoint]++ if config.fanout is not None:+ items: Iterable[Any] = _fanout_items(+ config, config.fanout, application_id, api_key, index_name, team_id, job_id, manager, region+ )+ else:+ rest_config: RESTAPIConfig = {+ "client": _client_config(application_id, api_key, config, region),+ "resource_defaults": {},+ "resources": [+ {+ "name": endpoint,+ "endpoint": _endpoint_config(config, index_name, should_use_incremental_field, incremental_field),+ }+ ],+ }+ items = rest_api_resource(+ rest_config,+ team_id,+ job_id,+ db_incremental_field_last_value if should_use_incremental_field else None,+ resume_hook=lambda state: _save_resume_state(config, manager, state),+ initial_paginator_state=_resume_state(config, manager),+ )return SourceResponse(name=endpoint,- items=lambda: resource,+ items=lambda: items,primary_keys=config.primary_keys,- # Full-refresh endpoints with no stable datetime field to partition on.+ # Full-refresh endpoints with no stable datetime field to partition on. The daily+ # analytics tables stay unpartitioned too: they hold at most one row per day.partition_count=1,partition_size=1,+ # The time-series endpoints return their whole window in one response, so the watermark+ # is the max `date` of a single batch regardless of the order Algolia lists the days in.+ sort_mode="asc",)@@ -282,6 +425,11 @@ def validate_credentials(if config is None:config = ALGOLIA_ENDPOINTS["records"] if index_name else ALGOLIA_ENDPOINTS["indices"]+ # A fan-out endpoint's path carries a parameter resolved from its parent's rows, so there is+ # no URL to probe directly. The parent needs the same `analytics` ACL, so probe that instead.+ if config.fanout is not None:+ config = ALGOLIA_ENDPOINTS[config.fanout.parent_name]+# An index-scoped probe with no index name configured falls back to listing indices.if config.requires_index and not index_name:config = ALGOLIA_ENDPOINTS["indices"]@@ -295,8 +443,9 @@ def validate_credentials(session = make_tracked_session(redact_values=(api_key,))try:if config.api == AlgoliaApi.ANALYTICS:- # Confirm the `analytics` ACL with a one-row read against the analytics host.- params: dict[str, Any] = {"limit": 1}+ # Only the paginated breakdowns take `limit`, so sending one to a time-series+ # endpoint would be an undocumented param on an ACL probe.+ params: dict[str, Any] = {"limit": 1} if config.pagination == PaginationStyle.OFFSET else {}if config.requires_index and index_name:params["index"] = index_nameresponse = session.get(url, headers=headers, params=params, timeout=10)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/canonical_descriptions.pyindex 2d3fd49f116b..4699c9197cac 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/canonical_descriptions.py@@ -109,4 +109,117 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"decision": "Automatic decision on the test outcome, when available.",},},+ "conversion_rate": {+ "description": "Daily conversion rate for tracked searches on the index: conversion events "+ "divided by tracked searches.",+ "docs_url": "https://www.algolia.com/doc/rest-api/analytics/#tag/conversions/operation/getConversionRate",+ "columns": {+ "date": "Day the metrics cover, in YYYY-MM-DD format.",+ "rate": "Conversion rate for the day. Null when Algolia received no tracked searches.",+ "trackedSearchCount": "Number of searches that returned a query ID (click analytics enabled).",+ "conversionCount": "Number of conversion events attributed to searches on this day.",+ },+ },+ "add_to_cart_rate": {+ "description": "Daily add-to-cart rate for tracked searches on the index: add-to-cart events divided "+ "by tracked searches.",+ "docs_url": "https://www.algolia.com/doc/rest-api/analytics/#tag/conversions/operation/getAddToCartRate",+ "columns": {+ "date": "Day the metrics cover, in YYYY-MM-DD format.",+ "rate": "Add-to-cart rate for the day. Null when Algolia received no tracked searches.",+ "trackedSearchCount": "Number of searches that returned a query ID (click analytics enabled).",+ "addToCartCount": "Number of add-to-cart events attributed to searches on this day.",+ },+ },+ "purchase_rate": {+ "description": "Daily purchase rate for tracked searches on the index: purchase events divided by "+ "tracked searches.",+ "docs_url": "https://www.algolia.com/doc/rest-api/analytics/#tag/conversions/operation/getPurchaseRate",+ "columns": {+ "date": "Day the metrics cover, in YYYY-MM-DD format.",+ "rate": "Purchase rate for the day. Null when Algolia received no tracked searches.",+ "trackedSearchCount": "Number of searches that returned a query ID (click analytics enabled).",+ "purchaseCount": "Number of purchase events attributed to searches on this day.",+ },+ },+ "revenue": {+ "description": "Daily revenue attributed to searches on the index, from purchase events. Revenue is the "+ "event's price multiplied by quantity for each purchased object.",+ "docs_url": "https://www.algolia.com/doc/rest-api/analytics/#tag/conversions/operation/getRevenue",+ "columns": {+ "date": "Day the revenue covers, in YYYY-MM-DD format.",+ "currencies": "Revenue for the day keyed by currency code, each holding that currency's "+ "code and revenue amount.",+ },+ },+ "click_through_rate": {+ "description": "Daily click-through rate for tracked searches on the index: click events divided by "+ "tracked searches.",+ "docs_url": "https://www.algolia.com/doc/rest-api/analytics/#tag/clicks/operation/getClickThroughRate",+ "columns": {+ "date": "Day the metrics cover, in YYYY-MM-DD format.",+ "rate": "Click-through rate for the day. Null when there were no queries, 0 when there were "+ "queries but no click events.",+ "clickCount": "Number of clicks on search results on this day.",+ "trackedSearchCount": "Number of searches that returned a query ID (click analytics enabled).",+ },+ },+ "average_click_position": {+ "description": "Daily average position of clicked search results on the index. A value of 1 means users "+ "only clicked the first result.",+ "docs_url": "https://www.algolia.com/doc/rest-api/analytics/#tag/clicks/operation/getAverageClickPosition",+ "columns": {+ "date": "Day the metrics cover, in YYYY-MM-DD format.",+ "average": "Average position of the clicked results. Null until Algolia receives a click event.",+ "clickCount": "Number of clicks on search results on this day.",+ },+ },+ "users_count": {+ "description": "Daily count of unique users searching the index. Users are distinguished by their "+ "user token, or by IP address when no token is sent.",+ "docs_url": "https://www.algolia.com/doc/rest-api/analytics/#tag/analytics/operation/getUsersCount",+ "columns": {+ "date": "Day the count covers, in YYYY-MM-DD format.",+ "count": "Number of unique users on this day. Daily values do not sum to the period total, "+ "because a user active on several days counts once per day.",+ },+ },+ "top_filters": {+ "description": "Filter attributes used most often on the index over the recent period. Only attributes "+ "listed in the index's attributesForFaceting setting appear here.",+ "docs_url": "https://www.algolia.com/doc/rest-api/analytics/#tag/filters/operation/getTopFilterAttributes",+ "columns": {+ "attribute": "Name of the filter attribute.",+ "count": "Number of searches that applied a filter on this attribute.",+ },+ },+ "top_filter_values": {+ "description": "Filter values used most often for each filter attribute on the index over the recent "+ "period, one row per attribute/operator/value combination.",+ "docs_url": "https://www.algolia.com/doc/rest-api/analytics/#tag/filters/operation/getTopFilterForAttribute",+ "columns": {+ "attribute": "Name of the filter attribute the value belongs to.",+ "operator": "Character applying the filter, such as ':' for a facet filter or '>' for a numeric filter.",+ "value": "The filter value.",+ "count": "Number of searches that applied this attribute, operator and value together.",+ },+ },+ "top_countries": {+ "description": "Countries with the most searches on the index over the recent period.",+ "docs_url": "https://www.algolia.com/doc/rest-api/analytics/#tag/analytics/operation/getTopCountries",+ "columns": {+ "country": "Country code the searches came from.",+ "count": "Number of searches from this country.",+ },+ },+ "click_positions": {+ "description": "Clicks per position range in the index's search results over the recent period, so you "+ "can see how many clicks the first, second or tenth result received.",+ "docs_url": "https://www.algolia.com/doc/rest-api/analytics/#tag/clicks/operation/getClickPositions",+ "columns": {+ "position": "Range of result positions as [start, end]. Positions 11 and up are summed over "+ "the range, and -1 marks the end of the result list.",+ "clickCount": "Number of clicks on results in this position range.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/settings.pyindex 369a2e7c4857..0f10a7ee4a48 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/settings.py@@ -3,7 +3,11 @@ from enum import Enumfrom posthog.dataclasses import frozen-from products.warehouse_sources.backend.types import IncrementalField+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.fanout import (+ DependentEndpointConfig,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import incremental_field+from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldTypeclass PaginationStyle(Enum):@@ -13,6 +17,8 @@ class PaginationStyle(Enum):PAGE = "page"# Analytics and A/B testing endpoints page via `offset`/`limit`.OFFSET = "offset"+ # Analytics time-series and click-position endpoints answer the whole period at once.+ SINGLE = "single"class AlgoliaApi(Enum):@@ -32,7 +38,7 @@ class AlgoliaEndpointConfig:pagination: PaginationStyle# Key in the JSON response that holds the list of rows (`hits`, `items`, `searches`, `abtests`).data_selector: str- primary_keys: list[str] = field(default_factory=lambda: ["objectID"])+ primary_keys: list[str] | None = field(default_factory=lambda: ["objectID"])# Whether the endpoint targets a specific index (so it needs the `index_name` field).requires_index: bool = Trueshould_sync_default: bool = True@@ -43,13 +49,25 @@ class AlgoliaEndpointConfig:api: AlgoliaApi = AlgoliaApi.SEARCH# Request click/conversion metrics alongside the base analytics table (analytics endpoints only).click_analytics: bool = False+ # Query param carrying the incremental cursor. None means the endpoint is full refresh.+ start_param: str | None = None+ # Set when the path takes a parameter resolved from another endpoint's rows.+ fanout: DependentEndpointConfig | None = None+ @property+ def default_incremental_field(self) -> str | None:+ return self.incremental_fields[0]["field"] if self.incremental_fields else None-# All Algolia endpoints below are full-refresh: the index browse endpoint and the-# synonyms/rules search endpoints expose no server-side "updated since" filter, so an-# incremental sync would still page the whole resource. The cursor (browse) and page-# (search/list) tokens make every endpoint resumable, so a heartbeat timeout picks back-# up where it left off rather than restarting.++# Algolia keeps attributing events to recent days after those days close, so an incremental sync+# re-reads a trailing window from the stored watermark and merges it back on `date`.+ANALYTICS_LOOKBACK_DAYS = 3++_DATE_INCREMENTAL_FIELDS: list[IncrementalField] = [incremental_field("date", IncrementalFieldType.Date)]+++# Everything without a `start_param` is full refresh, because no server-side "updated since"+# filter exists for it. Its page token still makes it resumable after a heartbeat timeout.ALGOLIA_ENDPOINTS: dict[str, AlgoliaEndpointConfig] = {"records": AlgoliaEndpointConfig(name="records",@@ -144,6 +162,140 @@ ALGOLIA_ENDPOINTS: dict[str, AlgoliaEndpointConfig] = {should_sync_default=False,api=AlgoliaApi.ANALYTICS,),+ # Analytics API time series: one row per day, filtered forward from `startDate`.+ "conversion_rate": AlgoliaEndpointConfig(+ name="conversion_rate",+ path="/2/conversions/conversionRate",+ method="GET",+ pagination=PaginationStyle.SINGLE,+ data_selector="dates",+ primary_keys=["date"],+ should_sync_default=False,+ api=AlgoliaApi.ANALYTICS,+ start_param="startDate",+ incremental_fields=_DATE_INCREMENTAL_FIELDS,+ ),+ "add_to_cart_rate": AlgoliaEndpointConfig(+ name="add_to_cart_rate",+ path="/2/conversions/addToCartRate",+ method="GET",+ pagination=PaginationStyle.SINGLE,+ data_selector="dates",+ primary_keys=["date"],+ should_sync_default=False,+ api=AlgoliaApi.ANALYTICS,+ start_param="startDate",+ incremental_fields=_DATE_INCREMENTAL_FIELDS,+ ),+ "purchase_rate": AlgoliaEndpointConfig(+ name="purchase_rate",+ path="/2/conversions/purchaseRate",+ method="GET",+ pagination=PaginationStyle.SINGLE,+ data_selector="dates",+ primary_keys=["date"],+ should_sync_default=False,+ api=AlgoliaApi.ANALYTICS,+ start_param="startDate",+ incremental_fields=_DATE_INCREMENTAL_FIELDS,+ ),+ "revenue": AlgoliaEndpointConfig(+ name="revenue",+ path="/2/conversions/revenue",+ method="GET",+ pagination=PaginationStyle.SINGLE,+ data_selector="dates",+ primary_keys=["date"],+ should_sync_default=False,+ api=AlgoliaApi.ANALYTICS,+ start_param="startDate",+ incremental_fields=_DATE_INCREMENTAL_FIELDS,+ ),+ "click_through_rate": AlgoliaEndpointConfig(+ name="click_through_rate",+ path="/2/clicks/clickThroughRate",+ method="GET",+ pagination=PaginationStyle.SINGLE,+ data_selector="dates",+ primary_keys=["date"],+ should_sync_default=False,+ api=AlgoliaApi.ANALYTICS,+ start_param="startDate",+ incremental_fields=_DATE_INCREMENTAL_FIELDS,+ ),+ "average_click_position": AlgoliaEndpointConfig(+ name="average_click_position",+ path="/2/clicks/averageClickPosition",+ method="GET",+ pagination=PaginationStyle.SINGLE,+ data_selector="dates",+ primary_keys=["date"],+ should_sync_default=False,+ api=AlgoliaApi.ANALYTICS,+ start_param="startDate",+ incremental_fields=_DATE_INCREMENTAL_FIELDS,+ ),+ "users_count": AlgoliaEndpointConfig(+ name="users_count",+ path="/2/users/count",+ method="GET",+ pagination=PaginationStyle.SINGLE,+ data_selector="dates",+ primary_keys=["date"],+ should_sync_default=False,+ api=AlgoliaApi.ANALYTICS,+ start_param="startDate",+ incremental_fields=_DATE_INCREMENTAL_FIELDS,+ ),+ # Analytics API breakdowns: a "top N over the period" snapshot with no date column.+ "top_filters": AlgoliaEndpointConfig(+ name="top_filters",+ path="/2/filters",+ method="GET",+ pagination=PaginationStyle.OFFSET,+ data_selector="attributes",+ primary_keys=["attribute"],+ should_sync_default=False,+ api=AlgoliaApi.ANALYTICS,+ ),+ "top_filter_values": AlgoliaEndpointConfig(+ name="top_filter_values",+ path="/2/filters/{attribute}",+ method="GET",+ pagination=PaginationStyle.OFFSET,+ data_selector="values",+ # Every child row repeats the attribute, so the key is unique table-wide, not per parent.+ primary_keys=["attribute", "operator", "value"],+ should_sync_default=False,+ api=AlgoliaApi.ANALYTICS,+ fanout=DependentEndpointConfig(+ parent_name="top_filters",+ resolve_param="attribute",+ resolve_field="attribute",+ include_from_parent=[],+ ),+ ),+ "top_countries": AlgoliaEndpointConfig(+ name="top_countries",+ path="/2/countries",+ method="GET",+ pagination=PaginationStyle.OFFSET,+ data_selector="countries",+ primary_keys=["country"],+ should_sync_default=False,+ api=AlgoliaApi.ANALYTICS,+ ),+ "click_positions": AlgoliaEndpointConfig(+ name="click_positions",+ path="/2/clicks/positions",+ method="GET",+ pagination=PaginationStyle.SINGLE,+ data_selector="positions",+ # A row's only identity is its `position` range, which arrives as a two-element array.+ primary_keys=None,+ should_sync_default=False,+ api=AlgoliaApi.ANALYTICS,+ ),}ENDPOINTS = tuple(ALGOLIA_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/source.pyindex 170853f2a13b..7c6371ee0602 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/source.py@@ -19,6 +19,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.algolia.alfrom products.warehouse_sources.backend.temporal.data_imports.sources.algolia.settings import (ALGOLIA_ENDPOINTS,ENDPOINTS,+ INCREMENTAL_FIELDS,)from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, ResumableSourcefrom products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (@@ -46,6 +47,17 @@ _ENDPOINT_DESCRIPTIONS: dict[str, str] = {"searches_no_results": "Most frequent searches on the index that returned zero results. Full refresh only.","searches_no_clicks": "Most frequent searches on the index that received no clicks. Full refresh only.","ab_tests": "A/B tests configured on the application, with per-variant results. Full refresh only.",+ "conversion_rate": "Daily conversion rate on the index, with tracked search and conversion counts.",+ "add_to_cart_rate": "Daily add-to-cart rate on the index, with tracked search and add-to-cart counts.",+ "purchase_rate": "Daily purchase rate on the index, with tracked search and purchase counts.",+ "revenue": "Daily revenue attributed to searches on the index, broken down by currency.",+ "click_through_rate": "Daily click-through rate on the index, with click and tracked search counts.",+ "average_click_position": "Daily average position of clicked search results on the index.",+ "users_count": "Daily count of unique users searching the index.",+ "top_filters": "Most frequently used filter attributes on the index. Full refresh only.",+ "top_filter_values": "Most frequent filter values for each filter attribute on the index. Full refresh only.",+ "top_countries": "Countries with the most searches on the index. Full refresh only.",+ "click_positions": "Clicks per position range in the index's search results. Full refresh only.",}@@ -72,7 +84,7 @@ The API key needs the ACLs for the data you want to sync:- `browse` — index records- `settings` — synonyms and query rules- `listIndexes` — the list of indices-- `analytics` — top searches, top hits, zero-result/zero-click searches, and A/B tests+- `analytics` — search, click, conversion and revenue metrics, filter and country breakdowns, and A/B testsSet the region to match where your Algolia application is hosted. It selects the analytics host used for the analytics and A/B test tables.""",@@ -142,14 +154,13 @@ Set the region to match where your Algolia application is hosted. It selects theforce_refresh: bool = False,api_version: str | None = None,) -> list[SourceSchema]:- # No Algolia endpoint exposes a server-side "updated since" filter, so every table is- # full refresh (no incremental fields); the cursor/page tokens still make each one- # resumable. An empty mapping keeps every endpoint full refresh, since- # `build_endpoint_schemas` treats any present entry as incremental.+ # `merge_only` covers every endpoint because Algolia restates recent days as late+ # events arrive, so a re-read has to update those rows rather than append a copy.return build_endpoint_schemas(ENDPOINTS,- {},+ INCREMENTAL_FIELDS,names,+ merge_only=ENDPOINTS,descriptions=_ENDPOINT_DESCRIPTIONS,should_sync_default={name: cfg.should_sync_default for name, cfg in ALGOLIA_ENDPOINTS.items()},)@@ -187,6 +198,9 @@ Set the region to match where your Algolia application is hosted. It selects thejob_id=inputs.job_id,manager=resumable_source_manager,region=config.region,+ should_use_incremental_field=inputs.should_use_incremental_field,+ db_incremental_field_last_value=inputs.db_incremental_field_last_value,+ incremental_field=inputs.incremental_field,)def get_canonical_descriptions(self) -> CanonicalDescriptions:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/tests/test_algolia.py b/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/tests/test_algolia.pyindex bdfb8f1f5559..25fd95dd0c2a 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/tests/test_algolia.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/tests/test_algolia.py@@ -1,5 +1,6 @@import jsonimport dataclasses+from datetime import UTC, date, datetimefrom typing import Anyimport pytest@@ -13,6 +14,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.algolia.alInvalidApplicationIdError,_base_url,_endpoint_url,+ _to_start_date,algolia_source,validate_credentials,)@@ -67,7 +69,15 @@ def _wire(session: mock.MagicMock, responses: list[Response]) -> list[dict[str,return snapshots-def _build(endpoint: str, manager: mock.MagicMock, index_name: str | None = "idx", region: str = "us") -> Any:+def _build(+ endpoint: str,+ manager: mock.MagicMock,+ index_name: str | None = "idx",+ region: str = "us",+ should_use_incremental_field: bool = False,+ db_incremental_field_last_value: Any = None,+ incremental_field: str | None = None,+) -> Any:return algolia_source(endpoint=endpoint,application_id="APP",@@ -77,6 +87,9 @@ def _build(endpoint: str, manager: mock.MagicMock, index_name: str | None = "idxjob_id="job",manager=manager,region=region,+ should_use_incremental_field=should_use_incremental_field,+ db_incremental_field_last_value=db_incremental_field_last_value,+ incremental_field=incremental_field,)@@ -408,6 +421,35 @@ class TestValidateCredentials:assert args[0] == "https://analytics.de.algolia.com/2/searches"assert kwargs["params"]["index"] == "idx"+ def test_fanout_schema_probe_targets_the_parent_listing(self) -> None:+ with mock.patch(ALGOLIA_SESSION_PATCH) as factory:+ session = factory.return_value+ session.get.return_value = _response({}, status_code=200)+ valid, error = validate_credentials(+ application_id="APP",+ api_key="key",+ index_name="idx",+ schema_name="top_filter_values",+ )+ assert valid is True and error is None+ args, kwargs = session.get.call_args+ assert args[0] == "https://analytics.algolia.com/2/filters"+ assert kwargs["params"]["limit"] == 1++ def test_time_series_schema_probe_sends_no_limit(self) -> None:+ with mock.patch(ALGOLIA_SESSION_PATCH) as factory:+ session = factory.return_value+ session.get.return_value = _response({}, status_code=200)+ validate_credentials(+ application_id="APP",+ api_key="key",+ index_name="idx",+ schema_name="conversion_rate",+ )+ args, kwargs = session.get.call_args+ assert args[0] == "https://analytics.algolia.com/2/conversions/conversionRate"+ assert kwargs["params"] == {"index": "idx"}+def test_invalid_application_id_rejected_before_request(self) -> None:with mock.patch(ALGOLIA_SESSION_PATCH) as factory:valid, error = validate_credentials(application_id="evil.com/", api_key="key", index_name="idx")@@ -455,3 +497,180 @@ class TestValidateCredentials:valid, error = self._run(resp, index_name="idx")assert valid is Falseassert error is not None and "502" in error+++class TestStartDate:+ @pytest.mark.parametrize(+ "value,expected",+ [+ # The watermark reaches a source as whatever the pipeline persisted, and the lookback+ # walks it back so days Algolia is still counting events for get re-read and merged.+ ("2026-03-20", "2026-03-17"),+ (datetime(2026, 3, 20, 11, 30, tzinfo=UTC), "2026-03-17"),+ (date(2026, 3, 20), "2026-03-17"),+ # No watermark yet, or one we can't read: send no floor and take Algolia's own window+ # rather than a date its analytics retention may reject.+ (None, None),+ ("not a date", None),+ ],+ )+ def test_floors_watermark_by_the_lookback_window(self, value: Any, expected: str | None) -> None:+ assert _to_start_date(value) == expected+++class TestTimeSeriesEndpoints:+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_full_refresh_reads_the_whole_window_in_one_request(self, MockSession: mock.MagicMock) -> None:+ session = MockSession.return_value+ manager = _make_manager()+ calls = _wire(+ session,+ [+ _response(+ {+ "rate": 0.2,+ "trackedSearchCount": 10,+ "conversionCount": 2,+ "dates": [+ {"date": "2026-03-18", "rate": 0.1, "trackedSearchCount": 5, "conversionCount": 1},+ {"date": "2026-03-19", "rate": 0.3, "trackedSearchCount": 5, "conversionCount": 1},+ ],+ }+ )+ ],+ )++ rows = _rows(_build("conversion_rate", manager))++ # Rows come from the daily breakdown, not the period totals wrapping it.+ assert [r["date"] for r in rows] == ["2026-03-18", "2026-03-19"]+ assert len(calls) == 1+ assert calls[0]["url"] == "https://analytics.algolia.com/2/conversions/conversionRate"+ assert calls[0]["params"] == {"index": "idx"}+ # Nothing to page through, so nothing to resume from.+ manager.save_state.assert_not_called()++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_incremental_sync_sends_start_date_from_the_watermark(self, MockSession: mock.MagicMock) -> None:+ session = MockSession.return_value+ calls = _wire(session, [_response({"dates": [{"date": "2026-03-19", "count": 4}]})])++ _rows(+ _build(+ "users_count",+ _make_manager(),+ should_use_incremental_field=True,+ db_incremental_field_last_value="2026-03-19",+ incremental_field="date",+ )+ )++ assert calls[0]["params"]["startDate"] == "2026-03-16"++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_first_incremental_sync_omits_start_date(self, MockSession: mock.MagicMock) -> None:+ # A None cursor is dropped by the client, leaving Algolia's own default period.+ session = MockSession.return_value+ calls = _wire(session, [_response({"dates": []})])++ _rows(+ _build(+ "users_count",+ _make_manager(),+ should_use_incremental_field=True,+ db_incremental_field_last_value=None,+ incremental_field="date",+ )+ )++ assert "startDate" not in calls[0]["params"]++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_full_refresh_ignores_a_stored_watermark(self, MockSession: mock.MagicMock) -> None:+ session = MockSession.return_value+ calls = _wire(session, [_response({"dates": []})])++ _rows(_build("users_count", _make_manager(), db_incremental_field_last_value="2026-03-19"))++ assert "startDate" not in calls[0]["params"]++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_click_positions_reads_the_position_distribution(self, MockSession: mock.MagicMock) -> None:+ session = MockSession.return_value+ calls = _wire(+ session,+ [+ _response(+ {"positions": [{"position": [1, 1], "clickCount": 9}, {"position": [21, -1], "clickCount": 1}]}+ )+ ],+ )++ rows = _rows(_build("click_positions", _make_manager()))++ assert [r["position"] for r in rows] == [[1, 1], [21, -1]]+ assert len(calls) == 1+++class TestTopFilterValuesFanout:+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_requests_each_filter_attribute_from_the_parent_listing(self, MockSession: mock.MagicMock) -> None:+ session = MockSession.return_value+ calls = _wire(+ session,+ [+ _response({"attributes": [{"attribute": "brand", "count": 7}, {"attribute": "a/b", "count": 2}]}),+ _response({"values": [{"attribute": "brand", "operator": ":", "value": "acme", "count": 5}]}),+ _response({"values": [{"attribute": "a/b", "operator": ":", "value": "x", "count": 1}]}),+ ],+ )++ rows = _rows(_build("top_filter_values", _make_manager()))++ assert [(r["attribute"], r["value"]) for r in rows] == [("brand", "acme"), ("a/b", "x")]+ assert calls[0]["url"] == "https://analytics.algolia.com/2/filters"+ # The attribute is bound into the child path percent-encoded, so a name containing a+ # slash can't escape the endpoint it belongs to.+ assert calls[1]["url"] == "https://analytics.algolia.com/2/filters/brand"+ assert calls[2]["url"] == "https://analytics.algolia.com/2/filters/a%2Fb"+ assert all(call["params"]["index"] == "idx" for call in calls)++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_checkpoints_completed_attributes_and_resumes_from_them(self, MockSession: mock.MagicMock) -> None:+ session = MockSession.return_value+ manager = _make_manager()+ _wire(+ session,+ [+ _response({"attributes": [{"attribute": "brand"}, {"attribute": "color"}]}),+ _response({"values": [{"attribute": "brand", "operator": ":", "value": "acme"}]}),+ _response({"values": [{"attribute": "color", "operator": ":", "value": "red"}]}),+ ],+ )++ _rows(_build("top_filter_values", manager))++ completed = [call.args[0].fanout["completed"] for call in manager.save_state.call_args_list]+ assert completed[-1] == ["/2/filters/brand", "/2/filters/color"]++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_resume_skips_attributes_already_synced(self, MockSession: mock.MagicMock) -> None:+ session = MockSession.return_value+ manager = _make_manager(+ AlgoliaResumeConfig(fanout={"completed": ["/2/filters/brand"], "current": None, "child_state": None})+ )+ calls = _wire(+ session,+ [+ _response({"attributes": [{"attribute": "brand"}, {"attribute": "color"}]}),+ _response({"values": [{"attribute": "color", "operator": ":", "value": "red"}]}),+ ],+ )++ rows = _rows(_build("top_filter_values", manager))++ assert [r["attribute"] for r in rows] == ["color"]+ assert [c["url"] for c in calls] == [+ "https://analytics.algolia.com/2/filters",+ "https://analytics.algolia.com/2/filters/color",+ ]diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/tests/test_algolia_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/tests/test_algolia_source.pyindex 5a44925a0c9b..8ea038c591ee 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/tests/test_algolia_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/algolia/tests/test_algolia_source.py@@ -1,4 +1,7 @@-from products.warehouse_sources.backend.temporal.data_imports.sources.algolia.settings import ENDPOINTS+from products.warehouse_sources.backend.temporal.data_imports.sources.algolia.settings import (+ ALGOLIA_ENDPOINTS,+ ENDPOINTS,+)from products.warehouse_sources.backend.temporal.data_imports.sources.algolia.source import AlgoliaSourcefrom products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.algolia import (AlgoliaSourceConfig,@@ -16,12 +19,19 @@ class TestAlgoliaSource:# it must force the key to be re-entered.assert self.source.connection_host_fields == ["application_id"]- def test_get_schemas_all_full_refresh(self) -> None:- schemas = self.source.get_schemas(self.config, self.team_id)+ def test_incremental_endpoints_declare_a_server_side_date_filter(self) -> None:+ # An endpoint that advertises incremental sync without a `startDate` to bind the cursor+ # to would re-read its whole period every run while reporting itself as incremental.+ for name, config in ALGOLIA_ENDPOINTS.items():+ assert bool(config.incremental_fields) == (config.start_param is not None), name++ def test_get_schemas_offers_merge_but_never_append(self) -> None:+ schemas = {schema.name: schema for schema in self.source.get_schemas(self.config, self.team_id)}- assert {s.name for s in schemas} == set(ENDPOINTS)- # No Algolia endpoint exposes a server-side updated-since filter, so every schema is- # full refresh only.- assert all(not s.supports_incremental for s in schemas)- assert all(not s.supports_append for s in schemas)- assert all(s.incremental_fields == [] for s in schemas)+ assert set(schemas) == set(ENDPOINTS)+ # Each sync re-reads a trailing window, so appending would store each day twice.+ assert all(not schema.supports_append for schema in schemas.values())+ assert schemas["conversion_rate"].supports_incremental+ assert [f["field"] for f in schemas["conversion_rate"].incremental_fields] == ["date"]+ assert not schemas["records"].supports_incremental+ assert not schemas["top_filters"].supports_incremental