: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 datetime import timedelta
from products.warehouse_sources.sources.sdk import Endpoint, IncrementalField, IncrementalFieldType
API_VERSION = "v2"
BASE_URL = f"https://api.axiom.co/{API_VERSION}/"
PAGE_SIZE = 100
PRIMARY_KEYS = ["id"]
ENDPOINTS: dict[str, Endpoint] = {
"datasets": {"path": "datasets", "paginator": "single_page"},
"monitors": {"path": "monitors", "paginator": "single_page"},
"annotations": {"path": "annotations", "paginator": "single_page"},
"dashboards": {
"path": "dashboards",
"paginator": {"type": "offset", "limit": PAGE_SIZE, "total_path": None},
},
"saved_queries": {
"path": "apl-starred-queries",
"params": {"who": "all"},
"paginator": {"type": "offset", "limit": PAGE_SIZE, "total_path": None},
},
"users": {"path": "users", "paginator": "single_page"},
"groups": {"path": "rbac/groups", "paginator": "single_page"},
}
MONITOR_HISTORY = "monitor_history"
# The history API returns one identical row per notifier and email recipient, so the key adds the
# position of each row among the rows that share the other key values.
MONITOR_HISTORY_PRIMARY_KEYS = ["checkId", "timestamp", "state", "deliveryIndex"]
# The endpoint has no pagination, so a bounded window keeps each response small.
MONITOR_HISTORY_WINDOW = timedelta(days=7)
# Start of the first window when a monitor has no createdAt value.
MONITOR_HISTORY_DEFAULT_LOOKBACK = timedelta(days=90)
INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {
MONITOR_HISTORY: [
IncrementalField(
label="timestamp",
type=IncrementalFieldType.DateTime,
field="timestamp",
field_type=IncrementalFieldType.DateTime,
)
],
}
AUTH_ERRORS = {
401: "Axiom rejected the token. Check that the token is valid and has not expired.",
403: "Axiom denied access. Check the token permissions and the organization ID for personal access tokens.",
}