Skip to content

feat(emails): flatten the send request body - #163

Merged
mayteio merged 1 commit into
mainfrom
posthog/flatten-email-send-body
Nov 2, 2026
Merged

mayteio merged 1 commit into
mainfrom
posthog/flatten-email-send-body

Conversation

@mayteio

@mayteio mayteio commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

Problem

The emails contract pins the send body as {"template": {"id"}, "to", "message_data", "identifiers": {"distinct_id"}}. The server now documents a flat body (PostHog/posthog#126287) that uses the same names as the SDK arguments, so the contract should require that.

Changes

  • send SHALL post {"template_id", "to", "message_data", "distinct_id"}, with distinct_id only when the caller passed one. The table row, the requirement and every scenario body are updated.
  • acceptance/public/emails.feature pins the flat body.
  • The SDK-facing API, results and errors don't change.
  • Proposed, applied and archived as 2026-10-30-flatten-email-send-body. The proposal notes that the server keeps accepting the nested body, so released SDK versions keep working.

Implementations: PostHog/posthog-js and PostHog/posthog-python, branches posthog/node-email-flat-body and posthog/emails-flat-send-body.

How did you test this code?

npx -y @fission-ai/openspec@1.4.1 validate --specs --strict --no-interactive passes, the same command CI runs.


🤖 Generated with Claude Code

Created with PostHog Desktop

send now posts template_id and distinct_id at the top level, matching the SDK argument names and the HTTP docs. Proposed, applied and archived as 2026-10-30-flatten-email-send-body.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Generated-By: PostHog Desktop
Task-Id: e72a2c10-f145-4f7c-8754-a4fcc06a18be
@mayteio mayteio self-assigned this Oct 30, 2026
@mayteio
mayteio marked this pull request as ready for review November 2, 2026 09:15
@mayteio
mayteio requested a review from a team as a code owner November 2, 2026 09:15

@ioannisj ioannisj left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 An AI agent wrote this on behalf of @ioannisj.

No findings. The flat body matches what the server takes since PostHog/posthog#126287, and that PR keeps the nested body working for the SDK versions already out. The spec, the HTTP mapping row and the acceptance feature all line up with it.

@mayteio
mayteio merged commit c9dc4ce into main Nov 2, 2026
10 checks passed
@mayteio
mayteio deleted the posthog/flatten-email-send-body branch November 2, 2026 11:48
posthog Bot added a commit that referenced this pull request Nov 9, 2026
Deep re-audit of posthog-php, posthog-ruby and posthog-go against the 69
cross-SDK contracts, at sdk-specs 5160f2f.

Selection: php and ruby were the two stalest pointers (6 weeks, outside the
~4-week window) and had the largest backfill; go is the remaining matrix SDK
named in the mcp-analytics applicability table, which five of this cycle's 19
spec commits touch. All three are server SDKs, where the Emails, Exception
Event Metadata, Tracing Headers and config-version-2 flag deltas land.

Contract surface grew to 69 with Experiment Exposure (#162).

Main findings:
- Emails went from one implementation to four. All three SDKs ship it and all
  three pass, including #163's flattened send body, Cloud app-host resolution,
  and a once-per-call idempotency key.
- #129's span-context bridge and #123's trace context on exception events
  landed in all three. posthog-go is alone in getting the detached-work
  scenario right, and alone in the trace-context path being reachable only
  through an opt-in helper in a separate module.
- None of the three reads /flags?v=4, so Experiment Exposure is ➖ on all three
  by the spec's own applicability sentence — raised as a scope question.
- posthog-ruby ships a 3,798-line MCP package the spec's applicability table
  records as "not yet"; scored 🟡, with the table flagged for update.
- The #132 jitter requirement is now unmet on five of seven SDKs checked;
  posthog-go passes jitter: 0 at every ingestion call site while its own
  Emails client jitters.

Scope: compliance/ only.

Generated-By: PostHog Desktop
Task-Id: 86b4f98b-a338-40c2-912e-9e3a9dc366fd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants