Skip to content

feat(email): map every transactional template to its workflows template - #122502

Merged
trunk-io[bot] merged 1 commit into
masterfrom
posthog/transactional-emails-workflows-map
Oct 26, 2026
Merged

trunk-io[bot] merged 1 commit into
masterfrom
posthog/transactional-emails-workflows-map

Conversation

@mayteio

@mayteio mayteio commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Problem

  • #122019 routes a transactional email through Workflows only when its template is in WORKFLOWS_TEMPLATE_ID_MAP, and it maps password_reset alone.
  • The other 35 templates now exist as transactional Workflows templates in the US project, but the flag cannot move them until the map names them.

Changes

  • Every template in CUSTOMER_IO_TEMPLATE_ID_MAP now has its Workflows template id, so any of them can move with a flag rule and no deploy.
  • Nothing changes for recipients on merge: a template still sends through Customer.io until a rule on transactional-emails-via-workflows matches it.
  • The map keeps the order of the Customer.io map, so the two read side by side.
  • The registration test in test_email.py gains one assertion: every Workflows key must name a Customer.io template. A mistyped key would otherwise never match a send and leave that template on Customer.io without any error.

Note

The templates read variables.* and the recipient address from the send. They rely on the HTML unescaping that #122019 adds, so this PR needs to land after it.

How did you test this code?

Test rationale: the new assertion catches a key in WORKFLOWS_TEMPLATE_ID_MAP that names no template, which routes nothing and fails silently. It extends test_all_http_templates_are_registered_in_customer_io_map, the existing guard for the same map-registration invariant, rather than adding a test.

  • Ran posthog/test/test_email.py in a cloud sandbox against the base branch plus this commit.
  • Each id came from the template list in the US project and was checked to be transactional with a live sending workflow.
  • Not checked: an end-to-end send for the 35 new entries. The first flag rule for each template is that check.

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: PostHog Desktop (Claude Code), claude-opus-5-5


Created with PostHog Desktop

🤖 Generated with Claude Code

@mayteio mayteio self-assigned this Oct 23, 2026
@github-actions

github-actions Bot commented Oct 23, 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) — 1 new duplicated block (worst 82 tokens)

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.

First copy Second copy Lines Tokens
posthog/tasks/alerts/detectors/statistical/mad.py:104 posthog/tasks/alerts/detectors/statistical/zscore.py:138 18 82
⚠️ Duplication (TypeScript) — 2 new duplicated blocks (worst 138 tokens)

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.

First copy Second copy Lines Tokens
products/warehouse_suggestions/frontend/components/MaterializeSuggestionRow.tsx:31 products/warehouse_suggestions/frontend/components/UnmaterializeSuggestionRow.tsx:36 32 138
products/replay_vision/frontend/replay_scanners/replayScannersLogic.ts:630 products/replay_vision/frontend/replay_scanners/watchFeedLogic.ts:505 11 102
✅ Comment density — 3% of added code lines are comments (1 of 38)

This section warns when comments are more than 3% of the code lines a PR adds, and alerts above 6%. Before agent-assisted PRs, the typical share was about 2%. Only full-line comments count. Docstrings, generated files, snapshots, migrations, and workflow files are left out.

Comments that restate the code, record how the change came about, or narrate the next line add noise for the next reader. Keep the comments that explain a reason the code cannot show, and remove the rest. See .agents/skills/writing-code-comments/SKILL.md for the house rules.

Files with the most added comment lines:

File Comment lines Added lines
posthog/test/test_email.py 1 3

This check does not block merging. It updates on every push and clears when the share drops.

✅ Playwright — all passed

All tests passed.

View test results →

@mayteio
mayteio marked this pull request as ready for review October 23, 2026 07:18
@parameterai

parameterai Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Risk: No findings

This increment routes the Workflows template pin through the settings checks in get_workflows_template_id instead of bypassing them, so a pinned retry only skips the feature flag. The change tightens behavior; the only new edge (Customer.io fallback when the Workflows API key is removed between attempts) is operator-triggered, documented, and tested as intended.

Sentinel reviewed 6af879b · Review settings

@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team October 23, 2026 07:19
@trunk-io

trunk-io Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Static Badge   Static Badge   Static Badge

Failed Test Failure Summary Logs
test_filter_permission The test setup failed because the PostgreSQL database connection was closed while querying an instance setting. Logs ↗︎
test_new_passthrough_field_writes_through_to_team The test setup failed because the PostgreSQL database connection was closed while querying an instance setting. Logs ↗︎
test_experiments_config_confidence_level_must_be_between_zero_and_one_4_ninety_percent The test setup failed because the PostgreSQL database connection was closed while querying an instance setting. Logs ↗︎
test_project_creation_with_limited_feature The test setup failed because the PostgreSQL database connection was closed while querying an instance setting. Logs ↗︎

... and 227 more

View Full Report ↗︎ ⋅ Docs

@a-lider a-lider 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.

All these templates are identical to cio, right?
I checked only the invite and password reset ones

Base automatically changed from posthog/transactional-emails-via-workflows to master October 24, 2026 09:18
@trunk-io

trunk-io Bot commented Oct 24, 2026 •

Copy link
Copy Markdown

😎 Merged successfully - details.

Adds the Workflows message template id for all 36 Customer.io transactional templates, so each one can move through the transactional-emails-via-workflows flag without a deploy. Adds a check that every Workflows map key names a Customer.io template.

Generated-By: PostHog Desktop
Task-Id: a5c9c2a4-4563-4d98-a4b6-ef13d86f4473
@mayteio
mayteio force-pushed the posthog/transactional-emails-workflows-map branch from 6af879b to 2e8b19e Compare October 24, 2026 09:19

mayteio commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

/depot retry

mayteio commented Oct 26, 2026

Copy link
Copy Markdown
Contributor Author

/trunk merge

@trunk-io
trunk-io Bot merged commit 5d78865 into master Oct 26, 2026
248 of 249 checks passed
@trunk-io
trunk-io Bot deleted the posthog/transactional-emails-workflows-map branch October 26, 2026 10:51
@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 11:23 UTC Run
prod-us ✅ Deployed 2026-10-26 11:34 UTC Run
prod-eu ✅ Deployed 2026-10-26 11:36 UTC Run

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.

3 participants