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.

1.1 KB
Raw Blame
from products.warehouse_sources.sources.sdk import IncrementalField, IncrementalFieldType, frozen

API_VERSION = "2026-10-12"
PAGE_SIZE = 100
DISCOVERY_QUERY = 'array::unique(*[!(_type match "system.*") && !(_id in path("_.**"))]._type)'


@frozen
class SanityEndpoint:
    document_type: str
    primary_keys: tuple[str, ...] = ("_id",)
    partition_key: str = "_createdAt"
    incremental_field: str = "_updatedAt"


ENDPOINTS: dict[str, SanityEndpoint] = {
    "sanity.fileAsset": SanityEndpoint(document_type="sanity.fileAsset"),
    "sanity.imageAsset": SanityEndpoint(document_type="sanity.imageAsset"),
}


def document_endpoint(document_type: str) -> SanityEndpoint:
    return ENDPOINTS.get(document_type) or SanityEndpoint(document_type=document_type)


def incremental_fields(endpoint: SanityEndpoint) -> list[IncrementalField]:
    return [
        {
            "label": endpoint.incremental_field,
            "type": IncrementalFieldType.DateTime,
            "field": endpoint.incremental_field,
            "field_type": IncrementalFieldType.DateTime,
        }
    ]