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.

feat(data-warehouse): add Waydev import source (#84456)

Tom Owersa1389c421855
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/waydev.py b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/waydev.py
index 2889128cad2a..3edae0601544 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/waydev.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs/waydev.py
@@ -6,4 +6,4 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common imp
@config.config
class WaydevSourceConfig(config.Config):
- pass
+ api_key: str
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/canonical_descriptions.py
new file mode 100644
index 000000000000..531074ba13cf
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/canonical_descriptions.py
@@ -0,0 +1,39 @@
+"""Canonical, documentation-sourced descriptions for Waydev endpoints and columns.
+
+Sourced from the official Waydev API reference (https://api-docs.waydev.co). Keyed by the
+resource names in `settings.py` `ENDPOINTS`, which match the `ExternalDataSchema.name` of a
+synced Waydev table. Columns absent here fall back to LLM enrichment.
+"""
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
+ CanonicalDescriptions,
+)
+
+CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
+ "Metrics": {
+ "description": "The catalog of engineering metrics Waydev can report on for your account, such as "
+ "impact, code churn, active days, and efficiency.",
+ "docs_url": "https://api-docs.waydev.co/",
+ "columns": {
+ "id": "Metric identifier, used elsewhere as the metric key.",
+ "name": "Human-readable name of the metric.",
+ "unit": "Unit the metric is measured in.",
+ "description": "HTML-formatted description of what the metric measures.",
+ },
+ },
+ "Incidents": {
+ "description": "An incident logged against a repository in Waydev, used to compute "
+ "DORA metrics such as change failure rate and mean time to recovery.",
+ "docs_url": "https://api-docs.waydev.co/retrieves-all-the-incidents-in-your-account",
+ "columns": {
+ "id": "Unique identifier of the incident.",
+ "developer_id": "Identifier of the developer associated with the incident.",
+ "repository_id": "Identifier of the repository the incident was logged against.",
+ "number": "Reference number of the incident.",
+ "title": "Title of the incident.",
+ "url": "URL to the incident in its source system.",
+ "issued_at": "Date and time the incident was raised.",
+ "fixed_at": "Date and time the incident was marked as resolved, if any.",
+ },
+ },
+}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/settings.py
new file mode 100644
index 000000000000..e26e4a1eb652
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/settings.py
@@ -0,0 +1,10 @@
+from products.warehouse_sources.backend.types import IncrementalField
+
+ENDPOINTS = (
+ "Metrics",
+ "Incidents",
+)
+
+# Neither endpoint documents a server-side timestamp filter (Incidents only supports
+# page/limit/repository_id, and Metrics is a static catalog), so both sync full refresh.
+INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/source.py
index 95adcc7ba230..a963645e4547 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/source.py
@@ -1,30 +1,134 @@
-from typing import cast
+from typing import Optional, cast
from posthog.schema import (
DataWarehouseSourceCategory,
ExternalDataSourceType as SchemaExternalDataSourceType,
+ ReleaseStatus,
SourceConfig,
+ SourceFieldInputConfig,
+ SourceFieldInputConfigType,
)
-from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, SimpleSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, ResumableSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (
+ CanonicalDescriptions,
+)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.registry import SourceRegistry
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.schema import (
+ SourceSchema,
+ build_endpoint_schemas,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceInputs, SourceResponse
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.waydev import WaydevSourceConfig
+from products.warehouse_sources.backend.temporal.data_imports.sources.waydev.settings import (
+ ENDPOINTS,
+ INCREMENTAL_FIELDS,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.waydev.waydev import (
+ WaydevResumeConfig,
+ validate_credentials as validate_waydev_credentials,
+ waydev_source,
+)
from products.warehouse_sources.backend.types import ExternalDataSourceType
@SourceRegistry.register
-class WaydevSource(SimpleSource[WaydevSourceConfig]):
+class WaydevSource(ResumableSource[WaydevSourceConfig, WaydevResumeConfig]):
+ lists_tables_without_credentials = True # static endpoint catalog — safe for public docs
+ supported_versions = ("v2",)
+ default_version = "v2"
+ api_docs_url = "https://docs.waydev.co/reference/getting-started-with-your-api"
+
@property
def source_type(self) -> ExternalDataSourceType:
return ExternalDataSourceType.WAYDEV
+ def get_non_retryable_errors(self) -> dict[str, str | None]:
+ return {
+ "401 Client Error": "Your Waydev API token is invalid or expired. Generate a new token in "
+ "Waydev under Studio > Waydev API and reconnect.",
+ "Unauthorized": "Your Waydev API token is invalid or expired. Generate a new token in "
+ "Waydev under Studio > Waydev API and reconnect.",
+ }
+
+ def get_canonical_descriptions(self) -> CanonicalDescriptions:
+ from products.warehouse_sources.backend.temporal.data_imports.sources.waydev.canonical_descriptions import (
+ CANONICAL_DESCRIPTIONS,
+ )
+
+ return CANONICAL_DESCRIPTIONS
+
+ def get_schemas(
+ self,
+ config: WaydevSourceConfig,
+ team_id: int,
+ with_counts: bool = False,
+ names: list[str] | None = None,
+ force_refresh: bool = False,
+ api_version: str | None = None,
+ ) -> list[SourceSchema]:
+ return build_endpoint_schemas(ENDPOINTS, INCREMENTAL_FIELDS, names)
+
+ def validate_credentials(
+ self,
+ config: WaydevSourceConfig,
+ team_id: int,
+ schema_name: Optional[str] = None,
+ api_version: str | None = None,
+ ) -> tuple[bool, str | None]:
+ ok, status_code = validate_waydev_credentials(config.api_key)
+ if ok:
+ return True, None
+ if status_code == 401:
+ return False, "Invalid Waydev API token"
+ return False, "Could not connect to Waydev with the provided API token"
+
+ def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[WaydevResumeConfig]:
+ return ResumableSourceManager[WaydevResumeConfig](inputs, WaydevResumeConfig)
+
+ def source_for_pipeline(
+ self,
+ config: WaydevSourceConfig,
+ resumable_source_manager: ResumableSourceManager[WaydevResumeConfig],
+ inputs: SourceInputs,
+ ) -> SourceResponse:
+ resource = waydev_source(
+ api_key=config.api_key,
+ endpoint=inputs.schema_name,
+ team_id=inputs.team_id,
+ job_id=inputs.job_id,
+ resumable_source_manager=resumable_source_manager,
+ )
+ return SourceResponse(
+ name=resource.name,
+ items=lambda: resource,
+ primary_keys=["id"],
+ column_hints=resource.column_hints,
+ )
+
@property
def get_source_config(self) -> SourceConfig:
return SourceConfig(
name=SchemaExternalDataSourceType.WAYDEV,
category=DataWarehouseSourceCategory.ENGINEERING___MONITORING,
label="Waydev",
+ caption="Enter the personal access token generated in Waydev under Studio > Waydev API.",
+ docsUrl="https://posthog.com/docs/cdp/sources/waydev",
iconPath="/static/services/waydev.png",
- fields=cast(list[FieldType], []),
- unreleasedSource=True,
+ releaseStatus=ReleaseStatus.ALPHA,
+ keywords=["dora"],
+ fields=cast(
+ list[FieldType],
+ [
+ SourceFieldInputConfig(
+ name="api_key",
+ label="API token",
+ type=SourceFieldInputConfigType.PASSWORD,
+ required=True,
+ placeholder="",
+ secret=True,
+ ),
+ ],
+ ),
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/tests/test_waydev.py b/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/tests/test_waydev.py
new file mode 100644
index 000000000000..90d828b3b1af
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/tests/test_waydev.py
@@ -0,0 +1,191 @@
+import json
+from collections.abc import Iterable
+from typing import Any, cast
+
+import pytest
+from unittest import mock
+
+from requests import Response
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
+from products.warehouse_sources.backend.temporal.data_imports.sources.waydev.waydev import (
+ WaydevResumeConfig,
+ _client_config,
+ get_resource,
+ validate_credentials,
+ waydev_source,
+)
+
+# validate_credentials builds its own tracked session in the waydev module.
+WAYDEV_SESSION_PATCH = (
+ "products.warehouse_sources.backend.temporal.data_imports.sources.waydev.waydev.make_tracked_session"
+)
+
+
+def _make_http_response(body: Any, status_code: int = 200) -> Response:
+ resp = Response()
+ resp.status_code = status_code
+ resp._content = json.dumps(body).encode()
+ resp.headers["Content-Type"] = "application/json"
+ return resp
+
+
+class TestGetResource:
+ def test_metrics_has_no_data_selector_or_extra_params(self) -> None:
+ resource = get_resource("Metrics")
+ endpoint = cast(dict[str, Any], resource["endpoint"])
+ assert endpoint["path"] == "/metrics"
+ assert endpoint.get("data_selector") is None
+ assert endpoint.get("params") is None
+
+ def test_incidents_paginates_and_selects_the_data_key(self) -> None:
+ resource = get_resource("Incidents")
+ endpoint = cast(dict[str, Any], resource["endpoint"])
+ assert endpoint["path"] == "/incidents"
+ assert endpoint["data_selector"] == "data"
+ assert endpoint["params"] == {"limit": 100}
+
+ def test_unknown_endpoint_raises(self) -> None:
+ with pytest.raises(KeyError):
+ get_resource("NotAnEndpoint")
+
+
+class TestClientConfig:
+ def test_sends_raw_token_under_authorization_with_no_scheme_prefix(self) -> None:
+ config = _client_config("test-key")
+ assert config["auth"] == {
+ "type": "api_key",
+ "name": "Authorization",
+ "api_key": "test-key",
+ "location": "header",
+ }
+
+
+class TestWaydevSourceResumeBehavior:
+ """End-to-end resume behaviour of ``waydev_source`` via ``rest_api_resource``."""
+
+ def _drive(
+ self, endpoint: str, manager: mock.MagicMock, responses: list[Response]
+ ) -> tuple[mock.MagicMock, list[dict[str, Any]]]:
+ sent_params: list[dict[str, Any]] = []
+ response_iter = iter(responses)
+
+ def fake_send(request: Any, *_args: Any, **_kwargs: Any) -> Response:
+ sent_params.append(dict(request.params or {}))
+ return next(response_iter)
+
+ with mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.rest_client.make_tracked_session"
+ ) as mock_session_cls:
+ mock_session = mock_session_cls.return_value
+ mock_session.headers = {}
+ mock_session.prepare_request.side_effect = lambda req: req
+ mock_session.send.side_effect = fake_send
+
+ resource = waydev_source(
+ api_key="test-key",
+ endpoint=endpoint,
+ team_id=123,
+ job_id="test_job",
+ resumable_source_manager=manager,
+ )
+ list(cast(Iterable[Any], resource))
+ return mock_session, sent_params
+
+ def test_metrics_fetches_exactly_one_page_and_saves_no_state(self) -> None:
+ manager = mock.MagicMock(spec=ResumableSourceManager)
+ manager.can_resume.return_value = False
+
+ _, sent_params = self._drive(
+ "Metrics",
+ manager,
+ [_make_http_response([{"id": "impact", "name": "Impact"}])],
+ )
+
+ assert len(sent_params) == 1
+ manager.save_state.assert_not_called()
+
+ def test_incidents_fresh_run_pages_until_an_empty_page(self) -> None:
+ manager = mock.MagicMock(spec=ResumableSourceManager)
+ manager.can_resume.return_value = False
+
+ responses = [
+ _make_http_response({"current_page": 1, "data": [{"id": 1}]}),
+ _make_http_response({"current_page": 2, "data": [{"id": 2}]}),
+ _make_http_response({"current_page": 3, "data": []}),
+ ]
+ _, sent_params = self._drive("Incidents", manager, responses)
+
+ assert [p.get("page") for p in sent_params] == [1, 2, 3]
+ saved = [call.args[0] for call in manager.save_state.call_args_list]
+ assert saved == [WaydevResumeConfig(next_page=2), WaydevResumeConfig(next_page=3)]
+
+ def test_incidents_resume_seeds_paginator_with_saved_page(self) -> None:
+ manager = mock.MagicMock(spec=ResumableSourceManager)
+ manager.can_resume.return_value = True
+ manager.load_state.return_value = WaydevResumeConfig(next_page=5)
+
+ responses = [_make_http_response({"current_page": 5, "data": []})]
+ _, sent_params = self._drive("Incidents", manager, responses)
+
+ assert [p.get("page") for p in sent_params] == [5]
+ manager.load_state.assert_called_once()
+
+ def test_no_incidents_at_all_does_not_save_state(self) -> None:
+ manager = mock.MagicMock(spec=ResumableSourceManager)
+ manager.can_resume.return_value = False
+
+ _, sent_params = self._drive("Incidents", manager, [_make_http_response({"current_page": 1, "data": []})])
+
+ assert len(sent_params) == 1
+ manager.save_state.assert_not_called()
+
+ def test_a_single_real_page_still_probes_once_more_before_stopping(self) -> None:
+ # stop_after_empty_page means the last real page is always followed by one more
+ # request that comes back empty (no total-pages field is documented for this endpoint).
+ manager = mock.MagicMock(spec=ResumableSourceManager)
+ manager.can_resume.return_value = False
+
+ responses = [
+ _make_http_response({"current_page": 1, "data": [{"id": 1}]}),
+ _make_http_response({"current_page": 2, "data": []}),
+ ]
+ _, sent_params = self._drive("Incidents", manager, responses)
+
+ assert [p.get("page") for p in sent_params] == [1, 2]
+ saved = [call.args[0] for call in manager.save_state.call_args_list]
+ assert saved == [WaydevResumeConfig(next_page=2)]
+
+ def test_does_not_load_state_when_cannot_resume(self) -> None:
+ manager = mock.MagicMock(spec=ResumableSourceManager)
+ manager.can_resume.return_value = False
+
+ self._drive("Incidents", manager, [_make_http_response({"current_page": 1, "data": []})])
+
+ manager.load_state.assert_not_called()
+
+
+class TestValidateCredentials:
+ @mock.patch(WAYDEV_SESSION_PATCH)
+ def test_ok(self, mock_session: mock.MagicMock) -> None:
+ mock_session.return_value.get.return_value = mock.MagicMock(status_code=200)
+ assert validate_credentials("token") == (True, 200)
+
+ @mock.patch(WAYDEV_SESSION_PATCH)
+ def test_unauthorized(self, mock_session: mock.MagicMock) -> None:
+ mock_session.return_value.get.return_value = mock.MagicMock(status_code=401)
+ assert validate_credentials("token") == (False, 401)
+
+ @mock.patch(WAYDEV_SESSION_PATCH)
+ def test_swallows_transport_errors(self, mock_session: mock.MagicMock) -> None:
+ mock_session.return_value.get.side_effect = Exception("boom")
+ assert validate_credentials("token") == (False, None)
+
+ @mock.patch(WAYDEV_SESSION_PATCH)
+ def test_probes_the_metrics_endpoint_with_a_raw_authorization_header(self, mock_session: mock.MagicMock) -> None:
+ mock_session.return_value.get.return_value = mock.MagicMock(status_code=200)
+ validate_credentials("token")
+
+ call = mock_session.return_value.get.call_args
+ assert call.args[0] == "https://api.waydev.co/v2/metrics"
+ assert call.kwargs["headers"] == {"Authorization": "token"}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/tests/test_waydev_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/tests/test_waydev_source.py
new file mode 100644
index 000000000000..f29a577a8c3c
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/tests/test_waydev_source.py
@@ -0,0 +1,148 @@
+import pytest
+from unittest import mock
+
+from posthog.schema import ReleaseStatus, SourceFieldInputConfig, SourceFieldInputConfigType
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.waydev import WaydevSourceConfig
+from products.warehouse_sources.backend.temporal.data_imports.sources.waydev.settings import ENDPOINTS
+from products.warehouse_sources.backend.temporal.data_imports.sources.waydev.source import WaydevSource
+from products.warehouse_sources.backend.temporal.data_imports.sources.waydev.waydev import WaydevResumeConfig
+from products.warehouse_sources.backend.types import ExternalDataSourceType
+
+
+class TestWaydevSource:
+ def setup_method(self) -> None:
+ self.source = WaydevSource()
+ self.team_id = 123
+ self.config = WaydevSourceConfig(api_key="key")
+
+ def test_source_type(self) -> None:
+ assert self.source.source_type == ExternalDataSourceType.WAYDEV
+
+ def test_get_source_config(self) -> None:
+ config = self.source.get_source_config
+
+ assert config.name.value == "Waydev"
+ assert config.label == "Waydev"
+ assert config.releaseStatus == ReleaseStatus.ALPHA
+ assert config.unreleasedSource is None
+ assert config.iconPath == "/static/services/waydev.png"
+ assert config.docsUrl == "https://posthog.com/docs/cdp/sources/waydev"
+
+ field_names = [f.name for f in config.fields if isinstance(f, SourceFieldInputConfig)]
+ assert field_names == ["api_key"]
+
+ def test_api_key_field_is_secret_password(self) -> None:
+ config = self.source.get_source_config
+ api_key_field = next(f for f in config.fields if isinstance(f, SourceFieldInputConfig) and f.name == "api_key")
+ assert api_key_field.type == SourceFieldInputConfigType.PASSWORD
+ assert api_key_field.secret is True
+ assert api_key_field.required is True
+
+ def test_api_version(self) -> None:
+ assert self.source.supported_versions == ("v2",)
+ assert self.source.default_version == "v2"
+ assert self.source.api_docs_url is not None and self.source.api_docs_url.startswith("https://")
+
+ @pytest.mark.parametrize(
+ "observed_error",
+ [
+ "401 Client Error: Unauthorized for url: https://api.waydev.co/v2/incidents",
+ "Unauthorized",
+ ],
+ )
+ def test_non_retryable_errors_match_auth_failures(self, observed_error: str) -> None:
+ non_retryable_errors = self.source.get_non_retryable_errors()
+ assert any(key in observed_error for key in non_retryable_errors)
+
+ @pytest.mark.parametrize(
+ "other_error",
+ [
+ "429 Client Error: Too Many Requests for url: https://api.waydev.co/v2/incidents",
+ "500 Server Error: Internal Server Error for url: https://api.waydev.co/v2/metrics",
+ ],
+ )
+ def test_non_retryable_errors_do_not_match_transient(self, other_error: str) -> None:
+ non_retryable_errors = self.source.get_non_retryable_errors()
+ assert not any(key in other_error for key in non_retryable_errors)
+
+ def test_get_schemas_are_all_full_refresh(self) -> None:
+ # Neither endpoint documents a server-side timestamp filter.
+ schemas = {schema.name: schema for schema in self.source.get_schemas(self.config, self.team_id)}
+
+ assert set(schemas) == set(ENDPOINTS)
+ for schema in schemas.values():
+ assert schema.supports_incremental is False
+ assert schema.incremental_fields == []
+
+ def test_get_schemas_filtered_by_names(self) -> None:
+ schemas = self.source.get_schemas(self.config, self.team_id, names=["Incidents"])
+ assert len(schemas) == 1
+ assert schemas[0].name == "Incidents"
+
+ def test_get_schemas_filtered_unknown_name_returns_empty(self) -> None:
+ assert self.source.get_schemas(self.config, self.team_id, names=["nope"]) == []
+
+ def test_lists_tables_without_credentials_publishes_catalog(self) -> None:
+ # Static endpoint catalog (no I/O) — the public docs table list should render.
+ assert self.source.lists_tables_without_credentials is True
+ documented = self.source.get_documented_tables()
+ assert {table["name"] for table in documented} == set(ENDPOINTS)
+
+ def test_canonical_descriptions_cover_every_endpoint(self) -> None:
+ canonical = self.source.get_canonical_descriptions()
+ assert set(canonical) == set(ENDPOINTS)
+
+ @pytest.mark.parametrize(
+ ("mock_return", "expected_valid", "expected_message"),
+ [
+ ((True, 200), True, None),
+ ((False, 401), False, "Invalid Waydev API token"),
+ ((False, 403), False, "Could not connect to Waydev with the provided API token"),
+ ((False, None), False, "Could not connect to Waydev with the provided API token"),
+ ],
+ )
+ @mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.waydev.source.validate_waydev_credentials"
+ )
+ def test_validate_credentials(
+ self,
+ mock_validate: mock.MagicMock,
+ mock_return: tuple[bool, int | None],
+ expected_valid: bool,
+ expected_message: str | None,
+ ) -> None:
+ mock_validate.return_value = mock_return
+
+ is_valid, error_message = self.source.validate_credentials(self.config, self.team_id)
+
+ assert is_valid is expected_valid
+ assert error_message == expected_message
+ mock_validate.assert_called_once_with("key")
+
+ def test_get_resumable_source_manager_bound_to_resume_config(self) -> None:
+ inputs = mock.MagicMock()
+ manager = self.source.get_resumable_source_manager(inputs)
+ assert manager._data_class is WaydevResumeConfig
+
+ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.waydev.source.waydev_source")
+ def test_source_for_pipeline_plumbs_arguments(self, mock_waydev_source: mock.MagicMock) -> None:
+ inputs = mock.MagicMock()
+ inputs.schema_name = "Incidents"
+ inputs.team_id = self.team_id
+ inputs.job_id = "job-1"
+ manager = mock.MagicMock()
+ mock_waydev_source.return_value.name = "Incidents"
+ mock_waydev_source.return_value.column_hints = None
+
+ response = self.source.source_for_pipeline(self.config, manager, inputs)
+
+ mock_waydev_source.assert_called_once_with(
+ api_key="key",
+ endpoint="Incidents",
+ team_id=self.team_id,
+ job_id="job-1",
+ resumable_source_manager=manager,
+ )
+ assert response.primary_keys == ["id"]
+ assert response.name == "Incidents"
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/waydev.py b/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/waydev.py
new file mode 100644
index 000000000000..d0ae4703b2ef
--- /dev/null
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/waydev/waydev.py
@@ -0,0 +1,115 @@
+from typing import Any, Optional
+
+from posthog.dataclasses import frozen
+
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source import (
+ RESTAPIConfig,
+ rest_api_resource,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (
+ PageNumberPaginator,
+ SinglePagePaginator,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.resource import Resource
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import (
+ ClientConfig,
+ EndpointResource,
+)
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManager
+from products.warehouse_sources.backend.temporal.data_imports.sources.common.source_helpers import validate_via_probe
+
+BASE_URL = "https://api.waydev.co/v2"
+# The public reference documents a `limit` param (default 25) with no stated maximum;
+# 100 keeps page count down without a documented ceiling to test against.
+INCIDENTS_PAGE_SIZE = 100
+
+
+@frozen
+class WaydevResumeConfig:
+ next_page: int
+
+
+def _client_config(api_key: str) -> ClientConfig:
+ return {
+ "base_url": BASE_URL,
+ # The public reference sends the raw token under Authorization with no scheme prefix.
+ "auth": {
+ "type": "api_key",
+ "name": "Authorization",
+ "api_key": api_key,
+ "location": "header",
+ },
+ }
+
+
+def get_resource(name: str) -> EndpointResource:
+ resources: dict[str, EndpointResource] = {
+ "Metrics": {
+ "name": "Metrics",
+ "table_name": "metrics",
+ "write_disposition": "replace",
+ "endpoint": {
+ "path": "/metrics",
+ # Response is a bare JSON array with no pagination documented.
+ "paginator": SinglePagePaginator(),
+ },
+ "table_format": "delta",
+ },
+ "Incidents": {
+ "name": "Incidents",
+ "table_name": "incidents",
+ "write_disposition": "replace",
+ "endpoint": {
+ "path": "/incidents",
+ "params": {"limit": INCIDENTS_PAGE_SIZE},
+ "data_selector": "data",
+ "paginator": PageNumberPaginator(base_page=1, page_param="page", stop_after_empty_page=True),
+ },
+ "table_format": "delta",
+ },
+ }
+ return resources[name]
+
+
+def waydev_source(
+ api_key: str,
+ endpoint: str,
+ team_id: int,
+ job_id: str,
+ resumable_source_manager: ResumableSourceManager[WaydevResumeConfig],
+) -> Resource:
+ config: RESTAPIConfig = {
+ "client": _client_config(api_key),
+ "resources": [get_resource(endpoint)],
+ }
+
+ initial_paginator_state: Optional[dict[str, Any]] = None
+ if resumable_source_manager.can_resume():
+ resume_config = resumable_source_manager.load_state()
+ if resume_config is not None:
+ initial_paginator_state = {"page": resume_config.next_page}
+
+ def save_checkpoint(state: Optional[dict[str, Any]]) -> None:
+ # Only persist when there's a next page to resume to; the Redis TTL handles
+ # cleanup on completion.
+ if state and state.get("page"):
+ resumable_source_manager.save_state(WaydevResumeConfig(next_page=int(state["page"])))
+
+ return rest_api_resource(
+ config,
+ team_id,
+ job_id,
+ db_incremental_field_last_value=None,
+ resume_hook=save_checkpoint,
+ initial_paginator_state=initial_paginator_state,
+ )
+
+
+def validate_credentials(api_key: str) -> tuple[bool, int | None]:
+ """Probe the metrics endpoint to confirm the token is genuine."""
+ return validate_via_probe(
+ lambda: make_tracked_session(redact_values=(api_key,)),
+ f"{BASE_URL}/metrics",
+ headers={"Authorization": api_key},
+ )