: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
feat(data-warehouse): add 5 missing tables to the Kustomer source (#118887)
Tom Owers7b49dba0f24b
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.mdindex b6d64a05bd40..d81d4d065292 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/COVERAGE_GAPS_APPENDIX.md@@ -6989,18 +6989,18 @@ Note: All four PostHog tables come from just two paths (/model/allocation with t## Kustomer — gaps-Today (9): `brands`, `companies`, `conversations`, `customers`, `satisfaction_forms`, `sub_statuses`, `tags`, `teams`, `users`+Today (14): `brands`, `companies`, `conversations`, `customers`, `messages`, `notes`, `queues`, `satisfaction_forms`, `sub_statuses`, `tags`, `teams`, `users`, `work_items`, `work_sessions`Diffed against: <https://developer.kustomer.com/sitemap.xml>-- [ ] `GET /v1/messages (getmessages)` — the message body of every conversation; conversations without messages cannot answer response-content questions (high)+- [x] `GET /v1/messages (getmessages)` — the message body of every conversation; conversations without messages cannot answer response-content questions (high) → `messages`- [ ] `GET /v1/customers/{id}/events (getallcustomerevents) and GET /v1/conversations/{id}/events (getconversationevents)` — state-transition history for the conversations and customers already synced (high). Not added: `getallcustomerevents` is deprecated and returns 404, and `getconversationevents` is per conversation with no updated-since filter on the parent list, so every full-refresh sync would make one or more requests per conversation against the org's shared rate limit.- [x] `GET /v1/satisfaction and satisfaction responses (getsatisfaction, getsatisfactionresponse)` — CSAT is the headline support metric and is entirely absent (high). Added as `satisfaction_forms` (`GET /v1/satisfaction` lists survey forms, not responses). `getsatisfactionresponse` skipped: it reads one response by id and there is no list endpoint.- [x] `GET /v1/companies (getcompanies)` — lookup resolving the company a customer belongs to for account-level support reporting (high) → `companies`- [x] `GET /v1/substatuses (getsubstatuses)` — lookup resolving the sub-status id carried on every conversation row (high) → `sub_statuses` (the real path is `GET /v1/sub-statuses?resource=conversation`)-- [ ] `GET /v1/queues (getqueues) and queue metrics (queuemetrics)` — lookup for routing queues plus the queue-depth metric behind SLA reporting (medium)-- [ ] `GET /v1/notes (getnotesfororg)` — internal agent notes attached to conversations and customers (medium)-- [ ] `GET /v1/work-items (getworkitems) and work sessions (getworksessions)` — agent handling time and routing assignment history (medium)+- [x] `GET /v1/queues (getqueues) and queue metrics (queuemetrics)` — lookup for routing queues plus the queue-depth metric behind SLA reporting (medium) → `queues` (the real path is `GET /v1/routing/queues`). `queuemetrics` skipped: it is a point-in-time wait-time snapshot read per queue id from `GET /v1/chat/queues/metrics/{ids}`, with no history to sync.+- [x] `GET /v1/notes (getnotesfororg)` — internal agent notes attached to conversations and customers (medium) → `notes`+- [x] `GET /v1/work-items (getworkitems) and work sessions (getworksessions)` — agent handling time and routing assignment history (medium) → `work_items` and `work_sessions` (the real paths are `GET /v1/routing/work-items` and `GET /v1/routing/work-sessions`)- [ ] `conversation time metrics (getconversationtimesbyconversationid, getv2conversationtimesbyconversationid)` — first-response and resolution durations per conversation (medium)- [ ] `GET /v1/kobjects and /v1/klasses (getkobjects, getklasses)` — custom objects and their schema, where Kustomer tenants put order/subscription data (medium)- [ ] `GET /v1/routing/user-statuses (getroutinguserstatuses)` — agent availability state over time for staffing analysis (medium)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/kustomer/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/kustomer/canonical_descriptions.pyindex d99359f9dbee..061d3cecb024 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/kustomer/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/kustomer/canonical_descriptions.py@@ -137,4 +137,76 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {criteria="Conditions a conversation must meet for the survey to be sent.",),},+ "messages": {+ "description": "A single message sent or received in a conversation, on any channel.",+ "docs_url": "https://developer.kustomer.com/kustomer-api-docs/reference/getmessages",+ "columns": _columns(+ channel="Channel the message was sent on (e.g. email, chat, sms).",+ app="App or integration that delivered the message.",+ direction="Whether the message is inbound from the customer ('in') or outbound from your team ('out').",+ preview="Short plain-text preview of the message body.",+ size="Size of the message.",+ status="Delivery status of the message (e.g. received, sent).",+ meta="Channel-specific metadata, such as the email subject, sender and recipients.",+ sentiment="Sentiment information derived for the message.",+ externalId="Identifier of the message in the external channel, if any.",+ sentAt="Time at which the message was sent.",+ ),+ },+ "notes": {+ "description": "An internal note that an agent added to a conversation or customer. Customers do not see notes.",+ "docs_url": "https://developer.kustomer.com/kustomer-api-docs/reference/getnotesfororg",+ "columns": _columns(+ body="Text of the note.",+ ),+ },+ "queues": {+ "description": "A routing queue that holds conversations and other work until an agent is assigned.",+ "docs_url": "https://developer.kustomer.com/kustomer-api-docs/reference/getqueues",+ "columns": _columns(+ name="Internal name of the queue.",+ displayName="Display name of the queue.",+ description="Description of the queue.",+ priority="Priority of the queue relative to other queues.",+ itemSize="Capacity that one work item from this queue uses.",+ system="Whether Kustomer created the queue as a system queue.",+ modifiedAt="Time at which the queue was last modified.",+ ),+ },+ "work_items": {+ "description": "A unit of routed work, such as a conversation, that a queue assigns to an agent.",+ "docs_url": "https://developer.kustomer.com/kustomer-api-docs/reference/getworkitems",+ "columns": _columns(+ resourceType="Type of the routed resource (e.g. conversation).",+ status="Routing status of the work item (e.g. queued, assigned).",+ paused="Whether the work item is paused.",+ channel="Channel of the routed resource (e.g. email, chat, voice).",+ queuedCount="Number of times the work item entered a queue.",+ priority="Routing priority of the work item.",+ itemSize="Capacity that the work item uses.",+ resourceCreatedAt="Time at which the routed resource was created.",+ workItemNumber="Sequential number of the work item.",+ lastRevision="Details of the latest routing revision, such as when the agent accepted the item.",+ modifiedAt="Time at which the work item was last modified.",+ ),+ },+ "work_sessions": {+ "description": "An agent's routing session, from sign-in to sign-out, with capacity and time spent in each status.",+ "docs_url": "https://developer.kustomer.com/kustomer-api-docs/reference/getworksessions",+ "columns": _columns(+ routable="Whether routing can assign work to the agent.",+ statusType="Current status type of the agent (available, unavailable, busy or offline).",+ workItemCount="Number of work items assigned to the agent.",+ pausedWorkItemCount="Number of paused work items assigned to the agent.",+ signedInAt="Time at which the agent signed in.",+ capacity="Capacity limits and remaining capacity for each priority.",+ capacityRemaining="Remaining capacity of the agent.",+ totalCapacity="Total capacity of the agent.",+ handledItemCount="Number of work items the agent handled in the session.",+ handledConversationCount="Number of conversations the agent handled in the session.",+ totalAvailable="Time the agent spent available.",+ totalUnavailable="Time the agent spent unavailable.",+ totalTimeByStatus="Time the agent spent in each routing status, keyed by status id.",+ ),+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/kustomer/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/kustomer/settings.pyindex 4f6671ff79ce..816d51d7b4a8 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/kustomer/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/kustomer/settings.py@@ -28,6 +28,16 @@ KUSTOMER_ENDPOINTS: dict[str, KustomerEndpointConfig] = {"sub_statuses": KustomerEndpointConfig(path="/v1/sub-statuses", params={"resource": "conversation"}),# Satisfaction (CSAT) form definitions. Responses are only readable one id at a time."satisfaction_forms": KustomerEndpointConfig(path="/v1/satisfaction"),+ # These lists paginate by page number, so an ascending sort keeps rows created+ # during a sync from shifting later pages.+ "messages": KustomerEndpointConfig(path="/v1/messages", params={"sort": "asc"}),+ "notes": KustomerEndpointConfig(path="/v1/notes", params={"sort": "asc"}),+ "queues": KustomerEndpointConfig(path="/v1/routing/queues"),+ "work_items": KustomerEndpointConfig(path="/v1/routing/work-items", params={"sort": "asc"}),+ # `user=true` would return only the sessions of the user who owns the API key.+ "work_sessions": KustomerEndpointConfig(+ path="/v1/routing/work-sessions", params={"sort": "asc", "user": "false", "active": "false"}+ ),}ENDPOINTS = tuple(KUSTOMER_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/kustomer/tests/test_kustomer.py b/products/warehouse_sources/backend/temporal/data_imports/sources/kustomer/tests/test_kustomer.pyindex d68d1a7aa45a..af4e70e04134 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/kustomer/tests/test_kustomer.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/kustomer/tests/test_kustomer.py@@ -62,13 +62,26 @@ class TestValidateCredentials:class TestRequestParams:- def test_sub_statuses_requests_conversation_resource(self) -> None:- # The sub-statuses list rejects requests without the `resource` filter.- result = _driver().run("sub_statuses", [_page([])])+ @pytest.mark.parametrize(+ "endpoint, expected_params",+ [+ # The sub-statuses list rejects requests without the `resource` filter.+ ("sub_statuses", {"resource": "conversation", "sort": None}),+ # Page-number lists sort ascending so new rows do not shift later pages.+ ("messages", {"sort": "asc"}),+ ("notes", {"sort": "asc"}),+ ("work_items", {"sort": "asc"}),+ # Without `user=false` only the API key owner's sessions come back.+ ("work_sessions", {"sort": "asc", "user": "false", "active": "false"}),+ ("queues", {"sort": None, "user": None}),+ ],+ )+ def test_endpoint_request_params(self, endpoint: str, expected_params: dict[str, str | None]) -> None:+ result = _driver().run(endpoint, [_page([])])assert result.raised is None- assert result.paths == ["/v1/sub-statuses"]- assert result.params("resource") == ["conversation"]+ for name, value in expected_params.items():+ assert result.params(name) == [value]class TestPagination:diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/kustomer/tests/test_kustomer_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/kustomer/tests/test_kustomer_source.pyindex c744f67e2ee9..f6eb9abe85c3 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/kustomer/tests/test_kustomer_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/kustomer/tests/test_kustomer_source.py@@ -21,6 +21,11 @@ EXPECTED_PATHS = {"companies": "/v1/companies","sub_statuses": "/v1/sub-statuses","satisfaction_forms": "/v1/satisfaction",+ "messages": "/v1/messages",+ "notes": "/v1/notes",+ "queues": "/v1/routing/queues",+ "work_items": "/v1/routing/work-items",+ "work_sessions": "/v1/routing/work-sessions",}