Skip to content

feat(alerts): centralize email delivery - #71600

Merged
MattPua merged 2 commits into
masterfrom
posthog-code/alerts-email-destination-product
Jul 16, 2026
Merged

feat(alerts): centralize email delivery#71600
MattPua merged 2 commits into
masterfrom
posthog-code/alerts-email-destination-product

Conversation

@MattPua

@MattPua MattPua commented Jul 16, 2026

Copy link
Copy Markdown
Member

Problem

Insight alert emails are sent from the legacy alert task module instead of the shared alerts product. New alert products would need to duplicate the same email delivery setup.

Changes

  • Add a shared alert email sender using the existing PostHog transactional email transport.
  • Route insight alert firing and auto-disabled emails through the shared alerts facade.
  • Preserve existing subscribers, templates, campaign keys, sender behavior, and HogFunction destinations.

How did you test this code?

  • bin/hogli test products/alerts/backend/test/test_email_notifications.py
  • bin/hogli test posthog/tasks/alerts/test/test_alert_subscriptions.py
  • bin/hogli ci:preflight --strict
  • Tests cover delivery to every recipient, removed organization members, firing email rendering, and disabled email rendering.

👉 Stay up-to-date with PostHog coding conventions for a smoother review.

Automatic notifications

  • Publish to changelog?
  • Alert Sales and Marketing teams?

Docs update

No docs update. Existing email behavior is unchanged.

🤖 Agent context

Autonomy: Human-driven (agent-assisted)

Implemented with PostHog Code using Codex CLI. Invoked /sending-notifications, /writing-tests, and /improving-drf-endpoints. The native email HogFunction approach was discarded because it introduced a separate email concept instead of generalizing the existing insight alert email path.


Created with PostHog Code

@MattPua MattPua self-assigned this Jul 16, 2026
@MattPua
MattPua force-pushed the posthog-code/alerts-email-destination-product branch from 5bab427 to 34a6754 Compare July 16, 2026 17:04
Generated-By: PostHog Code
Task-Id: ec75816d-f0d0-439e-9c74-91a9ebf84493
@MattPua
MattPua force-pushed the posthog-code/alerts-email-destination-product branch from 34a6754 to 0040a2d Compare July 16, 2026 17:30
@MattPua MattPua changed the title feat(alerts): add shared email destination support feat(alerts): centralize email delivery Jul 16, 2026
@MattPua
MattPua marked this pull request as ready for review July 16, 2026 17:43
@MattPua MattPua added the stamphog Request AI approval (no full review) label Jul 16, 2026
@pr-assigner-resolver-posthog
pr-assigner-resolver-posthog Bot requested a review from a team July 16, 2026 17:43
@greptile-apps

greptile-apps Bot commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Reviews (1): Last reviewed commit: "feat(alerts): centralize email delivery" | Re-trigger Greptile

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

Contained refactor that centralizes existing alert-email sending into a shared facade function with no behavior change; covered by new and updated tests, author is on the owning team, and Greptile's automated review raised no concerns.

  • Author wrote 0% of the modified lines and has 13 merged PRs in these paths (familiarity MODERATE).
  • 👍 on the PR from greptile-apps[bot], hex-security-app[bot].
Gate mechanics and policy version
Gate Result
prerequisites all clear
deny-list no deny categories matched
size 43L, 3F substantive, 103L/5F incl. docs/generated/snapshots — within ceiling
tier T1-agent / T1c-medium (103L, 5F, two-areas, feat)
stamphog 2.0.0b3 .stamphog/policy.yml @ 87f6ea1 · reviewed head 0040a2d

@trunk-io

trunk-io Bot commented Jul 16, 2026

Copy link
Copy Markdown

Static BadgeStatic BadgeStatic BadgeStatic Badge

View Full Report ↗︎Docs

@github-actions

Copy link
Copy Markdown
Contributor

🤖 CI report

Playwright — all passed

All tests passed.

View test results →

@MattPua
MattPua merged commit 81a03b4 into master Jul 16, 2026
238 checks passed
@MattPua
MattPua deleted the posthog-code/alerts-email-destination-product branch July 16, 2026 19:16
@deployment-status-posthog

deployment-status-posthog Bot commented Jul 16, 2026

Copy link
Copy Markdown

Deploy status

Environment Status Deployed At Workflow
dev ✅ Deployed 2026-07-16 19:51 UTC Run
prod-us ✅ Deployed 2026-07-16 20:12 UTC Run
prod-eu ✅ Deployed 2026-07-16 20:12 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