: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
from products.warehouse_sources.sources.sdk import DependentEndpointConfig
# Lattice's default page size is only 10; always request the max of 100.
PAGE_SIZE = 100
# Reviews and reviewees only exist per review cycle, so they fan out over `/v1/reviewCycles`.
REVIEW_CYCLE_FANOUT = DependentEndpointConfig(
parent_name="review_cycles",
resolve_param="review_cycle_id",
resolve_field="id",
include_from_parent=["id"],
parent_field_renames={"id": "review_cycle_id"},
)
# Tasks and custom attributes are only listed per user, so they fan out over `/v1/users`.
USER_FANOUT = DependentEndpointConfig(
parent_name="users",
resolve_param="user_id",
resolve_field="id",
include_from_parent=["id"],
parent_field_renames={"id": "user_id"},
)
@dataclass(frozen=False)
class LatticeEndpointConfig:
name: str
path: str
primary_keys: list[str] = field(default_factory=lambda: ["id"])
fanout: DependentEndpointConfig | None = None
page_size: int = PAGE_SIZE
incremental_fields: list[Any] = field(default_factory=list)
default_incremental_field: str | None = None
# The Lattice Talent API v1 has no server-side incremental filters on any list
# endpoint (Fivetran's connector re-imports every table each sync for the same
# reason), so every stream is an honest full refresh.
LATTICE_ENDPOINTS: dict[str, LatticeEndpointConfig] = {
"users": LatticeEndpointConfig(
name="users",
path="/v1/users",
),
"departments": LatticeEndpointConfig(
name="departments",
path="/v1/departments",
),
"goals": LatticeEndpointConfig(
name="goals",
path="/v1/goals",
),
"goal_updates": LatticeEndpointConfig(
name="goal_updates",
path="/v1/goals/updates",
# The numeric `id` is not documented as unique; `entityId` is the update's UUID.
primary_keys=["entityId"],
),
"feedbacks": LatticeEndpointConfig(
name="feedbacks",
path="/v1/feedbacks",
),
"review_cycles": LatticeEndpointConfig(
name="review_cycles",
path="/v1/reviewCycles",
),
"reviewees": LatticeEndpointConfig(
name="reviewees",
path="/v1/reviewCycle/{review_cycle_id}/reviewees",
fanout=REVIEW_CYCLE_FANOUT,
),
"reviews": LatticeEndpointConfig(
name="reviews",
path="/v1/reviewCycle/{review_cycle_id}/reviews",
# Unlike reviewees, reviews have no fetch-by-id endpoint, so the id is only known
# to be unique within its cycle.
primary_keys=["review_cycle_id", "id"],
fanout=REVIEW_CYCLE_FANOUT,
),
"tags": LatticeEndpointConfig(
name="tags",
path="/v1/tags",
),
"updates": LatticeEndpointConfig(
name="updates",
path="/v1/updates",
),
"user_tasks": LatticeEndpointConfig(
name="user_tasks",
path="/v1/user/{user_id}/tasks",
primary_keys=["user_id", "id"],
fanout=USER_FANOUT,
),
"user_custom_attributes": LatticeEndpointConfig(
name="user_custom_attributes",
path="/v1/user/{user_id}/customAttributes",
# Rows only nest the attribute and value objects, so their ids are lifted into top-level key columns.
primary_keys=["user_id", "custom_attribute_id", "custom_attribute_value_id"],
fanout=USER_FANOUT,
),
}
ENDPOINTS = tuple(LATTICE_ENDPOINTS.keys())