Skip to content

feat(email): let the workflows email flag target each region - #123060

Merged
trunk-io[bot] merged 1 commit into
masterfrom
posthog/transactional-email-flag-region
Oct 26, 2026
Merged

trunk-io[bot] merged 1 commit into
masterfrom
posthog/transactional-email-flag-region

Conversation

@mayteio

@mayteio mayteio commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Problem

  • PostHog's own transactional emails can send through Workflows behind transactional-emails-via-workflows (feat(email): send transactional emails through workflows behind a flag #122019). Both the US and EU instances send to the US project, so the flag decides for both.
  • The flag can only match on email and transactional_email_template. A template's rollout % applies to US and EU recipients together, so EU can't stay off, or move on its own schedule, while US ramps.

Changes

  • The flag check now also passes region (US, EU or DEV, from CLOUD_DEPLOYMENT) as a person property. Instances with no region, such as self-hosted, pass nothing.
  • Nothing changes on merge. Current release conditions don't mention region, so they match exactly as before. Adding region = US to a condition keeps it US-only. Adding a separate region = EU condition rolls EU out separately.
  • Not in this PR: EU sends only reach the US templates once the EU instance's POSTHOG_TRANSACTIONAL_EMAIL_API_KEY is a US project key. That's a secret change. Until then, an EU send that the flag matches gets a 4xx from the US project, and the email falls back to Customer.io.

How did you test this code?

Test rationale: test_workflows_flag_sees_the_instance_region fails if the flag stops receiving the instance region, or if an instance with no region passes a None value that a condition could misread. The closest existing test, test_send_via_http_routes_through_workflows_when_flag_matches, runs with no region configured, so it covers only the case without region.

I'm an agent and couldn't run the Django test suite here (no Postgres or Docker), so CI runs the tests. I ran ruff check, ruff format --check and py_compile on both files.

Release status

  • This change is behind a feature flag and is not available to users

Docs update

None.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Agent: Claude Code, Opus 5.5 (claude-opus-5-5)

  • Prepared so EU can move onto Workflows after a privacy check. It is safe to merge earlier, because it does nothing until a release condition uses region.
  • We considered syncing templates into an EU project and sending from there. The current plan sends from the US project, because PostHog's own account data on EU users already lives there.

🤖 Generated with Claude Code


Created with PostHog Desktop

Pass the instance region as a person property when evaluating transactional-emails-via-workflows, so release conditions can roll out US and EU separately. Both regions send to the US project.

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

Generated-By: PostHog Desktop
Task-Id: e6cfbed2-6717-47d6-9d53-11a4b8b76372
@mayteio mayteio self-assigned this Oct 24, 2026
@trunk-io

trunk-io Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

😎 Merged successfully - details.

@github-actions

github-actions Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🤖 CI report

⚠️ Trunk lane — backend Python lane

This PR is assigned to the backend Python lane. It runs backend Python tests and may merge in parallel with PRs in other lanes.

✅ Duplication (Python) — clean

New Python code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

✅ Duplication (TypeScript) — clean

New TypeScript code duplication introduced by this branch. Fails at 70+ tokens in app code, or 150+ tokens when both copies live in test files. Advisory while the gate proves itself: extract a shared helper instead of copying.

✅ Playwright — all passed

All tests passed.

View test results →

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

This Standard review started from the posthog-review label. Comment @posthog review --deep for a Deep review, or @posthog help to see all commands.

@posthog posthog Bot removed the reviewhog label Oct 24, 2026
@trunk-io

trunk-io Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

Static Badge   Static Badge   Static Badge

View Full Report ↗︎ ⋅ Docs

@mayteio mayteio added the stamphog Request AI approval (no full review) label Oct 26, 2026
@mayteio
mayteio marked this pull request as ready for review October 26, 2026 10:30
@parameterai

parameterai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Risk: No findings

This PR passes the instance's cloud region (from CLOUD_DEPLOYMENT) as a region person property to the transactional-emails-via-workflows feature flag, so US and EU instances can roll the flag out independently; the rest is a test. The region is an operator-controlled setting, not user input, and the flag only selects the email sending channel, so the change introduces no new security surface.

Sentinel reviewed 9cfc529 · Review settings

@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team October 26, 2026 10:30

@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 security-sensitive email routing change has independent assurance from a current-head review and a STRONG-familiarity author. No unresolved substantive concerns or other refusal grounds were found.

  • Author wrote 100% of the modified lines and has 40 merged PRs in these paths (familiarity STRONG).
  • PostHog Review (Standard) reviewed the current head: no findings.
  • posthog[bot] reviewed the current head.
Gate mechanics and policy version
Gate Result
prerequisites ✓ all clear
deny-list ✓ no deny categories matched
size ✓ 10L, 1F substantive, 32L/2F incl. docs/generated/snapshots — within ceiling
tier ✓ T1-agent / T1b-small (32L, 2F, single-area, feat)
stamphog 2.6.1 .stamphog/policy.yml @ 9cfc529 · reviewed head 9cfc529

@trunk-io
trunk-io Bot merged commit 6b047b9 into master Oct 26, 2026
371 checks passed
@trunk-io
trunk-io Bot deleted the posthog/transactional-email-flag-region branch October 26, 2026 11:40
@deployment-status-posthog

deployment-status-posthog Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-10-26 12:11 UTC Run
prod-us ✅ Deployed 2026-10-26 12:23 UTC Run
prod-eu ✅ Deployed 2026-10-26 12:25 UTC Run

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stamphog Request AI approval (no full review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant