: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 products.warehouse_sources.sources.sdk import IncrementalField, IncrementalFieldType, incremental_field
ZAPSIGN_BASE_URL = "https://api.zapsign.com.br"
ZAPSIGN_SANDBOX_BASE_URL = "https://sandbox.api.zapsign.com.br"
DOCUMENTS_RESOURCE = "documents"
TEMPLATES_RESOURCE = "templates"
SIGNERS_RESOURCE = "signers"
AUDIT_TRAIL_RESOURCE = "audit_trail"
USERS_RESOURCE = "users"
SIGNER_VERIFICATIONS_RESOURCE = "signer_verifications"
ENDPOINTS = (
DOCUMENTS_RESOURCE,
TEMPLATES_RESOURCE,
SIGNERS_RESOURCE,
AUDIT_TRAIL_RESOURCE,
USERS_RESOURCE,
SIGNER_VERIFICATIONS_RESOURCE,
)
# Only the documents list exposes a server-side time filter (`created_from`/`created_to`, on the
# creation date). ZapSign has no `updated_at` filter anywhere, so `created_at` is the sole
# incremental cursor; every other endpoint is full refresh only.
INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {
DOCUMENTS_RESOURCE: [incremental_field("created_at", IncrementalFieldType.DateTime)],
TEMPLATES_RESOURCE: [],
SIGNERS_RESOURCE: [],
AUDIT_TRAIL_RESOURCE: [],
USERS_RESOURCE: [],
SIGNER_VERIFICATIONS_RESOURCE: [],
}
ENDPOINT_PATHS: dict[str, str] = {
DOCUMENTS_RESOURCE: "/api/v1/docs/",
TEMPLATES_RESOURCE: "/api/v1/templates/",
USERS_RESOURCE: "/api/v1/users/",
}
# Signers have no list endpoint of their own — they're read from each document's detail response.
DOCUMENT_DETAIL_PATH = "/api/v1/docs/{token}/"
AUDIT_TRAIL_PATH = "/api/v1/docs/signer-log/{token}"
SIGNER_VERIFICATION_PATH = "/api/v1/signer-verification-details/{token}/"
PRIMARY_KEYS: dict[str, list[str]] = {
DOCUMENTS_RESOURCE: ["token"],
TEMPLATES_RESOURCE: ["token"],
# Signer tokens look globally unique, but ZapSign doesn't document that guarantee, so the
# parent document token stays in the key (`_documents_token` is injected by the fan-out).
SIGNERS_RESOURCE: ["_documents_token", "token"],
# Audit trail events carry no id of their own.
AUDIT_TRAIL_RESOURCE: ["_documents_token", "time", "event"],
# Account users carry no id; the email is what documents reference in `created_by`.
USERS_RESOURCE: ["email"],
# The verification endpoint is addressed by the signer token alone, so it identifies the row.
SIGNER_VERIFICATIONS_RESOURCE: ["_signers_token"],
}
# `created_at` never changes after creation, unlike `last_update_at`, so partitions stay stable.
PARTITION_KEYS: dict[str, list[str]] = {
DOCUMENTS_RESOURCE: ["created_at"],
TEMPLATES_RESOURCE: ["created_at"],
AUDIT_TRAIL_RESOURCE: ["time"],
}
# String timestamp columns coerced to datetimes by the framework's `convert_types`.
TIMESTAMP_COLUMNS: dict[str, tuple[str, ...]] = {
DOCUMENTS_RESOURCE: ("created_at", "last_update_at"),
TEMPLATES_RESOURCE: ("created_at", "last_update_at"),
SIGNERS_RESOURCE: ("last_view_at", "signed_at"),
AUDIT_TRAIL_RESOURCE: ("time",),
}