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 luma event blasts table (#113300)

Tom Owers7c440bb6f8f1
diff --git a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt
index d33605d369b9..1391d22360b9 100644
--- a/posthog/test/repo_invariants/dataclass_frozen_baseline.txt
+++ b/posthog/test/repo_invariants/dataclass_frozen_baseline.txt
@@ -787,8 +787,6 @@
1 products/warehouse_sources/backend/temporal/data_imports/sources/logz_io/settings.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/loop_returns/loop_returns.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/loops/loops.py
-1 products/warehouse_sources/backend/temporal/data_imports/sources/luma/luma.py
-1 products/warehouse_sources/backend/temporal/data_imports/sources/luma/settings.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/mailchimp/mailchimp.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/mailerlite.py
1 products/warehouse_sources/backend/temporal/data_imports/sources/mailerlite/settings.py
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 b4c4c10a3bfd..7fb0aa46a351 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
@@ -5306,7 +5306,7 @@ Note: Coverage is close to complete — the spec has ~20 listable GET collection
## Luma — gaps
-Today (4): `events`, `guests`, `people`, `person_tags`
+Today (5): `event_blasts`, `events`, `guests`, `people`, `person_tags`
Diffed against: <https://docs.luma.com/llms.txt>
@@ -5320,8 +5320,9 @@ Diffed against: <https://docs.luma.com/llms.txt>
- [ ] `GET /v1/organizations/events/list` — org-wide event list spanning all calendars, broader than the single-calendar events table (medium)
- [ ] `GET /v1/calendars/get` — the calendar record itself (name, timezone, settings) as a dimension (low)
- [ ] `GET /v1/organizations/admins/list` — organization admin roster (low)
+- [x] `GET /v1/events/blasts/list` — per-event email blasts with recipient and open counts, synced as `event_blasts` (medium)
-Note: Luma's docs are ReadMe-hosted with no downloadable OpenAPI; llms.txt is the vendor's own complete operation index and was used as the reference. Source is static (luma/source.py enumerates four schemas, all full-refresh because Luma has no updated-since filter).
+Note: Luma's docs are ReadMe-hosted with no downloadable OpenAPI; llms.txt is the vendor's own complete operation index and was used as the reference. Source is static (luma/source.py enumerates five schemas, all full-refresh because Luma has no updated-since filter).
## MailerLite — gaps
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 b7481667a369..dcfe0efa02c7 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
@@ -52,6 +52,25 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"eth_address": "Ethereum wallet address the guest registered with, when collected.",
},
},
+ "event_blasts": {
+ "description": "An email blast sent or scheduled to an event's guests, with its recipients and open counts.",
+ "docs_url": "https://docs.luma.com/reference/get_v1-events-blasts-list",
+ "columns": {
+ "id": "Unique identifier for the blast.",
+ "event_id": "Identifier of the event the blast was sent for (evt-...).",
+ "subject": "Email subject line of the blast.",
+ "content_md": "Markdown body of the blast.",
+ "status": "Send status of the blast: scheduled, sent, or quarantined (held for review).",
+ "scheduled_for": "When the blast is or was scheduled to send (ISO 8601).",
+ "sent_at": "When the blast finished sending (ISO 8601), or null if not yet sent.",
+ "recipient_groups": "Guest statuses and ticket types the blast targets.",
+ "recipient_count": "Number of guests emailed. Zero until the blast is sent.",
+ "email_open_count": "Number of recipients who opened the blast email.",
+ "sender": "Who sent the blast: a user or the calendar, with a display name.",
+ "can_edit": "Whether the blast can still be edited.",
+ "can_reschedule": "Whether the blast can still be rescheduled. True until it is sent.",
+ },
+ },
"people": {
"description": "A person on your Luma calendar's audience list, aggregated across event registrations and subscriptions.",
"docs_url": "https://docs.luma.com/reference",
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 72b6b5ddd02e..66654a66c6a7 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
@@ -29,10 +29,10 @@ class LumaRetryableError(Exception):
pass
[email protected](frozen=True)
class LumaResumeConfig:
- # `next_cursor` from the last fully processed page, passed back as `pagination_cursor`. For the
- # guests fan-out this is the *events list* cursor: state is saved only after every guest of an
+ # `next_cursor` from the last fully processed page, passed back as `pagination_cursor`. For
+ # fan-out endpoints this is the *events list* cursor: state is saved only after every child of an
# events page has been yielded, so a resume re-pulls at most one page of parents and merge
# dedupes the re-pulled rows on the primary key.
pagination_cursor: str | None = None
@@ -54,8 +54,11 @@ def _fetch_page(
cursor: str | None,
logger: FilteringBoundLogger,
extra_params: dict[str, Any] | None = None,
+ paginate: bool = True,
) -> tuple[list[dict[str, Any]], Optional[str]]:
- params: dict[str, Any] = {"pagination_limit": PAGE_SIZE, **(extra_params or {})}
+ params: dict[str, Any] = {**(extra_params or {})}
+ if paginate:
+ params["pagination_limit"] = PAGE_SIZE
# The first request omits the cursor; subsequent requests pass `next_cursor` from the previous page.
if cursor is not None:
params["pagination_cursor"] = cursor
@@ -102,18 +105,23 @@ def _get_event_api_ids(entries: list[dict[str, Any]]) -> list[str]:
return api_ids
-def _get_guest_rows_for_event(
+def _get_child_rows_for_event(
session: requests.Session,
+ config: LumaEndpointConfig,
event_api_id: str,
logger: FilteringBoundLogger,
) -> Iterator[list[dict[str, Any]]]:
- config = LUMA_ENDPOINTS["guests"]
cursor: str | None = None
while True:
entries, next_cursor = _fetch_page(
- session, config.path, cursor, logger, extra_params={"event_api_id": event_api_id}
+ session,
+ config.path,
+ cursor,
+ logger,
+ extra_params={config.event_id_param: event_api_id},
+ paginate=config.paginated,
)
- rows = [{**_flatten_entry(entry, config.nested_key), "event_api_id": event_api_id} for entry in entries]
+ rows = [{**_flatten_entry(entry, config.nested_key), config.event_id_param: event_api_id} for entry in entries]
if rows:
yield rows
if not next_cursor or not entries:
@@ -123,13 +131,14 @@ def _get_guest_rows_for_event(
def _get_fan_out_rows(
session: requests.Session,
+ config: LumaEndpointConfig,
logger: FilteringBoundLogger,
resumable_source_manager: ResumableSourceManager[LumaResumeConfig],
) -> Iterator[list[dict[str, Any]]]:
resume = resumable_source_manager.load_state() if resumable_source_manager.can_resume() else None
events_cursor = resume.pagination_cursor if resume else None
if events_cursor is not None:
- logger.debug(f"Luma: resuming guests fan-out from events cursor {events_cursor}")
+ logger.debug(f"Luma: resuming {config.name} fan-out from events cursor {events_cursor}")
while True:
event_entries, next_events_cursor = _fetch_page(session, EVENTS_PATH, events_cursor, logger)
@@ -137,16 +146,16 @@ def _get_fan_out_rows(
skipped = len(event_entries) - len(event_api_ids)
if skipped:
logger.warning(
- f"Luma: {skipped} of {len(event_entries)} events had no usable api_id; their guests are skipped"
+ f"Luma: {skipped} of {len(event_entries)} events had no usable api_id; their {config.name} are skipped"
)
for event_api_id in event_api_ids:
- yield from _get_guest_rows_for_event(session, event_api_id, logger)
+ yield from _get_child_rows_for_event(session, config, event_api_id, logger)
if not next_events_cursor or not event_entries:
break
events_cursor = next_events_cursor
- # Save AFTER yielding every guest of this events page, so a crash re-pulls at most one page
+ # Save AFTER yielding every child row of this events page, so a crash re-pulls at most one page
# of parents; merge dedupes the re-pulled rows on the primary key.
resumable_source_manager.save_state(LumaResumeConfig(pagination_cursor=events_cursor))
@@ -189,7 +198,7 @@ def get_rows(
session = make_tracked_session(headers=_headers(api_key), redact_values=(api_key,))
if config.fan_out_over_events:
- yield from _get_fan_out_rows(session, logger, resumable_source_manager)
+ yield from _get_fan_out_rows(session, config, logger, resumable_source_manager)
else:
yield from _get_top_level_rows(session, config, logger, resumable_source_manager)
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 38e0957600c2..35f3b1dc5df1 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
@@ -1,7 +1,7 @@
from dataclasses import dataclass, field
-@dataclass
+@dataclass(frozen=True)
class LumaEndpointConfig:
name: str
path: str
@@ -10,12 +10,17 @@ class LumaEndpointConfig:
nested_key: str | None = None
# Luma object identifiers (`evt-...`, `gst-...`, ...) are globally unique `api_id`s.
primary_keys: list[str] = field(default_factory=lambda: ["api_id"])
- # Guests are fetched per event via `event_api_id`, iterating the events list as the parent.
+ # Fan-out children are fetched per event, iterating the events list as the parent.
fan_out_over_events: bool = False
+ # Query param carrying the parent event id, also written onto each child row for joins and keys.
+ 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
EVENTS_PATH = "/public/v1/calendar/list-events"
GUESTS_PATH = "/public/v1/event/get-guests"
+BLASTS_PATH = "/v1/events/blasts/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.
@@ -32,6 +37,15 @@ LUMA_ENDPOINTS: dict[str, LumaEndpointConfig] = {
primary_keys=["event_api_id", "api_id"],
fan_out_over_events=True,
),
+ # Blasts (emails to an event's guests) are keyed by `id` on the current API, not the legacy `api_id`.
+ "event_blasts": LumaEndpointConfig(
+ name="event_blasts",
+ path=BLASTS_PATH,
+ primary_keys=["event_id", "id"],
+ fan_out_over_events=True,
+ event_id_param="event_id",
+ paginated=False,
+ ),
"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/tests/test_luma.py b/products/warehouse_sources/backend/temporal/data_imports/sources/luma/tests/test_luma.py
index cd29ba5e3f8f..32ff5740624b 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
@@ -17,6 +17,7 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.luma.luma
validate_credentials,
)
from products.warehouse_sources.backend.temporal.data_imports.sources.luma.settings import (
+ BLASTS_PATH,
ENDPOINTS,
EVENTS_PATH,
GUESTS_PATH,
@@ -49,7 +50,12 @@ class _FakeResumableManager:
def _page_router(pages: PageMap) -> Any:
def fake_fetch(
- session: Any, path: str, cursor: str | None, logger: Any, extra_params: dict | None = None
+ session: Any,
+ path: str,
+ cursor: str | None,
+ logger: Any,
+ extra_params: dict | None = None,
+ paginate: bool = True,
) -> tuple[list[dict], Optional[str]]:
return pages[(path, cursor)]
@@ -132,12 +138,21 @@ class TestGuestsFanOut:
manager: _FakeResumableManager,
monkeypatch: Any,
pages: FanOutPageMap,
+ endpoint: str = "guests",
) -> list[dict]:
+ self.calls: list[tuple[str, dict | None, bool]] = []
+
def fake_fetch(
- session: Any, path: str, cursor: str | None, logger: Any, extra_params: dict | None = None
+ session: Any,
+ path: str,
+ cursor: str | None,
+ logger: Any,
+ extra_params: dict | None = None,
+ paginate: bool = True,
) -> tuple[list[dict], Optional[str]]:
- event_api_id = (extra_params or {}).get("event_api_id")
- return pages[(path, cursor, event_api_id)]
+ self.calls.append((path, extra_params, paginate))
+ event_id = next(iter((extra_params or {}).values()), None)
+ return pages[(path, cursor, event_id)]
monkeypatch.setattr(luma, "_fetch_page", fake_fetch)
monkeypatch.setattr(luma, "make_tracked_session", lambda **kwargs: MagicMock())
@@ -145,7 +160,7 @@ class TestGuestsFanOut:
rows: list[dict] = []
for batch in get_rows(
api_key="luma-key",
- endpoint="guests",
+ endpoint=endpoint,
logger=MagicMock(),
resumable_source_manager=manager, # type: ignore[arg-type]
):
@@ -173,6 +188,27 @@ class TestGuestsFanOut:
assert rows == [{"api_id": "gst-a", "name": "Ada", "event_api_id": "evt-1"}]
assert manager.saved == []
+ def test_event_blasts_are_fetched_per_event_without_pagination(self, monkeypatch: Any) -> None:
+ manager = _FakeResumableManager()
+ pages: FanOutPageMap = {
+ (EVENTS_PATH, None, None): (
+ [
+ {"api_id": "evt-1", "event": {"api_id": "evt-1"}},
+ {"api_id": "evt-2", "event": {"api_id": "evt-2"}},
+ ],
+ None,
+ ),
+ (BLASTS_PATH, None, "evt-1"): ([{"id": "bst-a", "event_id": "evt-1", "status": "sent"}], None),
+ (BLASTS_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),
+ ]
+
def test_paginates_guests_within_an_event(self, monkeypatch: Any) -> None:
manager = _FakeResumableManager()
pages: FanOutPageMap = {
@@ -268,6 +304,16 @@ class TestFetchPage:
assert kwargs["params"]["event_api_id"] == "evt-1"
assert kwargs["params"]["pagination_limit"] == luma.PAGE_SIZE
+ def test_unpaginated_request_omits_pagination_limit(self) -> None:
+ session = self._session_returning(200, {"entries": [{"id": "bst-a"}]})
+ rows, next_cursor = _fetch_page_unwrapped(
+ session, BLASTS_PATH, None, MagicMock(), extra_params={"event_id": "evt-1"}, paginate=False
+ )
+ _, kwargs = session.get.call_args
+ assert kwargs["params"] == {"event_id": "evt-1"}
+ assert rows == [{"id": "bst-a"}]
+ assert next_cursor is None
+
def test_first_request_omits_cursor(self) -> None:
session = self._session_returning(200)
_fetch_page_unwrapped(session, EVENTS_PATH, None, MagicMock())