Skip to content

feat(migrate-email): move Resend sends in every PostHog SDK's language - #472

Merged
Silthus merged 186 commits into
mainfrom
feat/migrate-email-all-sdks
Nov 13, 2026
Merged

Silthus merged 186 commits into
mainfrom
feat/migrate-email-all-sdks

Conversation

@Silthus

@Silthus Silthus commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Problem

migrate-email-resend moves a Resend send to PostHog only when the code is JavaScript or TypeScript. A Python, Go, Ruby, PHP, .NET, Rust, or Elixir backend gets a plan where every site stays on Resend, with the reason "until the skill moves that language". PostHog's SDKs in all eight languages send transactional email now, so those sites can move.

Impact

No metric: PostHog's send API does not record the X-PostHog-Migrated-From header that migrated_from sets, so no insight can count the sends this skill moves, per language or at all. Recording it on $workflows_email_sent would let one insight count moved sends per provider and per organization.

Caution

🔴 Merge risk: high · two-way door until the next context-mill release ships the skill; one-way once agents run it, because a migration's changes persist in each app's code and PostHog account (rewritten send code and email files, senders, imported suppressions, keys).

  • A person who runs the skill on a Python, Go, Ruby, PHP, .NET, Rust, or Elixir backend: on the base every site stays on Resend; at HEAD the agent rewrites each site PostHog can take into that SDK's send. A send of a Resend template now moves by bringing the email into the code. The rows are uncovered until the owed live run: a wrong rewrite that the person deploys drops an email or changes what it holds, without an error.
  • A JavaScript or TypeScript site changes too: feat(skills): move Resend sends to posthog-node in migrate-email #451's rules, now read from rewrite-node.md, plus the rules this PR adds for every language. A send of a Resend template moves by bringing the email into the code, where feat(skills): move Resend sends to posthog-node in migrate-email #451 moved it only to a template made in PostHog. A site whose emails had no open pixel moves only on the person's yes, and a template made in PostHog asks about Resend's click tracking. Webhook handlers are listed: a site whose handler matches events by email_id or a tag stays, and the report names the PostHog events that replace the rest. A site with its own request deadline keeps it, with no retries, and one that told network failures apart stays. These rows are uncovered until the owed live run: a wrong rewrite changes what an email holds, adds an open pixel the person didn't agree to, sends an email twice past its deadline, or leaves a handler waiting for events that no longer come, without an error.
  • A run that leaves any site on Resend: on the base, the import right before cutover was the last, so an address Resend suppressed after cutover kept getting the moved sends. At HEAD the report asks for a weekly re-import while a site sends through Resend, with a prompt that runs only Step 5's import, and a final one after the last site leaves, which narrows that harm. A run that moves every site is unchanged. The re-import's own rows are uncovered until the live run: a re-import into a project production doesn't send from, when the person confirms the wrong project, leaves production's list stale; and a re-import that switched the MCP to the production project and didn't switch back leaves the person's later MCP work in that project.
  • A run on an app whose sites rely on Resend's suppression list to stop mailing addresses added by hand or by the app: on the base those sites move, and the moved sends reach those addresses, since PostHog blocks a transactional send only to an address that hard-bounced. At HEAD Step 3 asks once and keeps them on Resend, also when nobody answers. Uncovered until the live run: a wrong answer moves a site that relied on the list.
  • Also uncovered until the live run, each a rule that rests on what the person or the app's files tell the agent: secrets and template keys (a send with rendered content that carries a login code or a reset link and misses the SDK's sensitive flag, or whose key a template saved in PostHog already has, takes that template's settings, so its links go through PostHog's click redirect and its subject lands on engagement events, and a key whose template isn't transactional fails each send; the report tells the person to keep the moved keys off templates they save later); and the app's runtime (a wrong read of the language version the app runs, or of an edge runtime, installs an SDK release that can't run there, and every moved send in that language fails).
  • Every other skill is unchanged: the shadow diff shows only the migrate-email-resend bundle changes, and every other bundle is byte-identical.
  • Tier: critical: the skill rewrites how apps send transactional email through PostHog Workflows, the critical path of email delivery, where a wrong rewrite drops or doubles sends without an error.
  • Switch-off: none: a revert only stops new runs; a migration an agent already ran stays in that app's code and PostHog account. Nothing changes in an app until its person reviews and deploys the rewrite. Fix forward.

Rollout

Changes

  • One rewrite file per SDK: rewrite-node.md, rewrite-python.md, rewrite-go.md, rewrite-ruby.md, rewrite-php.md, rewrite-dotnet.md, rewrite-rust.md, and rewrite-elixir.md. Each one gives the install, the client with the secret key and migrated_from, the flag-loading setting for a send-only client, both send forms, the result and the error with its code and name, the branch for a suppressed recipient, and the check to run. The names come from the SDK release PRs and match references/sdks.md in the PostHog skill.
  • Step 7 picks the SDK by the site's language from a table, and reads only the rewrite files it needs. Its client, identify, and rewrite rules are the same for every language. The Node.js code moved into rewrite-node.md.
  • Resend's mapping:
    • The language row now keeps only sends in a language without a PostHog SDK that sends email, such as Java.
    • The Rewrite section has a part for each language, mapping Resend's call and answer to PostHog's. The traps it covers: Python's and PHP's error code changes from an HTTP status to a string code, .NET's Guid message ID becomes a string, Elixir's error name becomes an atom, and Resend's Elixir SDK takes no idempotency key.
    • Resend's mailers for Elixir (Swoosh) and .NET (FluentEmail) stay, next to Laravel's and Rails'.
  • Resend's SDK reference lists the client, send, batch, and error shape of each language, so Steps 1 and 3 find them.
  • A template stored at Resend moves into the code (template-to-code.md, from the provider stack): its HTML and text become a file next to the send, rendered with React Email, the app's template engine, or the language's own way, and the send uses the code form. A template made in PostHog is used only when the person asks for one.
  • Every SDK gets the shared Step 7 rules: a client of its own for email, a deadline kept on a client with that timeout and no retries, an abortable signal or cancellable context kept or the site kept on Resend, and a suppressed send handled like a sent one.
  • Suppression list (Steps 3, 5, and 9): Step 3 asks once which sites rely on the provider's suppression list for addresses added by hand or by the app, and keeps them, since PostHog blocks a moved send only to an address that hard-bounced. The import passes PostHog's reason value. An app call that removes an address becomes an "After cutover" item, and the report says which entries don't block moved sends.
  • Steps 1, 3, 8, and 9:
    • Step 1 reads Cargo.toml, mix.exs, and .csproj manifests.
    • Step 3 records each site's language.
    • Step 8 runs the check the rewrite file names.
    • The description and the config no longer say posthog-node.

How it was tested

  • The lane gate on f98eb3b: vitest run scripts, 342 tests in 30 files, and node scripts/build.js pass. migrate-email-skill.test.js keeps the tests that run the built skill: every reference path in the bundle resolves, the transactional email docs and every rewrite file are in the bundle, the step chain walks from 1-detect.md to 9-report.md through the built links, the env key check runs in bash on fourteen env files, each provider bundle holds no provider folder but its own, the Wizard menu lists each migrate command, and in each provider bundle every "Step N says under" reference, the entry's and the report's pointers to Step 5's "Re-import only" included, names a section that step has. The tests that matched the skill's own sentences are gone (QA swarm 2026-11-12).
  • Shadow diff from feat(skills): move Resend sends to posthog-node in migrate-email #451's head a090b5b to f98eb3b: only the migrate-email-resend bundle, manifest.json and skill-menu.json change; every other bundle is byte-identical. Saved in proof storage.
  • Every PostHog name was checked against the SDK sources, and every Resend name against Resend's SDK sources (Python, Ruby, PHP, Laravel, Go, .NET, Rust, and the Hex resend package for Elixir). The QA swarm checked each SDK claim it raised against the SDK sources too.
  • Gaps accepted on 96e10a2, carried to f98eb3b:
    • Live run: an agent run of the migration on a real app needs the released email SDKs and the production send API; Michael's planned trial on generated codebases runs it after both land.
    • CI: build.yml runs only on PRs into main, and this PR's base is feat(skills): move Resend sends to posthog-node in migrate-email #451's branch. The lane gate ran it locally.
    • Prod shape: the inputs are customer-written send code and config and each person's Resend account content; there is no store of real customer codebases to sample. Michael's planned trial on generated codebases covers it after the SDKs land. The events Step 8 queries are produced by PostHog's send pipeline, checked against its source; only the live run on a real app exercises them.

Review

  • Round 1 (Opus 5.5) found 2 major and 5 minor issues, and all of them are fixed in c4ed38c:

    • Each SDK's check now covers the whole project, and a major upgrade reads the changelog and searches for the app's other SDK calls.
    • The client snippets read the env without raising, so a missing key can't stop the app from booting.
    • Sync and async clients run side by side in Python.
    • Rust and Ruby upgrades move the version requirement.
    • go mod tidy runs after the rewrite.
    • Resend's status error classes map to a status check.
    • Edge runtimes use posthog-node.
  • Round 2 (GPT-6.1 Sol) found 1 issue, fixed in a658c75: posthog-rs builds either the async client or the blocking one, so the Rust file uses the one the app's features build.

  • The final read on a658c75 found nothing.

  • 6ab1cc2 merges the migration lane's per-SDK rules, from feat(skills): move SendGrid sends to PostHog in every SDK language #459's shared SDK reference, so the rewrite files are the only place for them. Each language now covers its network error after retries and its bad-argument error, plus .NET's lack of a synchronous send. Checked against the current SDK PR heads in f6b6af8:

    • No release takes cc, bcc, or attachments yet, so they stay on the provider.
    • Go and Ruby load flag definitions from their host with the secret key, so behind a proxy email gets its own client on PostHog's host.
    • PHP gets its own email client and leaves PostHog::init alone.
  • Final reads on the merge found three Elixir problems, all fixed. Email gets its own named instance when the app already uses PostHog (ef2c2e9). A missing host or token can no longer stop the app from starting (fbd1e83), and neither can one the app configures as nil (78d56ce). The final read on 78d56ce found nothing.

  • bb711c5: Step 7 lists the ten error names once, and each rewrite file points there instead of at a provider mapping. Each rewrite file also says whether reply-to takes one address or a list, checked on each SDK head. The final read on bb711c5 found nothing.

  • 5398fd9: behind a reverse proxy, email gets its own client on PostHog's host, for every SDK, in place of the Go and Ruby special cases. A client with the secret key loads flag definitions from its host with it: Go and Ruby when they start, and Python and .NET when the app evaluates a flag (checked on the SDK heads). A final read on the stack found this. 5398fd9 has no final read of its own yet, because feat(migrate-email): move Resend sends in every PostHog SDK's language #472 is past its sixth.

  • 6924d48: a GPT-6.1 Sol final read on 5398fd9 (the 7th, on Michael's word) found the proxy test matched only the separate-client wording. The test now also asserts "leave the secret key off the app's existing client": red with that clause removed, green with it (250 tests).

  • 2ebcce0: a send of a template stored at Resend now moves by bringing the email into the code, on Michael's direction for every provider: its HTML and text become a file next to the send, the code renders the variables, and the send uses the code form. A template made in PostHog, sent by its ID, is used only when the person asks for one. template-to-code.md comes from the provider stack as is, and Steps 3, 7 and 9 carry the same change. Resend never escapes a value, so the shared escaping rule applies. A fallback covers a missing value only. A from, reply-to or subject that the site passes wins over the template's, as Resend does. Five new tests fail on 6924d48 and pass here (254 tests); the build passes.

  • 6b41f33: the shared step changes from #459 move here, so each provider PR adds only its own provider. The steps no longer assume Node.js, keep each moved site failing the way it did, and list the app's webhook handlers and suppression writes for the report. feat(skills): move SendGrid sends to PostHog in every SDK language #459's two Resend shadow runs with these steps classified every site the same.

  • QA swarm 2026-11-12, on 82d6ebf with feat(skills): move Resend sends to posthog-node in migrate-email #451's fixes merged in (22df812):

    • Round 1 (Claude Opus 5.5 fresh eyes, GPT-6.1 Sol on six lenses and five team lenses): fixed in e36fd64 and 08c9d15. .NET gets a PostHogClient of its own for email, since AddPostHog() registers IPostHogEmails from the app's client. In Go and .NET, a deadline longer than the SDK's request timeout needs a client with that timeout. The Rust blocking client isn't awaited. Elixir always uses a named instance. A send in the code form is sensitive in PostHog and counts no clicks, so a site whose clicks feed a handler moves only to a non-sensitive PostHog template. Temporary template copies are deleted on every way out. A template the app changes at Resend stays. A Go link value with another scheme, such as tel:, stays. The tests that matched the skill's wording, and an it.each that ran no case, are deleted. Rejected: a missing token crashing Node.js and Ruby (both SDKs disable the client instead), the React Email rebuild (an app on React Email edits its emails as components), and prod shape (PostHog stores no person's code), now recorded as a gap.
    • Round 2 on the fixes, and ReviewHog round 1: fixed in bb14da9. A blank .NET host falls back instead of throwing, a .NET deadline over 100 seconds stays (its HttpClient default), a shared template's copy waits for its last site, a stored message ID points to the suppressed-send rule, and an error handler that also covers a call staying on Resend keeps Resend's handler. ReviewHog round 2 on bb14da9: a Go template that fills CSS from a value, such as rgb(255, 0, 0), gets ZgotmplZ from html/template (checked in Go 1.23), so such a site stays; fixed in eeeb620. ReviewHog round 3 on eeeb620: the report's "Before cutover" check now names a template brought into the code, and the Python email client sets enable_local_evaluation=False, so a worker forked under a preloading server doesn't poll flags with the email key; fixed in 64bb2a2. A final read on 64bb2a2 found that AsyncPosthog has no such option and raises TypeError on it; fixed in 8ead8e1. Final reads on bb14da9, eeeb620 and 8ead8e1 found nothing.
    • Relayed from the provider lanes and settled here: per-SDK timeout and retry options under "A deadline" in each rewrite file, with one shared rule in Step 7; Go's context and .NET's token carry the deadline and cancellation; Rust takes whole seconds; Node.js has no signal. A lost template copy comes from the dashboard, since the full-access key is gone after Step 5. An unquoted attribute value is quoted before an escaped value goes in. Resend's mapping lists the calls that change its suppression list. A branch on one kind of network failure, such as ECONNRESET or requests.Timeout, keeps its site on the provider, since every SDK reports one network_error; a kept deadline's own timeout still matches in Go and .NET. A limit on connecting alone, or apart from reading, keeps its site too, except in Go, whose email client takes the request's transport. Fixed in 0158aef, f6978e7 and ad23a92, with Resend's Node.js application_error for a network failure now also taking network_error.
    • ReviewHog round 4 on 0158aef: posthog-php sends email through curl, which Composer doesn't ask for, so the app requires ext-curl and the report lists enabling it where that isn't shown; fixed in f6978e7. A final read on f6978e7 found that Go keeps transport limits; fixed in ad23a92. ReviewHog round 5 on ad23a92: posthog-python hands its timeout to requests or httpx as one number, which limits each network wait, so an aiohttp total timeout keeps its site on the provider; fixed in 7ccc0ee. The reads on ad23a92 and 7ccc0ee, run under the standing review rule past Fleet's cap, found nothing.
    • Relayed from the provider lanes, on Michael's call to fix both now, fixed in eef1481: a site whose provider didn't track its clicks, or where nobody knows, moves to a PostHog template only when the person marks it sensitive, since PostHog sends a non-sensitive template's links through its click redirect; Resend's account file says where its per-domain click tracking shows. A library's default timeout, such as httpx's or ky's, is not the site's deadline. Every SDK's timeout limits the whole request except Python's and Ruby's, which limit each network wait, and a limit of another kind keeps its site on the provider, such as axios's idle timeout and ky's, which ends once the headers arrive. Resend's sensitive template sends its links without the click redirect. The message ID is a UUID, so .NET code that keeps a Guid takes Guid.Parse. A final read on eef1481 found that Faraday's timeout limits each wait only on its net_http adapter; fixed in efb8451. ReviewHog round 6 on efb8451: a handler that acts on a Resend event with no PostHog event, such as email.delivery_delayed, keeps its sites on Resend; fixed in f658354. Final reads on efb8451 and f658354, under the standing review rule, found nothing.
    • Step 8's tests, on Michael's call, merged from feat(skills): move Resend sends to posthog-node in migrate-email #451 in ced460c: a test that mocked the provider's client runs the real PostHog SDK and intercepts PostHog's send request, asserting on that request and on what the app does. Node.js, Python and Ruby intercept in process, with msw, nock 14 or later, undici's MockAgent or a fake global fetch, responses, requests-mock, respx or pytest-httpx, and webmock. Go, .NET, PHP, Rust and Elixir can't swap the SDK's HTTP client from a test, so the test runs a local server and points the email client's host and app host at it, through an optional app host variable; Go and .NET allow an http app host only for a loopback address (d51979c). No test tool is added as a dev dependency without asking the person once, in any language. Node.js, Go, .NET and PHP need none; in Python, Ruby, Rust and Elixir, on a no, the test runs a local server from the standard library, such as Python's http.server or Ruby's TCPServer, and no test keeps a mock of the send (6f7abcb, 8776c81, 63c3dfe). An earlier version kept the mock on a no; final read 12 found it, and the judge on 96e10a2 failed its rejection. Also relayed from the provider lanes: a Ruby request that sets only some of Net::HTTP's timeouts, or sets them apart, stays, since posthog-ruby sets all three to one number (e14c1fc); Step 3 writes must be marked sensitive into a template's plan note, so the report checks it for every provider (a943460); and a branch on the name service_unavailable skips network_error, which every PostHog SDK also names so, so a network failure takes the path the old code gave it (45c5716). A final read on a943460 and ReviewHog round 7 found the http app host point; a final read on d51979c, under the standing review rule, found nothing.
    • A recurring suppression re-import, on Michael's call, after the SendGrid and Mandrill judges found that a site that stays keeps adding bounces and complaints PostHog never sees (21e1d27). Step 5 gains "Re-import only", which runs the import alone with no plan file, and the skill entry points to it, so the person re-runs only the import. It first asks the person whether production sends from the MCP's project, with a differing local token as a hint, since the local env file may name a development project; on a no it offers to switch the MCP to the production project and switches back when the step ends, and it stops when they can't tell or the project isn't in the organization's list. With no import tool it tells the person where to add the new addresses by hand, naming the production project, and says so instead of a count, as it does when it couldn't get the list (a65bb90, b28e13b, b2dfe53, 731b092, 8929f93, e5735c8, 8b9757e, 349a407). Steps 5, 7 and 8 now read the project token with project-get, the one MCP tool that returns it; projects-get lists projects without their tokens (731b092). When any site stays, the report asks for a weekly re-import while a site sends through the provider, gives the prompt, says a repeat is safe, and asks for a final import after the last site leaves. Weekly, not the release cadence, since the sites that stay add entries between releases. A provider's account.md only says where its list comes from.
    • A provider that keeps no suppression list of its own, such as a mailbox provider behind an SMTP host, gets no weekly re-import ask: Step 5 records empty list: <provider name> keeps no suppression list before it checks the import tool, and the report leaves the ask out (d8dd2d4, 94d44d3), relayed from the SMTP lane.
    • A re-import alone, for a provider that keeps no suppression list, starts with the provider's notes and stops there, telling the person there is nothing to re-import, before it reads the env file or asks about the project (2b8d0d6, 5f5debd), relayed from the SMTP lane's judge.
    • Untracked opens, on Michael's call (17c6ca1): PostHog adds its open pixel to every email it sends, so Step 3 asks the person once, for all sites whose emails had none, whether PostHog may add it. A yes moves them, with a plan note the report names; a no or no answer keeps them as open tracking off, and a site nobody can tell about stays as open tracking not checked. Step 7 points there, and Resend's account file says where its per-domain open tracking shows. A new bundle test fails when a "Step N says under" reference names a section the step lacks (red with the new heading renamed). A final read and ReviewHog round 8 on 17c6ca1, under the standing review rule, found nothing.
    • 96e10a2 merges feat(skills): move Resend sends to posthog-node in migrate-email #451's cff58f5, which brings this PR's network-failure rule for Resend down to feat(skills): move Resend sends to posthog-node in migrate-email #451; this tree already had it, so the merge changes no file.
    • 090ac92 merges feat(skills): move Resend sends to posthog-node in migrate-email #451's 2df1f26, which names project-get for the project token in Steps 7 and 8; this tree already had it, so the merge changes no file.
    • cb26a5f merges feat(skills): move Resend sends to posthog-node in migrate-email #451's eeed7cb, which lists Resend webhook handlers and keeps the sites they act on, and states the SDK's limit for sites without a deadline. This tree already had both in its own words, so the merge keeps feat(migrate-email): move Resend sends in every PostHog SDK's language #472's text there, and carries feat(skills): move Resend sends to posthog-node in migrate-email #451's Step 8 check of each error in a rewritten line against its old version. e7a7f3f merges feat(skills): move Resend sends to posthog-node in migrate-email #451's 77b680b, which gives Step 8 one rule for which errors are new, as final read 30 asked; feat(migrate-email): move Resend sends in every PostHog SDK's language #472's own text takes the same rule.
    • 6c45e23 merges feat(skills): move Resend sends to posthog-node in migrate-email #451's 2fe8430, keeping feat(migrate-email): move Resend sends in every PostHog SDK's language #472's text, and 4087e6c carries feat(skills): move Resend sends to posthog-node in migrate-email #451's newer fixes in this tree's form, one rule for every SDK: Step 7 asks the person once whether a template saved in PostHog already has any of the moved sends' keys and gives such sends another key, since such a send takes that template's settings and fails when it isn't transactional (the ReviewHog P1 on 7-rewrite.md, where a code send was called sensitive whatever its key); a send with rendered content that carries a login code, a reset link or another secret sets the SDK's sensitive flag; and before an SDK install or upgrade, Step 7 checks the language version the app runs against what the release supports, and keeps that language's sites on the provider when it doesn't. Step 8 counts a listed error against the list's number less the copies the changed lines no longer have, and its rule covers warnings (final read 31). Final read 32 on 4087e6c found that no rewrite file named the sensitive flag; each SDK's latest release takes it, checked in its package, and each rewrite file's "The send" now names it (808f61d), with the moved template keys in the report and an edge runtime's check. Final read 33 moved the keys to "After cutover" and gave an unnamed edge runtime its own reason (fd58f93). ReviewHog on 808f61d and fd58f93 found nothing. Final reads 34 to 36 scoped the runtime check to the dependency manifest the SDK goes into (f1ba031, a0b01bc, 8f51a57, 6b0083e): when the release doesn't support a server whose build installs that manifest, directly or through a workspace or a root lockfile install, every moving site on it stays, an edge site too, since the install would reach that server; only otherwise does an edge site get its own check. The report's key note names the click redirect and the subject on engagement events too.
    • ReviewHog round 13 on 6b0083e: a request with its own deadline whose HTTP client also retried it would lose those retries on the move. Such a site now stays (ef71e1f), counted only when the retry setup covers a POST, as final read 39 asked (6fdfdf7), with the setups named as examples (6d4801f). The agent reads the setup's options, since axios-retry and urllib3's Retry retry a POST only at their defaults (caff403), and a requests adapter with a number as its max_retries counts too (7aad014), from the gate judge and final read 42. Final reads 40 to 43 and ReviewHog rounds 14 to 16 found nothing.
    • 66dc2b2 merges feat(skills): move Resend sends to posthog-node in migrate-email #451's a090b5b, which is 2fe8430 plus main's omnibus and commandments files, so the merge brings only those. ReviewHog on a090b5b found that a site reading Resend's response headers, such as retry-after, moved although PostHog's answer carries no headers. Such a site now stays, unless it reads only the retry delay of a refused send, which moves to the PostHog error's (6d3d8b0). Each rewrite file names its SDK's retry-delay field and unit under "The answer", checked against each SDK's latest release, and a site that keeps its own deadline keeps its own wait and retry (610e703, from final read 44). ReviewHog on 610e703: a Resend template whose text is an empty string sends no text part, which PostHog can't do, since it makes one from the HTML; such a template, and a code send with text: "" beside html, now stay (d186900). Final read 46 widened it to react and to a text the code builds that can be empty, and the shared template rule now keeps any template whose provider sent its emails with no text part (088f35b). Final read 47: that rule now sits in the part Step 3 reads, and an empty Text in Go moves, since Resend's Go SDK leaves it out of the request (3b204b7). Final read 48: a dashboard copy can't tell an empty plain text from a missing one, so the run asks, or offers the full-access key to read that template from the API, keeps the site when neither settles it, and every template's note records its plain text, so Step 7 never asks again (f3bb668, 355df95, 74040e5).
    • ReviewHog on 74040e5: Step 5's rule for an app's calls that change Resend's suppression list keyed on reason text PostHog never stores. PostHog writes its own reason, such as Imported (bounced), takes only bounce, complaint or manual, keeps no source an app could check, and blocks a transactional send only to an address that hard-bounced. So the app no longer syncs these calls (b99cea5 to 4db6763, over final reads 52 to 59 and ReviewHog on 9eb4180). The import passes the reason value. Step 3 asks once which sites rely on Resend's list for addresses added by hand or by the app, before any template work, and keeps them, also on a non-answer. A call that removes an address becomes an "After cutover" item for when a moved send fails with recipient_suppressed. The report says that an address that complained or was added by hand gets the moved sends, so the weekly re-import limits mail only to bounced addresses.
    • ReviewHog on 4db6763: posthog-rs's async email send waits between retries with tokio::time::sleep, so a Rust site whose async code runs on another runtime, such as async-std or smol, or on a Tokio runtime built without timers, stays (0a6ae00, f98eb3b).

Decisions

Question Answer Who Where
A stored Resend template Moves into the code by default; a template made in PostHog only on request 👤 Human this PR, 2ebcce0
Email client per SDK Always one of its own, never the app's: .NET builds a PostHogClient, Elixir a named instance 🤖 Agent QA swarm 2026-11-12
A deadline Kept per SDK with its timeout option and no retries; Go and .NET pass it on the send and raise the client timeout when it is longer; a deadline the SDK can't hold stays 🤖 Agent QA swarm and provider lanes 2026-11-12
A deadline on a request whose HTTP client retries a POST The site stays on Resend: the send that keeps the deadline takes no retries; the agent reads the setup's options, and one that skips a POST keeps the deadline 🤖 Agent ReviewHog round 13 and final read 39, 2026-11-13
A site that reads Resend's response headers Stays, unless it reads only the retry delay of a refused send, which moves to the PostHog error's retry delay; PostHog's answer carries no headers 🤖 Agent ReviewHog on #451's a090b5b and final read 44, 2026-11-13
An app's calls that change Resend's suppression list Not synced to PostHog, which keeps no source an app could check; Step 3 keeps the sites that rely on the list, also on a non-answer, and a removal becomes an "After cutover" item; replaces the synced-reason rule 🤖 Agent ReviewHog on 74040e5 and final reads 52 to 58, 2026-11-13
Complaint and hand-added entries reaching moved sends Stated in the report: PostHog blocks a transactional send only to an address that hard-bounced, by design, and no per-address action changes that 🤖 Agent final read 54, 2026-11-13
A send or template whose text is an empty string Stays on Resend, also beside react or when the code builds a text that can be empty: it sends no text part, and PostHog makes one from the HTML; a send without text moves 🤖 Agent ReviewHog on 610e703, 2026-11-13
Clicks on a code-form send None: PostHog treats it as sensitive, since Step 7 gives it a key no saved template has; a site whose clicks feed a handler moves only to a non-sensitive PostHog template 🤖 Agent QA swarm 2026-11-12
Tests Only tests that run the built skill; no tests that match its sentences 🤖 Agent QA swarm 2026-11-12
A branch on one kind of network failure Stays on the provider, except a kept deadline's timeout in Go and .NET 🤖 Agent provider lanes 2026-11-12
Suppressions added by sites that stay Re-import the list weekly while any site sends through the provider, with a prompt that runs only Step 5's import, and once more after the last site leaves; unchanged when every site moves 👤 Human conductor relay 2026-11-12
The MCP tool that reads the project token project-get, called without an ID, the one tool that returns api_token; replaces projects-get, which lists projects without it 🤖 Agent final read 22, 2026-11-12
The weekly re-import ask for a provider with no list Left out when the plan says the provider keeps no suppression list 🤖 Agent SMTP lane relay 2026-11-13
A re-import alone for a provider with no suppression list Ends before the project check, with nothing to re-import 🤖 Agent SMTP lane relay 2026-11-13
Step 8 tests of a mocked provider client Run the real PostHog SDK with PostHog's send request intercepted, and assert on that request and on what the app does; replaces keeping the test at its mock level 👤 Human conductor relay 2026-11-12
No interception tool in the suite Every language asks before adding a test tool; Node.js, Go, .NET and PHP need none, and Python, Ruby, Rust and Elixir run a standard-library server on a no. Replaces keeping the mock on a no, which was the conductor's wording, not Michael's 🤖 Agent conductor, after the judge on 96e10a2, 2026-11-12
Opens the provider didn't track Ask once whether PostHog may add its open pixel; yes moves the sites, no or no answer keeps them as open tracking off, unknown tracking keeps them as open tracking not checked 👤 Human conductor relay 2026-11-12
Clicks the provider didn't track A site moves to a PostHog template only when the person marks it sensitive; otherwise it stays 👍 Accepted default conductor relay 2026-11-12
A library's default timeout Not the site's deadline: the site sends with the PostHog SDK's own timeout and retries 👍 Accepted default conductor relay 2026-11-12
A limit of another kind than the SDK's timeout Stays on the provider: axios's idle timeout, ky's, and a whole-request limit in Python or Ruby 🤖 Agent provider lanes 2026-11-12
A handler on a Resend event PostHog lacks Its sites stay on Resend 🤖 Agent ReviewHog round 6
A Ruby request with some of its Net::HTTP timeouts Stays: posthog-ruby sets open, read and write to one number 🤖 Agent provider lanes 2026-11-12
A Rust site on an async runtime other than Tokio Stays, also on a Tokio runtime built without timers: posthog-rs's async send waits between retries with Tokio's timer 🤖 Agent ReviewHog on 4db6763, 2026-11-13
A template that must be marked sensitive Step 3 writes it into the template's plan note, so the report checks it for every provider 🤖 Agent provider lanes 2026-11-12
Secret emails sent from code The SDK's sensitive flag on a send with rendered content that carries a secret; each rewrite file names it, and a release without it keeps the site 🤖 Agent ReviewHog P1 and final read 32, 2026-11-13
Template keys a saved template already has Ask the person once and give such sends another key; the report lists the moved keys after cutover, for templates saved later 🤖 Agent ReviewHog P1 and final read 33, 2026-11-13
The app's runtime version Checked before the SDK's install against every server that installs from the manifest it goes into; one unsupported server keeps every site on that manifest, and an edge runtime the rewrite file doesn't name keeps its own sites 🤖 Agent #451's ReviewHog and final read 32, 2026-11-13
A workspace server whose package manager only warns on engines Still keeps the sites on the SDK's manifest: a kept site loses nothing, and misreading the package manager's strictness breaks a deploy 🤖 Agent final read 38, 2026-11-13
React Email apps Keep the component rebuild 🤖 Agent QA swarm 2026-11-12
Prod shape Owed, recorded as a gap: the inputs are customer-written code, config and each person's Resend account, and no store of real customer codebases exists to sample; Michael's trial on generated codebases covers it 🤖 Agent Fleet judge 2026-11-12

Involvement: no grilling rounds, no prototypes. QA swarm 2026-11-12: one two-family panel with five team lenses, one round on the fixes, and sixty-one final reads, the two-family ones with their points fixed or declined with a reason; forty-six ReviewHog reviews, every finding fixed and the last two clean; relayed findings from six provider lanes settled. Proof captured: shadow diff; live run, CI and prod shape owed as gaps.

Merge

Stacked on #451. It ships with the eight SDK releases, like #450 and #451, and merges after them. The provider PRs, #459 to #468, each stand on this one alone and land in any order after it. Retarget them to main before this merges: deleting this branch on merge would close them.

🤖 Generated with Claude Code

Silthus and others added 30 commits October 31, 2026 09:51
The migrate group keeps Statsig's mapping and SDK reference under
references/statsig/, and its step files point there, but the generator
copied only the top-level reference files. Copy references/<variant-id>/
into each variant's bundle, and nothing of the other variants.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Move the sender setup of send-transactional-email's STEP 3 into
context/shared/email-sender-setup.md, so the email migration skill
includes the same text. A partial now takes the indentation of its
{{> name}} line on every line, so it nests under a step. The built
send skill is unchanged byte for byte.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
v0 prepares a move off Resend and changes no send call site. It finds
every Resend send, classifies each one as ready to move or staying on
Resend with a reason, sets up the PostHog sender next to Resend's DNS
records, imports Resend's suppression list when the import tool exists,
hands over the project secret key, checks the sending tier, and writes
posthog-migrate-email-resend-report.md with a summary block.

Steps are provider-neutral; references/resend/ holds what is specific
to Resend. Statsig and Resend now publish as wizard migrate subcommands.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixture runs wrote reasons into the summary block, which the Wizard
can't parse, and counted a forwarding helper as one site or as each
caller. The report step now shows bare values, and a site is the place
that decides a send's content and fields.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…the sending skill

The send-transactional-email skill is gone from this stack, so migrate-email
bundles the transactional email pages and names the sending-transactional-emails
skill for the general move.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… PostHog's reply-to rules

The preflight looked for two MCP tools that don't exist. It now looks
for the make-transactional pair, and a missing pair records the API as
not confirmed instead of stopping, because it can also mean a missing
scope. The mapping now keeps a site on Resend for reply-to addresses
with a name or more than 10, and lists every reserved header and the
header and tag length limits.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The migrate-email skill now rewrites every call site PostHog can send:
hosted Resend templates become local templates, React and html/text sites
send rendered content, and the client carries migratedFrom. It checks the
build and one email on one person before it writes the report.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d provider in tests

Fixture runs looped over or truncated a one-recipient list, and one run
mocked posthog-node to rebuild a Resend request. The rewrite now narrows
the helper's parameter to one address, and the verify step asserts on the
fields posthog.emails.send gets.

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

A moved site now treats recipient_suppressed like a send that went out,
a site-built subject becomes a module placeholder so the template hash
stays stable, fallbacks use single quotes, and the report warns that
idempotency keys don't cross providers. The rules and Step 7 no longer
contradict the mapping.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… uses sending cap

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

posthog-node has no migratedFrom option. The Wizard records the migration
on its setup wizard finished event instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-email rewrites a site

A posthog-node release with posthog.emails can still lack templateKey,
local template content, or the extra send fields. The rewrite now checks
the installed types for what each moving site needs, and keeps a site
on Resend when the latest release lacks it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…partial imports in migrate-email

Step 1 now admits the SMTP host and a framework mailer and needs at least one
send; step 3 stops when it finds no site. A suppression import that stops
partway stays unticked and lands in the report's "Before cutover" list. A
template site needs its content from the person or stays on Resend. The
sender setup is inlined into step 4, which keeps the existing `from` domain and
records an unverified domain instead of waiting. AGENTS.md says the migrate
subcommands run once the wizard runs migrate as a family.

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

The selected variant's `references/<variant-id>/` files now go through the same
loop as the root reference files, so the separate copy helper is gone. The
partial expander drops the indentation it gained for the sender partial, which
nothing includes any more, and the bundle test drops the migrate-statsig case
that guarded nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…rt every behaviour change

Step 8 checks that the app sends to the MCP's project, notes the start of the
test, and counts only events since then whose workflow matches the send. It
compares typecheck errors with a baseline step 7 takes before it changes code.
A template's content waits in a temporary file for step 7 instead of in memory,
an HTML fallback keeps a template on Resend, and a derived templateKey is
normalized and unique. The report lists each suppressed-recipient branch,
copy-address refusal, and cross-provider idempotency risk, and reminds the
person to delete the full-access Resend key. The posthog-node client setup is
inlined into step 7, and description.md says this skill wins over the general
moving guide.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…tes from files

Step 4 records a domain as not verified, with its records or Domain Connect
link, when the person can't publish them during the run. Step 3 asks the person
to save each template from the dashboard to a file outside the repository and
reads it, since the Wizard can't take pasted HTML.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… keep template files traceable

Step 8 takes the start of the test from `execute-sql` and compares Unix
timestamps, so the project's timezone can't shift the window. The plan lists
each saved template file, step 7 reads the module from it, and step 9 deletes
every listed file. A derived templateKey falls back to the template id when
the name normalizes to nothing and stays unique across the run. Step 8 may fix
other posthog-node code the upgrade breaks, and the report lists those files.

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

The clock query carries a fresh random literal so a cached answer can't widen
the test window. Step 3 may write the template files it saves, the dashboard
copy includes the template's alias or name for its key, and a major
dependency upgrade lands in the report's "Before cutover" list.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…end, and move templates only to PostHog

The first PostHog release sends a template made in PostHog by template id, or rendered html and text. A Resend template site moves only once the person makes the template in PostHog, or stays on Resend for now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolves the inventory, mapping and report conflicts toward the scope cut:
a Resend template site moves only to a template made in PostHog, sent by
templateId, and headers, tags and attachments stay on Resend.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Under the scope cut, a moved template site sends a template made in
PostHog by templateId with templateData. Rendered sends keep templateKey,
subject, html and text. No local-template module, no upload on first send,
and no cc, bcc, headers, tags or attachments.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
posthog-node's migratedFrom client option sends the provider a send
moved from with every email request. Step 7 now sets it, and the
Resend mapping names its value.

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

Review round 1 on #451:
- Step 3 asks for the template ID once the person made the template in
  PostHog. A template without one stays: PostHog template not made yet.
- Step 7 checks that the client takes migratedFrom, and undoes the
  posthog-node install when no site is left to move.
- Template files from an API read are deleted once their site is
  classified, and the full-access Resend key right after Step 5.
- Step 8 reads only the token's line of the env file, and picks a
  signed-in flow for the test email.
- replyTo moves as one address or a list.

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

Review round 2 on #451:
- Step 3 asks for the address a PostHog template sends from and writes it
  in the site's from column, so Step 4 sets up a sender for its domain.
- The report asks the person to send a test of each PostHog template and
  check that it is transactional, has a verified sender and fills its
  variables.
- Step 5 asks to delete the full-access key on every way out of the step,
  and after a partial import only once the person won't repeat it.
- Step 8 allows a signed-out flow: the person signs in as the recipient
  afterwards, so product events show on the same distinct ID.
- migratedFrom is set only when the client options take it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mes a person

Review round 3 on #451:
- Step 5 asks once whether to repeat an import that stopped partway, and
  asks about the full-access key after that answer or the repeat.
- Step 8's test email comes from a moved site that passes distinctId;
  without one, the chain is recorded as not checked.
- The client example marks migratedFrom as conditional.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
main equals #451's merged head a090b5b, which this branch already contains, so the tree is unchanged from f98eb3b.

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

@posthog posthog Bot 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.

PostHog Review · Standard · reviewed 418cc5a: no findings.

@Silthus
Silthus merged commit 8cd7381 into main Nov 13, 2026
17 checks passed
Silthus added a commit that referenced this pull request Nov 13, 2026
Silthus added a commit that referenced this pull request Nov 13, 2026
Map each SendGrid list to PostHog's reason, name Global Unsubscribes for
Step 3's question about sites that rely on the suppression list, and
replace "Suppression writes" with the calls section Step 3 and Step 5
read, without the import's entry rules.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus added a commit that referenced this pull request Nov 13, 2026
Silthus added a commit that referenced this pull request Nov 13, 2026
Silthus added a commit that referenced this pull request Nov 13, 2026
…ules

- account.md maps each SuppressionReason to PostHog's reason: bounce,
  complaint, or manual. It says PostHog blocks a moved send only to a
  bounce entry, and names how an address gets onto the outbound list
  for Step 3's question on sites that rely on Postmark's list.
- mapping.md drops which suppression-list calls count, which Step 5 no
  longer reads, points those calls at Step 3 too, and says PostHog
  refuses only a hard-bounced address with recipient_suppressed.
- A send without a text body notes that PostHog makes the text part,
  and code that reads a header of Postmark's answer stays.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus added a commit that referenced this pull request Nov 13, 2026
Silthus added a commit that referenced this pull request Nov 13, 2026
- account.md maps each SparkPost source to PostHog's reason (bounce,
  complaint, manual), and says only a bounce blocks a moved send.
- mapping.md feeds Step 3's new suppression question: the Manually Added
  and Compliance entries and the app's suppression writes, per account,
  with the reason `relies on SparkPost's suppression list`.
- mapping.md drops the "which entries count" text Step 5 no longer reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus added a commit that referenced this pull request Nov 13, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus added a commit that referenced this pull request Nov 13, 2026
…ter #472

BOUNCE imports as bounce and COMPLAINT as complaint. PostHog refuses a moved send only for a bounce entry, so the widening checks count only BOUNCE entries. Name where Amazon SES entries are added by hand for Step 3's question, and drop the entries-that-count text Step 5 no longer reads.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus added a commit that referenced this pull request Nov 13, 2026
Silthus added a commit that referenced this pull request Nov 13, 2026
Silthus added a commit that referenced this pull request Nov 13, 2026
…t rules

Map each Rejection Denylist entry to PostHog's reason, drop the "which
adds count" text Step 5 no longer reads, and name the Rejection Denylist
and its custom and unsubscribe entries for Step 3's new question. PostHog
now makes a text part whenever a send has none, so an HTML send that
Mailchimp Transactional sent with no text part stays, and the Sending
Defaults' plain-text box joins the account questions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus added a commit that referenced this pull request Nov 13, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus added a commit that referenced this pull request Nov 13, 2026
…472

Map Bounces, Complaints and Unsubscribes to PostHog's bounce, complaint
and manual reasons, and leave out allowlists. Feed Step 3's
suppression-list question with Mailgun's unsubscribes, which also stopped
transactional sends. Drop the unsubscribes report count and the "which
entries count" text that Step 5 no longer reads, and say that PostHog
blocks a moved send only to an address that hard-bounced.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus added a commit that referenced this pull request Nov 13, 2026
…-email-track-opens-and-clicks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus added a commit that referenced this pull request Nov 13, 2026
main's tree equals #472's final head 418cc5a, merged in the parent commit, so this merge takes no content.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus added a commit that referenced this pull request Nov 13, 2026
Silthus added a commit that referenced this pull request Nov 13, 2026
…y send_message fields from the installed gem

A site that reads a header of SparkPost's answer, other than the retry
delay, now stays, as Resend's does under #472's Step 7. A Retry-After
read moves to the PostHog error's retry delay. A Ruby send_message
call maps the fields the installed gem sent, where a keyword can
override a positional argument.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus added a commit that referenced this pull request Nov 13, 2026
Silthus added a commit that referenced this pull request Nov 13, 2026
…Step 3's list question

Follow #472's shared steps: each entry on the provider's list maps to a
PostHog reason (bounce, complaint, manual), and Step 3's question about
sites that rely on the list covers only sites whose host's provider
keeps one, naming that provider in the reason.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus added a commit that referenced this pull request Nov 13, 2026
#472's template check keeps a template the provider sent with no text
part. A Brevo template has no text part of its own to turn off, and
Brevo makes a plain text version of HTML emails itself, so the check
doesn't keep it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus added a commit that referenced this pull request Nov 13, 2026
…og's retry delay

A Loops retry loop that waited for Retry-After now reads the retry
delay PostHog's error carries since #472, converted to the loop's unit,
and keeps its own path only when PostHog named no wait.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Silthus added a commit that referenced this pull request Nov 17, 2026
)

* fix(skills): keep migrate-email's chain query uncached on its rerun

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

* fix(skills): keep cc, bcc, headers, tags and attachments sites on Resend, and move templates only to PostHog

The first PostHog release sends a template made in PostHog by template id, or rendered html and text. A Resend template site moves only once the person makes the template in PostHog, or stays on Resend for now.

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

* Drop local templates and parked fields from the cutover steps

Under the scope cut, a moved template site sends a template made in
PostHog by templateId with templateData. Rendered sends keep templateKey,
subject, html and text. No local-template module, no upload on first send,
and no cc, bcc, headers, tags or attachments.

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

* feat(migrate-email): set migratedFrom on the posthog-node client

posthog-node's migratedFrom client option sends the provider a send
moved from with every email request. Step 7 now sets it, and the
Resend mapping names its value.

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

* fix(migrate-email): ask for the PostHog template ID before a template site moves

Review round 1 on #451:
- Step 3 asks for the template ID once the person made the template in
  PostHog. A template without one stays: PostHog template not made yet.
- Step 7 checks that the client takes migratedFrom, and undoes the
  posthog-node install when no site is left to move.
- Template files from an API read are deleted once their site is
  classified, and the full-access Resend key right after Step 5.
- Step 8 reads only the token's line of the env file, and picks a
  signed-in flow for the test email.
- replyTo moves as one address or a list.

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

* fix(migrate-email): check each PostHog template and its sender before cutover

Review round 2 on #451:
- Step 3 asks for the address a PostHog template sends from and writes it
  in the site's from column, so Step 4 sets up a sender for its domain.
- The report asks the person to send a test of each PostHog template and
  check that it is transactional, has a verified sender and fills its
  variables.
- Step 5 asks to delete the full-access key on every way out of the step,
  and after a partial import only once the person won't repeat it.
- Step 8 allows a signed-out flow: the person signs in as the recipient
  afterwards, so product events show on the same distinct ID.
- migratedFrom is set only when the client options take it.

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

* fix(migrate-email): ask about a repeat import and test a send that names a person

Review round 3 on #451:
- Step 5 asks once whether to repeat an import that stopped partway, and
  asks about the full-access key after that answer or the repeat.
- Step 8's test email comes from a moved site that passes distinctId;
  without one, the chain is recorded as not checked.
- The client example marks migratedFrom as conditional.

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

* fix(migrate-email): ask for the PostHog template ID and sender before a template site moves

Review round 1 on #450:
- Step 3 checks a template site's other fields before it asks about the
  template, and asks for the PostHog template ID and the address it sends
  from. A template without an ID stays: PostHog template not made yet.
  The address goes in the from column, so Step 4 sets up its domain.
- mapping.md quotes a fallback that holds ' with ", carries a
  definition-level fallback_value, notes that default replaces an empty
  string, and keeps a fallback with both quotes or HTML on Resend.
- The report asks the person to test each PostHog template before cutover.

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

* fix(skills): read Dirent.path when parentPath is missing in the migrate-email test

Node 20.11, the oldest release engines allows, has no Dirent.parentPath,
so the bundle tests threw before their assertions. Use the same
parentPath ?? path fallback as build-phases.js.

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

* fix(migrate-email): match account.md's template-content rule to Step 3

account.md said template content goes only into a temporary file, while
Step 3 reads the person's dashboard copies where they saved them. Only an
API answer goes into the temporary file now.

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

* fix(migrate-email): keep a site on Resend when its idempotency key doesn't fit PostHog's

PostHog takes an idempotency key of 1 to 255 printable ASCII characters
without spaces. A site whose key can hold a space or a non-ASCII
character, or run longer, stays on Resend. The report names each key a
retry across the deploy could send twice, since the providers don't
share keys.

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

* fix(migrate-email): name PostHog's idempotency key rule exactly

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

* fix(migrate-email): end Step 8's email check when the person declines the test email

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

* docs(migrate-email): say where a send without distinctId lands

Rename "Find the user ID" to "Link emails to your users", name the
identify() ID, say that without distinctId PostHog records the email on a
separate person keyed by the address, and add invites and signup checks to
the cases that leave it out.

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

* docs(migrate-email): test Step 8 on a site that passes distinctId

Step 7 now leaves distinctId off an address check before the account
exists, so Step 8 picks its test site from the plan rows that pass one.

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

* feat(skills): move SendGrid sends to PostHog in every SDK language

Add a SendGrid variant to migrate-email, and make the shared steps move
a site in any language with a PostHog email send, from posthog-sdks.md.
Step 3 records each site's language and the provider's webhook handlers,
and the report lists the PostHog events that take their place.

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

* fix(migrate-email): close round-1 review findings on the SendGrid layer

- PHP: give the email send its own client with loadFeatureFlags off, so
  the secret key never reaches a proxy host; Step 7 says flag loading
  sends it.
- Python async needs posthog[async]; argument errors, network_error,
  cc/bcc types, attachment fields and captureEngagement's default are
  stated per language.
- Step 7 keeps a narrow catch narrow and catches argument errors where
  the old site handled a bad value.
- SendGrid: headers, customArgs and categories always stay; if/unless
  and each convert only for booleans and lists; trackingSettings keeps
  a template site; Go and Elixir decode base64 attachments; a from name
  with special characters is quoted; EU subusers read from the EU host.
- Shared steps: template section named by role, fields a mapping moves
  without, CNAME clashes in Step 4, suppression sources without an
  export, key places that set a value, report lists only actions, and
  per-part package removal. AGENTS.md lists wizard migrate sendgrid.

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

* fix(migrate-email): let each provider's mapping decide which languages move

The Resend shadow run moved a Python Resend send once posthog-sdks.md
listed Python, against Resend's mapping. Steps 3 and 7 now say the
provider's mapping.md decides which languages move, and Resend's row
says it moves only with posthog-node.

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

* fix(migrate-email): close round-2 review findings on the SendGrid layer

- Go and Ruby start flag polling with the secret key and have no off
  switch: behind a reverse proxy, the email send gets its own client
  pointed at PostHog's host. Step 7 names that exception to reusing
  the app's client.
- A branch on the provider's invalid-send status becomes a branch on
  PostHog's validation_error name, in Step 7 and SendGrid's mapping.
- A bare {{name}} inside {{#each}} reads the item: it becomes
  {{ item.name }}.
- An EU subuser is also spotted by the client's data residency, and the
  EU host note sits at the top of account.md.
- The report keeps a provider package that other code imports or
  re-exports, or that mapping.md keeps for other uses.
- account.md no longer says how PostHog treats blocked addresses.

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

* docs(migrate-email): say why cc, bcc and attachments stay on Resend

The rows said only "Always", so an agent made up a reason, such as
posthog-node not taking attachments. They now say this skill doesn't
move them yet.

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

* docs(migrate-email): name the real reason a field stays on Resend

Step 9's report tells the person what would let a site move, from the
row's reason. cc, bcc, attachments, headers and tags now say PostHog's
send doesn't take them yet, not that this skill doesn't move them.

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

* docs(migrate-email): give scheduled sends and topics a reason too

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

* docs(migrate-email): name why each kept field stays

Carry #451's reason wording to SendGrid's field rows that kept a field
with a bare "Always". For Resend's cc, bcc and attachments, say the skill
doesn't move them yet: posthog-sdks.md in this PR lists them for Node.js,
so "PostHog's send doesn't take it" would contradict it.

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

* fix(migrate-email): keep a site on Resend when its key length is unbounded

A key built from a URL or caller text could read as either "can be
longer than 255 characters" or not. Such a key now counts as one that
can, so the site stays on Resend and the report names the value to bound.

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

* fix(migrate-email): keep a network error raising where an HTTP-only catch let it pass

The write-mode proof moved a Python site whose `except HTTPError` caught only
SendGrid's answers; the rewrite's `except EmailError` also caught the network
error PostHog raises with the same type, so the site returned False where it
raised before. Step 7, posthog-sdks.md and SendGrid's mapping now say a network
error shares the error type with code `network_error`, and to raise it again
where the old catch let a network failure through.

posthog-sdks.md also names the app host option for Node.js, Python and Go.

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

* fix(migrate-email): keep sends that ignored a refusal going, quote Liquid singly

From the provider round-1 reviews:
- Step 7: a site whose old call answered a refused send without raising, and
  that never read the answer, logs PostHog's error and goes on, and still
  raises or returns network_error.
- Step 3: Liquid strings take single quotes, since the email builder escapes
  double quotes and the template then fails with a TokenizationError.
- SendGrid: Ruby, PHP, Go and .NET clients don't raise on a refusal, so such
  sites follow the new Step 7 rule; a send without trackingSettings follows
  the account's tracking, which the run now asks about.

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

* fix(migrate-email): let a field that stood for an account setting be added

A send that followed an account's tracking setting of off sets
captureEngagement: false after the move; Step 7's rule against new fields
now allows a field the provider's mapping derives from an account setting.

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

* fix(migrate-email): name untracked sends in the added-field exception

Amazon SES and SMTP sends without tracking were never tracked, with no
account setting involved; the exception now covers any field mapping.md adds
because the old send behaved that way without setting it.

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

* fix(migrate-email): quote Resend fallbacks with single quotes only

A double-quoted Liquid fallback inside the template's JSON body raises
TokenizationError. Every fallback is quoted with ', and a fallback that
holds a ' keeps the site on Resend, since Liquid has no escape character.

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

* fix(migrate-email): keep network_error on the Node error a sendgrid rewrite throws

The Node rule rethrew PostHog's error with only its status, and a network
failure has none, so the old catch lost the code that says the request
never reached PostHog. Carry error.code as well.

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

* fix(migrate-email): decide the send shapes real code showed

A survey of public code that sends with each provider found sites the
rules left open. Step 3 now says:
- a queue job or transport that posts a prebuilt message makes each
  builder a site, an unread caller keeps the send, and an uncalled
  helper is not a site;
- in a function that picks between providers, only this provider's
  branch is the site;
- an empty or off value counts as not set;
- a from that can't get a verified sender keeps the site, and a site
  with no from needs the default sender's address.
posthog-sdks.md says what a synchronous .NET site does.

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

* fix(migrate-email): cover SendGrid's callback send and snake_case keys

Real Node code sends with sgMail.send(msg, callback), which passes the
error to the callback and never throws, and writes dynamic_template_data
in snake_case, which the helper converts. Name both, say what a
callback becomes, and drop the lost-name note when the name is the
address itself.

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

* fix(migrate-email): keep uncalled send functions as sites, name more senders

An uncalled helper is dead code only when it forwards a message nobody
builds. A function that builds its own send stays a site, as every
sample app's send functions do. A fixed sender on a domain whose DNS
the person can't publish keeps its site too, and the report asks the
person to rotate a provider key written in the source.

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

* fix(migrate-email): leave a catch of every error as it is

A bare except or a catch of every exception caught network failures
before the move too, so it lets no network_error through after it.

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

* fix(migrate-email): read config values once, and follow template IDs like from

Real code reads recipients and template IDs from env or config. Step 3
reads them from the example env file or the config, or asks the person
once, before a site stays for want of them. A helper whose callers mix
one address and several stays, and the plan names the single-address
callers. Step 7 names a raw HTTP call that never checked its status as
a send that ignored refusals.

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

* fix(migrate-email): keep SendGrid template sites when tracking is off, honor HttpErrorAsException

A template site can't carry captureEngagement: false, so it stays when account tracking is off. A .NET client with HttpErrorAsException threw on a refused send, so its sites keep throwing. PostHog's data is an object, never SendGrid's [response, body] list. A Task-returning .NET method moves. Config values that decide a site are read from the config or asked, not from an example env placeholder, and Step 3 notes where each client takes its key.

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

* fix(migrate-email): keep SendGrid sites with mixed or unknown account tracking, reach later handlers on network errors

captureEngagement: false turns off both opens and clicks, so a SendGrid site whose account has only one of them off stays, as Mailgun's do, and so does one whose tracking the person can't name. A template site's sender comes from its template, so Step 3 asks for no default sender for it. Where a later handler of the same try took a network failure, Step 7 runs that handler's code for network_error, since a raise inside one handler skips the ones after it.

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

* fix(migrate-email): a rate-limit branch skips PostHog's quota_limited

PostHog answers a used-up quota with status 429 and code quota_limited, which no retry fixes, so a retry or wait on 429 checks the code too.

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

* fix(migrate-email): keep PostHog's code next to the status in SendGrid's Node rethrow

err.code keeps SendGrid's status for the old catch; err.posthogCode lets a 429 branch skip quota_limited.

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

* fix(migrate-email): one PostHog catch for several provider handlers, and keep suppression writes in step with PostHog's list

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

* fix(migrate-email): mirror a provider's suppression removal only when no imported list still holds the address, on every path of Step 5

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

* fix(migrate-email): a mirrored suppression removal also clears entries that mirrored additions made

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

* fix(migrate-email): a template value counts as its declared type, and unchecked request input is named for the person

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

* fix(migrate-email): a template value from unchecked input keeps the site on the provider

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

* fix(migrate-email): record the PostHog key as set only after a check finds it

Step 6 ticked the key phase as set when the person said they would add
the key themselves. The step now checks the env file with a count-only
grep (or a successful set_env_values in the Wizard). A promise to add it
later, or a refusal, records the key as not set, and the report lists it
before cutover.

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

* fix(migrate-email): accept spaces around = in the key check

dotenv loads a key with leading whitespace or spaces around =, so the
count-only grep accepts them too.

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

* fix(migrate-email): check the last assignment of the PostHog key

The count-only grep counted a key that an env loader reads as empty: a
value that is only a comment (= #phs_x), and a key overridden by a later
empty line. The check now reads only the last line that sets the
variable and needs its value to start with phs_, still printing only a
count. The test runs the documented command against fixture env files
in place of matching its wording.

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

* docs(migrate-email): ask for the transactional_email:write scope

Code sends now need transactional_email:write. A key with hog_flow:write
keeps working through the legacy scope fallback.

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

* fix(migrate-email): name the transactional email scope in the preflight

The make-transactional tools move to transactional_email:write, and a
login with hog_flow:write still works.

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

* feat(migrate-email): move Resend sends in every PostHog SDK's language

The skill kept every send outside JavaScript and TypeScript on Resend.
PostHog's Node.js, Python, Go, Ruby, PHP, .NET, Rust and Elixir SDKs
all send email now, so Step 7 picks the SDK by the site's language:

- One rewrite file per SDK, with the install, the client, both send
  forms, the answer and its error, and the check to run.
- Resend's mapping gives each language's call and answer, and keeps
  only sends in a language without a PostHog SDK, such as Java.
- Resend's SDK reference lists the clients, sends, batches and mailers
  of every language, so Step 1 and Step 3 find them.

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

* fix(migrate-email): keep the app booting and check the whole project in every SDK

- Read the PostHog env variables without raising, so a missing key
  fails only the send.
- Run each SDK's check on the whole project, and read the changelog on
  a major upgrade.
- Sync and async clients side by side in Python and Rust.
- Move Rust's and Ruby's version requirement on upgrade, and run
  go mod tidy after the rewrite.
- Map Resend's status error classes to a status check.
- Edge runtimes use posthog-node.

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

* fix(migrate-email): use the one Rust client the app's features build

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

* feat(migrate-email): carry posthog-sdks.md's rules into the rewrite files

The additions from #459's posthog-sdks.md that #472's rewrite files don't
have yet, so #459 can delete posthog-sdks.md once #472 carries them.

In each rewrite-<lang>.md: cc, bcc and attachments (Node.js, Python, Go,
Elixir), or that the SDK has none yet (Ruby, PHP, .NET, Rust); the network
error left after the retries; the language's bad-argument error; .NET's
missing synchronous send; Go's context.Background(); Python's async extra;
React Email rendered with @react-email/render in Node.js.

Facts that hold for every SDK go into Step 7 rather than into each file,
under "What every SDK's send takes and answers": one `to` per call, the
two forms, what no SDK takes, the attachment shape, PostHog's message id,
branching on the error code, the retries, and where a bad argument fails.
Step 7's capability list also names cc, bcc and attachments.

Facts on which posthog-sdks.md and these files disagree are left out, for
the docs lane to check against the SDK heads first.

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

* fix(migrate-email): check the merged SDK rules against the SDK heads

- No release takes cc, bcc or attachments yet, so drop their lines and
  name them in Step 7's list of what no SDK takes.
- Go and Ruby load flag definitions from their host with the secret
  key: behind a proxy, email gets its own client on PostHog's host.
  Elixir turns local evaluation off behind a proxy.
- PHP gets its own email client, so PostHog::init stays the app's.
- Drop the per-send retry count and the unchecked text-part line.

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

* fix(migrate-email): give Elixir email its own instance when the app uses PostHog

Turning local evaluation off on the app's own config breaks the flags
it evaluates locally.

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

* fix(migrate-email): never pass nil for Elixir's host or token

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

* fix(migrate-email): fall back past a nil :posthog host in Elixir

Application.get_env/3 returns an explicitly configured nil, so the
named email instance put the US Cloud fallback after both lookups.

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

* fix(migrate-email): list the error names once and state reply-to per SDK

The rewrite files pointed at a coarse-name list that only the Resend
mapping has. Step 7 now lists the ten names, and each rewrite file
points there. Each rewrite file now says whether reply-to takes one
address, a list, or both, as the SDK heads do.

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

* fix(migrate-email): give email its own client behind a reverse proxy

A client with the secret key loads flag definitions from its host with
it: Go and Ruby when they start, Python and .NET when the app
evaluates a flag. Reusing the app's client behind a reverse proxy
handed the key to the proxy. Step 7 now gives email its own client on
PostHog's host behind a proxy, for every SDK, in place of the Go and
Ruby special cases.

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

* test(migrate-email): pin keeping the secret key off the proxied client

The step 7 proxy test matched only the separate-client wording, so
dropping "leave the secret key off the app's existing client" still
passed. Assert that clause too; it fails without it.

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

* feat(migrate-email): bring stored templates into the code

A send of a template stored at the provider now moves by bringing the
email into the code: its HTML and text become a file next to the send,
the code renders the variables with the provider's escaping, and the
site sends the code form. A template made in PostHog, sent by its ID,
is used only when the person asks for one.

- template-to-code.md: the check, where the email goes, how each
  language renders it without a new dependency, and the escaping rule.
- Steps 3, 7 and 9: the new default, the template form on request, and
  the report items for emails brought into the code.
- SendGrid: Handlebars in the code, including the helpers the template
  form couldn't take.

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

* feat(migrate-email): fill SendGrid substitutions in the code

A send with its own content and legacy substitutions stayed on SendGrid
only because SendGrid put the values in. The code now does the same
replace before the send, under the escaping rule of template-to-code.md.

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

* feat(migrate-email): bring Resend templates into the code

A send of a template stored at Resend now moves by bringing the email
into the code: its HTML and text become a file next to the send, the
code renders the variables, and the site sends the code form. A
template made in PostHog, sent by its ID, is used only when the person
asks for one.

- template-to-code.md, from the provider stack (#459's 4b15d2e), as is.
- Steps 3, 7 and 9 and description.md: the same change as 4b15d2e,
  ported onto this base's text.
- Resend: a "Templates" part with the in-code table. Resend never
  escapes a value, so the shared escaping rule applies. A fallback
  covers a missing value only, since Resend inserts "" as it is. A
  value the site passes for from, reply-to or subject wins over the
  template's, as Resend does. The Liquid conversion moves under
  "Templates made in PostHog".

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

* docs(migrate-email): record engagement events only when engagement capture is on

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

* fix(migrate-email): keep SendGrid sites with opens untracked instead of turning engagement capture off

captureEngagement only decides whether engagement events land on the
recipient's person. PostHog still adds its open pixel and never rewrites
a code send's links, so provider tracking never maps to it.

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

* fix(migrate-email): list no PostHog click event for SendGrid clicks, and never add engagement capture in the rewrite

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

* fix(migrate-email): keep an app's PostHog key, and a Resend HTTP call's deadline

A reused posthog-node client that already sets secretKey or personalApiKey
keeps it, and the sends get their own client: posthog-node uses secretKey
for local flag evaluation and remote config too, and prefers it over
personalApiKey, so the email key would replace the app's key.

A Resend HTTP call with its own timeout keeps it through
emailRequestTimeoutMs, with maxRetries: 0 on the send, so a send never runs
past the site's deadline.

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

* fix(migrate-email): keep email off a disabled client, and pass numeric IDs as strings

A client that can be disabled answers every send with client_disabled
while it is, so a reused analytics client would stop emails where the old
provider still sent them: the sends get their own client. distinctId takes
a string, so a numeric user ID is passed as String(user.id), the same
string posthog-js identifies.

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

* fix(migrate-email): keep undeadlined HTTP sites on Resend and keep imported templates inert

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

* fix(migrate-email): record the send's own sender, replace markers in one pass, load Ruby flags off boot

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

* fix(migrate-email): map Go's other Resend error checks and keep Outlook comments in Go templates

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

* fix(migrate-email): render variables in Go's Outlook blocks and scope the Python async client to its loop

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

* fix(migrate-email): keep encoded URL values as they are in Go templates

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

* feat(migrate-email): move the shared step changes from the SendGrid layer into the core skill

The provider PRs now only add their own folder, so each can stand on the core alone.

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

* fix(migrate-email): list Resend webhook handlers, keep ignored argument errors ignored, check a template's reply-to

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

* fix(migrate-email): keep provider content inert in code literals, and keep ignored network failures ignored

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

* fix(migrate-email): keep the site's subject when a SendGrid version has none, quote unquoted attribute values

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

* fix(skills): close the migrate-email preparation gaps the QA swarm found

- Step 6 ticks the key only when a check finds it in the env file, and the
  report lists a key that is not set.
- Step 3 asks for a template to be made transactional only once a verified
  sender covers its address, since PostHog refuses it before.
- Step 2 and the report name sends with content from the code, which PostHog
  enables apart from template sends.
- The report asks for a last suppression import right before cutover, since
  the provider keeps adding entries.
- A template site that sets `reply_to` stays on Resend, as `replyTo` does.
- The CLI test reads the entries the Wizard gets from the menu.

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

* fix(migrate-email): SendGrid substitution tags, account mail settings, HTTP deadlines

Fill substitutions in the reply-to address too and wrap Node.js keys in
substitutionWrappers; keep or carry over the account's subscription
tracking, Plain Content and Footer settings; keep a raw request's deadline;
keep HTTPError handlers for SendGrid calls that stay; escape quotes in a
from name. Drop the test that pinned the mapping's wording.

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

* fix(skills): tighten the migrate-email key check and template rules

- Step 6's check accepts only a quote before `phs_`, so a placeholder such as
  `<phs_your_key>` or a value like `xphs_...` no longer counts as a set key.
- `mapping.md` matches Step 3: the person makes a template transactional only
  once a verified sender covers its address.
- A template made in PostHog for an email with a login code or reset link is
  marked sensitive, and the report checks it before cutover.
- Drop the tests that only matched skill sentences; the key check keeps its
  tests against real env files.

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

* fix(migrate-email): SendGrid client wrappers and deadlines, account Google Analytics and footer on PostHog templates

Read substitution wrappers and deadlines set on the SendGrid client, ask
about account Google Analytics and the Legacy Email Template, put the
account footer into a template made in PostHog, and drop the retired
Plain Content setting.

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

* fix(migrate-email): keep each site's own HTTP deadline

A moved HTTP send with its own deadline set the shortest deadline on one
shared client, which shortened other sites' deadlines. Give each distinct
deadline its own client instead, so no site gets a deadline it didn't have.

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

* fix(migrate-email): keep marketing sends on the provider

PostHog's transactional send ignores marketing opt-outs and is only for
emails a person needs. A newsletter whose fields all move passed the
field check and showed as ready to move. Check what a site sends first,
and keep marketing or unclear sends on the provider.

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

* fix(migrate-email): a bare name inside a SendGrid each reads only the current item

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

* fix(migrate-email): read the provider's report notes without the import tool

Step 5 read the provider's account.md only after the import tool check,
so without the tool, the facts account.md adds for the report never
reached the plan. Read it first on every path, through a "For the report"
section, and carry those facts into the report. A manual import also
happens right before cutover.

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

* fix(migrate-email): escape SendGrid subject values, one client per deadline, network failure branches

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

* fix(migrate-email): Handlebars subject escape, SendGrid secret rules, placeholders in from and reply-to, message id on a suppressed send

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

* fix(migrate-email): answer the round 1 review of the rewrite and verify steps

- Step 8 keeps each test at its boundary: an HTTP test intercepts
  PostHog's send with the real posthog-node client.
- Email always gets its own posthog-node client; changing the app's
  client would change how its flags evaluate.
- A request with a signal the code aborts stays on Resend.
- Step 7 allows the fields mapping.md adds, such as maxRetries: 0.
- Step 8 matches the moved site's send by template and its engagement
  by send, not by workflow.
- The plan records the full-access key and the baseline typecheck
  errors; posthog-node is upgraded only when it lacks a capability.
- The step test walks the built continuation chain.

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

* fix(migrate-email): match baseline typecheck errors without their line

The rewrite adds lines above an old error, so a file-and-line match made
Step 8 fix errors that were there before. Record and match each error by
file, code, and message.

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

* fix(migrate-email): count each baseline typecheck error

An error that was there before could hide a new copy of itself. Record
how many times each error shows, and fix the extra ones in lines the
rewrite changed.

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

* fix(migrate-email): keep a named recipient on Resend

PostHog's send takes one bare address in to, and refuses an entry with a
name, such as Jane <jane@example.com>. A one-entry list with a name
passed the field check. Keep it on Resend, as reply-to already does.

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

* fix(migrate-email): settle deadlines, attribute quoting, and suppression calls for every provider

Findings relayed from the provider lanes:
- Each rewrite file names its SDK's email timeout and retry options
  under "A deadline". Go and .NET keep a deadline on the call (context,
  cancellation token); the others get a client per distinct deadline.
  Rust keeps whole seconds only, so a finer deadline stays.
- template-to-code quotes an unquoted attribute value before inserting
  an escaped value: a space, = or a backtick still ends it.
- A lost template copy comes from the dashboard: the full-access key an
  API read needs is gone after Step 5.
- Resend's mapping lists the calls that change its suppression list,
  which Step 5 reads.

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

* fix(migrate-email): keep a site on Resend when it needs a suppressed send's id

PostHog refuses a send to a suppressed address with no data.id, where
Resend accepted it and returned one. A helper that returns or stores the
id would get null on the success path, so such a site stays unless its
callers already handle a send without an id.

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

* fix(migrate-email): keep a Resend SDK send with an abortable signal on Resend

Resend's SDK takes a signal in the options of emails.send and passes it
to fetch. Dropping the options object would send an email the old code
cancelled, so the signal rule now covers SDK sends as well as fetch and
axios requests.

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

* fix(migrate-email): own email clients, long deadlines, clicks and template copies in every SDK

- .NET: a PostHogClient of its own for email; the IPostHogEmails that
  AddPostHog registers is the app's client.
- Go and .NET: the SDK ends each request at its own timeout, so a
  deadline longer than that needs a client with that timeout.
- Rust: the blocking client is not awaited.
- Elixir: email always gets a named instance.
- A send in the code form is sensitive in PostHog and counts no clicks:
  the email.clicked row, Step 7 and the report say so, and a site whose
  clicks feed a handler moves only to a non-sensitive PostHog template.
- Temporary template copies are deleted on every way out, not only after
  Step 7 writes the email.
- A template the app's code changes at the provider stays there.
- Go's html/template rewrites a link with another scheme, such as tel:,
  so such a value keeps its site on the provider.

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

* test(migrate-email): drop the tests that match the skill's own wording

They read source Markdown and matched sentences, so a paraphrase failed
them and a wrong SDK call passed. One it.each ran no case. The bundle,
step chain, key check and menu tests stay.

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

* fix(migrate-email): blank .NET host, long .NET deadlines, shared templates and kept Resend handlers

- .NET: a blank POSTHOG_HOST falls back to US Cloud instead of throwing
  in new Uri, and a deadline over 100 seconds keeps its site on Resend:
  the client's HttpClient ends each request at .NET's 100-second default.
- A temporary template copy is deleted only once no site that sends its
  template will bring it into the code.
- A stored message ID works for a send that goes out; the suppressed
  send rule covers the rest.
- Elixir sends always name the email instance.
- An error handler that also covers a call staying on Resend keeps
  Resend's handler next to PostHog's.

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

* fix(migrate-email): keep a Go site whose template fills CSS from a value

Go's html/template writes ZgotmplZ, with no error, for a CSS value such
as rgb(255, 0, 0) or a style with more than one property. A CSS value
the code builds goes in as template.CSS; one from elsewhere keeps its
site on the provider. Checked by rendering both in Go 1.23.

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

* fix(migrate-email): count brought-in templates as code content, stop Python flag polling

The report's "Before cutover" check names a site whose template was
brought into the code, which still sends with content from the code.
The Python email client sets enable_local_evaluation=False, so a
worker forked under a preloading server doesn't poll flag definitions
with the email key.

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

* fix(migrate-email): keep enable_local_evaluation off the Python async client

AsyncPosthog has no enable_local_evaluation option and never polls
flags; passing it raises TypeError at startup.

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

* fix(migrate-email): converge SendGrid with the finished core

The HTTP part now names SendGrid's deadline options and points to Step 7
for the client recipe. Clicks, sensitive PostHog templates, the plan's key
line, temporary copies, and attribute quoting follow the core. The
unsubscribe counts move into a For the report section that Step 5 reads.

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

* fix(migrate-email): keep SendGrid's untracked links out of PostHog's click redirect

A site whose clicks SendGrid never tracked asks for its PostHog template to
be marked sensitive, and account.md points to the mapping's click rule
instead of restating it.

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

* fix(migrate-email): name the outcome of SendGrid's untracked clicks

Unknown account click tracking counts as untracked, a site whose template
isn't marked sensitive stays, and the report checks the flag before cutover.
A sensitive template sends its links without PostHog's click redirect, as
PostHog's email tracking service does.

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

* fix(migrate-email): keep sites that branch on one kind of network failure

Every SDK retries network failures and reports what is left as one
network_error, so a branch on ECONNRESET, requests.Timeout or
Faraday::ConnectionFailed would never run: the site stays. A kept
deadline's own timeout still matches in Go (errors.Is through the
EmailError's cause) and .NET (the token's OperationCanceledException).
Resend's Node.js SDK names a network failure application_error with a
null status, so those branches also take network_error.

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

* fix(migrate-email): keep separate connect limits, require ext-curl for PHP

Every SDK has one timeout for connecting and reading, so a request
that limits connecting alone or apart from reading has a deadline no
SDK can keep: the site stays. posthog-php sends email through curl,
which Composer doesn't ask for: the app requires ext-curl, and the
report lists enabling it where the app runs when that isn't shown.

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

* fix(migrate-email): keep a Go request's transport limits

posthog-go sends email through Config.Transport, so a dialer timeout,
TLS handshake or response header limit on the request's transport is
kept by giving the email client that transport.

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

* fix(migrate-email): keep a Python whole-request limit on the provider

posthog-python hands its email timeout to requests or httpx as one
number, which limits each network wait, so an aiohttp total timeout is
a deadline it can't keep: the site stays.

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

* fix(migrate-email): carry SendGrid's click notes through the plan

The sensitive-template check goes into the plan row so Step 9 reports it,
unknown click tracking gets its own stay reason, and the no-clicks note
covers sites whose click tracking nobody knows.

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

* fix(migrate-email): defer SendGrid's network and connect limits to Step 7

The network-failure bullet now names only the transport errors SendGrid's
clients pass through and follows Step 7's rule, with its stay reason. The
HTTP part names SendGrid's connect-only limits for Step 7's rule on them.

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

* fix(migrate-email): keep SendGrid's Ruby http_options timeouts under Step 7

Net::HTTP always limits connecting apart from reading, so any timeout in
Ruby's http_options is a split limit the PostHog SDK can't keep.

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

* fix(migrate-email): move SendGrid Ruby sites whose timeouts match posthog-ruby's

posthog-ruby sets Net::HTTP's open, read and write timeouts to one value, so
http_options that set all three alike keep their deadline; any other mix
falls under Step 7's split-limit rule, and keep-alive options are no limit.

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

* docs(migrate-email): name the outcome of SendGrid's Ruby split limits

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

* fix(migrate-email): settle untracked clicks, timeout kinds, and the message ID

- A site whose clicks the provider didn't track, or nobody knows, moves to
  a template made in PostHog only when that template is marked sensitive,
  since PostHog's click redirect would rewrite its links. Resend's
  account.md says which setting means its clicks were off.
- A library's default timeout, such as httpx's or ky's, is not the site's
  own deadline. The SDK keeps a deadline only of its own kind: Python and
  Ruby limit each wait, the others the whole request, so axios's Node.js
  idle timeout and ky's headers-only timeout can't be kept.
- A sensitive template sends links without the click redirect, in
  Resend's mapping too.
- PostHog's message ID is a UUID, so a .NET Guid takes it.

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

* fix(migrate-email): read Faraday's timeout by its adapter

Faraday's timeout limits each wait only on the net_http adapter; on
Typhoeus it limits the whole request, which posthog-ruby can't keep.

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

* fix(migrate-email): keep a site whose handler needs an event PostHog lacks

Resend stops sending events for a moved site, and an event the table
maps to none, such as email.delivery_delayed, has nothing in PostHog to
take its place. A site whose emails such a handler acts on stays.

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

* docs(migrate-email): point SendGrid clicks and timeouts at the core rules

Untracked clicks now follow Step 3; account.md keeps only which SendGrid
settings mean clicks were off. Node.js SendGrid timeouts are axios's, a
limit the SDK can't keep. Ruby http_options point to rewrite-ruby.md.

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

* fix(migrate-email): upgrade mocked send tests to the HTTP boundary

A test that mocked the provider's client now runs the real posthog-node
client and intercepts PostHog's send request, asserting on that request
and on what the app does. It uses the suite's interception tool, asks
before adding one, and keeps the mock only when the person declines,
which the report lists.

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

* docs(migrate-email): keep SendGrid's sensitive-template plan note and Ruby split outcome

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

* fix(migrate-email): fake fetch instead of keeping a send mock

posthog-node sends with the global fetch, so a test suite without an
HTTP interception tool replaces globalThis.fetch with a fake for the
test. No dependency is added, and no test stays on a mock of the send.

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

* fix(migrate-email): keep a Ruby site with a partial Net::HTTP timeout

posthog-ruby sets open, read and write to one number, so a request that
sets only some of them, or sets them apart, has a limit the SDK can't
keep, and its site stays on the provider.

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

* fix(migrate-email): note a must-be-sensitive template in its plan row

Step 3 writes "must be marked sensitive" with its reason under the
sites table, for a secret in the email or for untracked clicks, so the
report's "Before cutover" check reads it for every provider.

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

* fix(migrate-email): keep network failures off Resend's 503 branch

Every PostHog SDK names a network failure service_unavailable, which
Resend's API gives only a 503. A branch on that name now also checks
that the code is not network_error, so a network failure takes the path
the old code gave it, whatever the order of the branches.

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

* fix(migrate-email): allow a loopback app host in Go and .NET tests

Go and .NET refuse an http app host unless AllowInsecureAppHost is set.
A test's local server needs it, so the email client sets it only for a
loopback app host, and the secret key never leaves the machine over
plain HTTP.

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

* feat(migrate-email): ask before adding an open pixel to untracked email

PostHog adds its open pixel to every email it sends. Step 3 now asks the
person once whether PostHog may add it to the emails of sites whose
provider never tracked their opens: a yes moves them and the report says
PostHog now counts their opens; a no stays as "open tracking off", and a
site nobody can tell about stays as "open tracking not checked". Step 7
points there, and Resend's account file says where its per-domain open
tracking shows. A bundle test checks that every "Step N says under"
reference names a section that step has.

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

* docs(migrate-email): point SendGrid opens and webhook events at the core rules

account.md now says which SendGrid settings mean a site's emails had no
open pixel, and which mean nobody can tell; Step 3 decides. A handler on
an event with no PostHog event keeps its sites. Step 3 writes the
sensitive note, so the SendGrid one goes.

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

* docs(migrate-email): scope SendGrid's webhook stay to events a moved site sends

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

* fix(migrate-email): route a network failure the way Resend's code did

Resend answers a network failure as application_error with a null
statusCode, and posthog-node as network_error named
service_unavailable. A branch on application_error now also takes
network_error, and a branch on service_unavailable skips it, so a
network failure takes the path the old code gave it.

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

* fix(migrate-email): test with a standard-library server, never a mock of the send

When the suite has no HTTP interception tool and the person declines adding
one, Step 8's test now runs a local server from the language's standard
library (Python http.server, Ruby TCPServer, Rust TcpListener, Erlang's
httpd or gen_tcp) instead of mocking the PostHog SDK's send. The report
drops the line that listed such mocks.

The skill test now runs the Step pointer check for every provider and
fails on any provider directory in a bundle other than its own.

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

* fix(migrate-email): ask about a test dependency only where one is needed

Node.js, Go, .NET and PHP intercept without a new dependency, so Step 8
asks the person about a dev dependency only in Python, Ruby, Rust and
Elixir. The Step pointer check gets its own per-provider test again, so a
broken pointer fails under a name that says what broke.

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

* fix(migrate-email): ask before adding any test tool, in every language

Step 8 offered WireMock.Net to a .NET suite while exempting .NET from the
question, so an agent could add it without the person's yes. The rule to
ask now covers every language; Node.js, Go, .NET and PHP still need no
tool beyond what comes with them.

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

* feat(migrate-email): re-import the suppression list weekly while sites stay

A site that stays on the provider after cutover keeps adding bounces and
complaints to the provider's list, which PostHog never sees, so a moved
send can mail a suppressed address. Step 5 gains a "Re-import only" path
that runs the import alone, the skill entry points to it, and the report
asks for a weekly re-import while any site stays, with the prompt that
runs it, and one final import once the last site leaves. When every site
moved, the import before cutover stays the last one.

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

* fix(migrate-email): check the project before a suppression re-import

A re-import runs alone, with no plan and no Step 8 after it, so it now
checks first that the app sends to the MCP's project and stops when it
doesn't. When the import tool is missing, it tells the person where to
add the new addresses by hand. The per-provider pointer test already
covers the entry's pointer, so the separate re-import test goes.

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

* fix(migrate-email): write the re-import's project check out in Step 5

The re-import pointed at Step 8's whole section, whose opening skip rule
a run with no plan can't evaluate, so an agent could skip the project
check. Step 5 now states the comparison itself.

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

* fix(migrate-email): confirm the production project before a re-import

The local env file can name a development project while production sends
from another, so the re-import now asks the person whether production
sends from the MCP's project, with a differing local token as a hint,
and stops on a no or when they can't tell.

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

* fix(migrate-email): read the project token with project-get

projects-get lists the organization's projects without their API token;
project-get, called without an ID, is the one tool that returns the
active project and its api_token. Steps 5, 7 and 8 now name it. On a no,
the re-import asks which project production sends from and offers to
switch the MCP to it.

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

* fix(migrate-email): switch the MCP back after a re-import

A re-import that switched the MCP to the production project now switches
back to the project it started from when Step 5 ends, and stops when the
production project isn't in the current organization's list.

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

* fix(migrate-email): name the production project in a by-hand re-import

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

* fix(migrate-email): let a re-import without the tool say so

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

* fix(migrate-email): let a re-import say why it got no list

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

* fix(migrate-email): read the project token with project-get

projects-get lists the organization's projects without their API token;
project-get, called without an ID, is the one tool that returns the
active project and its api_token. Step 7's token lookup and Step 8's
project check now name it.

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

* docs(migrate-email): point SendGrid suppression writes at the weekly re-import

A site that stays on SendGrid keeps adding bounces, spam reports and
invalid emails that PostHog never sees; Step 5's "Re-import only" and
the report's weekly re-import bring them over.

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

* fix(migrate-email): ask for re-imports only when the provider keeps a list

A provider with no suppression list of its own, such as a mailbox
provider behind an SMTP host, has no list that grows while sites stay.
Step 5 writes that into the plan, and the report then leaves out the
weekly re-import ask.

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

* fix(migrate-email): record a provider with no list before the tool check

Step 5 checked the import tool before it looked at whether the provider
keeps a list, so a provider with none, for a person without the import
tool, got by-hand imports for a list that doesn't exist. The no-list
line is now written in "Read the provider's notes", which runs first.

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

* docs(migrate-email): keep SendGrid templates whose subject values PostHog would not escape

SendGrid's Handlebars escapes subject values, and PostHog renders a
template's subject as plain text, so a value with &, <, >, ", ', ` or =
would read differently. The code path keeps Handlebars' escape; the
PostHog-template path can't, so such a site stays.

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

* fix(migrate-email): end a re-import early when the provider keeps no suppression list

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

* docs(migrate-email): keep the throw of SendGrid's .NET retry handler on server errors

With ReliabilitySettings retries above 0, SendGrid's RetryDelegatingHandler
throws HttpRequestException on a 500, 502, 503 or 504 left after its last
retry; those sites now throw PostHog's exception for the same statuses.

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

* fix(migrate-email): keep sites a Resend webhook handler acts on, and state the SDK limit for sites without a deadline

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

* docs(migrate-email): keep .NET sites behind SendGrid's retry handler on SendGrid

The handler runs only when the client makes its own HttpClient or the code
adds it; it retried server errors and threw after the last retry, which
PostHog's send does neither of. Go's MakeRequestRetry stays the rate-limit
retry that PostHog's send replaces.

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

* fix(migrate-email): check every error in a rewritten line against its old version

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

* fix(migrate-email): check for a provider without a suppression list before the re-import's project check

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

* docs(migrate-email): key the .NET retry stay on the handler's retries, not AddSendGrid's options

AddSendGrid gives the client a factory HttpClient without SendGrid's retry handler, so its ReliabilitySettings retry nothing by themselves; a handler with zero retries keeps no site. The .NET inventory line now names ReliabilitySettings.

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

* fix(migrate-email): give Step 8 one rule for which typecheck errors are new

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

* docs(migrate-email): keep SendGrid retry failures and untracked plain-text links

A .NET client retries through any handler on its HttpClient, Polly and resilience handlers included; Go's MakeRequestRetry returned err on a 429 left after its retries; links in a plain-text part went untracked unless enableText or the account's plain-text click tracking was on.

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

* docs(migrate-email): read a subuser's SendGrid account, escape plain text, keep async Go sends

Account reads carry on-behalf-of for an app that sends for a subuser; SendGrid's Handlebars escapes plain-text values like the subject's; MakeRequestAsync sites stay; ConfigureHttpClientDefaults counts as a retry handler on the AddSendGrid client.

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

* docs(migrate-email): key SendGrid account reads on the sending key, honor allow list and bounce purge

on-behalf-of doesn't work with Mail Send, so a send uses its key's account; the import leaves out allow-listed addresses and bounces Bounce Purge would have removed; triple braces are plain in the plain text; the ConfigureHttpClientDefaults search covers every factory HttpClient.

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

* fix(migrate-email): tie the kept Resend error names to posthog-node, HTTP sites included

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

* docs(migrate-email): ask the SendGrid import filters in every run and apply each on its own

A re-import asks about the Address Allow List and Bounce Purge too, an unknown setting no longer undoes the other's filter, and their notes go through "For the report".

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

* fix(migrate-email): mark secret emails sensitive, check template keys, and ask before adding an open pixel

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

* docs(migrate-email): ask the SendGrid import filters with the report notes

Step 5 reads "For the report" whether or not the import runs, so the Allow List and Bounce Purge question lives there; unknown values leave out nothing and become a Before cutover task, and a by-hand import gets one too.

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

* fix(migrate-email): send sensitive only with rendered content, and only when posthog-node takes it

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

* docs(migrate-email): ask the SendGrid import filters before taking entries; report, don't remove

The question runs before the list is taken in every run, re-imports included; an unknown setting leaves out nothing and the report says it was not checked; the filters are spelled out for entries added by hand. No removal task, which could drop another list's suppression.

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

* fix(migrate-email): check the app's Node version and count removed errors

Step 7 now checks the Node.js version the app runs against the engines
of the posthog-node release it installs, and keeps every site on Resend
when that release doesn't support it: an older Node lacks
crypto.randomUUID(), which the send uses for its idempotency key.

Step 8 counts a listed error against the list's number less the copies
the changed lines no longer have, so an identical error the rewrite adds
in an unchanged line is found even when it replaces one it removed.

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

* fix(migrate-email): carry the key, sensitive and Node checks; count removed errors

Carry #451's fixes in #472's form:

- Step 7 asks whether a template saved in PostHog already has a send's
  key and gives such sends another key, so a code send never takes a
  saved template's settings, and sets the sensitive flag on a send with
  rendered content that carries a secret.
- Step 7 checks the language version the app runs against what the SDK
  release supports, and keeps that language's sites on the provider when
  it doesn't.
- Step 8 counts a listed error against the list's number less the copies
  the changed lines no longer have, and says that its rule covers
  warnings too.

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

* docs(migrate-email): apply the SendGrid import filters to entries added by hand, by rule

Any by-hand add, the missing-tool re-import included, asks the filter question first; notes and re-import messages give each setting's rule and count, never an address.

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

* docs(migrate-email): give the by-hand SendGrid filters as rules in the session and the report

A by-hand add asks only whether each setting is on and the purge days, then gives the rule; the report note carries the rule for whoever adds entries by hand when the import didn't run.

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

* fix(migrate-email): name each SDK's sensitive flag; list the moved keys

- Each rewrite file's "The send" names the sensitive option in its SDK's
  form, which every SDK's latest release takes, and Step 7 points there.
- The report's "Before cutover" list names the template keys the moved
  sends use, which a template saved in PostHog later must not reuse.
- The runtime check says what to check on an edge runtime, which has no
  Node.js version of its own.

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

* docs(migrate-email): write the SendGrid filter rules in every report, counts after the import

The note always carries each rule and the by-hand sentence; the Allow List's entries are asked only when the agent takes the entries itself, so a by-hand path never marks a known setting as not checked.

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

* docs(migrate-email): ask for the SendGrid Allow List's entries right before taking the list

The notes ask only whether each setting is on and the purge days; the entries are asked where the agent takes the list, so an import never runs without having asked.

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

* fix(migrate-email): move the template keys to after cutover; edge reason

- The report lists the moved sends' template keys under "After cutover",
  as a rule for templates the person saves from now on, since it asks
  for nothing before the deploy.
- An edge runtime the rewrite file doesn't name gets its own reason.

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

* docs(migrate-email): name missing Allow List entries in a SendGrid re-import

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

* fix(migrate-email): scope the runtime check to where each site runs

- A runtime the SDK release doesn't support keeps only the sites that
  run there, and an edge runtime the rewrite file doesn't name keeps only
  its own sites, each with its own reason.
- The report's note on template keys names every setting a saved
  template with a moved key changes: transactional, and the sensitive
  setting with its click redirect and subject on engagement events.

Co-Authored-By: Claude Opus 5.5 <noreply@…
edwinyjlim pushed a commit that referenced this pull request Nov 18, 2026
…ensitive (#486)

* fix(skills): ship a variant's own reference folder in its bundle

The migrate group keeps Statsig's mapping and SDK reference under
references/statsig/, and its step files point there, but the generator
copied only the top-level reference files. Copy references/<variant-id>/
into each variant's bundle, and nothing of the other variants.

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

* refactor(skills): share the email sender setup as a partial

Move the sender setup of send-transactional-email's STEP 3 into
context/shared/email-sender-setup.md, so the email migration skill
includes the same text. A partial now takes the indentation of its
{{> name}} line on every line, so it nests under a step. The built
send skill is unchanged byte for byte.

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

* feat(skills): add the migrate-email skill with a Resend variant

v0 prepares a move off Resend and changes no send call site. It finds
every Resend send, classifies each one as ready to move or staying on
Resend with a reason, sets up the PostHog sender next to Resend's DNS
records, imports Resend's suppression list when the import tool exists,
hands over the project secret key, checks the sending tier, and writes
posthog-migrate-email-resend-report.md with a summary block.

Steps are provider-neutral; references/resend/ holds what is specific
to Resend. Statsig and Resend now publish as wizard migrate subcommands.

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

* fix(skills): keep migrate-email's summary values bare and define a site

Fixture runs wrote reasons into the summary block, which the Wizard
can't parse, and counted a forwarding helper as one site or as each
caller. The report step now shows bare values, and a site is the place
that decides a send's content and fields.

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

* fix(skills): point migrate-email at the transactional email docs and the sending skill

The send-transactional-email skill is gone from this stack, so migrate-email
bundles the transactional email pages and names the sending-transactional-emails
skill for the general move.

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

* fix(skills): check migrate-email's API access with the real tools and PostHog's reply-to rules

The preflight looked for two MCP tools that don't exist. It now looks
for the make-transactional pair, and a missing pair records the API as
not confirmed instead of stopping, because it can also mean a missing
scope. The mapping now keeps a site on Resend for reply-to addresses
with a name or more than 10, and lists every reserved header and the
header and tag length limits.

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

* refactor(skills): share the posthog-node client setup as a partial

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

* feat(skills): move Resend sends to posthog-node in migrate-email

The migrate-email skill now rewrites every call site PostHog can send:
hosted Resend templates become local templates, React and html/text sites
send rendered content, and the client carries migratedFrom. It checks the
build and one email on one person before it writes the report.

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

* fix(skills): keep migrate-email from splitting sends or faking the old provider in tests

Fixture runs looped over or truncated a one-recipient list, and one run
mocked posthog-node to rebuild a Resend request. The rewrite now narrows
the helper's parameter to one address, and the verify step asserts on the
fields posthog.emails.send gets.

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

* fix(skills): handle suppressed recipients and dynamic subjects in migrate-email

A moved site now treats recipient_suppressed like a send that went out,
a site-built subject becomes a module placeholder so the template hash
stays stable, fallbacks use single quotes, and the report warns that
idempotency keys don't cross providers. The rules and Step 7 no longer
contradict the mapping.

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

* fix(skills): keep a suppressed copy address from passing as a sent email

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

* fix(skills): warn that retrying a send with a suppressed copy address uses sending cap

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

* fix(skills): leave migratedFrom off the posthog-node client in migrate-email

posthog-node has no migratedFrom option. The Wizard records the migration
on its setup wizard finished event instead.

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

* fix(skills): check that posthog-node has the code form before migrate-email rewrites a site

A posthog-node release with posthog.emails can still lack templateKey,
local template content, or the extra send fields. The rewrite now checks
the installed types for what each moving site needs, and keeps a site
on Resend when the latest release lacks it.

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

* fix(skills): detect resend over smtp, stop without sends, and record partial imports in migrate-email

Step 1 now admits the SMTP host and a framework mailer and needs at least one
send; step 3 stops when it finds no site. A suppression import that stops
partway stays unticked and lands in the report's "Before cutover" list. A
template site needs its content from the person or stays on Resend. The
sender setup is inlined into step 4, which keeps the existing `from` domain and
records an unverified domain instead of waiting. AGENTS.md says the migrate
subcommands run once the wizard runs migrate as a family.

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

* refactor(scripts): ship variant references through the local reference loop

The selected variant's `references/<variant-id>/` files now go through the same
loop as the root reference files, so the separate copy helper is gone. The
partial expander drops the indentation it gained for the sender partial, which
nothing includes any more, and the bundle test drops the migrate-statsig case
that guarded nothing.

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

* fix(skills): tie migrate-email's test send to its own events and report every behaviour change

Step 8 checks that the app sends to the MCP's project, notes the start of the
test, and counts only events since then whose workflow matches the send. It
compares typecheck errors with a baseline step 7 takes before it changes code.
A template's content waits in a temporary file for step 7 instead of in memory,
an HTML fallback keeps a template on Resend, and a derived templateKey is
normalized and unique. The report lists each suppressed-recipient branch,
copy-address refusal, and cross-provider idempotency risk, and reminds the
person to delete the full-access Resend key. The posthog-node client setup is
inlined into step 7, and description.md says this skill wins over the general
moving guide.

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

* fix(skills): let migrate-email move on when DNS waits and read templates from files

Step 4 records a domain as not verified, with its records or Domain Connect
link, when the person can't publish them during the run. Step 3 asks the person
to save each template from the dashboard to a file outside the repository and
reads it, since the Wizard can't take pasted HTML.

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

* fix(skills): pin migrate-email's test start to the database clock and keep template files traceable

Step 8 takes the start of the test from `execute-sql` and compares Unix
timestamps, so the project's timezone can't shift the window. The plan lists
each saved template file, step 7 reads the module from it, and step 9 deletes
every listed file. A derived templateKey falls back to the template id when
the name normalizes to nothing and stays unique across the run. Step 8 may fix
other posthog-node code the upgrade breaks, and the report lists those files.

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

* fix(skills): keep migrate-email's test clock uncached and report dependency upgrades

The clock query carries a fresh random literal so a cached answer can't widen
the test window. Step 3 may write the template files it saves, the dashboard
copy includes the template's alias or name for its key, and a major
dependency upgrade lands in the report's "Before cutover" list.

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

* fix(skills): keep migrate-email's chain query uncached on its rerun

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

* fix(skills): keep cc, bcc, headers, tags and attachments sites on Resend, and move templates only to PostHog

The first PostHog release sends a template made in PostHog by template id, or rendered html and text. A Resend template site moves only once the person makes the template in PostHog, or stays on Resend for now.

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

* Drop local templates and parked fields from the cutover steps

Under the scope cut, a moved template site sends a template made in
PostHog by templateId with templateData. Rendered sends keep templateKey,
subject, html and text. No local-template module, no upload on first send,
and no cc, bcc, headers, tags or attachments.

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

* feat(migrate-email): set migratedFrom on the posthog-node client

posthog-node's migratedFrom client option sends the provider a send
moved from with every email request. Step 7 now sets it, and the
Resend mapping names its value.

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

* fix(migrate-email): ask for the PostHog template ID before a template site moves

Review round 1 on #451:
- Step 3 asks for the template ID once the person made the template in
  PostHog. A template without one stays: PostHog template not made yet.
- Step 7 checks that the client takes migratedFrom, and undoes the
  posthog-node install when no site is left to move.
- Template files from an API read are deleted once their site is
  classified, and the full-access Resend key right after Step 5.
- Step 8 reads only the token's line of the env file, and picks a
  signed-in flow for the test email.
- replyTo moves as one address or a list.

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

* fix(migrate-email): check each PostHog template and its sender before cutover

Review round 2 on #451:
- Step 3 asks for the address a PostHog template sends from and writes it
  in the site's from column, so Step 4 sets up a sender for its domain.
- The report asks the person to send a test of each PostHog template and
  check that it is transactional, has a verified sender and fills its
  variables.
- Step 5 asks to delete the full-access key on every way out of the step,
  and after a partial import only once the person won't repeat it.
- Step 8 allows a signed-out flow: the person signs in as the recipient
  afterwards, so product events show on the same distinct ID.
- migratedFrom is set only when the client options take it.

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

* fix(migrate-email): ask about a repeat import and test a send that names a person

Review round 3 on #451:
- Step 5 asks once whether to repeat an import that stopped partway, and
  asks about the full-access key after that answer or the repeat.
- Step 8's test email comes from a moved site that passes distinctId;
  without one, the chain is recorded as not checked.
- The client example marks migratedFrom as conditional.

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

* fix(migrate-email): ask for the PostHog template ID and sender before a template site moves

Review round 1 on #450:
- Step 3 checks a template site's other fields before it asks about the
  template, and asks for the PostHog template ID and the address it sends
  from. A template without an ID stays: PostHog template not made yet.
  The address goes in the from column, so Step 4 sets up its domain.
- mapping.md quotes a fallback that holds ' with ", carries a
  definition-level fallback_value, notes that default replaces an empty
  string, and keeps a fallback with both quotes or HTML on Resend.
- The report asks the person to test each PostHog template before cutover.

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

* fix(skills): read Dirent.path when parentPath is missing in the migrate-email test

Node 20.11, the oldest release engines allows, has no Dirent.parentPath,
so the bundle tests threw before their assertions. Use the same
parentPath ?? path fallback as build-phases.js.

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

* fix(migrate-email): match account.md's template-content rule to Step 3

account.md said template content goes only into a temporary file, while
Step 3 reads the person's dashboard copies where they saved them. Only an
API answer goes into the temporary file now.

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

* fix(migrate-email): keep a site on Resend when its idempotency key doesn't fit PostHog's

PostHog takes an idempotency key of 1 to 255 printable ASCII characters
without spaces. A site whose key can hold a space or a non-ASCII
character, or run longer, stays on Resend. The report names each key a
retry across the deploy could send twice, since the providers don't
share keys.

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

* fix(migrate-email): name PostHog's idempotency key rule exactly

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

* fix(migrate-email): end Step 8's email check when the person declines the test email

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

* docs(migrate-email): say where a send without distinctId lands

Rename "Find the user ID" to "Link emails to your users", name the
identify() ID, say that without distinctId PostHog records the email on a
separate person keyed by the address, and add invites and signup checks to
the cases that leave it out.

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

* docs(migrate-email): test Step 8 on a site that passes distinctId

Step 7 now leaves distinctId off an address check before the account
exists, so Step 8 picks its test site from the plan rows that pass one.

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

* docs(migrate-email): say why cc, bcc and attachments stay on Resend

The rows said only "Always", so an agent made up a reason, such as
posthog-node not taking attachments. They now say this skill doesn't
move them yet.

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

* docs(migrate-email): name the real reason a field stays on Resend

Step 9's report tells the person what would let a site move, from the
row's reason. cc, bcc, attachments, headers and tags now say PostHog's
send doesn't take them yet, not that this skill doesn't move them.

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

* docs(migrate-email): give scheduled sends and topics a reason too

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

* fix(migrate-email): keep a site on Resend when its key length is unbounded

A key built from a URL or caller text could read as either "can be
longer than 255 characters" or not. Such a key now counts as one that
can, so the site stays on Resend and the report names the value to bound.

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

* fix(migrate-email): quote Resend fallbacks with single quotes only

A double-quoted Liquid fallback inside the template's JSON body raises
TokenizationError. Every fallback is quoted with ', and a fallback that
holds a ' keeps the site on Resend, since Liquid has no escape character.

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

* fix(migrate-email): record the PostHog key as set only after a check finds it

Step 6 ticked the key phase as set when the person said they would add
the key themselves. The step now checks the env file with a count-only
grep (or a successful set_env_values in the Wizard). A promise to add it
later, or a refusal, records the key as not set, and the report lists it
before cutover.

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

* fix(migrate-email): accept spaces around = in the key check

dotenv loads a key with leading whitespace or spaces around =, so the
count-only grep accepts them too.

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

* fix(migrate-email): check the last assignment of the PostHog key

The count-only grep counted a key that an env loader reads as empty: a
value that is only a comment (= #phs_x), and a key overridden by a later
empty line. The check now reads only the last line that sets the
variable and needs its value to start with phs_, still printing only a
count. The test runs the documented command against fixture env files
in place of matching its wording.

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

* docs(migrate-email): ask for the transactional_email:write scope

Code sends now need transactional_email:write. A key with hog_flow:write
keeps working through the legacy scope fallback.

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

* fix(migrate-email): name the transactional email scope in the preflight

The make-transactional tools move to transactional_email:write, and a
login with hog_flow:write still works.

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

* feat(migrate-email): move Resend sends in every PostHog SDK's language

The skill kept every send outside JavaScript and TypeScript on Resend.
PostHog's Node.js, Python, Go, Ruby, PHP, .NET, Rust and Elixir SDKs
all send email now, so Step 7 picks the SDK by the site's language:

- One rewrite file per SDK, with the install, the client, both send
  forms, the answer and its error, and the check to run.
- Resend's mapping gives each language's call and answer, and keeps
  only sends in a language without a PostHog SDK, such as Java.
- Resend's SDK reference lists the clients, sends, batches and mailers
  of every language, so Step 1 and Step 3 find them.

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

* fix(migrate-email): keep the app booting and check the whole project in every SDK

- Read the PostHog env variables without raising, so a missing key
  fails only the send.
- Run each SDK's check on the whole project, and read the changelog on
  a major upgrade.
- Sync and async clients side by side in Python and Rust.
- Move Rust's and Ruby's version requirement on upgrade, and run
  go mod tidy after the rewrite.
- Map Resend's status error classes to a status check.
- Edge runtimes use posthog-node.

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

* fix(migrate-email): use the one Rust client the app's features build

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

* feat(migrate-email): carry posthog-sdks.md's rules into the rewrite files

The additions from #459's posthog-sdks.md that #472's rewrite files don't
have yet, so #459 can delete posthog-sdks.md once #472 carries them.

In each rewrite-<lang>.md: cc, bcc and attachments (Node.js, Python, Go,
Elixir), or that the SDK has none yet (Ruby, PHP, .NET, Rust); the network
error left after the retries; the language's bad-argument error; .NET's
missing synchronous send; Go's context.Background(); Python's async extra;
React Email rendered with @react-email/render in Node.js.

Facts that hold for every SDK go into Step 7 rather than into each file,
under "What every SDK's send takes and answers": one `to` per call, the
two forms, what no SDK takes, the attachment shape, PostHog's message id,
branching on the error code, the retries, and where a bad argument fails.
Step 7's capability list also names cc, bcc and attachments.

Facts on which posthog-sdks.md and these files disagree are left out, for
the docs lane to check against the SDK heads first.

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

* fix(migrate-email): check the merged SDK rules against the SDK heads

- No release takes cc, bcc or attachments yet, so drop their lines and
  name them in Step 7's list of what no SDK takes.
- Go and Ruby load flag definitions from their host with the secret
  key: behind a proxy, email gets its own client on PostHog's host.
  Elixir turns local evaluation off behind a proxy.
- PHP gets its own email client, so PostHog::init stays the app's.
- Drop the per-send retry count and the unchecked text-part line.

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

* fix(migrate-email): give Elixir email its own instance when the app uses PostHog

Turning local evaluation off on the app's own config breaks the flags
it evaluates locally.

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

* fix(migrate-email): never pass nil for Elixir's host or token

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

* fix(migrate-email): fall back past a nil :posthog host in Elixir

Application.get_env/3 returns an explicitly configured nil, so the
named email instance put the US Cloud fallback after both lookups.

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

* fix(migrate-email): list the error names once and state reply-to per SDK

The rewrite files pointed at a coarse-name list that only the Resend
mapping has. Step 7 now lists the ten names, and each rewrite file
points there. Each rewrite file now says whether reply-to takes one
address, a list, or both, as the SDK heads do.

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

* fix(migrate-email): give email its own client behind a reverse proxy

A client with the secret key loads flag definitions from its host with
it: Go and Ruby when they start, Python and .NET when the app
evaluates a flag. Reusing the app's client behind a reverse proxy
handed the key to the proxy. Step 7 now gives email its own client on
PostHog's host behind a proxy, for every SDK, in place of the Go and
Ruby special cases.

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

* test(migrate-email): pin keeping the secret key off the proxied client

The step 7 proxy test matched only the separate-client wording, so
dropping "leave the secret key off the app's existing client" still
passed. Assert that clause too; it fails without it.

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

* feat(migrate-email): bring Resend templates into the code

A send of a template stored at Resend now moves by bringing the email
into the code: its HTML and text become a file next to the send, the
code renders the variables, and the site sends the code form. A
template made in PostHog, sent by its ID, is used only when the person
asks for one.

- template-to-code.md, from the provider stack (#459's 4b15d2e), as is.
- Steps 3, 7 and 9 and description.md: the same change as 4b15d2e,
  ported onto this base's text.
- Resend: a "Templates" part with the in-code table. Resend never
  escapes a value, so the shared escaping rule applies. A fallback
  covers a missing value only, since Resend inserts "" as it is. A
  value the site passes for from, reply-to or subject wins over the
  template's, as Resend does. The Liquid conversion moves under
  "Templates made in PostHog".

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

* feat(migrate-email): map turned-off open and click tracking to track_opens_and_clicks

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

* feat(migrate-email): map only turned-off open tracking to track_opens_and_clicks

PostHog never tracks clicks on a code send, so click tracking that is off needs nothing.

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

* docs(migrate-email): record engagement events only when engagement capture is on

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

* feat(migrate-email): map turned-off open tracking to the tracking option

Replace track_opens_and_clicks with tracking in the rewrite step and
every SDK's rewrite file. A provider's open tracking that is off turns
off the opens switch only, so engagement events stay on. The skill
never turns on click tracking, because a link can carry a token, and
it notes sites whose provider tracked clicks for the report.

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

* fix(migrate-email): use SDK tracking names and skip tracking on templates

Use the Go, Rust and .NET names for tracking. A site that moves to a
template made in PostHog sends no tracking, because the template uses
its own setting, so the report asks the person to check it.

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

* feat(migrate-email): map a provider's sensitive or no-track setting to sensitive

A code send takes an optional sensitive flag, and its clicks follow it
unless tracking sets them. The skill marks a send sensitive when the old
call turned off click tracking for that email or marked it sensitive. It
never marks a send as not sensitive, and drops the claim that clicks are
always off by default for code sends.

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

* fix(migrate-email): mark every migrated code send sensitive

A code send that leaves sensitive out takes the setting of a PostHog
template with the same key. The skill can't see the project's templates
or tell whether a link carries a token, so a key that matched a template
without protection would start rewriting a reset link. Pin the flag on
every code send, and say so in the report.

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

* fix(migrate-email): keep an app's PostHog key, and a Resend HTTP call's deadline

A reused posthog-node client that already sets secretKey or personalApiKey
keeps it, and the sends get their own client: posthog-node uses secretKey
for local flag evaluation and remote config too, and prefers it over
personalApiKey, so the email key would replace the app's key.

A Resend HTTP call with its own timeout keeps it through
emailRequestTimeoutMs, with maxRetries: 0 on the send, so a send never runs
past the site's deadline.

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

* fix(migrate-email): keep email off a disabled client, and pass numeric IDs as strings

A client that can be disabled answers every send with client_disabled
while it is, so a reused analytics client would stop emails where the old
provider still sent them: the sends get their own client. distinctId takes
a string, so a numeric user ID is passed as String(user.id), the same
string posthog-js identifies.

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

* fix(migrate-email): keep undeadlined HTTP sites on Resend and keep imported templates inert

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

* fix(migrate-email): record the send's own sender, replace markers in one pass, load Ruby flags off boot

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

* fix(migrate-email): map Go's other Resend error checks and keep Outlook comments in Go templates

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

* fix(migrate-email): render variables in Go's Outlook blocks and scope the Python async client to its loop

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

* fix(migrate-email): keep encoded URL values as they are in Go templates

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

* feat(migrate-email): move the shared step changes from the SendGrid layer into the core skill

The provider PRs now only add their own folder, so each can stand on the core alone.

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

* fix(migrate-email): list Resend webhook handlers, keep ignored argument errors ignored, check a template's reply-to

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

* fix(migrate-email): keep provider content inert in code literals, and keep ignored network failures ignored

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

* fix(skills): close the migrate-email preparation gaps the QA swarm found

- Step 6 ticks the key only when a check finds it in the env file, and the
  report lists a key that is not set.
- Step 3 asks for a template to be made transactional only once a verified
  sender covers its address, since PostHog refuses it before.
- Step 2 and the report name sends with content from the code, which PostHog
  enables apart from template sends.
- The report asks for a last suppression import right before cutover, since
  the provider keeps adding entries.
- A template site that sets `reply_to` stays on Resend, as `replyTo` does.
- The CLI test reads the entries the Wizard gets from the menu.

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

* fix(skills): tighten the migrate-email key check and template rules

- Step 6's check accepts only a quote before `phs_`, so a placeholder such as
  `<phs_your_key>` or a value like `xphs_...` no longer counts as a set key.
- `mapping.md` matches Step 3: the person makes a template transactional only
  once a verified sender covers its address.
- A template made in PostHog for an email with a login code or reset link is
  marked sensitive, and the report checks it before cutover.
- Drop the tests that only matched skill sentences; the key check keeps its
  tests against real env files.

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

* fix(migrate-email): keep each site's own HTTP deadline

A moved HTTP send with its own deadline set the shortest deadline on one
shared client, which shortened other sites' deadlines. Give each distinct
deadline its own client instead, so no site gets a deadline it didn't have.

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

* fix(migrate-email): keep marketing sends on the provider

PostHog's transactional send ignores marketing opt-outs and is only for
emails a person needs. A newsletter whose fields all move passed the
field check and showed as ready to move. Check what a site sends first,
and keep marketing or unclear sends on the provider.

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

* fix(migrate-email): read the provider's report notes without the import tool

Step 5 read the provider's account.md only after the import tool check,
so without the tool, the facts account.md adds for the report never
reached the plan. Read it first on every path, through a "For the report"
section, and carry those facts into the report. A manual import also
happens right before cutover.

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

* fix(migrate-email): answer the round 1 review of the rewrite and verify steps

- Step 8 keeps each test at its boundary: an HTTP test intercepts
  PostHog's send with the real posthog-node client.
- Email always gets its own posthog-node client; changing the app's
  client would change how its flags evaluate.
- A request with a signal the code aborts stays on Resend.
- Step 7 allows the fields mapping.md adds, such as maxRetries: 0.
- Step 8 matches the moved site's send by template and its engagement
  by send, not by workflow.
- The plan records the full-access key and the baseline typecheck
  errors; posthog-node is upgraded only when it lacks a capability.
- The step test walks the built continuation chain.

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

* fix(migrate-email): match baseline typecheck errors without their line

The rewrite adds lines above an old error, so a file-and-line match made
Step 8 fix errors that were there before. Record and match each error by
file, code, and message.

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

* fix(migrate-email): count each baseline typecheck error

An error that was there before could hide a new copy of itself. Record
how many times each error shows, and fix the extra ones in lines the
rewrite changed.

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

* fix(migrate-email): keep a named recipient on Resend

PostHog's send takes one bare address in to, and refuses an entry with a
name, such as Jane <jane@example.com>. A one-entry list with a name
passed the field check. Keep it on Resend, as reply-to already does.

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

* fix(migrate-email): settle deadlines, attribute quoting, and suppression calls for every provider

Findings relayed from the provider lanes:
- Each rewrite file names its SDK's email timeout and retry options
  under "A deadline". Go and .NET keep a deadline on the call (context,
  cancellation token); the others get a client per distinct deadline.
  Rust keeps whole seconds only, so a finer deadline stays.
- template-to-code quotes an unquoted attribute value before inserting
  an escaped value: a space, = or a backtick still ends it.
- A lost template copy comes from the dashboard: the full-access key an
  API read needs is gone after Step 5.
- Resend's mapping lists the calls that change its suppression list,
  which Step 5 reads.

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

* fix(migrate-email): keep a site on Resend when it needs a suppressed send's id

PostHog refuses a send to a suppressed address with no data.id, where
Resend accepted it and returned one. A helper that returns or stores the
id would get null on the success path, so such a site stays unless its
callers already handle a send without an id.

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

* fix(migrate-email): keep a Resend SDK send with an abortable signal on Resend

Resend's SDK takes a signal in the options of emails.send and passes it
to fetch. Dropping the options object would send an email the old code
cancelled, so the signal rule now covers SDK sends as well as fetch and
axios requests.

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

* fix(migrate-email): own email clients, long deadlines, clicks and template copies in every SDK

- .NET: a PostHogClient of its own for email; the IPostHogEmails that
  AddPostHog registers is the app's client.
- Go and .NET: the SDK ends each request at its own timeout, so a
  deadline longer than that needs a client with that timeout.
- Rust: the blocking client is not awaited.
- Elixir: email always gets a named instance.
- A send in the code form is sensitive in PostHog and counts no clicks:
  the email.clicked row, Step 7 and the report say so, and a site whose
  clicks feed a handler moves only to a non-sensitive PostHog template.
- Temporary template copies are deleted on every way out, not only after
  Step 7 writes the email.
- A template the app's code changes at the provider stays there.
- Go's html/template rewrites a link with another scheme, such as tel:,
  so such a value keeps its site on the provider.

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

* test(migrate-email): drop the tests that match the skill's own wording

They read source Markdown and matched sentences, so a paraphrase failed
them and a wrong SDK call passed. One it.each ran no case. The bundle,
step chain, key check and menu tests stay.

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

* fix(migrate-email): blank .NET host, long .NET deadlines, shared templates and kept Resend handlers

- .NET: a blank POSTHOG_HOST falls back to US Cloud instead of throwing
  in new Uri, and a deadline over 100 seconds keeps its site on Resend:
  the client's HttpClient ends each request at .NET's 100-second default.
- A temporary template copy is deleted only once no site that sends its
  template will bring it into the code.
- A stored message ID works for a send that goes out; the suppressed
  send rule covers the rest.
- Elixir sends always name the email instance.
- An error handler that also covers a call staying on Resend keeps
  Resend's handler next to PostHog's.

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

* fix(migrate-email): keep a Go site whose template fills CSS from a value

Go's html/template writes ZgotmplZ, with no error, for a CSS value such
as rgb(255, 0, 0) or a style with more than one property. A CSS value
the code builds goes in as template.CSS; one from elsewhere keeps its
site on the provider. Checked by rendering both in Go 1.23.

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

* fix(migrate-email): count brought-in templates as code content, stop Python flag polling

The report's "Before cutover" check names a site whose template was
brought into the code, which still sends with content from the code.
The Python email client sets enable_local_evaluation=False, so a
worker forked under a preloading server doesn't poll flag definitions
with the email key.

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

* fix(migrate-email): keep enable_local_evaluation off the Python async client

AsyncPosthog has no enable_local_evaluation option and never polls
flags; passing it raises TypeError at startup.

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

* fix(migrate-email): keep sites that branch on one kind of network failure

Every SDK retries network failures and reports what is left as one
network_error, so a branch on ECONNRESET, requests.Timeout or
Faraday::ConnectionFailed would never run: the site stays. A kept
deadline's own timeout still matches in Go (errors.Is through the
EmailError's cause) and .NET (the token's OperationCanceledException).
Resend's Node.js SDK names a network failure application_error with a
null status, so those branches also take network_error.

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

* fix(migrate-email): keep separate connect limits, require ext-curl for PHP

Every SDK has one timeout for connecting and reading, so a request
that limits connecting alone or apart from reading has a deadline no
SDK can keep: the site stays. posthog-php sends email through curl,
which Composer doesn't ask for: the app requires ext-curl, and the
report lists enabling it where the app runs when that isn't shown.

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

* fix(migrate-email): keep a Go request's transport limits

posthog-go sends email through Config.Transport, so a dialer timeout,
TLS handshake or response header limit on the request's transport is
kept by giving the email client that transport.

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

* fix(migrate-email): keep a Python whole-request limit on the provider

posthog-python hands its email timeout to requests or httpx as one
number, which limits each network wait, so an aiohttp total timeout is
a deadline it can't keep: the site stays.

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

* fix(migrate-email): settle untracked clicks, timeout kinds, and the message ID

- A site whose clicks the provider didn't track, or nobody knows, moves to
  a template made in PostHog only when that template is marked sensitive,
  since PostHog's click redirect would rewrite its links. Resend's
  account.md says which setting means its clicks were off.
- A library's default timeout, such as httpx's or ky's, is not the site's
  own deadline. The SDK keeps a deadline only of its own kind: Python and
  Ruby limit each wait, the others the whole request, so axios's Node.js
  idle timeout and ky's headers-only timeout can't be kept.
- A sensitive template sends links without the click redirect, in
  Resend's mapping too.
- PostHog's message ID is a UUID, so a .NET Guid takes it.

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

* fix(migrate-email): read Faraday's timeout by its adapter

Faraday's timeout limits each wait only on the net_http adapter; on
Typhoeus it limits the whole request, which posthog-ruby can't keep.

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

* fix(migrate-email): keep a site whose handler needs an event PostHog lacks

Resend stops sending events for a moved site, and an event the table
maps to none, such as email.delivery_delayed, has nothing in PostHog to
take its place. A site whose emails such a handler acts on stays.

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

* fix(migrate-email): upgrade mocked send tests to the HTTP boundary

A test that mocked the provider's client now runs the real posthog-node
client and intercepts PostHog's send request, asserting on that request
and on what the app does. It uses the suite's interception tool, asks
before adding one, and keeps the mock only when the person declines,
which the report lists.

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

* fix(migrate-email): fake fetch instead of keeping a send mock

posthog-node sends with the global fetch, so a test suite without an
HTTP interception tool replaces globalThis.fetch with a fake for the
test. No dependency is added, and no test stays on a mock of the send.

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

* fix(migrate-email): keep a Ruby site with a partial Net::HTTP timeout

posthog-ruby sets open, read and write to one number, so a request that
sets only some of them, or sets them apart, has a limit the SDK can't
keep, and its site stays on the provider.

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

* fix(migrate-email): note a must-be-sensitive template in its plan row

Step 3 writes "must be marked sensitive" with its reason under the
sites table, for a secret in the email or for untracked clicks, so the
report's "Before cutover" check reads it for every provider.

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

* fix(migrate-email): keep network failures off Resend's 503 branch

Every PostHog SDK names a network failure service_unavailable, which
Resend's API gives only a 503. A branch on that name now also checks
that the code is not network_error, so a network failure takes the path
the old code gave it, whatever the order of the branches.

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

* fix(migrate-email): allow a loopback app host in Go and .NET tests

Go and .NET refuse an http app host unless AllowInsecureAppHost is set.
A test's local server needs it, so the email client sets it only for a
loopback app host, and the secret key never leaves the machine over
plain HTTP.

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

* feat(migrate-email): ask before adding an open pixel to untracked email

PostHog adds its open pixel to every email it sends. Step 3 now asks the
person once whether PostHog may add it to the emails of sites whose
provider never tracked their opens: a yes moves them and the report says
PostHog now counts their opens; a no stays as "open tracking off", and a
site nobody can tell about stays as "open tracking not checked". Step 7
points there, and Resend's account file says where its per-domain open
tracking shows. A bundle test checks that every "Step N says under"
reference names a section that step has.

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

* fix(migrate-email): route a network failure the way Resend's code did

Resend answers a network failure as application_error with a null
statusCode, and posthog-node as network_error named
service_unavailable. A branch on application_error now also takes
network_error, and a branch on service_unavailable skips it, so a
network failure takes the path the old code gave it.

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

* fix(migrate-email): test with a standard-library server, never a mock of the send

When the suite has no HTTP interception tool and the person declines adding
one, Step 8's test now runs a local server from the language's standard
library (Python http.server, Ruby TCPServer, Rust TcpListener, Erlang's
httpd or gen_tcp) instead of mocking the PostHog SDK's send. The report
drops the line that listed such mocks.

The skill test now runs the Step pointer check for every provider and
fails on any provider directory in a bundle other than its own.

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

* fix(migrate-email): ask about a test dependency only where one is needed

Node.js, Go, .NET and PHP intercept without a new dependency, so Step 8
asks the person about a dev dependency only in Python, Ruby, Rust and
Elixir. The Step pointer check gets its own per-provider test again, so a
broken pointer fails under a name that says what broke.

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

* fix(migrate-email): ask before adding any test tool, in every language

Step 8 offered WireMock.Net to a .NET suite while exempting .NET from the
question, so an agent could add it without the person's yes. The rule to
ask now covers every language; Node.js, Go, .NET and PHP still need no
tool beyond what comes with them.

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

* fix(migrate-email): move untracked-open sites with opens off, no ask

A site whose emails had no open pixel, or whose provider's open tracking
nobody can confirm, now moves with the opens switch off instead of
staying or waiting for the person's yes. The plan notes it as opens off
with its reason, and the report lists those sites, the clicks PostHog no
longer counts, and that every code send is marked sensitive.

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

* feat(migrate-email): re-import the suppression list weekly while sites stay

A site that stays on the provider after cutover keeps adding bounces and
complaints to the provider's list, which PostHog never sees, so a moved
send can mail a suppressed address. Step 5 gains a "Re-import only" path
that runs the import alone, the skill entry points to it, and the report
asks for a weekly re-import while any site stays, with the prompt that
runs it, and one final import once the last site leaves. When every site
moved, the import before cutover stays the last one.

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

* fix(migrate-email): check the project before a suppression re-import

A re-import runs alone, with no plan and no Step 8 after it, so it now
checks first that the app sends to the MCP's project and stops when it
doesn't. When the import tool is missing, it tells the person where to
add the new addresses by hand. The per-provider pointer test already
covers the entry's pointer, so the separate re-import test goes.

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

* fix(migrate-email): write the re-import's project check out in Step 5

The re-import pointed at Step 8's whole section, whose opening skip rule
a run with no plan can't evaluate, so an agent could skip the project
check. Step 5 now states the comparison itself.

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

* fix(migrate-email): confirm the production project before a re-import

The local env file can name a development project while production sends
from another, so the re-import now asks the person whether production
sends from the MCP's project, with a differing local token as a hint,
and stops on a no or when they can't tell.

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

* fix(migrate-email): read the project token with project-get

projects-get lists the organization's projects without their API token;
project-get, called without an ID, is the one tool that returns the
active project and its api_token. Steps 5, 7 and 8 now name it. On a no,
the re-import asks which project production sends from and offers to
switch the MCP to it.

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

* fix(migrate-email): switch the MCP back after a re-import

A re-import that switched the MCP to the production project now switches
back to the project it started from when Step 5 ends, and stops when the
production project isn't in the current organization's list.

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

* fix(migrate-email): name the production project in a by-hand re-import

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

* fix(migrate-email): let a re-import without the tool say so

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

* fix(migrate-email): let a re-import say why it got no list

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

* fix(migrate-email): read the project token with project-get

projects-get lists the organization's projects without their API token;
project-get, called without an ID, is the one tool that returns the
active project and its api_token. Step 7's token lookup and Step 8's
project check now name it.

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

* fix(migrate-email): ask for re-imports only when the provider keeps a list

A provider with no suppression list of its own, such as a mailbox
provider behind an SMTP host, has no list that grows while sites stay.
Step 5 writes that into the plan, and the report then leaves out the
weekly re-import ask.

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

* fix(migrate-email): record a provider with no list before the tool check

Step 5 checked the import tool before it looked at whether the provider
keeps a list, so a provider with none, for a person without the import
tool, got by-hand imports for a list that doesn't exist. The no-list
line is now written in "Read the provider's notes", which runs first.

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

* fix(migrate-email): name the engagement switch and say why code sends count no clicks

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

* fix(migrate-email): name the project's engagement setting and the clicks table

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

* fix(migrate-email): keep a click-handler template site with opens off on Resend

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

* fix(migrate-email): keep an open-handler site with unknown tracking on the provider

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

* fix(migrate-email): end a re-import early when the provider keeps no suppression list

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

* fix(migrate-email): keep sites a Resend webhook handler acts on, and state the SDK limit for sites without a deadline

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

* fix(migrate-email): check every error in a rewritten line against its old version

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

* fix(migrate-email): check for a provider without a suppression list before the re-import's project check

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

* fix(migrate-email): give Step 8 one rule for which typecheck errors are new

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

* fix(migrate-email): tie the kept Resend error names to posthog-node, HTTP sites included

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

* fix(migrate-email): mark secret emails sensitive, check template keys, and ask before adding an open pixel

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

* fix(migrate-email): send sensitive only with rendered content, and only when posthog-node takes it

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

* fix(migrate-email): check the app's Node version and count removed errors

Step 7 now checks the Node.js version the app runs against the engines
of the posthog-node release it installs, and keeps every site on Resend
when that release doesn't support it: an older Node lacks
crypto.randomUUID(), which the send uses for its idempotency key.

Step 8 counts a listed error against the list's number less the copies
the changed lines no longer have, so an identical error the rewrite adds
in an unchanged line is found even when it replaces one it removed.

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

* fix(migrate-email): carry the key, sensitive and Node checks; count removed errors

Carry #451's fixes in #472's form:

- Step 7 asks whether a template saved in PostHog already has a send's
  key and gives such sends another key, so a code send never takes a
  saved template's settings, and sets the sensitive flag on a send with
  rendered content that carries a secret.
- Step 7 checks the language version the app runs against what the SDK
  release supports, and keeps that language's sites on the provider when
  it doesn't.
- Step 8 counts a listed error against the list's number less the copies
  the changed lines no longer have, and says that its rule covers
  warnings too.

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

* fix(migrate-email): name each SDK's sensitive flag; list the moved keys

- Each rewrite file's "The send" names the sensitive option in its SDK's
  form, which every SDK's latest release takes, and Step 7 points there.
- The report's "Before cutover" list names the template keys the moved
  sends use, which a template saved in PostHog later must not reuse.
- The runtime check says what to check on an edge runtime, which has no
  Node.js version of its own.

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

* fix(migrate-email): move the template keys to after cutover; edge reason

- The report lists the moved sends' template keys under "After cutover",
  as a rule for templates the person saves from now on, since it asks
  for nothing before the deploy.
- An edge runtime the rewrite file doesn't name gets its own reason.

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

* fix(migrate-email): fold #472's secret-only sensitive rule into every code send

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

* fix(migrate-email): scope the runtime check to where each site runs

- A runtime the SDK release doesn't support keeps only the sites that
  run there, and an edge runtime the rewrite file doesn't name keeps only
  its own sites, each with its own reason.
- The report's note on template keys names every setting a saved
  template with a moved key changes: transactional, and the sensitive
  setting with its click redirect and subject on engagement events.

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

* fix(migrate-email): check every server that shares the SDK's manifest

The runtime check now compares the SDK release with every server that
installs from the dependency manifest the SDK goes into, and keeps the
sites of all of them when one runs a version the release doesn't
support, since the install reaches that server too.

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

* fix(migrate-email): keep every site on a manifest an unsupported server shares

When the SDK release doesn't support a server that installs from the
manifest the SDK goes into, every moving site on that manifest stays,
edge sites included. Only then does an edge site get its own check.

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

* fix(migrate-email): count workspace and root lockfile installs in the runtime check

A server whose build installs the SDK's manifest through a workspace or
a root lockfile install counts like one that installs it directly.

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

* fix(migrate-email): keep a site whose HTTP client retries a request with a deadline

A request with its own deadline moves with no retries, since it never
retried. When the code also set its HTTP client up to retry the request,
such as a requests session with a urllib3 Retry adapter, it did retry,
and the moved send would drop those retries. Such a site now stays.

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

* fix(migrate-email): count only a retry setup that covers the POST

Faraday's retry middleware skips a POST by default, and urllib3's Retry
retries a POST only on a failed connection, so a site whose retry setup
skips the POST never retried the send and keeps its deadline.

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

* fix(migrate-email): name the retry setups as examples, not a full list

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

* fix(migrate-email): read the retry setup's options before counting it

axios-retry and urllib3's Retry retry a POST only at their defaults; the
code's options can turn that off. The agent now reads them.

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

* fix(migrate-email): count a requests adapter whose max_retries is a number

HTTPAdapter(max_retries=3) builds urllib3's Retry itself, so it retries a
failed connection on a POST too.

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

* fix(migrate-email): keep a site that reads Resend's response headers

Resend's answers carry response headers: headers in Node.js,
http_headers in Python, headers and rate-limit fields on Ruby, Go,
.NET and Rust errors. PostHog's answer carries none, and its error
carries only the retry delay. A site that reads any other header value
now stays on Resend, and a read of the retry delay moves to the PostHog
error's, with each SDK's name and unit.

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

* fix(migrate-email): name each SDK's retry delay in its rewrite file

Each PostHog SDK's error shape lives in its rewrite file under "The
answer", so the retry delay's name and unit move there, and Resend's
mapping keeps only where Resend carries the value. A site that keeps its
own deadline sends with no retries, so its own wait and retry stay.

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

* fix(migrate-email): keep a send that turns Resend's plain-text part off

Resend sends no text part when text is an empty string, on a send or a
template, and makes one from the HTML when text is left out. PostHog
makes the text part from the HTML whenever a send has none, so a send or
template with an empty text now stays on Resend, and one without text
moves as before.

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

* fix(migrate-email): cover react and run-time empty text, word the template rule per provider

Resend also drops the text part for an empty text next to react, and for
a text the code builds that can be empty. The shared template rule now
keeps any template whose provider sent its emails with no text part, as
that provider's mapping says.

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

* fix(migrate-email): check the text-part rule in Step 3, count Go's empty Text as left out

Step 3 reads only the Check part of the template file, so the rule that
keeps a template whose provider sent no text part moves there. Resend's
Go SDK leaves an empty Text out of the request, so Resend made that text
part from the HTML, and such a site moves.

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

* fix(migrate-email): ask whether a copied Resend template turns its plain text off

A dashboard copy shows no plain text both for a template without one and
for one whose plain text is an empty string. Ask which, or read the
template from the API; when nobody can tell, the site stays.

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

* fix(migrate-email): offer the full-access key for the plain-text question and keep the answer

A dashboard copy has no key to read the template from the API, so the
question offers to make one. The answer goes into the template's plan
note, so a copy made again in Step 7 asks nothing new.

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

* fix(migrate-email): note every template's plain text, offer the key only in Step 3

The template's note records its plain text however the template was
read, so Step 7 never asks again, and the key is offered only in Step 3,
before Step 5 asks the person to delete it. A site stays whenever
neither the answer nor the API read settles it.

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

* fix(migrate-email): sync suppression calls on the reasons PostHog stores

PostHog's bulk add takes only bounce, complaint or manual, and writes its own
reason text, such as "Imported (bounced)". The removal guard now keys on that
prefix, and the import maps each Resend origin to the reason value.

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

* fix(migrate-email): report suppression-list calls instead of syncing them

PostHog's list records no source an app could check before a removal, a bulk
add skips an address removed earlier, and an app can't call the import tool.
PostHog blocks a transactional send only to an address that hard-bounced, and
records that itself. So each such call becomes a "Before cutover" item.

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

* fix(migrate-email): say only hard bounces block a moved send

PostHog blocks a transactional send only to an address that hard-bounced, so
the weekly re-import limits mail to bounced addresses, not complaints. A call
that removes an address becomes an "After cutover" item the person acts on
when a moved send fails with recipient_suppressed. A call that adds one names
the action before the deploy.

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

* fix(migrate-email): give the add item a check the app can make

Re-import only now names bounces alone, and an app call that adds an address
also records it where the moved sends can skip it.

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

* fix(migrate-email): ask in Step 3 which sites rely on a suppression add

A moved send reaches every address an app's add call put on the provider's
list, and an app-side flag misses past adds and survives a reactivation. So
Step 3 asks once which sites rely on the call, and keeps them on the provider.

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

* fix(migrate-email): ask about hand-added suppressions too

Step 3 asks which sites rely on the provider's list for addresses added by
hand or by the app, and a non-answer keeps every site when the app adds
addresses itself.

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

* fix(migrate-email): keep the sites when nobody can say who relies on the list

The suppression-list question gets its own Step 3 section, asks only about
sites that would move otherwise, keeps them on a non-answer, and says what
would let them move.

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

* fix(migrate-email): ask about the suppression list before the template work

The question now comes right after the field checks, so a site it keeps
needs no template copy or PostHog template, and the plan note carries what
would let the site move.

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

* fix(migrate-email): list the suppression note in the plan file rules

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

* fix(migrate-email): keep Rust sites on runtimes other than Tokio

posthog-rs's async email send waits between retries with tokio::time::sleep
and sends through reqwest, so a site on async-std or smol stays on Resend.

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

* fix(migrate-email): require Tokio's timers for the Rust async client

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

* fix(migrate-email): answer panel round 3 on tracking text

The report no longer tells the person to turn opens on for an email
whose provider tracked them, a case no opens-off site has. Turning
clicks on for a send with opens off needs opens on too. SendGrid's
click row matches Resend's. Sites that share one template made in
PostHog but differ on opens get a note naming both.

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

* fix(migrate-email): act on the shared-template opens note in Step 9

The note now fires only when the other site moves to the same template
made in PostHog, Step 3's note list names it, and Step 9's template
check asks the person to pick the shared template's opens setting
instead of turning opens off for both sites.

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

* fix(migrate-email): skip an unconfirmed opens-off template in Step 8's test send

A site that moves to a template made in PostHog with `opens off` in its
note takes the template's tracking, so Step 8's real test email could
carry an open pixel the site's emails never had. Step 8 now leaves such
a site out unless the person confirms the template's open tracking is
off, and records why when no other site fits.

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

* fix(migrate-email): keep an opens-off site on its provider when a tracked site shares its template

One PostHog template can't count opens for one site and not for
another, and splitting it left the moved call on the old template ID.
Such a site now stays, with the reason `template shared with a tracked
site`, and the note, its Step 9 branch, and the second-template advice
are gone. The `click` rows now need the template's tracking on.

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

* docs(migrate-email): ask Resend click tracking with opens, tighten tracking wording

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

* docs(migrate-email): move opens-off sites into code, never to a PostHog template

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

* docs(migrate-email): check opens before asking for a PostHog template

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

* docs(migrate-email): pick the code form for opens-off sites before template checks

Co-Authored-By: Claude Opus 5.5 <…
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