Repository navigation
Conversation
send() takes scheduled_at, a DateTimeInterface or an ISO 8601 string with an offset, on both forms. The client rounds it up to the next millisecond once and sends it in UTC on every retry. It refuses a string without an offset, and any app host that isn't PostHog Cloud, before any request. It checks that the 202 confirms the requested instant and throws schedule_not_confirmed with the message ID when it doesn't. The result has getStatus() and getScheduledAt(), and EmailError has getMessageId(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
posthog-php-socket Compliance ReportDate: 2026-11-26T15:49:39.124033+00:00 ✅ All Tests Passed!47/47 tests passed Capture Tests✅ 30/30 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
posthog-php-lib_curl Compliance ReportDate: 2026-11-26T15:49:25.721349+00:00 ✅ All Tests Passed!47/47 tests passed Capture Tests✅ 30/30 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
posthog-php-fork_curl Compliance ReportDate: 2026-11-26T15:49:39.648343+00:00 ✅ All Tests Passed!47/47 tests passed Capture Tests✅ 30/30 tests passed View Details
Feature_Flags Tests✅ 17/17 tests passed View Details
|
A scheduled send to an app_host that carries credentials put them in the error message. The refusal now names only the host and port. The new nullable properties get defaults so an object serialized by the previous version still reads. Also reuses the Cloud host map, drops clock bounds the parser already enforces, and tightens the tests and docs from review round 1. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… only Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ects Feed unserialize() fixtures written by the SDK before scheduling, and check that a 202 reporting the requested millisecond with extra digits is accepted. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A scheduled send that PostHog answers with queued and a null scheduled_at now throws schedule_not_confirmed with the message ID when the requested time is more than 60 seconds ahead of the clock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… as null The minute ahead used local wall-clock seconds, so it stretched by an hour when the local clock left daylight saving. A queued answer without the scheduled_at key now reads like a null time, as in posthog-python. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A 202 that drops the scheduled_at key may come from a PostHog that ignored the field, so it throws schedule_not_confirmed for any time, as in posthog-python. Only an explicit null within the minute sends now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Emails reads Clock::get() to retry and to check a queued scheduled send, and symfony/clock 6.2 has no Clock class. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…erialization A clock that throws while the client checks a queued answer now gives schedule_not_confirmed with the message ID instead of losing it. An unscheduled result serializes exactly as before scheduling, so an older SDK reads it without a dynamic property. The replay test checks the original ID and time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
__sleep broke serialization of SendEmailResult subclasses, so results keep PHP's default serialization. The minute check now catches a failure anywhere in reading and shifting the clock's time, and the test fails the clock once PostHog has answered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…andles The minute check catches the missing Clock class of symfony/clock 6.2 and reports schedule_not_confirmed with the message ID, so apps pinned to 6.2 can still upgrade. Split the compatibility test and check that a send without scheduled_at ignores a schedule in the answer. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ad now handles" This reverts commit 5981aa4.
…duled_at Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…out scheduled_at" This reverts commit e5c7bb8.
symfony/clock 6.2 has no Clock class. The guarded minute check turns the missing class into schedule_not_confirmed with the message ID, so apps pinned to 6.2 can still upgrade. A test refuses to load the class and fails when the guard catches less than every Throwable. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On symfony/clock 6.2 the minute check now reads the time from NativeClock, so a queued answer for a past time is accepted there too instead of throwing schedule_not_confirmed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n unconfirmed symfony/clock 6.2's NativeClock raises an implicit-nullable deprecation on PHP 8.4+, which apps that throw on deprecations turned into a false schedule_not_confirmed. Without the Clock class the minute check now reads PHP's own clock. A schedule_not_confirmed answer now logs the server's warnings before it throws. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Up to symfony/clock 6.3.0, Clock::get() loads a NativeClock that raises a deprecation on PHP 8.4+, so an app that throws on deprecations still got a false schedule_not_confirmed. The minute check now reads Clock::get() and falls back to PHP's clock on any failure, one path for 6.2, 6.3.0 and a clock that fails. Warnings are no longer logged when error_log is disabled, so an unconfirmed schedule still throws schedule_not_confirmed with the message ID. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…he temp script Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The result and the error now leave out an unset schedule or message ID through an untyped __sleep, so a subclass's own __sleep, __serialize or Serializable still decides its fields, and an untyped override loads. Warnings reach an error_log the app defines in the PostHog namespace. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Unscheduled results serialize natively again, as the previous version did, so lazy objects, dynamic and virtual properties keep their base behaviour. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
There was a problem hiding this comment.
PostHog Review · Standard · reviewed 7106cd9: 1 Should fix.
New pushes to this pull request won't start an automatic review. Comment @posthog review to review new changes.
See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.
marandaneto
left a comment
There was a problem hiding this comment.
The code looks good; no qualifying findings. Verdict: correct.
A queued answer without a scheduled time now counts as a send-now only when scheduled_at was at most a minute ahead when the first attempt went out. A retry or a replay no longer moves the window. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A local code that doesn't start with invalid_ is an application_error, as the SDK spec's error names say. The code, message, why, fix and field are unchanged, and the send still makes no request. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
💡 Motivation and Context
A PHP app can't send a transactional email later. It has to run its own job queue to send at the right time. PostHog Cloud now schedules a send that carries
scheduled_at, and this PR adds the field toemails()->send(), as the Node (PostHog/posthog-js#5694) and Python (PostHog/posthog-python#1240) SDKs do.Impact
The server counts scheduled sends on the send event (
scheduledandscheduled_lead_bucket), so the SDKs need no event of their own. This PR adds the PHP path to them.Warning
🟡 Merge risk: medium, 🔴 once released · one-way door once the release publishes:
scheduled_atonsend(),getStatus()andgetScheduledAt()onSendEmailResult, andgetMessageId()onEmailErrorbecome public APIscheduled_atchanges from a localinvalid_formrefusal to a scheduled send, on PostHog Cloud US and EU only. Any other app host throwsscheduling_requires_cloudbefore any request.scheduled_at, andemails()->get(), are unchanged. The shadow diff covers them: the base's whole test suite passes unchanged against the library at this head.error_logcan't write them. The base threw after PostHog had queued the email; now the result comes back. A new test covers it.queuedand went out now, and a time 30 seconds ahead came backscheduledwith its time and went out once, at the requested second. A same-key replay returned the same email.queuedanswer to a retry or a replay is tested with fakes only. The minute counts from the send's first attempt, as in every SDK. Residual: a send more than a minute ahead of its first attempt, whose retries reach PostHog only after the time has passed, reads a falseschedule_not_confirmedfor an email that went out once. A caller who then sends it again with a new key sends it twice; the error carries the message ID and says to read its status first.scheduled_atwhile its flag is off. Residual: uploads that no email uses.allowed_classesnames onlySendEmailResult(Known issues).SendEmailResultorEmailErrorand already definesgetStatus(),getScheduledAt()orgetMessageId()with another signature. Residual: that class fails to load after the upgrade (Known issues).workflows-email-scheduled-sendsflag answers 400 onscheduled_atwhile it is off, and the SDK surfaces that 400 without falling back to sending now.Rollout
schedule_not_confirmederror in an app that schedules. No alert exists for it in the SDK.Changes
send()takesscheduled_aton both forms: aDateTimeInterface, or an ISO 8601 string with an explicit offset (Zor±HH:MM).invalid_scheduled_atbefore any request.https://us.posthog.comorhttps://eu.posthog.comthrowsscheduling_requires_cloudbefore any request, uploads included. The error names only the host and port, never credentials in the URL. A proxy with a Cloudapp_hoststill schedules.status: scheduledwith the requested instant (any offset, compared at millisecond precision): accepted,getStatus()isscheduled,getScheduledAt()the time in UTC.status: queuedwithscheduled_at: nullfor a time that had passed or was at most 60 seconds ahead of the client clock when the send's first attempt went out: accepted. A retry or a replay never moves that minute,getStatus()isqueued,getScheduledAt()is null.status: queuedwithscheduled_at: nullfor a time more than 60 seconds ahead: throwsschedule_not_confirmedwithgetMessageId(), never a success.scheduled_atkey or another instant: throwsschedule_not_confirmedwithgetMessageId(). An accepted 202 is never retried.scheduled_atsurfaces as anEmailError. The client never falls back to sending now.EmailStatusdocumentsscheduled, whichget()already passed through.send()docblock, the public API snapshot and a minor changeset.💚 How did you test it?
Test-first in
test/EmailsTest.php, throughEmails::send()andEmails::get()with the fake PostHog transport. The new cases cover both forms; UTC and non-UTC offsets, strings andDateTimes; sub-millisecond rounding up, including into the next year; the same value on a retry; offset-less and impossible times refused before any request; Cloud US and EU hosts against self-hosted, proxy and local hosts; the exact-match, other-instant and missing-key 202s; a 202 that reports the requested millisecond with extra digits; results and errors serialized by the SDK before scheduling; thequeuedanswer for a past time, for a time a minute ahead, and refused for a time more than a minute ahead, without thescheduled_atkey, across a daylight-saving change of the local clock, and when the clock fails after PostHog answered, including symfony/clock 6.2, which has noClockclass, and 6.3.0, whoseNativeClockraises a deprecation on PHP 8.4+; a replay; a 400 with no fallback; andscheduledon the status read. I broke each guarded behaviour in turn (rounding, the Cloud check, the host in the message, the missing-key check, the 60-second leeway, the instant check, the offset, the date check, the serialization defaults), and each break failed a test.Locally, through PHP 8.5 in Docker: the full PHPUnit suite,
phpcson the changed files,composer api:checkandcomposer validate --strictpass.A five-lens review panel (
hedge proof review, round 1) found one real bug: a scheduled send to anapp_hostwith credentials in its URL copied them into the error message. It is fixed with a test. The other valid findings are fixed too.Later single-reader rounds found the send-now check reused one clock read across retries, and that the new properties changed how unscheduled results and errors serialize. Both are fixed test-first, and a result or error without a schedule serializes exactly as the base did. The send-now check now runs once, before the send's first attempt, so a retry or a replay never moves the minute: every SDK counts it the same way. A confirmed schedule comes back as an internal final subclass of
SendEmailResultthat holds the time, soSendEmailResultitself has no serialization hook: lazy objects, subclasses, and dynamic and virtual properties keep the base's behavior.EmailErrordrops a null message ID through an untyped__sleep(), so a subclass's own__sleep(),__serialize()orSerializablestill decides its fields.Shadow diff: the base's whole test suite, unchanged, passes against the library at this head, the
git archivetest included.Cross-version: the SDK at this head, installed with the real symfony/clock 6.2 (no
Clockclass) and 6.3.0 on PHP 8.2 and 8.5 with every deprecation thrown, queues a past time, schedules a future one and refuses an unconfirmed one in all four runs. Results and errors serialized by the base read cleanly here, and unscheduled ones serialized here read cleanly in the base.Live run on US Cloud at this head: a send for a time that had passed, and a send 30 seconds ahead plus a same-key replay. The first was queued now. The second was scheduled at the requested millisecond, the replay returned the same email, and the delivery log and the mailbox each show one email per send, the scheduled one sent after its time.
Known issues
scheduled_atand gets a schedule in the answer (the branch is nowlib/Emails.php:1274). The test is written and lands with the stacked batch PR.allowed_classesnames onlySendEmailResult, reads it as an incomplete object, such as in a cache shared across a rolling upgrade. An error with a message ID read by an older SDK gets a PHP 8.2+ dynamic-property deprecation, which fails the read in an app that throws on deprecations (lib/EmailError.php:72). Results and errors without a schedule serialize exactly as before, and this version reads old ones cleanly.getStatus(),getScheduledAt()orgetMessageId()with an incompatible signature fails to load after the upgrade.schedule_not_confirmederror doesn't carry them.Clock::get()(nowlib/Emails.php:1112, baselib/Emails.php:966) fails before a retry. This is base behavior: the send-now check falls back to PHP's clock, the retry wait doesn't yet.queuedanswer, the SDK still counts the minute from the send's first attempt, so a send whose time was more than 60 seconds ahead then readsschedule_not_confirmedeven if the time has passed by the answer. This is the cross-SDK rule. The email goes out once; read its status withgetMessageId()before you send it again.schedule_not_confirmed. The email still goes out once; read its status withgetMessageId()before you send it again.📝 Checklist
If releasing new changes
pnpm changeto generate a change intent file🤖 Agent context
Autonomy: Human-driven (agent-assisted)
Written by Claude Opus 5.5 (
claude-opus-5-5) in Claude Code, as an implementation lane under a conductor thread that Michael directs. It follows the scheduled-sends spec's v1 scope: the field, the Cloud-host check and the answer check, with no cancel, move, list or batch. The Python reference PR set the error names.DateTimeInterfacecounts as an aware time, since a PHPDateTimealways holds an instant.queuedwith a null time for a future requestschedule_not_confirmedwhen the time is more than 60 seconds ahead, in all SDKs. Replaced: accepting it, as spec v7 said.scheduling_requires_cloudandschedule_not_confirmed, in every SDK. Rejected: Node's old names.Involvement: no grilling rounds; tests mutation-checked; one five-lens review panel (Claude fresh eyes, GPT correctness, risk, design and anti-overengineering).
🤖 Generated with Claude Code
How did you test this code?
Merge card: medium, one-way door · 1 round, 25 final reads · gaps: prod-shape (👤 the user d-f03eae56), judge (🤖 agent d-a597f50e) · 9 known issues · 3227 min opened to ready
910a663(reused from76ca036)910a663(reused from62301f8)910a663d282e04to910a663910a663Not checked: none recorded
Full receipt: https://artifacts.posthog.com/a/9cqmzbX4J2Jf24xVHRMFnq