: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 dataclass, field
from typing import Any, Optional
from products.warehouse_sources.sources.sdk import DependentEndpointConfig
# The list endpoints accept pageSize 1..100; 100 minimises round trips.
PAGE_SIZE = 100
@dataclass(frozen=True)
class HumanitixEndpointConfig:
name: str
path: str
# Key of the row array in the paginated response envelope; it differs per endpoint
# (e.g. `events` for /events, `tags` for /tags) even though the envelope shape is identical.
# None for an endpoint that returns a single object instead of a list.
list_key: Optional[str] = None
# Humanitix objects are Mongo documents, so `_id` is a stable, globally unique primary key.
primary_keys: list[str] = field(default_factory=lambda: ["_id"])
# A stable (never-rewritten) datetime field to partition by.
partition_key: Optional[str] = None
# Set for endpoints nested under a parent resource, fetched once per parent row.
fanout: Optional[DependentEndpointConfig] = None
# Read by the shared fan-out builder. Every endpoint is full refresh, so no incremental fields.
incremental_fields: list[Any] = field(default_factory=list)
default_incremental_field: Optional[str] = None
page_size: int = PAGE_SIZE
# Set for endpoints fetched once per event date. The dates come from each event's `dates` array,
# so the shared single-hop fan-out builder can't express this.
per_event_date: bool = False
# Orders and tickets are only listed per event. Fan out over `/events` and stamp the parent event id
# onto each row, so `eventId` is always present (it is optional on orders) and scopes the key.
_EVENT_FANOUT = DependentEndpointConfig(
parent_name="events",
resolve_param="eventId",
resolve_field="_id",
include_from_parent=["_id"],
parent_field_renames={"_id": "eventId"},
)
# Humanitix Public API list endpoints. `/events` and `/tags` are account-scoped top-level lists;
# orders and tickets fan out per event, and check-in counts per event date. The `/global/*`
# endpoints return the public marketplace catalog rather than the account's own data, so they are
# not exposed here.
# All are full refresh only. Orders and tickets accept a `since` filter, but the API does not say
# which timestamp it compares, so a cursor on `updatedAt` could silently miss refunds and cancellations.
HUMANITIX_ENDPOINTS: dict[str, HumanitixEndpointConfig] = {
"events": HumanitixEndpointConfig(name="events", path="/events", list_key="events"),
"tags": HumanitixEndpointConfig(name="tags", path="/tags", list_key="tags"),
"orders": HumanitixEndpointConfig(
name="orders",
path="/events/{eventId}/orders",
list_key="orders",
primary_keys=["eventId", "_id"],
partition_key="createdAt",
fanout=_EVENT_FANOUT,
),
"tickets": HumanitixEndpointConfig(
name="tickets",
path="/events/{eventId}/tickets",
list_key="tickets",
primary_keys=["eventId", "_id"],
partition_key="createdAt",
fanout=_EVENT_FANOUT,
),
# Beta endpoint that returns one check-in summary object per event date, so it has no list key.
"check_in_counts": HumanitixEndpointConfig(
name="check_in_counts",
path="/events/{eventId}/check-in-count",
primary_keys=["eventId", "eventDateId"],
per_event_date=True,
),
}
ENDPOINTS = tuple(HUMANITIX_ENDPOINTS.keys())
INCREMENTAL_FIELDS: dict[str, list] = {}