: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(warehouse_sources): add ownerrez owners, listing sites, calendar and inquiries tables (#124006)
Tom Owers1c976df7926c
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 9e7058961e90..01e3158bfcdc 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@@ -9024,10 +9024,10 @@ Today (9): `Bookings`, `Deposits`, `Fees`, `Guests`, `Payments`, `Properties`, `Diffed against: <https://api.ownerreservations.com/openapi/v2.json>-- [ ] `Owners (GET /v2/owners)` — resolve owner_id values on properties and bookings for revenue analysis by owner (high)-- [ ] `Listing Sites (GET /v2/listingsites)` — resolve listing_site_id values on bookings and quotes for acquisition channel analysis (high)-- [ ] `Calendar (GET /v2/calendar)` — measure available nights, blocked nights, occupancy, and nightly rates by property (high)-- [ ] `Inquiries (GET /v2/inquiries)` — measure inquiry conversion into quotes and bookings (medium)+- [x] `Owners (GET /v2/owners)` — resolve owner_id values on properties and bookings for revenue analysis by owner (high)+- [x] `Listing Sites (GET /v2/listingsites)` — resolve listing_site_id values on bookings and quotes for acquisition channel analysis (high)+- [x] `Calendar (GET /v2/calendar)` — measure available nights, blocked nights, occupancy, and nightly rates by property (high)+- [x] `Inquiries (GET /v2/inquiries)` — measure inquiry conversion into quotes and bookings (medium)- [ ] `Listings (GET /v2/listings)` — compare property amenities and room details with booking demand and revenue (medium)- [ ] `Messages (GET /v2/messages)` — analyze guest communication volume and response times by booking thread (medium)- [ ] `Fields (GET /v2/fields)` — add custom entity attributes to booking, guest, and property analysis (medium)diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ownerrez/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ownerrez/canonical_descriptions.pyindex 48eb0290796a..809cac243b92 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ownerrez/canonical_descriptions.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ownerrez/canonical_descriptions.py@@ -188,4 +188,64 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {"updated_utc": "Timestamp the review was last updated.",},},+ "Inquiries": {+ "description": "A guest inquiry about staying at one of the account's properties, received directly or from a channel.",+ "docs_url": "https://api.ownerreservations.com/help/v2/inquiries/get-inquiries.md",+ "columns": {+ "id": "Unique identifier for the inquiry.",+ "property_id": "Identifier of the property the inquiry is about.",+ "guest_id": "Identifier of the guest who made the inquiry.",+ "listing_site_id": "Identifier of the listing site (channel) the inquiry came from, if any.",+ "listing_site": "Name of the listing site (channel) the inquiry came from, if any.",+ "type": "How the inquiry was received: in_person, email, phone, widget, inquiry_spot, or channel.",+ "arrival": "Requested arrival date in the property's time zone.",+ "departure": "Requested departure date in the property's time zone.",+ "adults": "Number of adult guests requested.",+ "children": "Number of child guests requested.",+ "infants": "Number of infant guests requested.",+ "pets": "Number of pets requested.",+ "guests": "Total number of guests requested.",+ "received_utc": "Timestamp the inquiry was received.",+ "created_utc": "Timestamp the inquiry was created in OwnerRez.",+ "updated_utc": "Timestamp the inquiry was last updated in OwnerRez.",+ },+ },+ "Owners": {+ "description": "A property owner the account manages properties for, used for owner statements and revenue splits.",+ "docs_url": "https://api.ownerreservations.com/help/v2/owners/get-owners.md",+ "columns": {+ "id": "Unique identifier for the owner.",+ "name": "The owner's name.",+ "email_address": "The owner's email address.",+ "active": "Whether the owner is active.",+ "last_owner_statement_id": "Identifier of the most recent owner statement for this owner.",+ },+ },+ "ListingSites": {+ "description": "A listing site (channel) that properties are listed on and bookings or inquiries can come from.",+ "docs_url": "https://api.ownerreservations.com/help/v2/listingsites/get-listingsites.md",+ "columns": {+ "id": "Unique identifier for the listing site.",+ "name": "The listing site's name.",+ "domain": "The listing site's domain.",+ "active": "Whether the listing site is active.",+ },+ },+ "Calendar": {+ "description": "One row per property night for the next 90 nights, with availability, rate, and booking rules. The whole window is refreshed on every sync.",+ "docs_url": "https://api.ownerreservations.com/help/v2/calendar/get-calendar.md",+ "columns": {+ "property_id": "Identifier of the property.",+ "date": "Property-local calendar date of the night (the night runs from this date to the following morning).",+ "currency_code": "ISO 4217 currency code for the property's rate amounts.",+ "status": "Availability of the night: available, booked, blocked, gap, or unavailable. Only available nights can be sold.",+ "booking_id": "Identifier of the booking or block occupying the night. Empty when the night is vacant.",+ "is_arrival": "Whether a booking arrives (checks in) on this date.",+ "is_departure": "Whether a booking departs the morning of this date.",+ "gap_type": "Gap classification (required or orphan) when the status is gap.",+ "holiday_name": "Holiday name when the night falls on a configured holiday.",+ "rate": "Nightly pricing for the night, excluding fees and taxes.",+ "rules": "Booking rules in effect for the night, such as minimum and maximum stay.",+ },+ },}diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ownerrez/ownerrez.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ownerrez/ownerrez.pyindex 0a0ba2312feb..1378ab9fc6e6 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ownerrez/ownerrez.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ownerrez/ownerrez.py@@ -1,5 +1,5 @@import base64-from datetime import UTC, date, datetime+from datetime import UTC, date, datetime, timedeltafrom typing import Any, Optionalfrom posthog.dataclasses import frozen@@ -12,6 +12,7 @@ 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 EndpointResourcefrom 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@@ -59,6 +60,10 @@ def _build_params(db_incremental_field_last_value: Optional[Any],) -> dict[str, Any]:params: dict[str, Any] = {"limit": PAGE_LIMIT}+ if config.date_window_days:+ today = datetime.now(UTC).date()+ params["from"] = today.isoformat()+ params["to"] = (today + timedelta(days=config.date_window_days - 1)).isoformat()if not config.since_param:return params@@ -70,6 +75,11 @@ def _build_params(return params+def _explode_nested_rows(item: dict[str, Any], explode_field: str) -> list[dict[str, Any]]:+ parent_fields = {key: value for key, value in item.items() if key != explode_field}+ return [{**parent_fields, **child} for child in item.get(explode_field) or []]++def ownerrez_source(email: str,api_key: str,@@ -84,6 +94,19 @@ def ownerrez_source(params = _build_params(endpoint_config, should_use_incremental_field, db_incremental_field_last_value)is_incremental = bool(endpoint_config.incremental_fields) and should_use_incremental_field+ resource_config: EndpointResource = {+ "name": endpoint_config.name,+ "endpoint": {+ "data_selector": "items",+ "path": endpoint_config.path,+ "params": params,+ },+ "table_format": "delta",+ }+ explode_field = endpoint_config.explode_field+ if explode_field:+ resource_config["data_map"] = lambda item: _explode_nested_rows(item, explode_field)+config: RESTAPIConfig = {"client": {"base_url": BASE_URL,@@ -113,17 +136,7 @@ def ownerrez_source(if is_incrementalelse "replace",},- "resources": [- {- "name": endpoint_config.name,- "endpoint": {- "data_selector": "items",- "path": endpoint_config.path,- "params": params,- },- "table_format": "delta",- }- ],+ "resources": [resource_config],}initial_paginator_state: Optional[dict[str, Any]] = Nonediff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ownerrez/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ownerrez/settings.pyindex 24735ab655bb..9f0f82a211d1 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ownerrez/settings.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ownerrez/settings.py@@ -14,6 +14,9 @@ PAGE_LIMIT = 100# no watermark yet (first sync, or an endpoint we never expose as incremental).EPOCH = "1970-01-01T00:00:00Z"+# GET /v2/calendar requires a from/to date range of at most 90 days and has no since/delta filter.+CALENDAR_WINDOW_DAYS = 90+def _updated_utc_incremental_field() -> list[IncrementalField]:return [@@ -44,6 +47,12 @@ class OwnerRezEndpointConfig:incremental_fields: list[IncrementalField] = field(default_factory=list)primary_keys: list[str] = field(default_factory=lambda: ["id"])partition_key: Optional[str] = None+ # When set, every request sends a required from/to date range covering this many nights,+ # starting today.+ date_window_days: Optional[int] = None+ # When set, each item is exploded into one row per entry of this nested list, with the+ # item's other top-level fields copied onto every row.+ explode_field: Optional[str] = NoneOWNERREZ_ENDPOINTS: dict[str, OwnerRezEndpointConfig] = {@@ -108,6 +117,32 @@ OWNERREZ_ENDPOINTS: dict[str, OwnerRezEndpointConfig] = {incremental_fields=_updated_utc_incremental_field(),partition_key="created_utc",),+ "Inquiries": OwnerRezEndpointConfig(+ name="Inquiries",+ path="/v2/inquiries",+ since_param="since_utc",+ incremental_fields=_updated_utc_incremental_field(),+ partition_key="created_utc",+ ),+ "Owners": OwnerRezEndpointConfig(+ name="Owners",+ path="/v2/owners",+ partition_key=None,+ ),+ "ListingSites": OwnerRezEndpointConfig(+ name="ListingSites",+ path="/v2/listingsites",+ partition_key=None,+ ),+ "Calendar": OwnerRezEndpointConfig(+ name="Calendar",+ path="/v2/calendar",+ # One row per property night over the forward window; the snapshot is replaced every sync.+ date_window_days=CALENDAR_WINDOW_DAYS,+ explode_field="days",+ primary_keys=["property_id", "date"],+ partition_key=None,+ ),}ENDPOINTS = tuple(OWNERREZ_ENDPOINTS.keys())diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/ownerrez/tests/test_ownerrez.py b/products/warehouse_sources/backend/temporal/data_imports/sources/ownerrez/tests/test_ownerrez.pyindex aa3882fd5de6..29c40c320ae7 100644--- a/products/warehouse_sources/backend/temporal/data_imports/sources/ownerrez/tests/test_ownerrez.py+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/ownerrez/tests/test_ownerrez.py@@ -2,6 +2,8 @@ import base64from datetime import UTC, date, datetimefrom typing import Any+import time_machine+from parameterized import parameterizedfrom products.warehouse_sources.backend.temporal.data_imports.sources.common.testing import (@@ -104,6 +106,41 @@ class TestOwnerrezSourceTransport:assert result.raised is Noneassert result.requests[0].param("since_utc") == "2026-03-04T02:58:14Z"+ @time_machine.travel("2026-03-04T23:30:00Z", tick=False)+ def test_calendar_requests_forward_window_and_emits_one_row_per_night(self) -> None:+ result = _driver().run(+ "Calendar",+ [+ _page(+ [+ {+ "property_id": 7,+ "currency_code": "USD",+ "days": [+ {"date": "2026-03-04", "status": "booked", "booking_id": 11},+ {"date": "2026-03-05", "status": "available", "rate": {"amount": 120.0}},+ ],+ },+ {"property_id": 8, "currency_code": "EUR"},+ ]+ )+ ],+ )++ assert result.raised is None+ assert result.requests[0].param("from") == "2026-03-04"+ assert result.requests[0].param("to") == "2026-06-01"+ assert result.rows == [+ {"property_id": 7, "currency_code": "USD", "date": "2026-03-04", "status": "booked", "booking_id": 11},+ {+ "property_id": 7,+ "currency_code": "USD",+ "date": "2026-03-05",+ "status": "available",+ "rate": {"amount": 120.0},+ },+ ]+def test_resumes_from_saved_next_url(self) -> None:result = _driver().run("Properties",