: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 4 missing tables to the IncidentIo source (#118635)
Tom Owersd5d237ebc1be
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 a0d7fe360969..d932a689eaab 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@@ -6228,10 +6228,10 @@ Diffed against: <https://api-docs.incident.io/>- [x] `/v2/alert_sources` — lookup resolving alert_source_config IDs on `alerts`, so alert volume can be attributed to Datadog/Sentry/etc (high). Added as `alert_sources`, with `secret_token` dropped from every row.- [x] `/v2/schedule_entries` — the actual on-call shifts; `schedules` today is only the rota config, so no one can query who was on call when (high). Added as `schedule_entries` (fan-out over `schedules`, since `schedule_id` is a required query param). The endpoint returns nothing before "now" without a window, so each full refresh reads the `final` entries from 365 days back to 30 days ahead.- [x] `/v3/catalog_types and /v3/catalog_entries` — the service/team catalog that custom fields, alert routes and escalation paths all reference by ID - the master lookup for the whole account (high). Added as `catalog_types` and `catalog_entries` (fan-out over `catalog_types`, since `catalog_type_id` is a required query param).-- [ ] `/v3/teams` — team lookup for attributing incidents, escalations and follow-ups to owning teams (medium)-- [ ] `/v2/actions` — per-incident action items during the response, complementing the already-synced follow_ups (medium)-- [ ] `/v2/incident_participants and /v2/incident_participant_workloads` — membership table of who participated in each incident plus incident.io's on-call workload metric (medium)-- [ ] `/v2/alert_attributes` — lookup resolving the attribute IDs in each alert's attribute payload (medium)+- [x] `/v3/teams` — team lookup for attributing incidents, escalations and follow-ups to owning teams (medium)+- [x] `/v2/actions` — per-incident action items during the response, complementing the already-synced follow_ups (medium). Added as `actions` from `GET /v3/actions`, because incident.io removes `/v2/actions` on 2026-12-31. Incremental on `updated_at` or `created_at`.+- [x] `/v2/incident_participants and /v2/incident_participant_workloads` — membership table of who participated in each incident plus incident.io's on-call workload metric (medium). Added as `incident_participant_workloads` (fan-out over `incidents`, since `incident_id` is a required query param). Each row has the participant type, so `/v2/incident_participants` adds no table: it splits the same users into nested `active` and `passive` lists.+- [x] `/v2/alert_attributes` — lookup resolving the attribute IDs in each alert's attribute payload (medium)- [x] `/v2/status_page_incidents and /v2/status_page_incident_updates` — customer-facing incident communications, separate objects from internal incidents (medium). Added as `status_page_incidents` (fan-out over `status_pages`, since `status_page_id` is a required query param). `/v2/status_page_incident_updates` is create-only (no list operation); the updates arrive in each incident's `updates` column.- [x] `/v2/status_pages` — status page lookup, and the parent the status page incident fan-out iterates. Added as `status_pages`.diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/canonical_descriptions.pyindex aa45f61a0a32..c410a3bd380b 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/canonical_descriptions.py@@ -307,4 +307,53 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"component_impacts": "Time periods in which the incident affected a component.",},},+ "teams": {+ "description": "A team in the incident.io organisation, with its members and the catalog entry that represents it.",+ "docs_url": "https://api-docs.incident.io/tag/Teams-V3",+ "columns": {+ "id": "Unique identifier for the team.",+ "name": "Name of the team.",+ "members": "Members of the team.",+ "catalog_entry": "The catalog entry that represents the team.",+ },+ },+ "actions": {+ "description": "An action item raised during the response to an incident in incident.io.",+ "docs_url": "https://api-docs.incident.io/tag/Actions-V3",+ "columns": {+ "id": "Unique identifier for the action.",+ "incident_id": "Identifier of the incident the action belongs to.",+ "description": "Description of the action.",+ "status": "Status of the action (outstanding, completed, deleted, or not_doing).",+ "assignee": "The user the action is assigned to, if any.",+ "creator": "The user, alert, API key, or workflow that created the action.",+ "completed_at": "Time at which the action was completed.",+ "created_at": "Time at which the action was created.",+ "updated_at": "Time at which the action was last updated.",+ },+ },+ "incident_participant_workloads": {+ "description": "A participant of an incident in incident.io, with the role they had and the time they spent on it.",+ "docs_url": "https://api-docs.incident.io/tag/IncidentParticipantWorkloads-V2",+ "columns": {+ "incident_id": "Identifier of the incident the user participated in.",+ "user_id": "Identifier of the participating user.",+ "user": "The participating user.",+ "participant_type": "The role the user had in the incident (observer, collaborator, or responder).",+ "archived_at": "Time at which the user left the incident, if they are no longer an active participant.",+ "workload": "Minutes the user spent on the incident, in total and split into working, late, and sleeping hours.",+ },+ },+ "alert_attributes": {+ "description": "An attribute defined on alerts in incident.io. The attributes of each alert reference it by ID.",+ "docs_url": "https://api-docs.incident.io/tag/Alert-Attributes-V2",+ "columns": {+ "id": "Unique identifier for the alert attribute.",+ "name": "Unique name of the attribute.",+ "type": "Engine resource name for the attribute's value type.",+ "array": "Whether the attribute holds an array of values.",+ "required": "Whether the attribute is required.",+ "emoji": "The emoji shown alongside the attribute in chat messages, stored without colons.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/incident_io.py b/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/incident_io.pyindex 05389c4afdf5..0183e0cb2363 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/incident_io.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/incident_io.py@@ -17,6 +17,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.resJSONResponseCursorPaginator,SinglePagePaginator,)+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.resource import Resourcefrom products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import (ClientConfig,EndpointResource,@@ -111,10 +112,16 @@ def _window_params(window: EntryWindow, now: datetime) -> dict[str, str]:}-def _drop_fields(fields: tuple[str, ...]) -> Callable[[dict[str, Any]], dict[str, Any]]:+def _row_map(config: IncidentIoEndpointConfig) -> Optional[Callable[[dict[str, Any]], dict[str, Any]]]:+ if not config.excluded_fields and not config.nested_id_columns:+ return None+def _mapper(row: dict[str, Any]) -> dict[str, Any]:- for name in fields:+ for name in config.excluded_fields:row.pop(name, None)+ for column, nested in config.nested_id_columns.items():+ value = row.get(nested)+ row[column] = value.get("id") if isinstance(value, dict) else Nonereturn rowreturn _mapper@@ -277,7 +284,7 @@ def _fanout_source(child_params.update(window_params)resource = cast(- Iterable[Any],+ Resource,build_dependent_resource(endpoint_configs=endpoints,child_endpoint=config.name,@@ -297,6 +304,9 @@ def _fanout_source(initial_paginator_state=initial_paginator_state,),)+ row_map = _row_map(config)+ if row_map is not None:+ resource.add_map(row_map)return _source_response(config, resource)@@ -340,8 +350,9 @@ def incident_io_source("paginator": _paginator(config),},}- if config.excluded_fields:- resource_config["data_map"] = _drop_fields(config.excluded_fields)+ row_map = _row_map(config)+ if row_map is not None:+ resource_config["data_map"] = row_maprest_config: RESTAPIConfig = {# Excluded fields are dropped from rows only after HTTP sample capture saw the raw body.diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/settings.pyindex 97b7997f0a3f..546f0630962a 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/settings.py@@ -60,6 +60,8 @@ class IncidentIoEndpointConfig:entry_window: Optional[EntryWindow] = None# Top-level response fields never written to the warehouse, e.g. credentials.excluded_fields: tuple[str, ...] = ()+ # Top-level column -> nested object whose `id` it copies, for rows keyed only by an embedded object.+ nested_id_columns: dict[str, str] = field(default_factory=dict)@propertydef default_incremental_field(self) -> Optional[str]:@@ -115,6 +117,16 @@ _STATUS_PAGE_INCIDENTS_FANOUT = DependentEndpointConfig(parent_params={"page_size": 250},)+# Workload rows carry neither the incident's id nor a top-level user id, so the incident id is copied from the parent.+_INCIDENT_PARTICIPANT_WORKLOADS_FANOUT = DependentEndpointConfig(+ parent_name="incidents",+ resolve_param="incident_id",+ resolve_field="id",+ include_from_parent=["id"],+ parent_field_renames={"id": "incident_id"},+ parent_params={"page_size": 250, "sort_by": "created_at_oldest_first"},+)+# Full refresh re-reads this window on every sync, so shifts older than the lookback drop out of the table._SCHEDULE_ENTRIES_WINDOW = EntryWindow(start_param="entry_window_start",@@ -302,6 +314,42 @@ INCIDENT_IO_ENDPOINTS: dict[str, IncidentIoEndpointConfig] = {partition_key="published_at",fanout=_STATUS_PAGE_INCIDENTS_FANOUT,),+ "teams": IncidentIoEndpointConfig(+ name="teams",+ path="/v3/teams",+ data_key="teams",+ paginated=True,+ page_size=250,+ ),+ # Replaces GET /v2/actions, which incident.io removes on 2026-12-31. Rows are ordered by id,+ # oldest first, and the list takes `created_at[gte]` / `updated_at[gte]` filters.+ "actions": IncidentIoEndpointConfig(+ name="actions",+ path="/v3/actions",+ data_key="actions",+ paginated=True,+ page_size=250,+ partition_key="created_at",+ incremental_fields=[+ _DATETIME_INCREMENTAL_FIELD_UPDATED_AT,+ _DATETIME_INCREMENTAL_FIELD_CREATED_AT,+ ],+ ),+ "incident_participant_workloads": IncidentIoEndpointConfig(+ name="incident_participant_workloads",+ # `{incident_id}` is bound per parent incident row by the fan-out.+ path="/v2/incident_participant_workloads?incident_id={incident_id}",+ data_key="incident_participant_workloads",+ page_size_param=None,+ primary_keys=["incident_id", "user_id"],+ fanout=_INCIDENT_PARTICIPANT_WORKLOADS_FANOUT,+ nested_id_columns={"user_id": "user"},+ ),+ "alert_attributes": IncidentIoEndpointConfig(+ name="alert_attributes",+ path="/v2/alert_attributes",+ data_key="alert_attributes",+ ),}INCIDENT_IO_ENDPOINTS_V3: dict[str, IncidentIoEndpointConfig] = {diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/tests/test_incident_io.py b/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/tests/test_incident_io.pyindex ec5206dde526..43e8183e56f0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/tests/test_incident_io.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/tests/test_incident_io.py@@ -136,6 +136,19 @@ class TestValidateCredentials:],True,),+ # Workloads take no page-size param, so the child probe sends only the parent incident id.+ (+ "incident_participant_workloads",+ "incidents",+ [{"id": "I1"}],+ 403,+ [+ "https://api.incident.io/v2/incidents?page_size=1",+ "https://api.incident.io/v2/incidents",+ "https://api.incident.io/v2/incident_participant_workloads?incident_id=I1",+ ],+ False,+ ),# No parent row to bind, so the child scope can't be probed and the parent probe decides.("catalog_entries",@@ -233,6 +246,43 @@ class TestGetRows:assert result.params("updated_at[gte]")[1] == "2024-05-01"assert any("after=01C" in state.next_url for state in result.saved_states if state.next_url)+ @pytest.mark.parametrize(+ "inputs, expected_updated_at_gte",+ [+ ({}, None),+ (+ {"incremental_field": "updated_at", "db_incremental_field_last_value": "2026-05-01T10:15:00Z"},+ "2026-05-01",+ ),+ (+ {+ "incremental_field": "updated_at",+ "should_use_incremental_field": False,+ "db_incremental_field_last_value": "2026-05-01T10:15:00Z",+ },+ None,+ ),+ ],+ )+ def test_actions_incremental_request_shaping(+ self, inputs: dict[str, Any], expected_updated_at_gte: str | None+ ) -> None:+ result = _driver().run(+ "actions",+ [+ ScriptedResponse(json=_page_body("actions", [{"id": "01A"}], "01A")),+ ScriptedResponse(json=_page_body("actions", [{"id": "01B"}], None)),+ ],+ **inputs,+ )++ assert result.raised is None+ assert [row["id"] for row in result.rows] == ["01A", "01B"]+ assert set(result.paths) == {"/v3/actions"}+ assert result.params("after") == [None, "01A"]+ assert result.params("updated_at[gte]") == [expected_updated_at_gte] * 2+ assert result.params("page_size") == ["250", "250"]+def test_alert_sources_drop_secret_token(self) -> None:body = {"alert_sources": [{"id": "01A", "name": "Datadog", "secret_token": "not-a-real-token"}]}result = _driver().run("alert_sources", [ScriptedResponse(json=body)])@@ -273,6 +323,48 @@ class TestFanout:assert result.requests[1].param("entry_window_start") == "opaque-1"assert result.requests[1].param("entry_window_end") == "2026-03-31T12:00:00Z"+ @pytest.mark.parametrize(+ "workload_row, expected_user_id",+ [+ ({"user": {"id": "U1", "name": "Example User"}, "participant_type": "responder"}, "U1"),+ ({"user": None, "participant_type": "observer"}, None),+ ({"participant_type": "observer"}, None),+ ],+ )+ def test_incident_participant_workloads_rows_carry_their_keys(+ self, workload_row: dict[str, Any], expected_user_id: str | None+ ) -> None:+ result = _driver().run(+ "incident_participant_workloads",+ [+ ScriptedResponse(json=_page_body("incidents", [{"id": "I1"}], "I1")),+ ScriptedResponse(+ json={+ "incident_participant_workloads": [workload_row],+ "metadata": {"data_synced_at": "2026-05-01T10:00:00Z"},+ }+ ),+ ScriptedResponse(json=_page_body("incidents", [{"id": "I2"}], None)),+ ScriptedResponse(json={"incident_participant_workloads": [], "metadata": {}}),+ ],+ )++ assert result.raised is None+ assert [(row["incident_id"], row["user_id"]) for row in result.rows] == [("I1", expected_user_id)]+ assert result.rows[0]["participant_type"] == workload_row["participant_type"]+ assert result.paths == [+ "/v2/incidents",+ "/v2/incident_participant_workloads",+ "/v2/incidents",+ "/v2/incident_participant_workloads",+ ]+ incident_requests = [request for request in result.requests if request.path == "/v2/incidents"]+ assert [request.param("after") for request in incident_requests] == [None, "I1"]+ assert {request.param("sort_by") for request in incident_requests} == {"created_at_oldest_first"}+ workload_requests = [request for request in result.requests if request.path != "/v2/incidents"]+ assert [request.param("incident_id") for request in workload_requests] == ["I1", "I2"]+ assert all(request.param("page_size") is None for request in workload_requests)+class TestIncidentIoSourceResponse:@pytest.mark.parametrize("endpoint", list(ENDPOINTS))diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/tests/test_incident_io_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/tests/test_incident_io_source.pyindex b16bc6a0c63b..0a8b159b95a2 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/tests/test_incident_io_source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/incident_io/tests/test_incident_io_source.py@@ -52,8 +52,8 @@ class TestIncidentIoSource:assert {schema.name for schema in schemas} == set(ENDPOINTS)incremental = {schema.name for schema in schemas if schema.supports_incremental}- # Only the incidents list exposes server-side timestamp filters with a sortable order.- assert incremental == {"incidents"}+ # Only lists with server-side timestamp filters and a stable oldest-first order are incremental.+ assert incremental == {"incidents", "actions"}@pytest.mark.parametrize("pinned, expected_url",