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 4 missing tables to the MixMax source (#121123)

Tom Owersa167fefd47d6
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 fcb64729c16e..90c14178675d 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
@@ -8071,14 +8071,14 @@ Today (15): `appointment_links`, `code_snippets`, `file_requests`, `insights_rep
Diffed against: <https://developer.mixmax.com/reference>
-- [ ] `sequence recipients (GET /v1/sequences/{id}/recipients)` — the per-recipient membership and stage state for the sequences we already sync — the core sequence fact table (high)
+- [x] `sequence recipients (GET /v1/sequences/{id}/recipients)` — the per-recipient membership and stage state for the sequences we already sync — the core sequence fact table (high). Added as `sequence_recipients` (fan-out over `sequences`, offset paging capped by the API at 10,000 recipients per sequence).
- [ ] `sent sequences (GET /v1/sequences/sent)` — per-send records with delivery outcome, the transaction table behind sequence performance (high). Skipped: the endpoint returns a single count of sequence messages sent in the past 24 hours, not per-send records.
- [ ] `contacts (GET /v1/contacts)` — lookup table resolving contact IDs referenced by messages, sequences, and live feed events (high). Skipped: Mixmax marks `/contacts` as deprecated. Live feed events already carry the recipient email and name.
- [x] `live feed events (GET /v1/livefeed/events)` — the individual open/click/reply events; the synced live_feed table is the container, not the events (high). Added as `live_feed_events` (fan-out over `live_feed` by `messageId`).
- [ ] `report data table (POST /v1/reports/data/table)` — Mixmax's own aggregated reporting grid — the vendor's headline metrics (high). Skipped: an aggregate query whose rows change with the caller's `groupBy` and query string, with no documented row key. The per-message counters are already on `live_feed`.
-- [ ] `contact groups and their members (GET /v1/contactgroups, GET /v1/contactgroups/{id}/contacts)` — segment definitions plus the membership join to contacts (medium)
-- [ ] `teams and team members (GET /v1/teams, GET /v1/teams/{id}/members)` — org structure lookup that resolves the user IDs we already sync (medium)
-- [ ] `unsubscribes (GET /v1/unsubscribes)` — suppression list needed to interpret sequence and message outcomes (medium)
+- [ ] `contact groups and their members (GET /v1/contactgroups, GET /v1/contactgroups/{id}/contacts)` — segment definitions plus the membership join to contacts (medium). Skipped: Mixmax marks both `/contactgroups` operations as deprecated with no replacement, like `/contacts`.
+- [x] `teams and team members (GET /v1/teams, GET /v1/teams/{id}/members)` — org structure lookup that resolves the user IDs we already sync (medium). Added as `teams` and `team_members` (fan-out over `teams`).
+- [x] `unsubscribes (GET /v1/unsubscribes)` — suppression list needed to interpret sequence and message outcomes (medium). Added as `unsubscribes`.
- [ ] `snippets (GET /v1/snippets)` — message snippets, a distinct resource from the code_snippets table already synced, and the target of the synced snippet_tags (medium)
- [ ] `yes/no enhancements (GET /v1/yesno)` — recipient responses to yes/no prompts embedded in emails (low)
- [ ] `Q&A enhancements (GET /v1/qa)` — recipient answers to in-email questions, parallel to the polls table (low)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/canonical_descriptions.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/canonical_descriptions.py
index d2142e477578..4366912b9e15 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/canonical_descriptions.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/canonical_descriptions.py
@@ -17,6 +17,23 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"name": "Human-readable name of the sequence.",
},
},
+ "sequence_recipients": {
+ "description": "Recipients added to each sequence, with their state and per-stage activity. Recipients still in a draft are not listed.",
+ "docs_url": f"{_DOCS}/sequencesidrecipients",
+ "columns": {
+ "_id": "Identifier of the recipient.",
+ "sequence_id": "Identifier of the sequence the recipient belongs to.",
+ "sequenceId": "Identifier of the sequence the recipient belongs to.",
+ "userId": "Identifier of the user who added the recipient.",
+ "to": "The recipient's email address and name.",
+ "state": "Recipient state, for example 'active', 'paused', 'completed' or 'failed'.",
+ "completedReason": "Why the recipient left the sequence, for example 'exhausted', 'manuallyCancelled', 'unsubscribed' or 'bounced'. May be null.",
+ "createdAt": "When the recipient was added, in Unix seconds.",
+ "lastStageSentOrdinal": "Position of the last stage sent, counting from 1.",
+ "analytics": "Open, click, and download totals across all stages.",
+ "stages": "Each stage as it applies to this recipient: state, schedule and send times (Unix milliseconds), and engagement counts.",
+ },
+ },
"sequence_folders": {
"description": "Folders used to organize sequences.",
"docs_url": f"{_DOCS}/sequence-folders",
@@ -97,6 +114,46 @@ CANONICAL_DESCRIPTIONS: CanonicalDescriptions = {
"fileName": "Name of the downloaded file. Only present for 'downloaded' events.",
},
},
+ "teams": {
+ "description": "Teams the API token's user is an accepted member of. Workspace admins also see every team in their workspace.",
+ "docs_url": f"{_DOCS}/teams-1",
+ "columns": {
+ "_id": "Identifier of the team.",
+ "name": "Name of the team.",
+ "createdAt": "When the team was created.",
+ "modifiedAt": "When the team was created or last renamed.",
+ },
+ },
+ "team_members": {
+ "description": "Members of each team, including pending invites.",
+ "docs_url": f"{_DOCS}/teams-members-get",
+ "columns": {
+ "team_id": "Identifier of the team.",
+ "memberId": "Identifier of the member on this team.",
+ "userId": "The member's Mixmax user id. Missing for invitees who are not Mixmax users yet.",
+ "email": "The member's email address.",
+ "name": "The member's name, for members who are Mixmax users.",
+ "role": "The member's role on the team: 'admin' or 'member'.",
+ "accepted": "True once the invite is accepted, false if it was declined. Missing while the invite is pending.",
+ "acceptedAt": "When the member accepted or declined the invite.",
+ "createdAt": "When the member was first added.",
+ "invitedAt": "When the invite was last sent.",
+ },
+ },
+ "unsubscribes": {
+ "description": "Addresses on the user's unsubscribe list, or the workspace's list when the user belongs to a workspace. Sequences do not send to these addresses.",
+ "docs_url": f"{_DOCS}/unsubscribes-get",
+ "columns": {
+ "_id": "Identifier of the unsubscribe record.",
+ "email": "The unsubscribed address, in lowercase.",
+ "name": "The contact's name, if one was given.",
+ "userId": "Identifier of the user who added the record, or whose message the contact unsubscribed from.",
+ "orgId": "Identifier of the workspace, when the record belongs to a workspace.",
+ "messageId": "The message the contact unsubscribed from, if any.",
+ "sequenceId": "The sequence the contact unsubscribed from, if any.",
+ "createdAt": "When the record was added.",
+ },
+ },
"appointment_links": {
"description": "The authenticated user's appointment (scheduling) links.",
"docs_url": f"{_DOCS}/appointment-links",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/mixmax.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/mixmax.py
index db49783b91ea..b8881bfcd5a6 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/mixmax.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/mixmax.py
@@ -20,6 +20,7 @@ from collections.abc import Iterable
from typing import Any, Optional, cast
from urllib.parse import quote, urlencode
+import structlog
from requests import Response
from products.warehouse_sources.backend.temporal.data_imports.sources.common.http import make_tracked_session
@@ -32,19 +33,25 @@ from products.warehouse_sources.backend.temporal.data_imports.sources.common.res
)
from products.warehouse_sources.backend.temporal.data_imports.sources.common.rest_source.paginators import (
BaseNextUrlPaginator,
+ OffsetPaginator,
SinglePagePaginator,
)
-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 ResumableSourceManager
from products.warehouse_sources.backend.temporal.data_imports.sources.common.source_helpers import validate_via_probe
from products.warehouse_sources.backend.temporal.data_imports.sources.common.typings import SourceResponse
from products.warehouse_sources.backend.temporal.data_imports.sources.mixmax.settings import (
- MESSAGE_ID_PARAM_FIELD,
MIXMAX_ENDPOINTS,
PAGE_SIZE,
+ PARENT_ID_PARAM_FIELD,
MixmaxEndpointConfig,
)
+logger = structlog.get_logger(__name__)
+
MIXMAX_BASE_URL = "https://api.mixmax.com/v1"
@@ -109,6 +116,24 @@ class MixmaxCursorPaginator(BaseNextUrlPaginator):
self._has_next_page = False
+class MixmaxOffsetPaginator(OffsetPaginator):
+ """Limit/offset paging for plain-array children, stopped at the API's offset ceiling."""
+
+ def __init__(self, limit: int, maximum_offset: int | None) -> None:
+ super().__init__(limit=limit, maximum_offset=maximum_offset, total_path=None)
+
+ def update_state(self, response: Response, data: Optional[list[Any]] = None) -> None:
+ super().update_state(response, data)
+ hit_cap = self.maximum_offset is not None and self.offset >= self.maximum_offset
+ if hit_cap and data is not None and len(data) == self.limit:
+ # Rows past the ceiling are unreachable without a search query, so this table is truncated.
+ logger.warning(
+ "mixmax_offset_cap_reached",
+ url=response.url,
+ maximum_offset=self.maximum_offset,
+ )
+
+
def _client_config(api_key: str) -> ClientConfig:
return {
"base_url": MIXMAX_BASE_URL,
@@ -119,11 +144,21 @@ def _client_config(api_key: str) -> ClientConfig:
}
-def _with_encoded_message_id(row: dict[str, Any]) -> dict[str, Any]:
- row[MESSAGE_ID_PARAM_FIELD] = quote(str(row["_id"]), safe="")
+def _with_encoded_parent_id(row: dict[str, Any]) -> dict[str, Any]:
+ row[PARENT_ID_PARAM_FIELD] = quote(str(row["_id"]), safe="")
return row
+def _child_endpoint_extra(config: MixmaxEndpointConfig) -> Endpoint:
+ if config.child_page_size is not None:
+ # The body is a plain array, so it needs no selector.
+ return {
+ "paginator": MixmaxOffsetPaginator(limit=config.child_page_size, maximum_offset=config.child_max_offset)
+ }
+ # Child responses are a single `{results: [...]}` page, capped server-side.
+ return {"paginator": SinglePagePaginator(), "data_selector": "results"}
+
+
def _fanout_source(
api_key: str, endpoint: str, config: MixmaxEndpointConfig, team_id: int, job_id: str
) -> SourceResponse:
@@ -141,12 +176,11 @@ def _fanout_source(
team_id=team_id,
job_id=job_id,
db_incremental_field_last_value=None,
- # The parent page size rides in `fanout.parent_params`; the child takes no page size.
+ # The parent page size rides in `fanout.parent_params`; the child page size rides in its paginator.
page_size_param=None,
parent_endpoint_extra={"paginator": MixmaxCursorPaginator(parent_config.path), "data_selector": "results"},
- # Child responses are a single `{results: [...]}` page, capped server-side.
- child_endpoint_extra={"paginator": SinglePagePaginator(), "data_selector": "results"},
- parent_data_map=_with_encoded_message_id,
+ child_endpoint_extra=_child_endpoint_extra(config),
+ parent_data_map=_with_encoded_parent_id,
),
)
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/posthog_com_doc.md b/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/posthog_com_doc.md
index a155262b9cfb..74b62534edfd 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/posthog_com_doc.md
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/posthog_com_doc.md
@@ -37,6 +37,8 @@ Mixmax's API does not expose a server-side "modified since" filter, so every tab
The `live_feed_events` table makes one request per live feed message, so it is not selected by default. Enable it only if you need per-event detail, and expect a large live feed to take a while to sync.
+The `sequence_recipients` table makes at least one request per sequence, and `team_members` makes one request per team. Mixmax lists at most 10,000 recipients per sequence through the API, so recipients past that limit are not synced.
+
## Configuration
<SourceParameters />
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/settings.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/settings.py
index 44abe43cf67b..3a77032838be 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/settings.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/settings.py
@@ -25,6 +25,10 @@ class MixmaxEndpointConfig:
should_sync_default: bool = True
description: str | None = None
fanout: DependentEndpointConfig | None = None
+ # Fan-out children paged with `limit`/`offset` and a plain-array body. None means the child
+ # answers in one `{results: [...]}` page.
+ child_page_size: int | None = None
+ child_max_offset: int | None = None
# The remaining fields exist to satisfy the shared FanoutEndpointLike protocol; no Mixmax
# endpoint is incremental.
incremental_fields: list[Any] = field(default_factory=list)
@@ -34,14 +38,18 @@ class MixmaxEndpointConfig:
# Parent rows carry their `_id` percent-encoded under this key, because the fan-out binds the
# resolved value into the child URL with no escaping.
-MESSAGE_ID_PARAM_FIELD = "_message_id_param"
+PARENT_ID_PARAM_FIELD = "_id_param"
+
+# /sequences/{id}/recipients caps a page at 50 and rejects `offset + limit` above 10,000.
+SEQUENCE_RECIPIENTS_PAGE_SIZE = 50
+SEQUENCE_RECIPIENTS_MAX_OFFSET = 10_000
# /livefeed/events takes a single `messageId` per request, so events fan out over the live feed's
# messages. Event ids are only documented as unique, so the key also carries the parent message id.
_LIVE_FEED_EVENTS_FANOUT = DependentEndpointConfig(
parent_name="live_feed",
resolve_param="message_id",
- resolve_field=MESSAGE_ID_PARAM_FIELD,
+ resolve_field=PARENT_ID_PARAM_FIELD,
include_from_parent=["_id"],
parent_field_renames={"_id": "message_id"},
parent_params={"limit": PAGE_SIZE},
@@ -50,6 +58,31 @@ _LIVE_FEED_EVENTS_FANOUT = DependentEndpointConfig(
child_response_actions=[{"status_code": 404, "action": "ignore"}],
)
+# The default sort (`lastMessageCreated`) moves a recipient each time a stage sends, which shifts
+# offset pages mid-walk. Email order stays put while the sync runs.
+_SEQUENCE_RECIPIENTS_FANOUT = DependentEndpointConfig(
+ parent_name="sequences",
+ resolve_param="sequence_id",
+ resolve_field=PARENT_ID_PARAM_FIELD,
+ include_from_parent=["_id"],
+ parent_field_renames={"_id": "sequence_id"},
+ parent_params={"limit": PAGE_SIZE},
+ child_params={"sortBy": "email", "sortDesc": "false"},
+ child_response_actions=[{"status_code": 404, "action": "ignore"}],
+)
+
+# Team member ids are only documented as ids "on this team", so the key also carries the team id.
+_TEAM_MEMBERS_FANOUT = DependentEndpointConfig(
+ parent_name="teams",
+ resolve_param="team_id",
+ resolve_field=PARENT_ID_PARAM_FIELD,
+ include_from_parent=["_id"],
+ parent_field_renames={"_id": "team_id"},
+ parent_params={"limit": PAGE_SIZE},
+ child_params={"expand": "members.userId"},
+ child_response_actions=[{"status_code": 404, "action": "ignore"}],
+)
+
# Mixmax exposes no server-side timestamp filter (`updated_after`/`since`), so every endpoint is
# full-refresh only — see the module docstring in `mixmax.py`. Collections use cursor pagination
@@ -60,6 +93,15 @@ MIXMAX_ENDPOINTS: dict[str, MixmaxEndpointConfig] = {
path="/sequences",
description="Automated multi-step outreach sequences you have access to.",
),
+ "sequence_recipients": MixmaxEndpointConfig(
+ name="sequence_recipients",
+ path="/sequences/{sequence_id}/recipients/",
+ primary_keys=["sequence_id", "_id"],
+ fanout=_SEQUENCE_RECIPIENTS_FANOUT,
+ child_page_size=SEQUENCE_RECIPIENTS_PAGE_SIZE,
+ child_max_offset=SEQUENCE_RECIPIENTS_MAX_OFFSET,
+ description="Recipients added to each sequence, with their state and per-stage activity (up to 10,000 per sequence).",
+ ),
"sequence_folders": MixmaxEndpointConfig(
name="sequence_folders",
path="/sequencefolders",
@@ -120,6 +162,23 @@ MIXMAX_ENDPOINTS: dict[str, MixmaxEndpointConfig] = {
should_sync_default=False,
description="Individual open, click, download, and reply events for each live feed message (up to 200 per message).",
),
+ "teams": MixmaxEndpointConfig(
+ name="teams",
+ path="/teams",
+ description="Teams you are a member of, plus every team in the workspace for workspace admins.",
+ ),
+ "team_members": MixmaxEndpointConfig(
+ name="team_members",
+ path="/teams/{team_id}/members",
+ primary_keys=["team_id", "memberId"],
+ fanout=_TEAM_MEMBERS_FANOUT,
+ description="Members of each team, including pending invites.",
+ ),
+ "unsubscribes": MixmaxEndpointConfig(
+ name="unsubscribes",
+ path="/unsubscribes",
+ description="Addresses on your (or your workspace's) unsubscribe list. Sequences do not send to these addresses.",
+ ),
"appointment_links": MixmaxEndpointConfig(
name="appointment_links",
path="/appointmentlinks/me",
diff --git a/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/tests/test_mixmax.py b/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/tests/test_mixmax.py
index 802f4d5ccac1..d75ec1489263 100644
--- a/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/tests/test_mixmax.py
+++ b/products/warehouse_sources/backend/temporal/data_imports/sources/mixmax/tests/test_mixmax.py
@@ -1,5 +1,8 @@
+import dataclasses
from typing import Any
+from unittest import mock
+
from parameterized import parameterized
from products.warehouse_sources.backend.temporal.data_imports.sources.common.testing import (
@@ -96,30 +99,130 @@ class TestPagination:
assert result.saved_states == []
-class TestLiveFeedEventsFanout:
- def test_fetches_events_per_live_feed_message_and_skips_missing_messages(self) -> None:
+class TestFanout:
+ @parameterized.expand(
+ [
+ (
+ "live_feed_events",
+ [
+ ScriptedResponse(json={"results": [{"_id": "m1"}], "next": "cur2", "hasNext": True}),
+ ScriptedResponse(
+ json={"results": [{"_id": "e1", "type": "opened"}, {"_id": "e2", "type": "replied"}]}
+ ),
+ ScriptedResponse(json={"results": [{"_id": "m2&limit=1"}], "hasNext": False}),
+ ScriptedResponse(status=404, json={}),
+ ],
+ [
+ {"_id": "e1", "type": "opened", "message_id": "m1"},
+ {"_id": "e2", "type": "replied", "message_id": "m1"},
+ ],
+ ["/v1/livefeed", "/v1/livefeed/events", "/v1/livefeed", "/v1/livefeed/events"],
+ [
+ {"limit": ("100",)},
+ {"messageId": ("m1",), "wasSentViaMixmax": ("true",)},
+ {"limit": ("100",), "next": ("cur2",)},
+ {"messageId": ("m2&limit=1",), "wasSentViaMixmax": ("true",)},
+ ],
+ ),
+ (
+ "team_members",
+ [
+ ScriptedResponse(json={"results": [{"_id": "t1"}, {"_id": "t/2"}], "hasNext": False}),
+ ScriptedResponse(
+ json={
+ "results": [
+ {"memberId": "mb1", "userId": "u1", "role": "admin", "name": "Jane Roe"},
+ {"memberId": "mb2", "email": "[email protected]", "role": "member"},
+ ]
+ }
+ ),
+ ScriptedResponse(status=404, json={}),
+ ],
+ [
+ {"memberId": "mb1", "userId": "u1", "role": "admin", "name": "Jane Roe", "team_id": "t1"},
+ {"memberId": "mb2", "email": "[email protected]", "role": "member", "team_id": "t1"},
+ ],
+ ["/v1/teams", "/v1/teams/t1/members", "/v1/teams/t%2F2/members"],
+ [
+ {"limit": ("100",)},
+ {"expand": ("members.userId",)},
+ {"expand": ("members.userId",)},
+ ],
+ ),
+ ]
+ )
+ def test_fetches_children_per_parent_and_skips_missing_parents(
+ self,
+ endpoint: str,
+ responses: list[ScriptedResponse],
+ expected_rows: list[dict[str, Any]],
+ expected_paths: list[str],
+ expected_queries: list[dict[str, tuple[str, ...]]],
+ ) -> None:
+ result = _driver().run(endpoint, responses)
+
+ assert result.raised is None
+ assert result.rows == expected_rows
+ assert result.paths == expected_paths
+ assert [dict(request.query) for request in result.requests] == expected_queries
+
+
+def _recipients(prefix: str, count: int) -> list[dict[str, Any]]:
+ return [{"_id": f"{prefix}{i}", "state": "active"} for i in range(count)]
+
+
+class TestSequenceRecipients:
+ @parameterized.expand(
+ [
+ # A short page ends the first sequence before the offset ceiling.
+ ("short_last_page", [2, 1], ["0", "2"]),
+ # Two full pages reach `offset + limit == 4`; asking for more would return 400.
+ ("stops_at_offset_ceiling", [2, 2], ["0", "2"]),
+ ("empty_sequence", [0], ["0"]),
+ ]
+ )
+ def test_pages_each_sequence_by_offset(
+ self, _name: str, first_sequence_pages: list[int], expected_first_offsets: list[str]
+ ) -> None:
+ config = dataclasses.replace(MIXMAX_ENDPOINTS["sequence_recipients"], child_page_size=2, child_max_offset=4)
+ first_sequence = [_recipients(f"p{page}r", size) for page, size in enumerate(first_sequence_pages)]
+ responses = [
+ ScriptedResponse(json={"results": [{"_id": "s1"}, {"_id": "s2"}], "hasNext": False}),
+ *(ScriptedResponse(json=page) for page in first_sequence),
+ ScriptedResponse(json=[{"_id": "only", "state": "completed"}]),
+ ]
+
+ with mock.patch.dict(MIXMAX_ENDPOINTS, {"sequence_recipients": config}):
+ result = _driver().run("sequence_recipients", responses)
+
+ assert result.raised is None
+ assert result.rows == [
+ *({**row, "sequence_id": "s1"} for page in first_sequence for row in page),
+ {"_id": "only", "state": "completed", "sequence_id": "s2"},
+ ]
+ assert result.paths == [
+ "/v1/sequences",
+ *["/v1/sequences/s1/recipients/"] * len(first_sequence_pages),
+ "/v1/sequences/s2/recipients/",
+ ]
+ # The offset starts again at 0 for the next sequence.
+ assert result.params("offset") == [None, *expected_first_offsets, "0"]
+ assert set(result.params("limit")[1:]) == {"2"}
+ assert set(result.params("sortBy")[1:]) == {"email"}
+ assert set(result.params("sortDesc")[1:]) == {"false"}
+
+ def test_skips_sequence_deleted_after_listing(self) -> None:
result = _driver().run(
- "live_feed_events",
+ "sequence_recipients",
[
- ScriptedResponse(json={"results": [{"_id": "m1"}], "next": "cur2", "hasNext": True}),
- ScriptedResponse(json={"results": [{"_id": "e1", "type": "opened"}, {"_id": "e2", "type": "replied"}]}),
- ScriptedResponse(json={"results": [{"_id": "m2&limit=1"}], "hasNext": False}),
- ScriptedResponse(status=404, json={}),
+ ScriptedResponse(json={"results": [{"_id": "gone"}], "hasNext": False}),
+ ScriptedResponse(status=404, json={"message": "Sequence not found"}),
],
)
assert result.raised is None
- assert result.rows == [
- {"_id": "e1", "type": "opened", "message_id": "m1"},
- {"_id": "e2", "type": "replied", "message_id": "m1"},
- ]
- assert result.paths == ["/v1/livefeed", "/v1/livefeed/events", "/v1/livefeed", "/v1/livefeed/events"]
- assert [dict(request.query) for request in result.requests] == [
- {"limit": ("100",)},
- {"messageId": ("m1",), "wasSentViaMixmax": ("true",)},
- {"limit": ("100",), "next": ("cur2",)},
- {"messageId": ("m2&limit=1",), "wasSentViaMixmax": ("true",)},
- ]
+ assert result.rows == []
+ assert result.paths == ["/v1/sequences", "/v1/sequences/gone/recipients/"]
class TestRetryClassification: