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.0 KB
Raw Blame
from typing import Literal

from products.warehouse_sources.sources.sdk import IncrementalField, frozen

BASE_URL = "https://api.onesignal.com"
INITIAL_TIME_OFFSET = "1970-01-01T00:00:00.000Z"


@frozen
class OneSignalEndpoint:
    path: str
    data_selector: str
    page_size: int
    pagination: Literal["cursor", "offset"]
    partition_key: str
    primary_keys: tuple[str, ...] = ("id",)
    incremental_fields: tuple[IncrementalField, ...] = ()


# The time filter is unverified with an account. Full refresh also updates changing message delivery totals.
ONESIGNAL_ENDPOINTS: dict[str, OneSignalEndpoint] = {
    "notifications": OneSignalEndpoint(
        path="/notifications",
        data_selector="notifications",
        page_size=50,
        pagination="cursor",
        partition_key="queued_at",
    ),
    "segments": OneSignalEndpoint(
        path="/apps/{app_id}/segments",
        data_selector="segments",
        page_size=300,
        pagination="offset",
        partition_key="created_at",
    ),
}