Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d500b2f
feat(emails): schedule, move, cancel and list emails
Silthus Nov 12, 2026
067e51d
refactor(emails): check scheduled_at strings with the status timestam…
Silthus Nov 12, 2026
8a365d2
fix(emails): name a too-late 409 as the shared SDK spec does
Silthus Nov 12, 2026
ef74081
fix(emails): match posthog-node on old servers, paging and too-late c…
Silthus Nov 12, 2026
5239890
test(emails): a supported scheduled send carries no scheduling_unsupp…
Silthus Nov 12, 2026
f01179a
Merge main into feat/email-scheduled-send
Silthus Nov 12, 2026
7d225c3
test(emails): one async test per scheduled-send behavior
Silthus Nov 12, 2026
baf3bf0
Merge main into feat/email-scheduled-send
Silthus Nov 12, 2026
afa81b7
test(emails): a list row missing any one field raises
Silthus Nov 12, 2026
9b8d122
test(emails): an update reply missing any one field raises
Silthus Nov 13, 2026
042f4ab
test(emails): a cancel reply without an ID and a list reply without r…
Silthus Nov 13, 2026
36eeabc
Merge main into feat/email-scheduled-send
Silthus Nov 13, 2026
001e1b1
fix(emails): refuse a move after one that got no answer
Silthus Nov 13, 2026
9de6d1e
Merge remote-tracking branch 'origin/main' into feat/email-scheduled-…
Silthus Nov 13, 2026
86075ee
fix(emails): count a 5xx move as unconfirmed and compare moves by ins…
Silthus Nov 13, 2026
6b38780
fix(emails): forget an email's unconfirmed move once a cancel is conf…
Silthus Nov 13, 2026
354b048
Merge remote-tracking branch 'origin/main' into feat/email-scheduled-…
Silthus Nov 13, 2026
3d5caea
fix(emails): keep a cancel's cleanup when a move of that email ends a…
Silthus Nov 13, 2026
cf2899e
fix(emails): read list rows without a recipient, as D5 now answers
Silthus Nov 13, 2026
e8939d2
fix(emails): moves out or queued at a confirmed cancel record nothing
Silthus Nov 13, 2026
5cf6d19
Merge origin/main into feat/email-scheduled-send, resetting the sched…
Silthus Nov 22, 2026
afc641d
feat(emails): schedule a send with scheduled_at on PostHog Cloud
Silthus Nov 22, 2026
c34f1ca
test(emails): assert the whole scheduling_requires_cloud message
Silthus Nov 22, 2026
4aee528
fix(emails): name an unconfirmed schedule in send's errors, drop comm…
Silthus Nov 22, 2026
9cdf0f8
refactor(emails): read scheduled_at once and derive the result's status
Silthus Nov 22, 2026
ebd9ce9
test(emails): check which region's app host a scheduled send reaches
Silthus Nov 22, 2026
6b3b639
fix(emails): refuse an early send-now answer and out-of-range offsets
Silthus Nov 24, 2026
8f96504
fix(emails): read scheduled_at strictly and round every fraction up
Silthus Nov 24, 2026
57c60a7
fix(emails): read scheduled_at with its own strict parser
Silthus Nov 24, 2026
905671d
fix(emails): confirm a schedule with the strict time parser
Silthus Nov 24, 2026
e94fc42
fix(emails): round up only on nanoseconds below a microsecond
Silthus Nov 24, 2026
ba52d82
fix(emails): count the 60 s send-now window from the first attempt
Silthus Nov 26, 2026
acb6c2f
test(emails): a retry doesn't restart the send-now window
Silthus Nov 26, 2026
f6a2e6b
Merge remote-tracking branch 'origin/main' into t3/112ad5a3
Silthus Nov 26, 2026
eacf325
fix(emails): name scheduling_requires_cloud an application_error
Silthus Nov 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/scripts/check_strict_types.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ python -m venv "$tmp/.venv"
cat > "$tmp/strict_posthog_types.py" <<'PY'
# pyright: strict
import atexit
from datetime import datetime, timezone

import posthog
from posthog import FeatureFlagEvaluations, FlagValue, Posthog
Expand Down Expand Up @@ -50,11 +51,14 @@ invite_send: SendEmailResult = emails.send(to="user@example.com", template_key="
tracked_send: SendEmailResult = emails.send(to="user@example.com", template_key="welcome", subject="Welcome", html="<p>Hi</p>", tracking={"clicks": True, "engagement": False})
untracked_send: SendEmailResult = emails.send(to="user@example.com", template_key="welcome", subject="Welcome", html="<p>Hi</p>", tracking=False)
not_sensitive_send: SendEmailResult = emails.send(to="user@example.com", template_key="newsletter", subject="News", html="<p>News</p>", sensitive=False)
_ = (template_send, rendered_send, invite_send, tracked_send, untracked_send, not_sensitive_send)
scheduled_send: SendEmailResult = emails.send(to="user@example.com", template_id="0190f6d2-7c1e-7b3a-9f5e-1c2d3e4f5a6b", scheduled_at=datetime(2026, 12, 1, tzinfo=timezone.utc))
scheduled_status: str = scheduled_send.status
scheduled_time: datetime | None = scheduled_send.scheduled_at
_ = (template_send, rendered_send, invite_send, tracked_send, untracked_send, not_sensitive_send, scheduled_status, scheduled_time)


async def async_email_types() -> None:
sent: SendEmailResult = await AsyncEmails("phs_example").send(to="user@example.com", template_key="welcome", subject="Hi", html="<p>Hi</p>")
sent: SendEmailResult = await AsyncEmails("phs_example").send(to="user@example.com", template_key="welcome", subject="Hi", html="<p>Hi</p>", scheduled_at="2026-12-01T09:00:00Z")
_ = sent


Expand Down Expand Up @@ -114,6 +118,7 @@ Emails("phs_example").send(to="user@example.com", template_id="0190f6d2-7c1e-7b3
Emails("phs_example").send(to="user@example.com", template_id="0190f6d2-7c1e-7b3a-9f5e-1c2d3e4f5a6b", sensitive=False) # expected-type-error
Emails("phs_example").send(to="user@example.com", template_key="welcome", subject="Hi", html="<p>Hi</p>", tracking={"open": False}) # expected-type-error
Emails("phs_example").send(to="user@example.com", template_key="welcome", subject="Hi", html="<p>Hi</p>", template_data={"name": "Ada"}) # expected-type-error
Emails("phs_example").send(to="user@example.com", template_key="welcome", subject="Hi", html="<p>Hi</p>", scheduled_at=1796115600) # expected-type-error
Emails("phs_example").send(to="user@example.com", template_key="welcome", subject="Hi", html="<p>Hi</p>", attachments=[{"filename": "a.txt", "content": [104, 105]}]) # expected-type-error
Emails("phs_example").send(to="user@example.com", template_key="welcome", subject="Hi", html="<p>Hi</p>", attachments=[{"filename": "a.txt", "content": b"hi", "path": "/tmp/a.txt"}]) # expected-type-error
Emails("phs_example").send(to="user@example.com", template_id="0190f6d2-7c1e-7b3a-9f5e-1c2d3e4f5a6b", attachments=[{"filename": "a.txt", "content": b"hi"}]) # expected-type-error
Expand Down
5 changes: 5 additions & 0 deletions .sampo/changesets/scheduled-email-sends.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
pypi/posthog: minor
---

Schedule a transactional email with `scheduled_at` on `emails.send()`, up to 7 days ahead, on PostHog Cloud. A naive `datetime`, a string without an offset, or a client whose host isn't PostHog Cloud (`scheduling_requires_cloud`) raises before any request. The client rounds the time up to the millisecond and checks that PostHog confirmed it, raising `schedule_not_confirmed` with the email's `message_id` otherwise. Send results now carry `status` and `scheduled_at`.
Loading