: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): add 5 missing tables to the Calendly source (#119905)
Tom Owersbe6a1f9d91e0
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 2154ba8fd78f..6943ddb92a0b 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@@ -2127,10 +2127,10 @@ Diffed against: <https://stoplight.io/api/v1/projects/cHJqOjY4NTM/table-of-conte- [x] `List Routing Form Submissions (/routing_form_submissions)` — submissions for the routing_forms we already sync, including questions/answers, tracking, and which event type they routed to (high)- [x] `List Contacts (/contacts)` — the person lookup table Calendly resolves invitee emails against (high)- [x] `List Event Type Hosts (/event_type_memberships)` — membership table joining the event_types we sync to their hosting users (high)-- [ ] `List Group Relationships (/group_relationships)` — lookup joining the groups we already sync to users and event types (medium)-- [ ] `List activity log entries (/activity_log_entries)` — state/transition history for org and user changes; the audit trail for who changed what (medium)-- [ ] `List Recaps and Get Transcript (Notetaker)` — meeting recaps and transcripts tied to scheduled events, for content analysis of calls (medium)-- [ ] `List outgoing communications (/outgoing_communications)` — SMS and email sent per event — reminder/notification delivery data (medium)+- [x] `List Group Relationships (/group_relationships)` — lookup joining the groups we already sync to users and event types (medium)+- [x] `List activity log entries (/activity_log_entries)` — state/transition history for org and user changes; the audit trail for who changed what (medium)+- [x] `List Recaps and Get Transcript (Notetaker)` — meeting recaps and transcripts tied to scheduled events, for content analysis of calls (medium)+- [x] `List outgoing communications (/outgoing_communications)` — SMS and email sent per event — reminder/notification delivery data (medium)- [ ] `List User Availability Schedules (/user_availability_schedules)` — availability rules per user, needed to compute utilization against bookable hours (medium)- [ ] `Get Invitee No Show (/invitee_no_shows)` — no-show records; a headline meeting-quality metric (also surfaced on the invitee object) (medium)- [ ] `List Organization Invitations (/organizations/{uuid}/invitations)` — seat onboarding funnel — who was invited, when, and whether they accepted (low)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/api_inventory.md b/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/api_inventory.mdindex 3c5f1fdb8e51..b3027f2c01c0 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/api_inventory.md+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/api_inventory.md@@ -8,29 +8,34 @@ Calendly REST API v2 — base URL `https://api.calendly.com`. Auth via a Persona- **Response shape:** list endpoints return `{"collection": [...], "pagination": {"count", "next_page", "next_page_token"}}`.- **Pagination:** cursor-based. Follow `pagination.next_page` (a fully-formed URL carrying all query params); a `null` value ends pagination.- **Scoping:** the top-level list endpoints require an `organization` URI, resolved once per sync from `GET /users/me` → `resource.current_organization`. `/contacts` is account-scoped and takes no such param; the fan-out children are scoped by their parent instead.-- **Primary key:** every resource carries a stable `uri`.-- **Partitioning:** all endpoints expose a stable `created_at`, used for datetime partitioning.+- **Primary key:** every resource carries a stable `uri`, except outgoing communications (see below).+- **Partitioning:** endpoints expose a stable `created_at`, used for datetime partitioning. Activity log entries use `occurred_at`, and transcripts have no timestamp, so they are not partitioned.## Endpoints synced-| Endpoint | Path | Incremental | Notes |-| -------------------------- | --------------------------- | ---------------------------------- | ------------------------------------- |-| `event_types` | `/event_types` | full refresh | no server-side time filter |-| `scheduled_events` | `/scheduled_events` | `min_start_time` (on `start_time`) | `sort=start_time:asc` |-| `groups` | `/groups` | full refresh | no server-side time filter |-| `organization_memberships` | `/organization_memberships` | full refresh | no server-side time filter |-| `routing_forms` | `/routing_forms` | full refresh | no server-side time filter |-| `contacts` | `/contacts` | full refresh | account-scoped, `sort=created_at:asc` |+| Endpoint | Path | Incremental | Notes |+| -------------------------- | --------------------------- | ------------------------------------ | --------------------------------------- |+| `event_types` | `/event_types` | full refresh | no server-side time filter |+| `scheduled_events` | `/scheduled_events` | `min_start_time` (on `start_time`) | `sort=start_time:asc` |+| `groups` | `/groups` | full refresh | no server-side time filter |+| `organization_memberships` | `/organization_memberships` | full refresh | no server-side time filter |+| `routing_forms` | `/routing_forms` | full refresh | no server-side time filter |+| `contacts` | `/contacts` | full refresh | account-scoped, `sort=created_at:asc` |+| `group_relationships` | `/group_relationships` | full refresh | no server-side time filter |+| `activity_log_entries` | `/activity_log_entries` | `min_occurred_at` (on `occurred_at`) | Enterprise plan, `sort=occurred_at:asc` |+| `outgoing_communications` | `/outgoing_communications` | full refresh | Enterprise plan, no `uri`, no `sort` |+| `meeting_recaps` | `/meeting_recaps` | full refresh | account-scoped, `available` recaps only |### Fanned out over a parent-| Endpoint | Path | Parent | Notes |-| -------------------------- | ------------------------------------- | ------------------ | ------------------------------------------------------ |-| `invitees` | `/scheduled_events/{uuid}/invitees` | `scheduled_events` | parent UUID in the path, `sort=created_at:asc` |-| `routing_form_submissions` | `/routing_form_submissions?form=` | `routing_forms` | parent URI as a query param, `sort=created_at:asc` |-| `event_type_memberships` | `/event_type_memberships?event_type=` | `event_types` | Calendly calls these event type hosts; takes no `sort` |+| Endpoint | Path | Parent | Notes |+| --------------------------- | ------------------------------------- | ------------------ | ------------------------------------------------------ |+| `invitees` | `/scheduled_events/{uuid}/invitees` | `scheduled_events` | parent UUID in the path, `sort=created_at:asc` |+| `routing_form_submissions` | `/routing_form_submissions?form=` | `routing_forms` | parent URI as a query param, `sort=created_at:asc` |+| `event_type_memberships` | `/event_type_memberships?event_type=` | `event_types` | Calendly calls these event type hosts; takes no `sort` |+| `meeting_recap_transcripts` | `/meeting_recaps/{uuid}/transcript` | `meeting_recaps` | one object per recap; a 404 skips the recap |-None of the four accepts a server-side timestamp filter, so all are full refresh and merge on `uri`.+None of the five accepts a server-side timestamp filter, so all are full refresh and merge on `uri`.Each object's `uri` is globally unique — an invitee URI embeds its event's UUID — so no fan-out childneeds its parent id in the primary key.@@ -53,8 +58,14 @@ needs its parent id in the primary key.`get_non_retryable_errors` already turns into a permanent failure with a message, and only that tablefails.+- `/outgoing_communications` rows have no `uri` or other id. The primary key is+ `type`, `to`, `event_uri` and `created_at`. The endpoint accepts `min_created_at` but no `sort`,+ and its order is not documented, so the table is full refresh.+- `/activity_log_entries` and `/outgoing_communications` need an Enterprise plan. Other plans get a+ 403, which fails only that table.+- `/meeting_recaps` returns only `available` recaps when no `status` is passed. Recaps that are still+ processing appear on a later sync.+## Not yet synced-- `/group_relationships`, `/activity_log_entries`, `/outgoing_communications`,- `/user_availability_schedules`, the Notetaker recaps and transcripts, and- `/organizations/{uuid}/invitations`.+- `/user_availability_schedules` and `/organizations/{uuid}/invitations`.diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/calendly.py b/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/calendly.pyindex 53d7c7670a50..ff5b713059d9 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/calendly.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/calendly.py@@ -36,7 +36,10 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.resfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (JSONResponsePaginator,)-from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import ClientConfig+from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.typing import (+ ClientConfig,+ Endpoint,+)from products.warehouse_sources.backend.temporal.data_imports.sources.common.resumable import ResumableSourceManagerfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.source_helpers import validate_via_probefrom products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse@@ -177,6 +180,11 @@ def _dependent_rows(assert config.fanout is not Noneparent_config = CALENDLY_ENDPOINTS[config.fanout.parent_name]organization = get_current_organization(token, base_url) if parent_config.scope_param == "organization" else None+ child_endpoint_extra: Endpoint = (+ {"paginator": "single_page", "data_selector": "resource"}+ if config.single_resource+ else {"paginator": _paginator(), "data_selector": "collection"}+ )return build_dependent_resource(endpoint_configs=CALENDLY_ENDPOINTS,@@ -192,13 +200,14 @@ def _dependent_rows(job_id=job_id,# No child endpoint here exposes a server-side time filter, so they all full refresh.db_incremental_field_last_value=None,- page_size_param="count",+ # The parent's `count` already rides in `parent_params`, so this only sizes child pages.+ page_size_param=None if config.single_resource else "count",parent_data_map=_with_parent_lookup_fields,# Both requests are declared explicitly because a child path carrying a `{placeholder}`# would otherwise be taken for a single-entity endpoint and paginated as one page. The# paginator is stateful, so parent and child each get their own instance.parent_endpoint_extra={"paginator": _paginator(), "data_selector": "collection"},- child_endpoint_extra={"paginator": _paginator(), "data_selector": "collection"},+ child_endpoint_extra=child_endpoint_extra,)@@ -281,7 +290,7 @@ def calendly_source(return SourceResponse(name=endpoint,items=items,- primary_keys=["uri"],+ primary_keys=config.primary_keys,partition_count=1,partition_size=1,partition_mode="datetime" if config.partition_key else None,diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/canonical_descriptions.pyindex 74debc8c4da5..7739af54c311 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/canonical_descriptions.py@@ -156,4 +156,70 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {last_interaction_date="Time of the most recent email or meeting with the contact.",),},+ "group_relationships": {+ "description": "A member's or admin's relationship to a Calendly group, joining groups to their people.",+ "docs_url": "https://developer.calendly.com/api-docs/4674a12f55f82-list-group-relationships",+ "columns": _columns(+ role="The owner's role in the group: member or admin.",+ owner="The organization membership or pending organization invitation the relationship belongs to.",+ organization="URI of the organization the group relationship is tied to.",+ group="URI of the group the relationship is tied to.",+ ),+ },+ "activity_log_entries": {+ "description": "An audit log entry recording an action taken in a Calendly organization and who took it.",+ "docs_url": "https://developer.calendly.com/api-docs/d37c7f031f339-list-activity-log-entries",+ "columns": {+ "uri": "Canonical resource reference (URI) that uniquely identifies the entry.",+ "occurred_at": "Time at which the action occurred.",+ "actor": "The user who took the action, with their organization and group roles.",+ "namespace": "Category of the entry, such as User.",+ "action": "Action recorded by the entry, such as Add.",+ "fully_qualified_name": "Namespace and action combined, such as User.Add.",+ "details": "Action-specific details of the change.",+ "organization": "URI of the organization the entry belongs to.",+ },+ },+ "outgoing_communications": {+ "description": "An SMS or email message Calendly sent for a scheduled event, such as a reminder or a notification.",+ "docs_url": "https://developer.calendly.com/api-docs/9f56d7339ee2e-list-outgoing-communications",+ "columns": {+ "type": "Channel of the message: sms or email.",+ "to": "Recipient phone number or email address.",+ "from": "Sender phone number or email address.",+ "subject": "Subject of the message.",+ "body": "Body of the message.",+ "sender_uri": "URI of the user who sent the message.",+ "sender_email": "Email address of the user who sent the message.",+ "event_type_uri": "URI of the event type of the scheduled event.",+ "event_uri": "URI of the scheduled event the message is about.",+ "sent_at": "Time at which the message was sent.",+ "created_at": "Time at which the message was created.",+ "scheduling_url": "Scheduling page URL of the event type.",+ },+ },+ "meeting_recaps": {+ "description": "A Notetaker recap of a meeting, for meetings scheduled through Calendly and external ones.",+ "docs_url": "https://developer.calendly.com/api-docs/1d124e7aebd2b-list-recaps",+ "columns": _columns(+ app_url="URL to open the recap in the Calendly web app.",+ event="URI of the scheduled event the recap belongs to, or null for an external event.",+ status="Processing state of the recap.",+ name="Name of the meeting.",+ location="Location details of the meeting.",+ start_time="Scheduled start time of the meeting.",+ end_time="Scheduled end time of the meeting.",+ attendees="Meeting attendees, with their names, emails, and whether they hosted.",+ transcript="URI of the recap's transcript.",+ ),+ },+ "meeting_recap_transcripts": {+ "description": "The plain-text transcript of a meeting recorded by Notetaker.",+ "docs_url": "https://developer.calendly.com/api-docs/f0bbffb831a37-get-transcript",+ "columns": {+ "uri": "Canonical resource reference (URI) that uniquely identifies the transcript.",+ "text": "Plain-text transcript, one 'Speaker: words' segment per line.",+ "meeting_recap": "URI of the meeting recap the transcript belongs to.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/settings.pyindex 38bee7a4772a..948163d63bc2 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/settings.py@@ -33,6 +33,10 @@ class CalendlyEndpointConfig:# Read by the shared fan-out helper for the `count` param and the incremental cursor.page_size: int = PAGE_SIZEdefault_incremental_field: Optional[str] = None+ primary_keys: list[str] = field(default_factory=lambda: ["uri"])+ # Set on a fan-out child that returns one object under `resource` rather than a paginated+ # `collection`, so the child request carries no `count` param and reads no `next_page`.+ single_resource: bool = FalseCALENDLY_ENDPOINTS: dict[str, CalendlyEndpointConfig] = {@@ -123,6 +127,61 @@ CALENDLY_ENDPOINTS: dict[str, CalendlyEndpointConfig] = {scope_param=None,sort="created_at:asc",),+ "group_relationships": CalendlyEndpointConfig(+ name="group_relationships",+ path="/group_relationships",+ ),+ # Needs an Enterprise plan. Entries are immutable and carry no `created_at`, so they partition+ # and advance on `occurred_at`, which `min_occurred_at` filters on server-side.+ "activity_log_entries": CalendlyEndpointConfig(+ name="activity_log_entries",+ path="/activity_log_entries",+ partition_key="occurred_at",+ incremental_filter_param="min_occurred_at",+ sort="occurred_at:asc",+ default_incremental_field="occurred_at",+ incremental_fields=[+ {+ "label": "occurred_at",+ "type": IncrementalFieldType.DateTime,+ "field": "occurred_at",+ "field_type": IncrementalFieldType.DateTime,+ },+ ],+ ),+ # Needs an Enterprise plan. The rows carry no `uri` or other id, so the key combines the+ # fields that tell two messages apart. The endpoint accepts `min_created_at` but no `sort`,+ # and its order is undocumented, so it stays full refresh.+ "outgoing_communications": CalendlyEndpointConfig(+ name="outgoing_communications",+ path="/outgoing_communications",+ primary_keys=["type", "to", "event_uri", "created_at"],+ ),+ # Account-scoped like `/contacts`. The API returns only recaps whose status is `available`+ # unless a `status` is passed, which is the set that has a transcript.+ "meeting_recaps": CalendlyEndpointConfig(+ name="meeting_recaps",+ path="/meeting_recaps",+ scope_param=None,+ ),+ # Fanned out over `meeting_recaps`, one transcript per recap. A transcript has no timestamp+ # to partition on, so it carries the recap URI instead for the join back.+ "meeting_recap_transcripts": CalendlyEndpointConfig(+ name="meeting_recap_transcripts",+ path="/meeting_recaps/{uuid}/transcript",+ scope_param=None,+ partition_key=None,+ single_resource=True,+ fanout=DependentEndpointConfig(+ parent_name="meeting_recaps",+ resolve_param="uuid",+ resolve_field=PARENT_UUID_FIELD,+ include_from_parent=["uri"],+ parent_field_renames={"uri": "meeting_recap"},+ # Calendly can list a recap before its transcript is ready; skip it until then.+ child_response_actions=[{"status_code": 404, "action": "ignore"}],+ ),+ ),}ENDPOINTS = tuple(CALENDLY_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/tests/test_calendly.py b/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/tests/test_calendly.pyindex 32ee74788cad..ff43b09e2c54 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/tests/test_calendly.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/calendly/tests/test_calendly.py@@ -44,6 +44,13 @@ CALENDLY_SESSION_PATCH = (ORG_URI = "https://api.calendly.com/organizations/ABC123"+# Endpoints whose rows lack a `uri` or a `created_at`, as (primary keys, partition key).+ENDPOINT_KEYS: dict[str, tuple[list[str], Optional[str]]] = {+ "activity_log_entries": (["uri"], "occurred_at"),+ "outgoing_communications": (["type", "to", "event_uri", "created_at"], "created_at"),+ "meeting_recap_transcripts": (["uri"], None),+}+# Parent row each fan-out child is bound to, keyed by the child endpoint.PARENT_URIS = {"invitees": "https://api.calendly.com/scheduled_events/EV1",@@ -194,24 +201,44 @@ class TestPagination:class TestRequestParams:- @mock.patch(CALENDLY_SESSION_PATCH)- @mock.patch(CLIENT_SESSION_PATCH)- def test_scheduled_events_adds_min_start_time_when_incremental(- self, MockClientSession: mock.MagicMock, mock_calendly_session: mock.MagicMock- ) -> None:- mock_calendly_session.return_value.get.return_value = _users_me_response()- snapshots = _wire(MockClientSession.return_value, [_response([{"uri": "a"}])])-- _rows(- _source(- _make_manager(),- endpoint="scheduled_events",- should_use_incremental_field=True,- db_incremental_field_last_value=datetime(2026, 1, 1, tzinfo=UTC),- )+ @parameterized.expand(+ [+ ("scheduled_events", "min_start_time", "start_time:asc"),+ ("activity_log_entries", "min_occurred_at", "occurred_at:asc"),+ ]+ )+ def test_incremental_endpoint_sends_its_time_filter(self, endpoint: str, filter_param: str, sort: str) -> None:+ result = _driver().run(+ endpoint,+ [_me_page(), _page([{"uri": "a"}])],+ should_use_incremental_field=True,+ db_incremental_field_last_value=datetime(2026, 1, 1, tzinfo=UTC),)- assert snapshots[0]["params"]["min_start_time"] == "2026-01-01T00:00:00.000000Z"+ assert result.raised is None+ assert result.requests[1].param(filter_param) == "2026-01-01T00:00:00.000000Z"+ # The filter only bounds the walk when rows arrive oldest first.+ assert result.requests[1].param("sort") == sort+ assert result.requests[1].param("organization") == ORG_URI++ @parameterized.expand(+ [+ ("group_relationships", ["/users/me", "/group_relationships"], ORG_URI),+ ("outgoing_communications", ["/users/me", "/outgoing_communications"], ORG_URI),+ # Recaps are listed for the token's user, so the organization lookup is skipped.+ ("meeting_recaps", ["/meeting_recaps"], None),+ ]+ )+ def test_top_level_endpoint_scoping(+ self, endpoint: str, expected_paths: list[str], organization: str | None+ ) -> None:+ result = _driver().run(endpoint, [*([_me_page()] if organization else []), _page([{"uri": "a"}])])++ assert result.raised is None+ assert result.paths == expected_paths+ assert result.requests[-1].param("organization") == organization+ assert result.requests[-1].param("sort") is None+ assert len(result.rows) == 1def test_non_incremental_endpoint_never_adds_filter(self) -> None:result = _driver().run(@@ -273,17 +300,36 @@ class TestFanoutEndpoints:assert result.requests[2].param("count") == "100"assert [row["uri"] for row in result.rows] == ["child-1"]+ def test_transcripts_fan_out_over_recaps_and_skip_missing_ones(self) -> None:+ recaps = [+ {"uri": "https://api.calendly.com/meeting_recaps/R1"},+ {"uri": "https://api.calendly.com/meeting_recaps/R2"},+ ]+ transcript = {"uri": "https://api.calendly.com/meeting_recaps/R1/transcript", "text": "Host: Hello"}++ result = _driver().run(+ "meeting_recap_transcripts",+ [_page(recaps), ScriptedResponse(json={"resource": transcript}), ScriptedResponse(status=404)],+ )++ assert result.raised is None+ assert result.paths == ["/meeting_recaps", "/meeting_recaps/R1/transcript", "/meeting_recaps/R2/transcript"]+ # The transcript endpoint returns one object and takes no paging params.+ assert result.requests[1].query == {}+ assert result.rows == [{**transcript, "meeting_recap": "https://api.calendly.com/meeting_recaps/R1"}]+class TestCalendlySource:@parameterized.expand([(name,) for name in ENDPOINTS])def test_source_response_shape(self, endpoint: str) -> None:response = _source(_make_manager(), endpoint=endpoint)+ primary_keys, partition_key = ENDPOINT_KEYS.get(endpoint, (["uri"], "created_at"))assert response.name == endpoint- assert response.primary_keys == ["uri"]+ assert response.primary_keys == primary_keysassert response.sort_mode == "asc"- assert response.partition_keys == ["created_at"]- assert response.partition_mode == "datetime"+ assert response.partition_keys == ([partition_key] if partition_key else None)+ assert response.partition_mode == ("datetime" if partition_key else None)WEBHOOK_URL = "https://webhooks.us.posthog.com/public/webhooks/dwh/hog-fn-1"