You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Send attribution: source, SDK version and migration marker on transactional sends #530
Send attribution on today's transactional send route, POST /api/projects/{id}/messaging_templates/{id}/send/ on upstream/master. It is the smallest first PR of Resend parity, decided in grilling #525 (read its handoff: "Send attribution", "What we count", the "Send source" vocabulary).
Every send through this route records its send source: source (api | sdk), sdk_version (when an SDK sent it), and migrated_from (for example resend, when the migration skill wrote the call site).
The SDK sets migratedFrom: 'resend' once on the client, and it travels as a request header. Pick the header name and how source and sdk_version are detected (for example from the SDK's user agent), and name the choice in the PR.
The properties land on the send's email events, so an insight can count Code-sending orgs (orgs with API or SDK sends) and Switched orgs (sends that carry migrated_from).
On the first send that carries migrated_from, the server sets the group property email_migrated_from on the organization (resend). Later sends don't overwrite it.
Unknown or missing headers never fail a send: attribution is best-effort and the send behaves exactly as today.
Out of scope: the body route, posthog-node changes (a later PR sends the header), the Wizard event, dashboards.
Done when
A draft PR on PostHog/posthog per Michael's pull request rules: impact check, test-first with the tdd skill (name the test seams), the design pass in PANEL.md of qa-swarm, the proofs PROOF.md owes, the description with the pr-description skill, one cross-family review (GPT-6.1 Sol, high) recorded with fleet proof review-start/review-finish, and fleet proof gate green on HEAD. Never mark it ready and never merge.
Running in its own T3 thread, thread:project:f66f06fc-0bc1-4bfe-b00a-4aab7f54eb13:6ac5ea52-3f11-4434-b03d-8d9598e2b6e2: Opus 5.5, high, worktree from master.
Claimed. Running in T3 thread 6ac5ea52-3f11-4434-b03d-8d9598e2b6e2 on Opus 5.5, high. It builds test-first to a draft PR on PostHog/posthog, branched from upstream/master.
🤖 Migration headerX-PostHog-Migrated-From, following the repo's x-posthog-* request header convention. It stays out of the OpenAPI schema, so generated MCP tools never set it.
🤖 SDK detection A User-Agent of exactly posthog-node/<version> or posthog-edge/<version> (posthog-node's own getCustomUserAgent()) means source: sdk and sdk_version: <version>. Anything else, including a missing User-Agent, is source: api.
🤖 Accepted migration sources Only resend, matched case-insensitively. Any other value records migrated_from: null, so a typo can never become an organization's set-once property. A new source is a one-line addition.
🤖 Event that carries attribution The internal transactional email api send usage event, which already carries the organization group. That is where Code-sending orgs and Switched orgs can be counted. The $email_* events in the customer's own project stay unchanged.
🤖 Set once A Redis cache.add mark per organization lets only the first migrated send call group_identify, because group properties have no set-once operation. A failed group_identify clears the mark, so the next migrated send retries. A cache eviction can send the property again, with the same value.
🤖 Which sends mark the organization Only queued sends. A rejected or unavailable send records attribution on its event but never marks the organization.
Reviewed head ed6b4b59bdf on branch feat/email-send-attribution (Silthus fork).
What it does. Every send through POST /messaging_templates/{id}/send/ puts source, sdk_version and migrated_from on the internal transactional email api send event. The first queued send with X-PostHog-Migrated-From: resend sets email_migrated_from = resend on the organization group, once. Attribution never changes a send.
Proof
Red then green at the send route seam: 8 of 9 first cases fail on base 769074f8342. Each review fix got its own red case first.
Live run on HEAD: Django and the real CDP API (cdp-api mode) on a local Postgres, analytics pointed at a local sink. Six sends answered 202 with the expected attribution, and exactly one $groupidentify arrived across two migrated sends. The table is in the PR body.
fleet proof gate passes on HEAD: live-run evidence at HEAD, HEAD reviewed, post-deploy watch pending until merge.
Review
Design pass on GPT-6.1 Sol (high): two items, both fixed.
Cross-family review on GPT-6.1 Sol (high): two items, both fixed.
Final read on GPT-6.1 Sol (high): one item, rejected with the reason in the PR.
Gaps
CI on the fork PR waits for a maintainer to approve the workflow runs. No review bot posted, the same as earlier PRs on this map.
Delivery into the mail catcher was not run, because this PR does not touch delivery.
Decisions (these replace the matching lines of the build decisions where they differ)
🤖 SDK detection A User-Agent that starts with the token posthog-node/<version> or posthog-edge/<version> means source: sdk. A token a proxy appends still counts. Anything else is source: api.
🤖 Set once A Redis cache.add mark per organization lets only the first migrated send report. A raised error, or no event id from the analytics client (a dropped event), clears the mark, so the next migrated send retries.
🤖 SDK version syntax Any version up to 32 characters of [\w.+-] after the SDK token. A stricter semver pattern was rejected, because the User-Agent is caller-controlled anyway.
Follow-ups
posthog-node sends X-PostHog-Migrated-From when migratedFrom is set (posthog-node PR 1 of the map).
Skill v0 sets the header on its fetch calls.
The insight for Code-sending orgs and Switched orgs on the Grow Workflows dashboard.
The body route reuses SendSource and mark_organization_migrated from products/messaging/backend/presentation/send_source.py.
Conductor note: the follow-up insight for Code-sending orgs and Switched orgs goes on its own dashboard, not on the team's Grow Workflows dashboard. (Michael, 2026-10-20: work never adds tiles to a shared team dashboard.)
Activity
Silthus commentedon Oct 20, 2026
Running in its own T3 thread,
thread:project:f66f06fc-0bc1-4bfe-b00a-4aab7f54eb13:6ac5ea52-3f11-4434-b03d-8d9598e2b6e2: Opus 5.5, high, worktree from master.Silthus commentedon Oct 20, 2026
Claimed. Running in T3 thread
6ac5ea52-3f11-4434-b03d-8d9598e2b6e2on Opus 5.5, high. It builds test-first to a draft PR onPostHog/posthog, branched fromupstream/master.Silthus commentedon Oct 20, 2026
Decisions made while building
X-PostHog-Migrated-From, following the repo'sx-posthog-*request header convention. It stays out of the OpenAPI schema, so generated MCP tools never set it.posthog-node/<version>orposthog-edge/<version>(posthog-node's owngetCustomUserAgent()) meanssource: sdkandsdk_version: <version>. Anything else, including a missing User-Agent, issource: api.resend, matched case-insensitively. Any other value recordsmigrated_from: null, so a typo can never become an organization's set-once property. A new source is a one-line addition.transactional email api sendusage event, which already carries the organization group. That is where Code-sending orgs and Switched orgs can be counted. The$email_*events in the customer's own project stay unchanged.cache.addmark per organization lets only the first migrated send callgroup_identify, because group properties have no set-once operation. A failedgroup_identifyclears the mark, so the next migrated send retries. A cache eviction can send the property again, with the same value.Silthus commentedon Oct 20, 2026
Resolved: draft PostHog/posthog#120628
Reviewed head
ed6b4b59bdfon branchfeat/email-send-attribution(Silthus fork).What it does. Every send through
POST /messaging_templates/{id}/send/putssource,sdk_versionandmigrated_fromon the internaltransactional email api sendevent. The first queued send withX-PostHog-Migrated-From: resendsetsemail_migrated_from = resendon the organization group, once. Attribution never changes a send.Proof
769074f8342. Each review fix got its own red case first.cdp-apimode) on a local Postgres, analytics pointed at a local sink. Six sends answered 202 with the expected attribution, and exactly one$groupidentifyarrived across two migrated sends. The table is in the PR body.hogli lint:tach, strict pre-push preflight.fleet proof gatepasses on HEAD: live-run evidence at HEAD, HEAD reviewed, post-deploy watch pending until merge.Review
Gaps
Decisions (these replace the matching lines of the build decisions where they differ)
posthog-node/<version>orposthog-edge/<version>meanssource: sdk. A token a proxy appends still counts. Anything else issource: api.cache.addmark per organization lets only the first migrated send report. A raised error, or no event id from the analytics client (a dropped event), clears the mark, so the next migrated send retries.[\w.+-]after the SDK token. A stricter semver pattern was rejected, because the User-Agent is caller-controlled anyway.Follow-ups
X-PostHog-Migrated-FromwhenmigratedFromis set (posthog-node PR 1 of the map).fetchcalls.SendSourceandmark_organization_migratedfromproducts/messaging/backend/presentation/send_source.py.Silthus commentedon Oct 20, 2026
Conductor note: the follow-up insight for Code-sending orgs and Switched orgs goes on its own dashboard, not on the team's Grow Workflows dashboard. (Michael, 2026-10-20: work never adds tiles to a shared team dashboard.)