Skip to content

feat(emails): add Category to code sends - #378

Merged
Silthus merged 41 commits into
mainfrom
feat/emails-send-category
Dec 2, 2026
Merged

Silthus merged 41 commits into
mainfrom
feat/emails-send-category

Conversation

@Silthus

@Silthus Silthus commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

💡 Motivation and Context

  • A .NET app that sends email from code with Emails.SendAsync can't put the email in a message category.
  • A team that moves a workflow's marketing email to a code send loses the email's category, so opt-outs and unsubscribe headers stop applying to it.

Depends on PostHog/posthog#142574 and PostHog/posthog#142564, both merged and live in US and EU, with the flag workflows-code-send-categories at 100%.

Changes:

  • SendCodeEmailOptions.Category takes a string?: the key of one of the project's message categories, such as newsletter.
  • The body carries category as that string only when it is set. Left unset, the body has no category, so every send without it keeps today's exact body.
  • A blank or whitespace key throws ArgumentException before any request, like a blank ReplyTo address. The server owns the key format and length.
  • category stays off template sends (SendTemplateEmailOptions), where the template's own category applies.
  • The XML docs say what the server does: a marketing category skips recipients who opted out of it or of all marketing email, fills {{ unsubscribe_url }} with the recipient's preferences link, and adds List-Unsubscribe headers. A marketing email can't have Cc or Bcc. PostHog refuses a send with category_not_found, marketing_copies_unsupported (marketing with copies), workflow_can_wait (marketing with attachments) or sandbox_fields_unsupported (marketing from the PostHog test sender), which reach the caller as EmailException.Code.
await posthog.Emails.SendAsync(new SendCodeEmailOptions
{
    To = "reader@example.com",
    TemplateKey = "monthly-news",
    Subject = "This month",
    Html = "<p>News</p><a href=\"{{ unsubscribe_url }}\">Unsubscribe</a>",
    Category = "newsletter",
});

Note

Public API change: new SendCodeEmailOptions.Category (string?). Additive.

Note

🔵 Merge risk: low · two-way door at merge, one-way door once released via NuGet: a published package version commits SendCodeEmailOptions.Category as public API

  • Opt-in: only apps that set Category after a NuGet release change. Every send without it keeps today's exact body, covered by the existing exact-body tests in EmailsTests.
  • Local validation: a blank or whitespace key throws ArgumentException before any request.
  • Backend dependency: feat(messaging): name a message category on a code send posthog#142574 and feat(messaging): send a code email in a message category posthog#142564 take category as a key string, live at 100%. An older server refuses category with a 400 field error, so the send fails loudly and never drops the field.
  • Switch-off: the server flag workflows-code-send-categories. Once released, fix forward in a new NuGet release.
  • Tier: critical (f: public SDK release)

Rollout

  • Stages: the backend is live with workflows-code-send-categories at 100%. This PR stays a draft until one real send through this branch passes, then a separately approved NuGet release.

💚 How did you test it?

  • SendsTheCategoryKeyWhenSet parses the body and asserts every field, with category as the JSON string newsletter. The existing exact-body tests, such as SendsTheRenderedContentWithoutUnsetFields, show a send without Category carries no category.
  • ReportsARefusedCategoryAfterOneRequest answers a categorized send with 400 category_not_found or sandbox_fields_unsupported, and asserts the caller gets that code as validation_error on category after one request.
  • RefusesInvalidContentBeforeAnyRequest gains a whitespace Category row.
  • Dropping the body["category"] line and the blank check turned both tests red.
  • Locally in Docker (mcr.microsoft.com/dotnet/sdk:10.0) after merging main: dotnet restore --locked-mode, bin/fmt --check and dotnet build --configuration Release passed, and UnitTests passed on netcoreapp3.1, net8.0 and net10.0.
  • Gap, owed before this leaves draft: one real send through this branch against PostHog.

📝 Checklist

  • All commits are signed (see Commit signing)
  • I reviewed the submitted code.
  • I added tests to verify the changes.
  • I updated the docs if needed.
  • No breaking change or entry added to the changelog.

If releasing new changes

  • Ran pnpm changeset to generate a changeset file

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Claude Code (Claude Opus 5.5) built Category. Antigravity (Gemini 4 Neon) merged main and applied doc and test fixes on the earlier design. The first design sent a category object (key, type, name, description) or a built-in "transactional", with create and restore on send. The merged server takes a plain key string instead, so this head drops MessageCategory, MessageCategoryType, the object validation and the tests that guarded them.

Question Answer Who Where
What does category carry? The key of an existing message category, as a string. Replaces the category object. 👤 Human PostHog/posthog#142574
Which send options take category? Code sends only. A template send uses the template's own category. 👤 Human PostHog/posthog#142574
What does the SDK check itself? A blank key. Key format and length stay with the server. 🤖 Agent this PR

Involvement: 3-lens review panel, Hedge final reads, ReviewHog; live-run proof owed.

🤖 Generated with Claude Code

How did you test this code?

Proof What ran Result Commit
live-run not run gap, accepted
cross-version not run gap, accepted
Review 3-lens panel (gpt-6.1-sol, gpt-6.2-sol, claude-opus-5-5), round 1, round 2, round 3, round 4, round 5, round 6, round 7, round 8, round 9, round 10, round 11, final read 1, final read 2, final read 3, final read 4, final read 5, final read 6, final read 7, final read 8, final read 9, final read 10, final read 11, final read 12, final read 13, final read 14, final read 15, final read 16, final read 17, final read 18, final read 19, final read 20, final read 21, final read 22, final read 23, final read 24, final read 25 105 findings: 80 fixed, 20 rejected, 5 other c6bcde2 to 02f0bd0
Proof judge an independent model reads the evidence against the diff not yet run at 02f0bd0

End table: no gate at HEAD yet. Run hedge proof gate, then hedge proof receipt.

Not checked: none recorded
Full receipt: https://artifacts.posthog.com/a/ITtOCMlcJGpc5i8yW8Y9vd

SendCodeEmailOptions.Category sends an email from code as marketing email in
one of the project's message categories, named by its key. Left out, the body
carries no category and PostHog sends transactional email as before.
EmailCategories.Transactional names the built-in value.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Silthus Silthus self-assigned this Nov 9, 2026
@Silthus

Silthus commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Opus 5.5 responding on behalf of Michael

Decisions:

  • 🤖 Which send options take category? Code sends only. A template send follows its template's own category, so the option would only restate it.
  • 🤖 How is the built-in value named? EmailCategories.Transactional, a const in a static class, like PostHogProperties.
  • 🤖 What does a blank category do? Throws before any request, like a blank ReplyTo. Length and key format stay with the server.
  • 🤖 Which error codes do the docs name? The three a code send can get. category_mismatch applies only to template sends.

@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 c6bcde2: 1 Should fix.

See this review and its findings in PostHog Review. Comment @posthog review --deep for a Deep review. A Deep review takes longer and looks deeper than a Standard review.

Comment thread src/PostHog/Emails/SendEmailOptions.cs Resolved
@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

posthog-dotnet Compliance Report

Date: 2026-12-02T07:18:59.296789+00:00
Duration: 125507ms

✅ All Tests Passed!

47/47 tests passed


Capture Tests

✅ 30/30 tests passed

View Details
Test Status Duration
Format Validation.Event Has Required Fields ✅ 261ms
Format Validation.Event Has Uuid ✅ 126ms
Format Validation.Event Has Lib Properties ✅ 110ms
Format Validation.Distinct Id Is String ✅ 115ms
Format Validation.Token Is Present ✅ 110ms
Format Validation.Custom Properties Preserved ✅ 117ms
Format Validation.Event Has Timestamp ✅ 110ms
Format Validation.Non Utc Event Timestamp Is Converted To Utc ✅ 122ms
Retry Behavior.Retries On 503 ✅ 8124ms
Retry Behavior.Does Not Retry On 400 ✅ 2118ms
Retry Behavior.Does Not Retry On 401 ✅ 2114ms
Retry Behavior.Respects Retry After Header ✅ 8118ms
Retry Behavior.Implements Backoff ✅ 22119ms
Retry Behavior.Retries On 500 ✅ 6118ms
Retry Behavior.Retries On 502 ✅ 6117ms
Retry Behavior.Retries On 504 ✅ 6114ms
Retry Behavior.Max Retries Respected ✅ 22136ms
Deduplication.Generates Unique Uuids ✅ 117ms
Deduplication.Preserves Uuid On Retry ✅ 6118ms
Deduplication.Preserves Uuid And Timestamp On Retry ✅ 13129ms
Deduplication.Preserves Uuid And Timestamp On Batch Retry ✅ 6121ms
Deduplication.No Duplicate Events In Batch ✅ 116ms
Deduplication.Different Events Have Different Uuids ✅ 111ms
Compression.Sends Gzip When Enabled ✅ 110ms
Batch Format.Uses Proper Batch Structure ✅ 110ms
Batch Format.Flush With No Events Sends Nothing ✅ 106ms
Batch Format.Multiple Events Batched Together ✅ 116ms
Error Handling.Does Not Retry On 403 ✅ 2112ms
Error Handling.Does Not Retry On 413 ✅ 2113ms
Error Handling.Retries On 408 ✅ 6113ms

Feature_Flags Tests

✅ 17/17 tests passed

View Details
Test Status Duration
Request Payload.Request With Person Properties Device Id ✅ 148ms
Request Payload.Flags Request Uses V2 Query Param ✅ 110ms
Request Payload.Flags Request Hits Flags Path Not Decide ✅ 109ms
Request Payload.Flags Request Omits Authorization Header ✅ 109ms
Request Payload.Token In Flags Body Matches Init ✅ 112ms
Request Payload.Groups Round Trip ✅ 113ms
Request Payload.Groups Default To Empty Object ✅ 109ms
Request Payload.Disable Geoip False Propagates As Geoip Disable False ✅ 110ms
Request Payload.Disable Geoip Omitted Defaults To False ✅ 109ms
Request Payload.Flag Keys To Evaluate Contains Only Requested Key ✅ 110ms
Request Lifecycle.No Flags Request On Init Alone ✅ 3ms
Request Lifecycle.No Flags Request On Normal Capture ✅ 109ms
Request Lifecycle.Two Flag Calls Produce Two Remote Requests ✅ 215ms
Request Lifecycle.Mock Response Value Is Returned To Caller ✅ 124ms
Retry Behavior.Retries Flags On 502 ✅ 1118ms
Retry Behavior.Retries Flags On 504 ✅ 1112ms
Side Effect Events.Get Feature Flag Captures Feature Flag Called Event ✅ 212ms

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

SDK performance: posthog-dotnet

Benchmarks completed. No changes flagged for review.

Flags require at least a 5% change in the median and all six pairs agreeing on direction. This is a noise filter, not proof of a performance change or a CI gate.

View all results
Test Measurement Before PR With PR Change Assessment
Capture and deliver events (32-byte payload, burst) Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Capture and deliver events (4,096-byte payload, burst) Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Capture and deliver events (32-byte payload, steady) Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Capture and deliver events (4,096-byte payload, steady) Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Queue an event (32-byte payload) Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Queue an event (4,096-byte payload) Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Evaluate all 10 flags Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Evaluate all 100 flags Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Evaluate all 1,000 flags Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Evaluate one boolean flag Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Evaluate a cohort-filtered flag Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Evaluate a flag (early match) Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Evaluate a flag (late match) Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Evaluate a flag (no match) Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Evaluate a property-filtered flag Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Evaluate a regex-filtered flag Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Evaluate a rollout flag Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Evaluate a multivariate flag Allocations per operation — — — unavailable; base:​ unsupported; head:​ unsupported; base:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​; head:​ CLR byte counters do not expose exact object allocation counts; native allocations are not included.​
Capture and deliver events (32-byte payload, burst) Allocated memory per operation 5.37 KiB/op 5.37 KiB/op <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, burst) Time per operation 4.01 µs/op 3.9 µs/op 2.7% less time Not flagged
Capture and deliver events (32-byte payload, burst) idle_managed_heap_bytes (estimated) 823.67 KiB 824.87 KiB 0.1% more memory Not flagged
Capture and deliver events (32-byte payload, burst) Idle process memory (RSS) 55.05 MiB 55.09 MiB <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, burst) Observed peak process memory (RSS) 57.69 MiB 57.69 MiB No observed change Not flagged
Capture and deliver events (32-byte payload, burst) Managed heap after settling (estimated) 2.24 MiB 2.24 MiB <0.1% more memory Not flagged
Capture and deliver events (32-byte payload, burst) Process memory after settling (RSS) 57.78 MiB 57.78 MiB No observed change Not flagged
Capture and deliver events (32-byte payload, burst) Process CPU time per operation 4.04 µs/op 3.92 µs/op 2.9% less time Not flagged
Capture and deliver events (32-byte payload, burst) Lifetime peak process memory (RSS) 57.78 MiB 57.78 MiB No observed change Not flagged
Capture and deliver events (4,096-byte payload, burst) Allocated memory per operation 39.87 KiB/op 39.87 KiB/op <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, burst) Time per operation 13.75 µs/op 13.59 µs/op 1.1% less time Not flagged
Capture and deliver events (4,096-byte payload, burst) idle_managed_heap_bytes (estimated) 2.13 MiB 2.13 MiB 0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, burst) Idle process memory (RSS) 57.02 MiB 56.97 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, burst) Observed peak process memory (RSS) 82.14 MiB 82.09 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, burst) Managed heap after settling (estimated) 25.63 MiB 25.63 MiB <0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, burst) Process memory after settling (RSS) 82.31 MiB 82.26 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, burst) Process CPU time per operation 14.91 µs/op 14.72 µs/op 1.3% less time Not flagged
Capture and deliver events (4,096-byte payload, burst) Lifetime peak process memory (RSS) 82.31 MiB 82.26 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, steady) Allocated memory per operation 18.15 KiB/op 18.15 KiB/op <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, steady) Time per operation 7.66 µs/op 7.66 µs/op No observed change Not flagged
Capture and deliver events (32-byte payload, steady) idle_managed_heap_bytes (estimated) 822.48 KiB 822.48 KiB No observed change Not flagged
Capture and deliver events (32-byte payload, steady) Idle process memory (RSS) 55.07 MiB 55.02 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, steady) Observed peak process memory (RSS) 55.65 MiB 55.59 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, steady) Managed heap after settling (estimated) 938.29 KiB 938.29 KiB No observed change Not flagged
Capture and deliver events (32-byte payload, steady) Process memory after settling (RSS) 55.63 MiB 55.58 MiB <0.1% less memory Not flagged
Capture and deliver events (32-byte payload, steady) Process CPU time per operation 7.78 µs/op 7.79 µs/op <0.1% more time Not flagged
Capture and deliver events (32-byte payload, steady) Lifetime peak process memory (RSS) 55.63 MiB 55.58 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady) Allocated memory per operation 30.97 KiB/op 30.97 KiB/op <0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, steady) Time per operation 11.38 µs/op 11.31 µs/op 0.7% less time Not flagged
Capture and deliver events (4,096-byte payload, steady) idle_managed_heap_bytes (estimated) 2.13 MiB 2.13 MiB 0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady) Idle process memory (RSS) 56.99 MiB 56.92 MiB 0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady) Observed peak process memory (RSS) 64.71 MiB 64.74 MiB <0.1% more memory Not flagged
Capture and deliver events (4,096-byte payload, steady) Managed heap after settling (estimated) 3.12 MiB 3.12 MiB <0.1% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady) Process memory after settling (RSS) 60.73 MiB 60.63 MiB 0.2% less memory Not flagged
Capture and deliver events (4,096-byte payload, steady) Process CPU time per operation 13.49 µs/op 13.56 µs/op 0.5% more time Not flagged
Capture and deliver events (4,096-byte payload, steady) Lifetime peak process memory (RSS) 64.35 MiB 64.4 MiB <0.1% more memory Not flagged
Queue an event (32-byte payload) Allocated memory per operation 1.67 KiB/op 1.67 KiB/op No observed change Not flagged
Queue an event (32-byte payload) Time per operation 1.31 µs/op 1.3 µs/op 0.8% less time Not flagged
Queue an event (32-byte payload) Process CPU time per operation 1.32 µs/op 1.31 µs/op 0.9% less time Not flagged
Queue an event (4,096-byte payload) Allocated memory per operation 1.67 KiB/op 1.67 KiB/op No observed change Not flagged
Queue an event (4,096-byte payload) Time per operation 1.23 µs/op 1.22 µs/op 1.1% less time Not flagged
Queue an event (4,096-byte payload) Process CPU time per operation 1.24 µs/op 1.22 µs/op 1.1% less time Not flagged
Evaluate all 10 flags Allocated memory per operation 22.43 KiB/op 22.43 KiB/op No observed change Not flagged
Evaluate all 10 flags Time per operation 28.29 µs/op 28.19 µs/op 0.3% less time Not flagged
Evaluate all 10 flags Process CPU time per operation 28.29 µs/op 28.19 µs/op 0.4% less time Not flagged
Evaluate all 100 flags Allocated memory per operation 217.11 KiB/op 217.11 KiB/op No observed change Not flagged
Evaluate all 100 flags Time per operation 255.5 µs/op 254.63 µs/op 0.3% less time Not flagged
Evaluate all 100 flags Process CPU time per operation 255.58 µs/op 254.7 µs/op 0.3% less time Not flagged
Evaluate all 1,000 flags Allocated memory per operation 2.11 MiB/op 2.11 MiB/op No observed change Not flagged
Evaluate all 1,000 flags Time per operation 2.08 ms/op 2.08 ms/op <0.1% less time Not flagged
Evaluate all 1,000 flags Process CPU time per operation 2.08 ms/op 2.08 ms/op <0.1% less time Not flagged
Evaluate 1,000 flags under concurrent load idle_managed_heap_bytes (estimated) 4.79 MiB 4.77 MiB 0.5% less memory Not flagged
Evaluate 1,000 flags under concurrent load Idle process memory (RSS) 108.26 MiB 108.27 MiB <0.1% more memory Not flagged
Evaluate 1,000 flags under concurrent load Observed peak process memory (RSS) 113.93 MiB 113.94 MiB <0.1% more memory Not flagged
Evaluate 1,000 flags under concurrent load Managed heap after settling (estimated) 4.89 MiB 4.87 MiB 0.5% less memory Not flagged
Evaluate 1,000 flags under concurrent load Process memory after settling (RSS) 114.04 MiB 114.05 MiB <0.1% more memory Not flagged
Evaluate 1,000 flags under concurrent load Lifetime peak process memory (RSS) 114.04 MiB 114.05 MiB <0.1% more memory Not flagged
Refresh 1,000 flag definitions idle_managed_heap_bytes (estimated) 19.55 MiB 19.55 MiB No observed change Not flagged
Refresh 1,000 flag definitions Idle process memory (RSS) 140.78 MiB 140.58 MiB 0.1% less memory Not flagged
Refresh 1,000 flag definitions Observed peak process memory (RSS) 148.86 MiB 149.32 MiB 0.3% more memory Not flagged
Refresh 1,000 flag definitions Managed heap after settling (estimated) 20.54 MiB 20.54 MiB No observed change Not flagged
Refresh 1,000 flag definitions Process memory after settling (RSS) 147.84 MiB 148.17 MiB 0.2% more memory Not flagged
Refresh 1,000 flag definitions Lifetime peak process memory (RSS) 148.3 MiB 148.81 MiB 0.3% more memory Not flagged
Evaluate one boolean flag Allocated memory per operation 1.68 KiB/op 1.68 KiB/op No observed change Not flagged
Evaluate one boolean flag Time per operation 2.16 µs/op 2.18 µs/op 0.8% more time Not flagged
Evaluate one boolean flag Process CPU time per operation 2.16 µs/op 2.18 µs/op 0.8% more time Not flagged
Evaluate a cohort-filtered flag Allocated memory per operation 1.94 KiB/op 1.94 KiB/op No observed change Not flagged
Evaluate a cohort-filtered flag Time per operation 2.16 µs/op 2.18 µs/op 0.8% more time Not flagged
Evaluate a cohort-filtered flag Process CPU time per operation 2.16 µs/op 2.18 µs/op 0.8% more time Not flagged
Evaluate a flag (early match) Allocated memory per operation 3.54 KiB/op 3.54 KiB/op No observed change Not flagged
Evaluate a flag (early match) Time per operation 3.42 µs/op 3.44 µs/op 0.5% more time Not flagged
Evaluate a flag (early match) Process CPU time per operation 3.42 µs/op 3.44 µs/op 0.5% more time Not flagged
Evaluate a flag (late match) Allocated memory per operation 5.14 KiB/op 5.14 KiB/op No observed change Not flagged
Evaluate a flag (late match) Time per operation 4.56 µs/op 4.59 µs/op 0.6% more time Not flagged
Evaluate a flag (late match) Process CPU time per operation 4.56 µs/op 4.59 µs/op 0.6% more time Not flagged
Evaluate a flag (no match) Allocated memory per operation 4.93 KiB/op 4.93 KiB/op No observed change Not flagged
Evaluate a flag (no match) Time per operation 3.9 µs/op 3.95 µs/op 1.1% more time Not flagged
Evaluate a flag (no match) Process CPU time per operation 3.9 µs/op 3.95 µs/op 1.1% more time Not flagged
Evaluate a property-filtered flag Allocated memory per operation 1.91 KiB/op 1.91 KiB/op No observed change Not flagged
Evaluate a property-filtered flag Time per operation 2.02 µs/op 2.04 µs/op 1% more time Not flagged
Evaluate a property-filtered flag Process CPU time per operation 2.02 µs/op 2.04 µs/op 1% more time Not flagged
Evaluate a regex-filtered flag Allocated memory per operation 6.34 KiB/op 6.34 KiB/op No observed change Not flagged
Evaluate a regex-filtered flag Time per operation 6.68 µs/op 6.77 µs/op 1.4% more time Not flagged
Evaluate a regex-filtered flag Process CPU time per operation 6.69 µs/op 6.78 µs/op 1.3% more time Not flagged
Evaluate a rollout flag Allocated memory per operation 1.78 KiB/op 1.78 KiB/op No observed change Not flagged
Evaluate a rollout flag Time per operation 2.57 µs/op 2.58 µs/op 0.4% more time Not flagged
Evaluate a rollout flag Process CPU time per operation 2.57 µs/op 2.58 µs/op 0.4% more time Not flagged
Evaluate a multivariate flag Allocated memory per operation 1.82 KiB/op 1.82 KiB/op No observed change Not flagged
Evaluate a multivariate flag Time per operation 2.31 µs/op 2.3 µs/op <0.1% less time Not flagged
Evaluate a multivariate flag Process CPU time per operation 2.31 µs/op 2.31 µs/op 0.1% less time Not flagged

Values are medians of paired measurements. Not flagged does not mean unchanged. Unavailable means a measurement could not be provided, not zero. Estimated allocation measurements retain their instrumentation uncertainty. RSS measures the whole process, not just SDK allocations; observed peaks are sampled checkpoints. Paired ranges in the diagnostics describe variability, not confidence intervals.

Compared f69acdb32159b5d404614a8a9438b4a6adbb470d → 02f0bd0b8390f0fec0c949842546f8bfb17e2772.

Full report and diagnostics

108 metric rows; 108 rows shown in all results. Omitted or shortened data remain in comparison.json, including per-runner environments, resource limits, measurement methods, samples and checkpoints.

The send API now takes a category object, upserted by key, or the string
"transactional". SendCodeEmailOptions.Category becomes a MessageCategory with
Key, Type, Name and an optional Description; MessageCategory.Transactional is
sent as "transactional". It replaces EmailCategories. A blank key or name, or
an undefined type, throws before any request.

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

Silthus commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Opus 5.5 responding on behalf of Michael

Decisions for contract revision 2, replacing the earlier lines:

  • 👤 What does category carry? A category object defined in code, or "transactional". Replaces a plain key string.
  • 👤 Which send options take category? Code sends only, in all 8 SDKs. On a template send it could only repeat the template's own category.
  • 👍 How is the built-in value modeled? MessageCategory.Transactional, a static instance sent as "transactional". It replaces EmailCategories.Transactional.
  • 🤖 How is the wire value written? Built by hand in EmailSender, like the rest of the body, not with a JSON converter.
  • 🤖 What does the SDK check itself? A blank key or name and an undefined type. Key format and lengths stay with the server.

@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 0878bb8: 1 Must fix.

Comment thread src/PostHog/Emails/EmailSender.cs Resolved
The send API keeps a category's description when the field is missing and
clears it when it is "". Pin that the SDK leaves description out only when it
is null, and document both on MessageCategory.Description.

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 05dde00: no findings.

The category tests compared the sent JSON text. They now send through
PostHogClient to an in-memory fake of the send endpoint that keeps the
project's categories: it upserts by key, refuses a type change with
category_mismatch, keeps a description when the field is missing and
clears it on an empty string. The tests check what the fake stored.

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

Silthus commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Opus 5.5 responding on behalf of Michael

One more decision, from the review of 05dde00:

  • 🤖 How do the category tests check a send? Against an in-memory fake of the send endpoint that keeps the project's categories (FakeMessagingApi), not by comparing the sent JSON text. The fake upserts by key, refuses a type change with category_mismatch, keeps a description when the field is missing and clears it on "", and refuses category fields outside the API's schema. The tests assert what the fake stored. This replaces the earlier rejection of the exact-JSON finding.

@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 84a43e1: no findings.

Silthus and others added 2 commits November 10, 2026 10:59
…egory

A code send whose template key names a template in a category follows that
template's category when Category is left out, and PostHog refuses
MessageCategory.Transactional for it with category_mismatch. The fake send
API now models that, two tests check both outcomes, and the docs name the
template exception instead of calling the two the same.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A template in a transactional category is sendable on every backend layer,
so the inherited category and the category_mismatch refusal hold whether or
not marketing template sends are on.

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

Silthus commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Opus 5.5 responding on behalf of Michael

One more decision, from the backend's template rule (PostHog/posthog#132118):

  • 👤 Is MessageCategory.Transactional the same as leaving Category out? No. A code send whose TemplateKey names a template in a category follows that template's category when Category is left out, and PostHog refuses MessageCategory.Transactional for it with category_mismatch. The SDK keeps the two apart on the wire, and the docs and changeset name the template exception. This replaces the earlier wording "the same as leaving it out".

@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 73da4ea: no findings.

A send whose template key names a template sends in the template's category,
so it neither creates nor updates the MessageCategory it names.

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 71e561c: no findings.

…t creation

A code send that names a category now creates it when the project has none with that key, and
otherwise leaves it as it is. The docs, the changeset and the fake send endpoint stop describing a
send that renames a category or keeps or clears its description, and the docs name the 400 codes a
caller branches on.

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

Silthus commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Opus 5.5 responding on behalf of Michael

One more decision, from the redesign of the send category on 2026-11-12 (PostHog/posthog#132118):

  • 👍 Does a code send update a category that already exists? No: "Create-only, no renames (Recommended)" (2026-11-12). A send that names a category creates it when the project has none with that key, or restores a deleted one, and otherwise leaves it untouched. Name and Description apply only when the send creates the category; renames happen in PostHog. This replaces "PostHog creates the category by its key, or updates its name and description", and the rule that a null description keeps it and "" clears it.

Silthus and others added 2 commits November 12, 2026 05:48
PostHog accepts a marketing email's HTML only with a link whose href is the
unsubscribe placeholder. The fake send endpoint now refuses a bare placeholder,
the category fixture carries a link, and the docs and changeset say a link.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Templates made in PostHog are transactional. PostHog refuses a send under
a template in a marketing category with marketing_template, and refuses
unsubscribe_link_required and copies_not_allowed only on marketing code
sends. The docs and the test fake now say and do the same.

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

Silthus commented Nov 12, 2026

Copy link
Copy Markdown
Contributor Author

Note

🤖 Claude Opus 5.5 responding on behalf of Michael

One more decision, from the send category work on 2026-11-12 (PostHog/posthog#132118):

  • 👍 Can a template made in PostHog be marketing? No: "Ship code sends, park templates (Recommended)" (2026-11-12). Code-send categories ship; template categories are parked. A send for a template in a marketing category is refused with 400 marketing_template, and unsubscribe_link_required and copies_not_allowed apply only to marketing code sends. A TemplateKey that names a template in a transactional category still follows that category. This replaces "a template in a marketing category becomes sendable and sends as marketing in that category".

@github-actions

Copy link
Copy Markdown
Contributor

This PR hasn't seen activity in a week! Should it be merged, closed, or further worked on? If you want to keep it open, post a comment or remove the stale label – otherwise this will be closed in another week.

@github-actions github-actions Bot added the stale label Nov 20, 2026
@Silthus Silthus removed the stale label Nov 23, 2026

@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 a649292: no findings.

…ys, test named transactional key, broaden deferral doc

@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 7a03900: no findings.

@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 987c2f3: no findings.

@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 12af017: no findings.

@posthog

posthog Bot commented Dec 2, 2026 •

Copy link
Copy Markdown
Contributor

PostHog Review · Deep · reviewed 02f0bd0

Nothing to post.

Step Status Result
Prepare the diff done 4 files, 1 chunk
Pick perspectives done 3 perspectives
Run review passes done 0 issues
Merge overlapping findings done 0 → 0
Validate findings done
Publish done Nothing to post

A panda relaxing and waving

Silthus and others added 3 commits December 2, 2026 07:53
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…egory body

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Silthus
Silthus marked this pull request as ready for review December 2, 2026 08:36
@Silthus
Silthus requested a review from a team as a code owner December 2, 2026 08:36
@veria-ai

veria-ai Bot commented Dec 2, 2026 •

Copy link
Copy Markdown

PR overview

No security issues were found in this pull request.

Reviews

@stamphog stamphog Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Approved.

The disclosed API and send-path changes have current-head independent review and a STRONG-familiarity author, with targeted regression tests. No concrete unresolved review concerns or other refusal grounds are present; backend rollout claims cannot be independently verified from this checkout.

  • Author wrote 100% of the modified lines and has 3 merged PRs in these paths (familiarity STRONG).
  • PostHog Review (Standard) reviewed the current head: no findings.
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
every_file_attested ✓ not a bot PR
size ✓ 33L, 3F substantive, 99L/6F incl. size-exempt files — within ceiling
tier ✓ T1-agent / T1d-complex (99L, 6F, cross-cutting, feat)
stamphog 2.11.0 .stamphog/policy.yml @ 02f0bd0 · reviewed head 02f0bd0

@Silthus
Silthus merged commit b083162 into main Dec 2, 2026
25 checks passed
@Silthus
Silthus deleted the feat/emails-send-category branch December 2, 2026 08:56
Silthus added a commit that referenced this pull request Dec 2, 2026
…416)

* revert(emails): remove Category from code sends

This reverts commit b083162 (#378).

Code-sent emails are staying strictly transactional, so message category
support on code sends is being reverted. The recent release shipped
shortly before this decision while the server feature flag was disabled.

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

* chore(emails): add a patch changeset for the Category revert

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

* fix(emails): keep Category as obsolete and refuse it before any request

Code-sent emails are transactional only. Keep SendCodeEmailOptions.Category
in the public API, marked [Obsolete], so code built against 2.31 still
compiles and loads. A send that sets it throws an EmailException with the
code invalid_form and the field category before any request, pointing
marketing email to a PostHog workflow. The SDK never sends a category,
and a null Category sends exactly as before.

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

* fix(emails): refuse Category before any other check

A categorized send with another invalid option now still gets the
invalid_form refusal with workflow advice, and no file is uploaded.

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

* docs(emails): note CS0618 fails builds that treat warnings as errors

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

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant