: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(eventbrite): add sales, attendee, question and subcategory tables (#107279)
Tom Owers9f6a605b1849
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 e1aac09af266..611f22e788e2 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@@ -2897,14 +2897,14 @@ Note: eppo.cloud/api/docs is a Swagger UI shell; the machine-readable spec is at## Eventbrite — gaps-Today (8): `attendees`, `categories`, `events`, `formats`, `orders`, `organizations`, `ticket_classes`, `venues`+Today (13): `attendee_report`, `attendees`, `canned_questions`, `categories`, `events`, `formats`, `orders`, `organizations`, `questions`, `sales_report`, `subcategories`, `ticket_classes`, `venues`Diffed against: <https://jsapi.apiary.io/apis/eventbriteapiv3public/api-description-document>-- [ ] `/reports/sales/ (Retrieve a Sales Report)` — the vendor's headline sales metric, aggregated gross/net/fees by event and date (high)-- [ ] `/reports/attendees/ (Retrieve an Attendee Report)` — aggregated attendee report, the companion headline metric to the sales report (high)-- [ ] `/events/{event_id}/questions/ and /events/{event_id}/canned_questions/` — lookup resolving the question ids referenced by the answers embedded in attendee and order records (high)-- [ ] `/subcategories/ (List of Subcategories)` — lookup resolving subcategory_id on events; only top-level categories are synced (high)+- [x] `/reports/sales/ (Retrieve a Sales Report)` — the vendor's headline sales metric, aggregated gross/net/fees by event and date (high) — added as `sales_report`, fanned out per event+- [x] `/reports/attendees/ (Retrieve an Attendee Report)` — aggregated attendee report, the companion headline metric to the sales report (high) — added as `attendee_report`, fanned out per event+- [x] `/events/{event_id}/questions/ and /events/{event_id}/canned_questions/` — lookup resolving the question ids referenced by the answers embedded in attendee and order records (high) — added as `questions` and `canned_questions`+- [x] `/subcategories/ (List of Subcategories)` — lookup resolving subcategory_id on events; only top-level categories are synced (high) — added as `subcategories`- [ ] `/organizations/{organization_id}/discounts/ (Search Discounts by Organization)` — discount and promo code definitions plus usage counts, needed to explain order pricing (medium)- [ ] `/organizations/{organization_id}/ticket_groups/` — ticket group lookup that groups the ticket classes already synced (medium)- [ ] `/organizations/{organization_id}/members/ (List Members of an Organization)` — organization membership, resolving who has access to the organizations already synced (medium)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/canonical_descriptions.pyindex 774de15aa2c2..c53e209fcfae 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/canonical_descriptions.py@@ -32,6 +32,16 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"short_name": "Short display name of the category.",},},+ "subcategories": {+ "description": "A subcategory nested under a top-level category, resolving the subcategory_id on events.",+ "docs_url": "https://www.eventbrite.com/platform/api#/reference/category",+ "columns": {+ "id": "Unique identifier for the subcategory.",+ "name": "Display name of the subcategory.",+ "resource_uri": "Eventbrite API URL of the subcategory.",+ "parent_category": "The top-level category this subcategory belongs to.",+ },+ },"formats": {"description": "An event format describing the style of an event (e.g. Conference, Seminar).","docs_url": "https://www.eventbrite.com/platform/api#/reference/format",@@ -132,4 +142,65 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"hidden": "Whether the ticket class is hidden from buyers.",},},+ "questions": {+ "description": "A custom question asked of ticket buyers during registration for an event.",+ "docs_url": "https://www.eventbrite.com/platform/api#/reference/questions",+ "columns": {+ "id": "Unique identifier for the question within its event.",+ "_events_id": "ID of the event the question belongs to.",+ "question": "The question text, as plain text and HTML.",+ "type": "Input type of the question (e.g. text, checkbox, dropdown).",+ "required": "Whether an answer is required to complete registration.",+ "respondent": "Who answers the question (e.g. ticket_buyer, attendee).",+ "choices": "The answer choices offered, with their availability and sold counts.",+ "ticket_classes": "Ticket classes the question applies to.",+ "parent_id": "ID of the question this one is nested under, if any.",+ "parent_choice_id": "ID of the parent question's choice that reveals this question.",+ "display_answer_on_order": "Whether the answer is shown on the order.",+ "sorting": "Position of the question in the registration form.",+ "resource_uri": "Eventbrite API URL of the question.",+ },+ },+ "canned_questions": {+ "description": "A default question Eventbrite offers for an event's registration form, such as first name or job title.",+ "docs_url": "https://www.eventbrite.com/platform/api#/reference/questions",+ "columns": {+ "id": "Identifier of the default question (a slug such as `job_title`), unique within its event.",+ "_events_id": "ID of the event the question belongs to.",+ "question": "The question text, as plain text and HTML.",+ "type": "Input type of the question (e.g. text, checkbox, dropdown).",+ "required": "Whether an answer is required to complete registration.",+ "include": "Whether the question is included in the event's registration form.",+ "editable": "Whether the question can be edited for this event.",+ "respondent": "Who answers the question (e.g. ticket_buyer, attendee).",+ "choices": "The answer choices offered.",+ "ticket_classes": "Ticket classes the question applies to.",+ "group_id": "Identifier of the group the question is displayed under.",+ "group_display_header": "Display header of the question's group.",+ "default_value": "Value pre-filled into the answer, if any.",+ "resource_uri": "Eventbrite API URL of the question.",+ },+ },+ "sales_report": {+ "description": "Sales totals for an event, aggregated per date — gross, net, fees, and quantity sold.",+ "docs_url": "https://www.eventbrite.com/platform/api#/reference/reports",+ "columns": {+ "_events_id": "ID of the event the totals are reported for.",+ "date": "Start of the aggregation period, in UTC.",+ "date_localized": "Start of the aggregation period, in the report's timezone.",+ "topics": "The grouping the row is aggregated by, when the report is grouped.",+ "totals": "Sales totals for the period: currency, gross, net, fees, royalty, and quantity.",+ },+ },+ "attendee_report": {+ "description": "Attendee totals for an event, aggregated per date — attendee and order counts.",+ "docs_url": "https://www.eventbrite.com/platform/api#/reference/reports",+ "columns": {+ "_events_id": "ID of the event the totals are reported for.",+ "date": "Start of the aggregation period, in UTC.",+ "date_localized": "Start of the aggregation period, in the report's timezone.",+ "topics": "The grouping the row is aggregated by, when the report is grouped.",+ "totals": "Attendee totals for the period: number of attendees and number of orders.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/eventbrite.py b/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/eventbrite.pyindex f48893b5533c..40e4ed2df2b4 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/eventbrite.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/eventbrite.py@@ -137,9 +137,12 @@ def _leaf_endpoint(incremental: Optional[IncrementalConfig] = None,) -> Endpoint:endpoint: Endpoint = {"path": config.path, "data_selector": config.data_key}+ params: dict[str, Any] = dict(config.params)if resolve is not None:param_name, parent, field = resolve- endpoint["params"] = {param_name: {"type": "resolve", "resource": parent, "field": field}}+ params[param_name] = {"type": "resolve", "resource": parent, "field": field}+ if params:+ endpoint["params"] = paramsif incremental is not None:endpoint["incremental"] = incrementalreturn endpoint@@ -234,7 +237,10 @@ def eventbrite_source(_parent_resource("events", ORG_EVENTS_PATH, "events", ("organization_id", "organizations", "id")))leaf = _leaf_endpoint(config, resolve=("event_id", "events", "id"), incremental=incremental)- resources.append({"name": endpoint, "endpoint": leaf})+ leaf_resource: EndpointResource = {"name": endpoint, "endpoint": leaf}+ if config.include_from_parent:+ leaf_resource["include_from_parent"] = config.include_from_parent+ resources.append(leaf_resource)rest_config = {"client": client, "resources": resources}built = rest_api_resources(diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/settings.pyindex 6953210c8325..c0cd2541f4a4 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/settings.py@@ -1,7 +1,9 @@-from dataclasses import dataclass, field+from dataclasses import fieldfrom enum import Enumfrom typing import Optional+from posthog.dataclasses import frozen+from products.warehouse_sources.backend.types import IncrementalField, IncrementalFieldType@@ -19,7 +21,7 @@ class EndpointScope(Enum):EVENT = "event"-@dataclass+@frozenclass EventbriteEndpointConfig:name: strpath: str@@ -31,6 +33,10 @@ class EventbriteEndpointConfig:# Resource change-timestamp field targeted by Eventbrite's server-side `changed_since` filter# (e.g. `changed`). When set, the endpoint supports true incremental sync; otherwise full refresh.changed_since_field: Optional[str] = None+ params: dict[str, str] = field(default_factory=dict) # Static query params the endpoint requires+ # Parent fields copied onto each child row as `_<parent>_<field>`, for fan-out endpoints whose+ # rows carry no reference back to the event they belong to.+ include_from_parent: list[str] = field(default_factory=list)def _changed_incremental_field() -> list[IncrementalField]:@@ -66,6 +72,12 @@ EVENTBRITE_ENDPOINTS: dict[str, EventbriteEndpointConfig] = {data_key="categories",scope=EndpointScope.TOP_LEVEL,),+ "subcategories": EventbriteEndpointConfig(+ name="subcategories",+ path="/subcategories/",+ data_key="subcategories",+ scope=EndpointScope.TOP_LEVEL,+ ),"formats": EventbriteEndpointConfig(name="formats",path="/formats/",@@ -109,6 +121,46 @@ EVENTBRITE_ENDPOINTS: dict[str, EventbriteEndpointConfig] = {data_key="ticket_classes",scope=EndpointScope.EVENT,),+ "questions": EventbriteEndpointConfig(+ name="questions",+ path="/events/{event_id}/questions/",+ data_key="questions",+ scope=EndpointScope.EVENT,+ # Question ids are only unique within their event, so the event id joins the key.+ primary_keys=["_events_id", "id"],+ include_from_parent=["id"],+ ),+ "canned_questions": EventbriteEndpointConfig(+ name="canned_questions",+ path="/events/{event_id}/canned_questions/",+ data_key="questions",+ scope=EndpointScope.EVENT,+ # Default questions are identified by slug (e.g. `job_title`), repeated across every event.+ primary_keys=["_events_id", "id"],+ include_from_parent=["id"],+ params={"include_all": "true"},+ ),+ # The report endpoints take their event as a query param rather than a path segment, and the+ # fan-out framework only binds a resolved parent field into the path — so the query string is+ # written into the path template.+ "sales_report": EventbriteEndpointConfig(+ name="sales_report",+ path="/reports/sales/?event_ids={event_id}",+ data_key="data",+ scope=EndpointScope.EVENT,+ primary_keys=["_events_id", "date"],+ partition_key="date",+ include_from_parent=["id"],+ ),+ "attendee_report": EventbriteEndpointConfig(+ name="attendee_report",+ path="/reports/attendees/?event_ids={event_id}",+ data_key="data",+ scope=EndpointScope.EVENT,+ primary_keys=["_events_id", "date"],+ partition_key="date",+ include_from_parent=["id"],+ ),}ENDPOINTS = tuple(EVENTBRITE_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/tests/test_eventbrite.py b/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/tests/test_eventbrite.pyindex 13adfc29ccd8..b59232a840e8 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/tests/test_eventbrite.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/eventbrite/tests/test_eventbrite.py@@ -220,6 +220,113 @@ class TestFanOut:assert [r["id"] for r in rows] == ["e1", "e2"]+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_questions_carry_their_event_id(self, MockSession: mock.MagicMock) -> None:+ # Question ids repeat across events, so the row is only addressable with the event id the+ # fan-out injects — without it the composite primary key collapses and merges multi-match.+ session = MockSession.return_value++ def router(url: str) -> Response:+ if url.endswith("/users/me/organizations/"):+ return _response("organizations", [{"id": "org1"}])+ if url.endswith("/organizations/org1/events/"):+ return _response("events", [{"id": "e1"}, {"id": "e2"}])+ if url.endswith("/events/e1/questions/"):+ return _response("questions", [{"id": "q1"}])+ if url.endswith("/events/e2/questions/"):+ return _response("questions", [{"id": "q1"}])+ raise AssertionError(f"unexpected url {url}")++ _wire(session, router)++ response = _run("questions", _make_manager())+ rows = _rows(response)++ assert rows == [{"id": "q1", "_events_id": "e1"}, {"id": "q1", "_events_id": "e2"}]+ assert set(response.primary_keys or []) <= rows[0].keys()++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_canned_questions_request_the_full_list(self, MockSession: mock.MagicMock) -> None:+ # Eventbrite documents `include_all` as required; without it the endpoint returns only the+ # questions already enabled on the event.+ session = MockSession.return_value++ def router(url: str) -> Response:+ if url.endswith("/users/me/organizations/"):+ return _response("organizations", [{"id": "org1"}])+ if url.endswith("/organizations/org1/events/"):+ return _response("events", [{"id": "e1"}])+ if url.endswith("/events/e1/canned_questions/"):+ return _response("questions", [{"id": "job_title"}])+ raise AssertionError(f"unexpected url {url}")++ snaps = _wire(session, router)++ rows = _rows(_run("canned_questions", _make_manager()))++ assert rows == [{"id": "job_title", "_events_id": "e1"}]+ canned_params = next(p for u, p in snaps if u.endswith("/events/e1/canned_questions/"))+ assert canned_params["include_all"] == "true"+++class TestReports:+ @pytest.mark.parametrize(+ "endpoint, report_path",+ [("sales_report", "/reports/sales/"), ("attendee_report", "/reports/attendees/")],+ )+ @mock.patch(CLIENT_SESSION_PATCH)+ def test_report_binds_event_into_the_query_string(+ self, MockSession: mock.MagicMock, endpoint: str, report_path: str+ ) -> None:+ # The report endpoints take their event as a query param, so the fan-out binds it through the+ # path template rather than a path segment — a row is only attributable to an event because+ # of that binding plus the injected parent id.+ session = MockSession.return_value++ def router(url: str) -> Response:+ if url.endswith("/users/me/organizations/"):+ return _response("organizations", [{"id": "org1"}])+ if url.endswith("/organizations/org1/events/"):+ return _response("events", [{"id": "e1"}, {"id": "e2"}])+ if url.endswith(f"{report_path}?event_ids=e1"):+ return _response("data", [{"date": "2026-03-04T00:00:00Z", "totals": {"quantity": 1}}])+ if url.endswith(f"{report_path}?event_ids=e2"):+ return _response("data", [{"date": "2026-03-04T00:00:00Z", "totals": {"quantity": 2}}])+ raise AssertionError(f"unexpected url {url}")++ _wire(session, router)++ response = _run(endpoint, _make_manager())+ rows = _rows(response)++ assert [(r["_events_id"], r["totals"]["quantity"]) for r in rows] == [("e1", 1), ("e2", 2)]+ assert set(response.primary_keys or []) <= rows[0].keys()++ @mock.patch(CLIENT_SESSION_PATCH)+ def test_report_without_pagination_envelope_stops_after_one_page(self, MockSession: mock.MagicMock) -> None:+ # Reports answer with no `pagination` object at all; the shared continuation paginator must+ # read that as a terminal page instead of looping.+ session = MockSession.return_value++ def router(url: str) -> Response:+ if url.endswith("/users/me/organizations/"):+ return _response("organizations", [{"id": "org1"}])+ if url.endswith("/organizations/org1/events/"):+ return _response("events", [{"id": "e1"}])+ if "/reports/sales/" in url:+ resp = Response()+ resp.status_code = 200+ resp._content = json.dumps({"timezone": "UTC", "event_ids": ["e1"], "data": [{"date": "d"}]}).encode()+ return resp+ raise AssertionError(f"unexpected url {url}")++ _wire(session, router)++ rows = _rows(_run("sales_report", _make_manager()))++ assert rows == [{"date": "d", "_events_id": "e1"}]+ assert session.send.call_count == 3+class TestIncrementalFilter:@mock.patch(CLIENT_SESSION_PATCH)@@ -328,19 +435,31 @@ class TestValidateCredentials:class TestEventbriteSourceResponse:- @pytest.mark.parametrize("endpoint", ["organizations", "events", "orders", "attendees"])+ @pytest.mark.parametrize(+ "endpoint, partition_key",+ [+ ("organizations", "created"),+ ("events", "created"),+ ("orders", "created"),+ ("attendees", "created"),+ ("sales_report", "date"),+ ("attendee_report", "date"),+ ],+ )@mock.patch(CLIENT_SESSION_PATCH)- def test_partitioned_endpoints(self, MockSession: mock.MagicMock, endpoint: str) -> None:+ def test_partitioned_endpoints(self, MockSession: mock.MagicMock, endpoint: str, partition_key: str) -> None:MockSession.return_value.headers = {}response = _run(endpoint, _make_manager())assert response.name == endpoint- assert response.primary_keys == ["id"]assert response.partition_mode == "datetime"assert response.partition_format == "week"- assert response.partition_keys == ["created"]+ assert response.partition_keys == [partition_key]- @pytest.mark.parametrize("endpoint", ["categories", "formats", "venues", "ticket_classes"])+ @pytest.mark.parametrize(+ "endpoint",+ ["categories", "subcategories", "formats", "venues", "ticket_classes", "questions", "canned_questions"],+ )@mock.patch(CLIENT_SESSION_PATCH)def test_non_partitioned_endpoints(self, MockSession: mock.MagicMock, endpoint: str) -> None:MockSession.return_value.headers = {}