: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): implement eventee import source (#66734)
Tom Owers05d5ebbe3061
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.mdindex 190972253a46..4985c7ff5c0e 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/SOURCES.md@@ -129,6 +129,7 @@ the row lists both.| elasticsearch | HTTP | requests | ✅ || emailoctopus | HTTP | requests | ✅ || eventbrite | HTTP | requests | ✅ |+| eventee | HTTP | requests | ✅ || everhour | HTTP | requests | ✅ || factorial | HTTP | requests + `rest_source.RESTClient` | ✅ || fillout | HTTP | requests + `rest_source.RESTClient` | ✅ |@@ -385,7 +386,6 @@ doesn't conflict with concurrent PRs.- eloqua- employment_hero- encharge-- eventee- eventzilla- exchange_rates_api- expensifydiff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/canonical_descriptions.pynew file mode 100644index 000000000000..92f1c5569d0d--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/canonical_descriptions.py@@ -0,0 +1,199 @@+"""Canonical, documentation-sourced descriptions for Eventee endpoints and columns.++Sourced from the public Eventee API reference (https://publiceventeeapi.docs.apiary.io/). Keyed by+the endpoint names in `settings.py` `EVENTEE_ENDPOINTS`, which match the `ExternalDataSchema.name` of+a synced Eventee table. Columns absent here fall back to LLM enrichment.+"""++from products.warehouse_sources.backend.temporal.data_imports.sources.common.canonical_descriptions import (+ CanonicalDescriptions,+)++_DOCS_URL = "https://publiceventeeapi.docs.apiary.io/"++CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {+ "halls": {+ "description": "A room or hall in the event venue where lectures and workshops take place.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the hall.",+ "name": "Display name of the hall.",+ "created_at": "Time at which the hall was created.",+ "updated_at": "Time at which the hall was last updated.",+ },+ },+ "lectures": {+ "description": "A talk or session in the event agenda, scheduled in a hall and optionally tied to speakers and tracks.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the lecture.",+ "name": "Title of the lecture.",+ "description": "Long-form description of the lecture.",+ "start": "Scheduled start time of the lecture.",+ "end": "Scheduled end time of the lecture.",+ "hall_id": "Identifier of the hall the lecture is scheduled in.",+ "speakers": "Speakers presenting the lecture.",+ "tracks": "Tracks (topic labels) the lecture belongs to.",+ "capacity": "Maximum number of attendees that can book the lecture.",+ "type": "Numeric type of the agenda item.",+ "stream": "Live stream configuration (URL and provider).",+ "virtual_meeting": "Virtual meeting configuration (URL and service).",+ "booking_info": "Booking availability and capacity for the lecture.",+ "created_at": "Time at which the lecture was created.",+ "updated_at": "Time at which the lecture was last updated.",+ },+ },+ "workshops": {+ "description": "A workshop in the event agenda — a hands-on session scheduled in a hall, with the same shape as a lecture.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the workshop.",+ "name": "Title of the workshop.",+ "description": "Long-form description of the workshop.",+ "start": "Scheduled start time of the workshop.",+ "end": "Scheduled end time of the workshop.",+ "hall_id": "Identifier of the hall the workshop is scheduled in.",+ "speakers": "Speakers running the workshop.",+ "tracks": "Tracks (topic labels) the workshop belongs to.",+ "capacity": "Maximum number of attendees that can book the workshop.",+ "created_at": "Time at which the workshop was created.",+ "updated_at": "Time at which the workshop was last updated.",+ },+ },+ "pauses": {+ "description": "A break or pause in the event agenda (e.g. a coffee break or networking slot).",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the pause.",+ "name": "Name of the pause.",+ "description": "Description of the pause (may contain HTML).",+ "start": "Scheduled start time of the pause.",+ "end": "Scheduled end time of the pause.",+ "created_at": "Time at which the pause was created.",+ "updated_at": "Time at which the pause was last updated.",+ },+ },+ "speakers": {+ "description": "A speaker presenting at the event, with their profile and contact details.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the speaker.",+ "name": "Full name of the speaker.",+ "email": "Email address of the speaker.",+ "photo": "URL of the speaker's profile photo.",+ "phone": "Phone number of the speaker.",+ "bio": "Biography of the speaker.",+ "web": "Personal or company website of the speaker.",+ "facebook": "Facebook profile URL of the speaker.",+ "twitter": "Twitter/X profile URL of the speaker.",+ "linkedIn": "LinkedIn profile URL of the speaker.",+ "position": "Job title of the speaker.",+ "company": "Company the speaker represents.",+ "country": "Two-letter country code for the speaker.",+ "language": "Languages the speaker presents in.",+ "event_id": "Identifier of the event the speaker belongs to.",+ "thumbnail": "URL of the speaker's thumbnail photo.",+ },+ },+ "tracks": {+ "description": "A track (topic label) used to categorize agenda items.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the track.",+ "name": "Display name of the track.",+ "color": "Hex color used to render the track.",+ },+ },+ "reviews": {+ "description": "An attendee's rating and comment for a lecture, captured in the Eventee app.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the review.",+ "username": "Username of the attendee who left the review.",+ "userphoto": "URL of the reviewer's profile photo.",+ "stars": "Star rating (1–5) given in the review.",+ "comment": "Free-text comment left in the review.",+ "user_id": "Identifier of the attendee who left the review.",+ "lecture_id": "Identifier of the reviewed lecture.",+ "lecture": "The reviewed lecture object.",+ "device": "Device the review was submitted from.",+ "OS": "Operating system of the device the review was submitted from.",+ "created_at": "Time at which the review was created.",+ "updated_at": "Time at which the review was last updated.",+ },+ },+ "groups": {+ "description": "An attendee group used to segment access and personalize the event experience.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the group.",+ "name": "Internal name of the group.",+ "public_name": "Name of the group shown to attendees.",+ "color": "Hex color used to render the group.",+ "emoji": "Emoji used to represent the group.",+ "agenda": "Whether the group can access the agenda.",+ "newsfeed": "Whether the group can access the newsfeed.",+ "networking": "Whether the group can access networking.",+ "session_ratings": "Whether the group can rate sessions.",+ "social_wall": "Whether the group can access the social wall.",+ "gamification": "Whether gamification is enabled for the group.",+ "ticket_names": "Ticket names mapped to the group.",+ "is_default": "Whether this is the default group for new attendees.",+ },+ },+ "participants": {+ "description": "An attendee participating in the event, with their profile, group, and check-in details.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the participant.",+ "email": "Email address of the participant.",+ "name": "Full name of the participant.",+ "first_name": "First name of the participant.",+ "last_name": "Last name of the participant.",+ "company": "Company the participant represents.",+ "position": "Job title of the participant.",+ "role": "Role of the participant within the event.",+ "group_id": "Identifier of the group the participant belongs to.",+ "checked_at": "Time at which the participant was checked in.",+ "registered_at": "Time at which the participant registered.",+ },+ },+ "partners": {+ "description": "A partner of the event — an exhibitor and/or sponsor — with their company profile.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the partner.",+ "company": "Name of the partner company.",+ "description": "Description of the partner company.",+ "web": "Website of the partner company.",+ "email": "Contact email of the partner company.",+ "phone": "Contact phone number of the partner company.",+ "address": "Address of the partner company.",+ "exhibitor_info": "Exhibitor details (booth number and photo) when the partner is an exhibitor.",+ "sponsor_info": "Sponsor details (photo) when the partner is a sponsor.",+ },+ },+ "registrations": {+ "description": "A registration submitted for the event, capturing the registrant's profile and status.",+ "docs_url": _DOCS_URL,+ "columns": {+ "id": "Unique identifier for the registration.",+ "email": "Email address of the registrant.",+ "first_name": "First name of the registrant.",+ "last_name": "Last name of the registrant.",+ "photo": "URL of the registrant's photo.",+ "phone": "Phone number of the registrant.",+ "bio": "Biography of the registrant.",+ "web": "Website of the registrant.",+ "facebook_link": "Facebook profile URL of the registrant.",+ "twitter_link": "Twitter/X profile URL of the registrant.",+ "linked_in_link": "LinkedIn profile URL of the registrant.",+ "position": "Job title of the registrant.",+ "company": "Company the registrant represents.",+ "send_email": "Whether a notification email should be sent to the registrant.",+ "group_id": "Identifier of the group the registrant is assigned to.",+ "email_valid": "Whether the registrant's email has been validated.",+ "status": "Status of the registration.",+ },+ },+}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/eventee.py b/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/eventee.pynew file mode 100644index 000000000000..a61d70bd7028--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/eventee.py@@ -0,0 +1,109 @@+from collections.abc import Iterator+from typing import Any++import requests+from structlog.types import FilteringBoundLogger+from tenacity import retry, retry_if_exception_type, stop_after_attempt, wait_exponential_jitter++from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import SourceResponse+from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session+from products.warehouse_sources.backend.temporal.data_imports.sources.eventee.settings import EVENTEE_ENDPOINTS++# The base URL is fixed: the Bearer token scopes to a single event, so there's no per-tenant host.+EVENTEE_BASE_URL = "https://api.eventee.com/public/v1"+REQUEST_TIMEOUT_SECONDS = 60+MAX_RETRY_ATTEMPTS = 5+++class EventeeRetryableError(Exception):+ pass+++def _get_session(api_key: str) -> requests.Session:+ return make_tracked_session(+ headers={"Authorization": f"Bearer {api_key}", "Accept": "application/json"},+ redact_values=(api_key,),+ )+++def validate_credentials(api_key: str) -> bool:+ """Confirm the token is genuine with a cheap probe. A valid token returns 200; an invalid or+ expired one returns 401 (`token_invalid`)."""+ try:+ response = _get_session(api_key).get(f"{EVENTEE_BASE_URL}/groups", timeout=10)+ return response.status_code == 200+ except Exception:+ return False+++def _extract_rows(data: Any, data_key: str | None) -> list[dict[str, Any]]:+ """Normalize an Eventee response into a list of row dicts.++ `/content` returns an object bundling several lists, so a table sourced from it reads its rows+ from `data[data_key]`. The standalone endpoints return their list directly; `/registrations`+ can return a single object, so a bare dict is wrapped into a one-element list.+ """+ if data_key is not None:+ if isinstance(data, dict):+ value = data.get(data_key) or []+ return value if isinstance(value, list) else [value]+ return []++ if isinstance(data, list):+ return data+ if isinstance(data, dict):+ return [data]+ return []+++def get_rows(+ api_key: str,+ endpoint: str,+ logger: FilteringBoundLogger,+) -> Iterator[list[dict[str, Any]]]:+ config = EVENTEE_ENDPOINTS[endpoint]+ session = _get_session(api_key)++ @retry(+ retry=retry_if_exception_type((EventeeRetryableError, requests.ReadTimeout, requests.ConnectionError)),+ stop=stop_after_attempt(MAX_RETRY_ATTEMPTS),+ wait=wait_exponential_jitter(initial=2, max=60),+ reraise=True,+ )+ def fetch(path: str) -> Any:+ url = f"{EVENTEE_BASE_URL}{path}"+ response = session.get(url, timeout=REQUEST_TIMEOUT_SECONDS)++ if response.status_code == 429 or response.status_code >= 500:+ raise EventeeRetryableError(f"Eventee API error (retryable): status={response.status_code}, url={url}")++ if not response.ok:+ logger.error(f"Eventee API error: status={response.status_code}, body={response.text}, url={url}")+ response.raise_for_status()++ return response.json()++ # Every endpoint returns its whole collection in a single response — no pagination.+ rows = _extract_rows(fetch(config.path), config.data_key)+ if rows:+ yield rows+++def eventee_source(+ api_key: str,+ endpoint: str,+ logger: FilteringBoundLogger,+) -> SourceResponse:+ config = EVENTEE_ENDPOINTS[endpoint]++ return SourceResponse(+ name=endpoint,+ items=lambda: get_rows(api_key=api_key, endpoint=endpoint, logger=logger),+ primary_keys=config.primary_keys,+ partition_count=1 if config.partition_key else None,+ partition_size=1 if config.partition_key else None,+ partition_mode="datetime" if config.partition_key else None,+ partition_format="month" if config.partition_key else None,+ partition_keys=[config.partition_key] if config.partition_key else None,+ sort_mode="asc",+ )diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/settings.pynew file mode 100644index 000000000000..41820b772b76--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/settings.py@@ -0,0 +1,51 @@+from dataclasses import dataclass, field+from typing import Optional++from products.warehouse_sources.backend.types import IncrementalField+++@dataclass+class EventeeEndpointConfig:+ name: str+ # Path under https://api.eventee.com/public/v1.+ path: str+ # When the endpoint returns a JSON object bundling several lists (the `/content` endpoint+ # carries halls/lectures/workshops/pauses/speakers/tracks), the rows for this table live under+ # this key. `None` means the response body is itself the list of rows (or a single object).+ data_key: Optional[str] = None+ primary_keys: list[str] = field(default_factory=lambda: ["id"])+ # Stable, creation-time field to partition on. Never an `updated_at`-style field — those rewrite+ # partitions on every sync. `None` for resources that expose no stable timestamp.+ partition_key: Optional[str] = None+ should_sync_default: bool = True+++# Eventee's public API exposes a handful of read endpoints scoped to a single event by the Bearer+# token. `/content` returns one object bundling the agenda resources, so each of those becomes its own+# table sourced from the same call; the rest return their rows directly. No endpoint documents a+# server-side timestamp filter or pagination, so every table is full refresh only.+EVENTEE_ENDPOINTS: dict[str, EventeeEndpointConfig] = {+ "halls": EventeeEndpointConfig(name="halls", path="/content", data_key="halls", partition_key="created_at"),+ "lectures": EventeeEndpointConfig(+ name="lectures", path="/content", data_key="lectures", partition_key="created_at"+ ),+ "workshops": EventeeEndpointConfig(+ name="workshops", path="/content", data_key="workshops", partition_key="created_at"+ ),+ "pauses": EventeeEndpointConfig(name="pauses", path="/content", data_key="pauses", partition_key="created_at"),+ # Speakers and tracks expose no created_at/updated_at, so there's nothing stable to partition on.+ "speakers": EventeeEndpointConfig(name="speakers", path="/content", data_key="speakers"),+ "tracks": EventeeEndpointConfig(name="tracks", path="/content", data_key="tracks"),+ "reviews": EventeeEndpointConfig(name="reviews", path="/reviews", partition_key="created_at"),+ "groups": EventeeEndpointConfig(name="groups", path="/groups"),+ "participants": EventeeEndpointConfig(name="participants", path="/participants", partition_key="registered_at"),+ "partners": EventeeEndpointConfig(name="partners", path="/partners"),+ "registrations": EventeeEndpointConfig(name="registrations", path="/registrations"),+}++ENDPOINTS = tuple(EVENTEE_ENDPOINTS.keys())++# Eventee has no server-side timestamp filter (`since` / `_gte` / `modified_after`) on any endpoint,+# so nothing is incremental — the map is kept (empty) to mirror the other sources' shape and make+# adding a filterable endpoint later an additive change.+INCREMENTAL_FIELDS: dict[str, list[IncrementalField]] = {name: [] for name in EVENTEE_ENDPOINTS}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/source.pyindex 62b354dcb7ec..597b6ed60543 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/source.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/source.py@@ -1,19 +1,40 @@-from typing import cast+from typing import Optional, castfrom posthog.schema import (DataWarehouseSourceCategory,ExternalDataSourceType as SchemaExternalDataSourceType,+ ReleaseStatus,SourceConfig,+ SourceFieldInputConfig,+ SourceFieldInputConfigType,)+from products.warehouse_sources.backend.temporal.data_imports.pipelines.pipeline.typings import (+ SourceInputs,+ SourceResponse,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.base import FieldType, SimpleSource+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.schema import SourceSchema+from products.warehouse_sources.backend.temporal.data_imports.sources.eventee.eventee import (+ eventee_source,+ validate_credentials as validate_eventee_credentials,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.eventee.settings import (+ ENDPOINTS,+ INCREMENTAL_FIELDS,+)from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs import EventeeSourceConfigfrom products.warehouse_sources.backend.types import ExternalDataSourceType@SourceRegistry.registerclass EventeeSource(SimpleSource[EventeeSourceConfig]):+ lists_tables_without_credentials = True # static endpoint catalog — safe for public docs+@propertydef source_type(self) -> ExternalDataSourceType:return ExternalDataSourceType.EVENTEE@@ -24,7 +45,83 @@ class EventeeSource(SimpleSource[EventeeSourceConfig]):name=SchemaExternalDataSourceType.EVENTEE,category=DataWarehouseSourceCategory.PRODUCTIVITY,label="Eventee",+ releaseStatus=ReleaseStatus.ALPHA,+ caption="""Enter your Eventee API token to pull your event's content into the PostHog Data warehouse.++Generate a token in your Eventee admin dashboard under **Settings → Features**. The token is scoped to a single event, so connect one source per event you want to import.++All Eventee tables are full refresh only — the API exposes no incremental sync filter.""",iconPath="/static/services/eventee.png",- fields=cast(list[FieldType], []),- unreleasedSource=True,+ docsUrl="https://posthog.com/docs/cdp/sources/eventee",+ fields=cast(+ list[FieldType],+ [+ SourceFieldInputConfig(+ name="api_key",+ label="API token",+ type=SourceFieldInputConfigType.PASSWORD,+ required=True,+ placeholder="",+ secret=True,+ ),+ ],+ ),+ )++ def get_canonical_descriptions(self) -> CanonicalDescriptions:+ from products.warehouse_sources.backend.temporal.data_imports.sources.eventee.canonical_descriptions import ( # noqa: PLC0415+ CANONICAL_DESCRIPTIONS,+ )++ return CANONICAL_DESCRIPTIONS++ def get_non_retryable_errors(self) -> dict[str, str | None]:+ return {+ # An invalid or expired token surfaces as a 401 (`token_invalid`) when `fetch` calls+ # `raise_for_status()`. Retrying can never fix a credential problem. Match the stable+ # status text and base host, not the per-request path.+ "401 Client Error: Unauthorized for url: https://api.eventee.com": "Your Eventee API token is invalid or has expired. Generate a new token in your Eventee admin dashboard (Settings → Features), then reconnect.",+ "403 Client Error: Forbidden for url: https://api.eventee.com": "Your Eventee API token does not have access to this event's data. Check the token in your Eventee admin dashboard, then reconnect.",+ }++ def get_schemas(+ self,+ config: EventeeSourceConfig,+ team_id: int,+ with_counts: bool = False,+ names: list[str] | None = None,+ force_refresh: bool = False,+ ) -> list[SourceSchema]:+ # Every endpoint is a snapshot with no server-side timestamp filter, so all are full refresh+ # only (no incremental/append).+ schemas = [+ SourceSchema(+ name=endpoint,+ supports_incremental=False,+ supports_append=False,+ incremental_fields=INCREMENTAL_FIELDS.get(endpoint, []),+ description="Full refresh only — Eventee exposes no incremental sync filter",+ )+ for endpoint in ENDPOINTS+ ]++ if names is not None:+ names_set = set(names)+ schemas = [s for s in schemas if s.name in names_set]++ return schemas++ def validate_credentials(+ self, config: EventeeSourceConfig, team_id: int, schema_name: Optional[str] = None+ ) -> tuple[bool, str | None]:+ if validate_eventee_credentials(config.api_key):+ return True, None++ return False, "Invalid Eventee API token"++ def source_for_pipeline(self, config: EventeeSourceConfig, inputs: SourceInputs) -> SourceResponse:+ return eventee_source(+ api_key=config.api_key,+ endpoint=inputs.schema_name,+ logger=inputs.logger,)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/tests/test_eventee.py b/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/tests/test_eventee.pynew file mode 100644index 000000000000..99d207619efd--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/tests/test_eventee.py@@ -0,0 +1,189 @@+from typing import Any+from urllib.parse import urlparse++import pytest+from unittest import mock++from products.warehouse_sources.backend.temporal.data_imports.sources.eventee.eventee import (+ EVENTEE_BASE_URL,+ MAX_RETRY_ATTEMPTS,+ EventeeRetryableError,+ eventee_source,+ get_rows,+ validate_credentials,+)+from products.warehouse_sources.backend.temporal.data_imports.sources.eventee.settings import (+ ENDPOINTS,+ EVENTEE_ENDPOINTS,+)++_MODULE = "products.warehouse_sources.backend.temporal.data_imports.sources.eventee.eventee"+++def _json_response(body: Any) -> mock.MagicMock:+ resp = mock.MagicMock()+ resp.json.return_value = body+ resp.status_code = 200+ resp.ok = True+ return resp+++def _error_response(status_code: int) -> mock.MagicMock:+ resp = mock.MagicMock()+ resp.status_code = status_code+ resp.ok = False+ resp.text = "error"+ return resp+++class TestValidateCredentials:+ @pytest.mark.parametrize(+ "status_code, expected",+ [+ (200, True),+ (401, False),+ (403, False),+ (500, False),+ ],+ )+ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_validate_credentials_status_mapping(self, mock_session, status_code, expected):+ response = mock.MagicMock()+ response.status_code = status_code+ mock_session.return_value.get.return_value = response++ assert validate_credentials("tok") is expected++ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_validate_sends_bearer_token(self, mock_session):+ response = mock.MagicMock()+ response.status_code = 200+ mock_session.return_value.get.return_value = response++ validate_credentials("tok")++ headers = mock_session.call_args.kwargs["headers"]+ assert headers["Authorization"] == "Bearer tok"++ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_validate_credentials_swallows_exceptions(self, mock_session):+ mock_session.return_value.get.side_effect = Exception("boom")+ assert validate_credentials("tok") is False+++class TestGetRows:+ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_content_subresource_extracted_by_data_key(self, mock_session):+ # /content bundles several lists; the `halls` table reads its rows from the `halls` key and+ # must not pick up rows from sibling keys.+ content = {+ "halls": [{"id": 1, "name": "Main"}],+ "lectures": [{"id": 99, "name": "Keynote"}],+ }+ mock_session.return_value.get.return_value = _json_response(content)++ batches = list(get_rows("tok", "halls", mock.MagicMock()))++ assert batches == [[{"id": 1, "name": "Main"}]]+ url = mock_session.return_value.get.call_args.args[0]+ assert urlparse(url).path == "/public/v1/content"++ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_standalone_array_endpoint(self, mock_session):+ mock_session.return_value.get.return_value = _json_response([{"id": 7}, {"id": 8}])++ batches = list(get_rows("tok", "groups", mock.MagicMock()))++ assert batches == [[{"id": 7}, {"id": 8}]]+ assert urlparse(mock_session.return_value.get.call_args.args[0]).path == "/public/v1/groups"++ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_single_object_response_wrapped_in_list(self, mock_session):+ # /registrations can return a bare object rather than an array.+ mock_session.return_value.get.return_value = _json_response({"id": 420, "email": "[email protected]"})++ batches = list(get_rows("tok", "registrations", mock.MagicMock()))++ assert batches == [[{"id": 420, "email": "[email protected]"}]]++ @pytest.mark.parametrize(+ "endpoint, body",+ [+ ("halls", {"halls": []}),+ ("halls", {"lectures": [{"id": 1}]}), # data_key missing entirely+ ("groups", []),+ ("groups", None),+ ],+ )+ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_empty_or_missing_data_yields_nothing(self, mock_session, endpoint, body):+ mock_session.return_value.get.return_value = _json_response(body)++ assert list(get_rows("tok", endpoint, mock.MagicMock())) == []++ @mock.patch("time.sleep")+ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_retries_retryable_status_then_succeeds(self, mock_session, _mock_sleep):+ mock_session.return_value.get.side_effect = [+ _error_response(500),+ _error_response(429),+ _json_response([{"id": 1}]),+ ]++ batches = list(get_rows("tok", "groups", mock.MagicMock()))++ assert batches == [[{"id": 1}]]+ assert mock_session.return_value.get.call_count == 3++ @mock.patch("time.sleep")+ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_retries_exhausted_raises(self, mock_session, _mock_sleep):+ mock_session.return_value.get.return_value = _error_response(503)++ with pytest.raises(EventeeRetryableError):+ list(get_rows("tok", "groups", mock.MagicMock()))++ assert mock_session.return_value.get.call_count == MAX_RETRY_ATTEMPTS++ @mock.patch("time.sleep")+ @mock.patch(f"{_MODULE}.make_tracked_session")+ def test_client_error_raises_for_status(self, mock_session, _mock_sleep):+ # A 401 is not retryable — it must propagate via raise_for_status so the source can mark it+ # non-retryable rather than burning retries on a bad token.+ resp = _error_response(401)+ resp.raise_for_status.side_effect = Exception("401 Client Error")+ mock_session.return_value.get.return_value = resp++ with pytest.raises(Exception, match="401 Client Error"):+ list(get_rows("tok", "groups", mock.MagicMock()))++ assert mock_session.return_value.get.call_count == 1+++class TestEventeeSourceResponse:+ @pytest.mark.parametrize("endpoint", list(ENDPOINTS))+ def test_response_metadata_per_endpoint(self, endpoint):+ config = EVENTEE_ENDPOINTS[endpoint]+ response = eventee_source("tok", endpoint, mock.MagicMock())++ assert response.name == endpoint+ assert response.primary_keys == config.primary_keys+ assert response.sort_mode == "asc"++ if config.partition_key:+ assert response.partition_mode == "datetime"+ assert response.partition_format == "month"+ assert response.partition_keys == [config.partition_key]+ else:+ assert response.partition_mode is None+ assert response.partition_keys is None++ @pytest.mark.parametrize("endpoint", list(ENDPOINTS))+ def test_partition_keys_are_stable_creation_fields(self, endpoint):+ # Partitioning on a mutable field (updated_at / checked_at) rewrites partitions every sync.+ config = EVENTEE_ENDPOINTS[endpoint]+ if config.partition_key:+ assert config.partition_key in ("created_at", "registered_at")++ def test_base_url_is_fixed(self):+ assert EVENTEE_BASE_URL == "https://api.eventee.com/public/v1"diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/tests/test_eventee_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/tests/test_eventee_source.pynew file mode 100644index 000000000000..f4c4af69fbf2--- /dev/null+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eventee/tests/test_eventee_source.py@@ -0,0 +1,115 @@+import pytest+from unittest import mock++from posthog.schema import ReleaseStatus, SourceFieldInputConfig, SourceFieldInputConfigType++from products.warehouse_sources.backend.temporal.data_imports.sources.eventee.settings import ENDPOINTS+from products.warehouse_sources.backend.temporal.data_imports.sources.eventee.source import EventeeSource+from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs import EventeeSourceConfig+from products.warehouse_sources.backend.types import ExternalDataSourceType+++class TestEventeeSource:+ def setup_method(self):+ self.source = EventeeSource()+ self.team_id = 123+ self.config = EventeeSourceConfig(api_key="tok")++ def test_source_type(self):+ assert self.source.source_type == ExternalDataSourceType.EVENTEE++ def test_get_source_config(self):+ config = self.source.get_source_config++ assert config.name.value == "Eventee"+ assert config.label == "Eventee"+ assert config.releaseStatus == ReleaseStatus.ALPHA+ assert config.unreleasedSource is None+ assert config.iconPath == "/static/services/eventee.png"+ assert config.docsUrl == "https://posthog.com/docs/cdp/sources/eventee"++ 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):+ config = self.source.get_source_config+ token_field = next(f for f in config.fields if isinstance(f, SourceFieldInputConfig) and f.name == "api_key")+ assert token_field.type == SourceFieldInputConfigType.PASSWORD+ assert token_field.secret is True+ assert token_field.required is True++ @pytest.mark.parametrize(+ "observed_error",+ [+ "401 Client Error: Unauthorized for url: https://api.eventee.com/public/v1/content",+ "403 Client Error: Forbidden for url: https://api.eventee.com/public/v1/groups",+ ],+ )+ def test_non_retryable_errors_match_auth_failures(self, observed_error):+ 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",+ [+ "401 Client Error: Unauthorized for url: https://api.stripe.com/v1/customers",+ "500 Server Error for url: https://api.eventee.com/public/v1/reviews",+ ],+ )+ def test_non_retryable_errors_does_not_match_unrelated(self, other_error):+ 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_full_refresh_only(self):+ schemas = self.source.get_schemas(self.config, self.team_id)++ assert {schema.name for schema in schemas} == set(ENDPOINTS)+ assert all(not schema.supports_incremental for schema in schemas)+ assert all(not schema.supports_append for schema in schemas)+ assert all(schema.incremental_fields == [] for schema in schemas)++ def test_get_schemas_filtered_by_names(self):+ schemas = self.source.get_schemas(self.config, self.team_id, names=["reviews"])+ assert len(schemas) == 1+ assert schemas[0].name == "reviews"++ def test_get_schemas_filtered_unknown_name_returns_empty(self):+ assert self.source.get_schemas(self.config, self.team_id, names=["nope"]) == []++ def test_lists_tables_without_credentials(self):+ # Static catalog with no I/O — required for the public docs Supported tables section to render.+ assert self.source.lists_tables_without_credentials is True+ tables = self.source.get_documented_tables()+ assert {t["name"] for t in tables} == set(ENDPOINTS)+ assert all("Full refresh" in t["sync_methods"] for t in tables)++ @pytest.mark.parametrize(+ "mock_return, expected_valid, expected_message",+ [+ (True, True, None),+ (False, False, "Invalid Eventee API token"),+ ],+ )+ @mock.patch(+ "products.warehouse_sources.backend.temporal.data_imports.sources.eventee.source.validate_eventee_credentials"+ )+ def test_validate_credentials(self, mock_validate, mock_return, expected_valid, expected_message):+ 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("tok")++ @mock.patch("products.warehouse_sources.backend.temporal.data_imports.sources.eventee.source.eventee_source")+ def test_source_for_pipeline_plumbs_arguments(self, mock_eventee_source):+ inputs = mock.MagicMock()+ inputs.schema_name = "reviews"++ self.source.source_for_pipeline(self.config, inputs)++ mock_eventee_source.assert_called_once()+ kwargs = mock_eventee_source.call_args.kwargs+ assert kwargs["api_key"] == "tok"+ assert kwargs["endpoint"] == "reviews"diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.py b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.pyindex b9a6b4b53dca..4bb434717038 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/generated_configs.py@@ -1079,7 +1079,7 @@ class EventbriteSourceConfig(config.Config):@config.configclass EventeeSourceConfig(config.Config):- pass+ api_key: str@config.config