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(warehouse-sources): add luma ticket types, coupons, tags, calendars (#114898)

Tom Owersa3dcd8307613
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.md
index d5d397e4f405..f759a0aa738d 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
@@ -5310,10 +5310,10 @@ Today (5): `event_blasts`, `events`, `guests`, `people`, `person_tags`
Diffed against: <https://docs.luma.com/llms.txt>
-- [ ] `GET /v1/events/ticket-types/list` — lookup resolving the ticket type ids on every guest ticket and order (high)
-- [ ] `GET /v1/calendars/event-tags/list` — event tag lookup — person_tags is synced but the event-side equivalent is not (high)
-- [ ] `GET /v1/organizations/calendars/list` — lookup resolving calendar ids that own events and contacts (high)
-- [ ] `GET /v1/events/coupons/list` — coupon dimension behind discounted ticket orders (medium)
+- [x] `GET /v1/events/ticket-types/list` — lookup resolving the ticket type ids on every guest ticket and order, synced as `ticket_types` (high)
+- [x] `GET /v1/calendars/event-tags/list` — event tag lookup — person_tags is synced but the event-side equivalent is not, synced as `event_tags` (high)
+- [x] `GET /v1/organizations/calendars/list` — lookup resolving calendar ids that own events and contacts, synced as `calendars` (organization API keys only) (high)
+- [x] `GET /v1/events/coupons/list` — coupon dimension behind discounted ticket orders, synced as `event_coupons` (medium)
- [ ] `GET /v1/calendars/coupons/list` — calendar-wide coupons applying across events (medium)
- [ ] `GET /v1/memberships/tiers/list` — membership tier lookup for paid community members (medium)
- [ ] `GET /v1/calendars/admins/list` — calendar admin/host membership table (medium)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/luma/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/luma/canonical_descriptions.py
index dcfe0efa02c7..9cab0930d295 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/luma/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/luma/canonical_descriptions.py
@@ -89,4 +89,65 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"name": "Name of the tag.",
},
},
+ "ticket_types": {
+ "description": "A ticket type offered for a Luma event, including its price and availability window. Hidden ticket types are included.",
+ "docs_url": "https://docs.luma.com/reference/get_v1-events-ticket-types-list",
+ "columns": {
+ "id": "Unique identifier for the ticket type.",
+ "event_id": "Identifier of the event the ticket type belongs to (evt-...).",
+ "name": "Name of the ticket type.",
+ "description": "Description of the ticket type.",
+ "type": "Pricing type of the ticket: free or paid.",
+ "cents": "Price of the ticket in the smallest currency unit (e.g. cents).",
+ "currency": "Currency of the ticket price.",
+ "is_flexible": "Whether guests can choose how much to pay.",
+ "min_cents": "Minimum price for flexible-price tickets, in the smallest currency unit.",
+ "require_approval": "Whether guests who pick this ticket type need host approval.",
+ "is_hidden": "Whether the ticket type is hidden from the public registration page.",
+ "max_capacity": "Maximum number of tickets of this type that can be issued.",
+ "valid_start_at": "When the ticket type becomes available (ISO 8601).",
+ "valid_end_at": "When the ticket type stops being available (ISO 8601).",
+ },
+ },
+ "event_coupons": {
+ "description": "A coupon code that discounts registration for a single Luma event.",
+ "docs_url": "https://docs.luma.com/reference/get_v1-events-coupons-list",
+ "columns": {
+ "id": "Unique identifier for the coupon.",
+ "event_id": "Identifier of the event the coupon applies to (evt-...).",
+ "code": "Coupon code guests enter at registration. Case insensitive.",
+ "remaining_count": "Number of remaining uses of the coupon.",
+ "valid_start_at": "When the coupon becomes valid (ISO 8601).",
+ "valid_end_at": "When the coupon expires (ISO 8601).",
+ "percent_off": "Percentage discount the coupon applies.",
+ "cents_off": "Fixed discount the coupon applies, in the smallest currency unit.",
+ "currency": "Currency of the fixed discount.",
+ "event_ticket_type_id": "Ticket type the coupon is restricted to, if any.",
+ },
+ },
+ "event_tags": {
+ "description": "A tag used to group events on your Luma calendar.",
+ "docs_url": "https://docs.luma.com/reference/get_v1-calendars-event-tags-list",
+ "columns": {
+ "id": "Unique identifier for the event tag.",
+ "name": "Name of the event tag.",
+ "color": "Display color of the event tag.",
+ },
+ },
+ "calendars": {
+ "description": "A calendar that belongs to your Luma organization. Only available with an organization API key.",
+ "docs_url": "https://docs.luma.com/reference/get_v1-organizations-calendars-list",
+ "columns": {
+ "id": "Unique identifier for the calendar (cal-...).",
+ "name": "Name of the calendar.",
+ "slug": "URL slug of the calendar.",
+ "url": "Public Luma URL of the calendar page.",
+ "description": "Description of the calendar.",
+ "launch_status": "Calendar status: launched (active), coming-soon, or archived.",
+ "is_personal": "Whether the calendar is a personal calendar.",
+ "tint_color": "Accent color of the calendar as a hex code.",
+ "location": "Location the calendar is associated with.",
+ "website": "Website linked from the calendar.",
+ },
+ },
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/luma/luma.py b/products/warehouse_sources/backend/temporal/data_imports/sources/luma/luma.py
index 66654a66c6a7..4053cc2b8e85 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/luma/luma.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/luma/luma.py
@@ -118,7 +118,7 @@ def _get_child_rows_for_event(
config.path,
cursor,
logger,
- extra_params={config.event_id_param: event_api_id},
+ extra_params={config.event_id_param: event_api_id, **config.static_params},
paginate=config.paginated,
)
rows = [{**_flatten_entry(entry, config.nested_key), config.event_id_param: event_api_id} for entry in entries]
@@ -172,7 +172,9 @@ def _get_top_level_rows(
logger.debug(f"Luma: resuming {config.name} from cursor {cursor}")
while True:
- entries, next_cursor = _fetch_page(session, config.path, cursor, logger)
+ entries, next_cursor = _fetch_page(
+ session, config.path, cursor, logger, extra_params=config.static_params, paginate=config.paginated
+ )
rows = [_flatten_entry(entry, config.nested_key) for entry in entries]
if rows:
yield rows
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/luma/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/luma/settings.py
index 35f3b1dc5df1..6be3eeb8083e 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/luma/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/luma/settings.py
@@ -16,11 +16,19 @@ class LumaEndpointConfig:
event_id_param: str = "event_api_id"
# Some newer list endpoints return every entry in one response and take no pagination params.
paginated: bool = True
+ # Fixed query params sent on every request to the endpoint.
+ static_params: dict[str, str] = field(default_factory=dict)
+ # Organization-level endpoints reject calendar-scoped API keys.
+ requires_organization_key: bool = False
EVENTS_PATH = "/public/v1/calendar/list-events"
GUESTS_PATH = "/public/v1/event/get-guests"
BLASTS_PATH = "/v1/events/blasts/list"
+TICKET_TYPES_PATH = "/v1/events/ticket-types/list"
+EVENT_COUPONS_PATH = "/v1/events/coupons/list"
+EVENT_TAGS_PATH = "/v1/calendars/event-tags/list"
+CALENDARS_PATH = "/v1/organizations/calendars/list"
# Luma public API list endpoints. All are full refresh only: pagination is cursor-based
# (`pagination_cursor` + `has_more`/`next_cursor`) and there is no server-side updated-since filter.
@@ -46,6 +54,27 @@ LUMA_ENDPOINTS: dict[str, LumaEndpointConfig] = {
event_id_param="event_id",
paginated=False,
),
+ # Hidden ticket types are included because guests registered under them keep referencing their ids.
+ "ticket_types": LumaEndpointConfig(
+ name="ticket_types",
+ path=TICKET_TYPES_PATH,
+ primary_keys=["event_id", "id"],
+ fan_out_over_events=True,
+ event_id_param="event_id",
+ paginated=False,
+ static_params={"include_hidden": "true"},
+ ),
+ "event_coupons": LumaEndpointConfig(
+ name="event_coupons",
+ path=EVENT_COUPONS_PATH,
+ primary_keys=["event_id", "id"],
+ fan_out_over_events=True,
+ event_id_param="event_id",
+ ),
+ "event_tags": LumaEndpointConfig(name="event_tags", path=EVENT_TAGS_PATH, primary_keys=["id"], paginated=False),
+ "calendars": LumaEndpointConfig(
+ name="calendars", path=CALENDARS_PATH, primary_keys=["id"], requires_organization_key=True
+ ),
"people": LumaEndpointConfig(name="people", path="/public/v1/calendar/list-people"),
"person_tags": LumaEndpointConfig(name="person_tags", path="/public/v1/calendar/list-person-tags"),
}
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/luma/source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/luma/source.py
index 0d302c2eb7d9..1310a1b7d2bf 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/luma/source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/luma/source.py
@@ -18,6 +18,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.typ
from products.warehouse_sources.backend.temporal.data_imports.sources.generated_configs.luma import LumaSourceConfig
from products.warehouse_sources.backend.temporal.data_imports.sources.luma.luma import (
LumaResumeConfig,
+ check_access,
luma_source,
validate_credentials,
)
@@ -110,6 +111,23 @@ You can create an API key under **Settings → Developer** in [Luma](https://lum
# single probe validates access to every schema.
return validate_credentials(config.api_key)
+ def get_endpoint_permissions(
+ self, config: LumaSourceConfig, team_id: int, endpoints: list[str], api_version: str | None = None
+ ) -> dict[str, str | None]:
+ permissions: dict[str, str | None] = {}
+ for endpoint in endpoints:
+ endpoint_config = LUMA_ENDPOINTS.get(endpoint)
+ if endpoint_config is None or not endpoint_config.requires_organization_key:
+ permissions[endpoint] = None
+ continue
+ status, _ = check_access(config.api_key, endpoint_config.path)
+ permissions[endpoint] = (
+ "Requires a Luma organization API key. Calendar API keys can't list organization calendars."
+ if status in (400, 401, 403)
+ else None
+ )
+ return permissions
+
def get_resumable_source_manager(self, inputs: SourceInputs) -> ResumableSourceManager[LumaResumeConfig]:
return ResumableSourceManager[LumaResumeConfig](inputs, LumaResumeConfig)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/luma/tests/test_luma.py b/products/warehouse_sources/backend/temporal/data_imports/sources/luma/tests/test_luma.py
index c1b7930f1ebe..bc83c31a3017 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/luma/tests/test_luma.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/luma/tests/test_luma.py
@@ -22,6 +22,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.luma.setti
EVENTS_PATH,
GUESTS_PATH,
LUMA_ENDPOINTS,
+ TICKET_TYPES_PATH,
)
# Call the undecorated function so the tenacity retry/backoff wrapper doesn't slow failure-path tests.
@@ -139,7 +140,16 @@ class TestGuestsFanOut:
rows.extend(batch)
return rows
- def test_event_blasts_are_fetched_per_event_without_pagination(self, monkeypatch: Any) -> None:
+ @pytest.mark.parametrize(
+ "endpoint,path,static_params",
+ [
+ ("event_blasts", BLASTS_PATH, {}),
+ ("ticket_types", TICKET_TYPES_PATH, {"include_hidden": "true"}),
+ ],
+ )
+ def test_unpaginated_children_are_fetched_per_event(
+ self, endpoint: str, path: str, static_params: dict[str, str], monkeypatch: Any
+ ) -> None:
manager = _FakeResumableManager()
pages: FanOutPageMap = {
(EVENTS_PATH, None, None): (
@@ -149,15 +159,15 @@ class TestGuestsFanOut:
],
None,
),
- (BLASTS_PATH, None, "evt-1"): ([{"id": "bst-a", "event_id": "evt-1", "status": "sent"}], None),
- (BLASTS_PATH, None, "evt-2"): ([], None),
+ (path, None, "evt-1"): ([{"id": "row-a", "status": "sent"}], None),
+ (path, None, "evt-2"): ([], None),
}
- rows = self._collect(manager, monkeypatch, pages, endpoint="event_blasts")
- assert rows == [{"id": "bst-a", "event_id": "evt-1", "status": "sent"}]
- blast_calls = [c for c in self.calls if c[0] == BLASTS_PATH]
- assert blast_calls == [
- (BLASTS_PATH, {"event_id": "evt-1"}, False),
- (BLASTS_PATH, {"event_id": "evt-2"}, False),
+ rows = self._collect(manager, monkeypatch, pages, endpoint=endpoint)
+ assert rows == [{"id": "row-a", "event_id": "evt-1", "status": "sent"}]
+ child_calls = [c for c in self.calls if c[0] == path]
+ assert child_calls == [
+ (path, {"event_id": "evt-1", **static_params}, False),
+ (path, {"event_id": "evt-2", **static_params}, False),
]
def test_paginates_guests_within_an_event(self, monkeypatch: Any) -> None:
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/luma/tests/test_luma_source.py b/products/warehouse_sources/backend/temporal/data_imports/sources/luma/tests/test_luma_source.py
index d7ad49d9f79d..41ac4f9e9215 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/luma/tests/test_luma_source.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/luma/tests/test_luma_source.py
@@ -54,6 +54,31 @@ class TestLumaSource:
assert kwargs["endpoint"] == "events"
assert kwargs["resumable_source_manager"] is manager
+ @parameterized.expand(
+ [
+ ("calendar_key_rejected", 403, "Requires a Luma organization API key"),
+ ("calendar_key_bad_request", 400, "Requires a Luma organization API key"),
+ ("organization_key", 200, None),
+ ("transient_failure", 500, None),
+ ]
+ )
+ def test_endpoint_permissions_probe_organization_endpoints(
+ self, _name: str, status: int, expected_reason_prefix: str | None
+ ) -> None:
+ with mock.patch(
+ "products.warehouse_sources.backend.temporal.data_imports.sources.luma.source.check_access",
+ return_value=(status, None),
+ ) as mock_check:
+ permissions = self.source.get_endpoint_permissions(self.config, self.team_id, ["calendars", "events"])
+
+ mock_check.assert_called_once_with("luma-key", "/v1/organizations/calendars/list")
+ assert permissions["events"] is None
+ reason = permissions["calendars"]
+ if expected_reason_prefix is None:
+ assert reason is None
+ else:
+ assert reason is not None and reason.startswith(expected_reason_prefix)
+
def test_source_for_pipeline_rejects_unknown_schema(self) -> None:
inputs = mock.MagicMock()
inputs.schema_name = "not_a_table"