:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(workflows): stop repeating the same low reputation warning (#124949)
Chris Shinebd1c75e0b6c8
diff --git a/posthog/tasks/email.py b/posthog/tasks/email.pyindex f1a0decaabe9..1c540a6d1152 100644--- a/posthog/tasks/email.py+++ b/posthog/tasks/email.py@@ -1023,8 +1023,11 @@ def send_email_sending_reputation_finding(if high_impactelse f"Reputation warning for email sending in project '{team}'")+ # AWS can close and reopen a LOW finding many times a day, and every reopen dispatches this+ # task again. Keying LOW on the ISO week lets the per-recipient dedupe send it once a week.+ dedupe_period = found_at if high_impact else datetime.datetime.fromisoformat(found_at).strftime("%G-W%V")message = EmailMessage(- campaign_key=f"email_sending_reputation_finding_{team_id}_{impact}_{found_at}",+ campaign_key=f"email_sending_reputation_finding_{team_id}_{impact}_{dedupe_period}",subject=subject,template_name="email_sending_reputation_finding",template_context={diff --git a/posthog/tasks/test/test_email.py b/posthog/tasks/test/test_email.pyindex c946bc1c51bc..1528fa3cf3f9 100644--- a/posthog/tasks/test/test_email.py+++ b/posthog/tasks/test/test_email.py@@ -33,6 +33,7 @@ from posthog.tasks.email import (send_canary_email,send_discussions_mentioned,send_email_change_emails,+ send_email_sending_reputation_finding,send_email_verification_code,send_external_data_failure_digest,send_fatal_plugin_error,@@ -206,6 +207,26 @@ class TestEmail(APIBaseTest, ClickhouseTestMixin):assert "\r" not in subjectassert "Welcome series" in subject+ @parameterized.expand(+ [+ ("low_again_later_that_week", "LOW", "2026-01-11T22:00:00+00:00", True),+ ("low_again_the_next_week", "LOW", "2026-01-12T09:00:00+00:00", False),+ ("high_again_within_the_hour", "HIGH", "2026-01-05T09:40:00+00:00", False),+ ]+ )+ def test_reputation_finding_warning_dedupes_repeat_low_findings_within_a_week(+ self, MockEmailMessage: MagicMock, _name: str, impact: str, second_at: str, deduped: bool+ ) -> None:+ mocked_email_messages = mock_email_messages(MockEmailMessage)+ self.organization_membership.level = OrganizationMembership.Level.ADMIN+ self.organization_membership.save()++ send_email_sending_reputation_finding(self.team.id, impact, "2026-01-05T09:00:00+00:00")+ send_email_sending_reputation_finding(self.team.id, impact, second_at)++ assert len(mocked_email_messages) == 2+ assert (mocked_email_messages[0].campaign_key == mocked_email_messages[1].campaign_key) is deduped+def test_send_delegation_invite_falls_back_when_organization_name_is_a_url(self, MockEmailMessage: MagicMock) -> None: