Skip to content

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

fix(workflows): add soft bounces and a volume floor to the ISP table (#100183)

Daniel Marchuk9fe4d6e7d02e
diff --git a/frontend/snapshots.yml b/frontend/snapshots.yml
index a5e627734aeb..240a281e291f 100644
--- a/frontend/snapshots.yml
+++ b/frontend/snapshots.yml
@@ -6225,25 +6225,25 @@ snapshots:
products-workflows-editor-tree--support-sla-routing--light:
hash: v1.k794b7964.8aec1d3b65bb0d2e1b4bee72e6192dec55912fcd0bdce146dcf48e16453ec44f.HDlYfFMWDXWuYU9krTw6IX8Emw0zG1uzsMvRfdNDIZQ
products-workflows-reputation--domain-withheld-from-caller--dark:
- hash: v1.k794b7964.b37b29c7894aedb7ca34c4976577e3aaed60f5e81a99d29c427ad4d5eeaf16ce.p2UYtjwRYsZEy_dF6JZTqzYZC8PD-WIUSALXCQGdpjM
+ hash: v1.k794b7964.c2e39d5fe9b32f1b638e90e39ce2cce629ade26846acc2d2530fa8c89986d4ec.un8cpP-nRmKMMaLVxSAP7vc-2PZ1zELYwqHEgXQ33L8
products-workflows-reputation--domain-withheld-from-caller--light:
- hash: v1.k794b7964.091ed3d12a75d2aff814c3ecc26ad7d35dc873a63c251610da3169c7e3c6b680.cFmrImD6HC6l6l-qkl5o_W89NUSW2NeK0PN6orswmZI
+ hash: v1.k794b7964.2a42eb93e07102fdaa2be66c61d24ec24d3824584a7fd8282086f5951be7cd60.1ZnyCHFAjY3SrKADM8oOrlMPLkBx7A3uERarZ6QX9JU
products-workflows-reputation--no-provider-data--dark:
- hash: v1.k794b7964.fb4106e727cdaf881bb150dc59925f5259d21e78cb9efa7e452e3440c143c93b.JPlPndGIFWdaK3sS9Gh0YICf3ncO7E_jOxe5SII9hHM
+ hash: v1.k794b7964.d5868f04ec995d95b42c5da29d86be9fe0180177c928c3aca9b178bb2b708dad.KEMPcrEoivqZ9ih7hmlXKz_OGmpe4SrDoi9B1wiMVms
products-workflows-reputation--no-provider-data--light:
- hash: v1.k794b7964.dd0d5b8e28e1b9da35ac9aa7c0995b196e75006f4701c5ce2e32450e46b99359.vJQb1izatw_Q0naM9-YnUKg2ei7iujSXmDWR_DMOq00
+ hash: v1.k794b7964.6b6d7a5158358a4110345590bd8d6f3b8be4b82a4126b14d3e7099850d068860.__4p80UwBytU6XA20QHzeFY876nKh8iLH_V3MUyOjMw
products-workflows-reputation--one-provider-filtering--dark:
- hash: v1.k794b7964.3284d7f1546ff422b89ee95222f0f3a39d0a3aecb17c22e0f8c9df41519b4c93.2KT_f33QvvlMvor3uncuvDEM-mgdKTJUOBu9OsiI5sA
+ hash: v1.k794b7964.33708acd8756fdd8a94edb5fbc42fec36c0e3b80fea591f7c921989c2b9b1d3d.Jr3pkLgeWS_NzZGXi_S5jbtgZf6fCWCFFqQTPwk812M
products-workflows-reputation--one-provider-filtering--light:
- hash: v1.k794b7964.a03a3a802b51ef3fffa0fc5cd66cee08207dc823b59ce287004796ba005afbd6.hxIVovENYvSv4p5ctxC9s6BWVIn37AogagUs1jFx7cM
+ hash: v1.k794b7964.a5fc256d47dd4b41c414dff7e52bd662ed291e83dad328b4d60a03c4d8116325.weiQmgMwlgNFnsFBxyzt1PVo6uIVmBIcHpJYGyiUxJ0
products-workflows-reputation--provider-data-without-workflow-rates--dark:
- hash: v1.k794b7964.26ad11c3a2c8b9856c325756bf26b12d4205aafc6b664999815c206eff24782f.ZYTZXXKw3jnFcpZPvYfph2q5SjUjQ2ZquVuBTbVE5Ro
+ hash: v1.k794b7964.307e7b4c2f84ce71b05b3b8f43dd85df28bda0f502c273dbd44f5beb9ad1d97e.qv6hpPIEVH6U-pcYaYXYt2bIKb0J9AceIgTS2ut66yQ
products-workflows-reputation--provider-data-without-workflow-rates--light:
- hash: v1.k794b7964.e2f2ecbc2b3c2d9ed27d0aff39baf68ed264a6d976f943c4c1965a497fc6d018.XTD4bmHAQ2D4WVYmWuLNd25JFYhbt9R2-gN64gUXkQo
+ hash: v1.k794b7964.09b8db29359499827a5ee3a6cd0b533eb9fb403a07349d6be22ab4148ee91bee.9ZFcUpOKTNhLNb1OesXvLQMOFEjnWiLDiN6dvtVzRWU
products-workflows-reputation--shared-sending-domain--dark:
- hash: v1.k794b7964.908aa54619e9e4669005bebc9ed7166052200b1613a2f36900bb18af7c74b2ba.PAhdvkGE9vb64e93_Ap6KJohFsSBjwa8BsPKVRT-IXE
+ hash: v1.k794b7964.5cf1b5557a39a1c56f57778a8f93fae97a2369d6a0d9debeaf9a32888867e76f.YVfscq34vkHHNa-V3zETBCtGV5g2HUXGoUCZTtdwwTg
products-workflows-reputation--shared-sending-domain--light:
- hash: v1.k794b7964.95181ed4e0a17456b9e62c3e467ddc605b1a733c81ea6f7c6e0c61928aa3f22d.ZMctRK-G6wUmjfa2paqyxhRtmF0TG_WVyOPLWhFWXyU
+ hash: v1.k794b7964.d2f19057ecd63916468e49499852f4b90854405ad3d4f8bbb04e766a6180a0bf.SIZeFe7wNudMSeL2euN2W8tSq5ATz9vp6KGnFbgeUmw
products-workflows-steps-customer-task-reference-input--account--dark:
hash: v1.k794b7964.835bf9b0ff1b7768ce199ca0d32952cb9fa278dd063a985849bb648ec9b655bd.W4Xi4ysAnLzglAUcc-NmmQ883jFKKE5zbV3JqZDfh3Y
products-workflows-steps-customer-task-reference-input--account--light:
diff --git a/products/workflows/backend/api/hog_flow.py b/products/workflows/backend/api/hog_flow.py
index 6eeb2d87ace7..09c1b056d400 100644
--- a/products/workflows/backend/api/hog_flow.py
+++ b/products/workflows/backend/api/hog_flow.py
@@ -2452,17 +2452,10 @@ def _fetch_isp_metrics(team_id: int, window_days: int, domains: list[str]) -> li
"emails_sent": row.emails_sent,
"delivery_rate": row.delivery_rate,
"bounce_rate": row.bounce_rate,
+ "transient_bounce_rate": row.transient_bounce_rate,
"complaint_rate": row.complaint_rate,
+ "complaint_base": row.complaint_base,
"unavailable": list(row.unavailable),
- "daily": [
- {
- "date": point.date,
- "emails_sent": point.emails_sent,
- "delivery_rate": point.delivery_rate,
- "bounce_rate": point.bounce_rate,
- }
- for point in row.daily
- ],
}
for row in rows
]
@@ -2571,19 +2564,6 @@ class AwsTenantReputationSerializer(serializers.Serializer):
)
-class IspDailyPointSerializer(serializers.Serializer):
- """One bucket of a provider's sending history."""
-
- date = serializers.CharField(read_only=True, help_text="Bucket date, as an ISO 8601 calendar date.")
- emails_sent = serializers.IntegerField(read_only=True, help_text="Emails sent to this provider on this date.")
- delivery_rate = serializers.FloatField(
- read_only=True, help_text="Emails this provider accepted on this date, divided by emails sent to it (0-1)."
- )
- bounce_rate = serializers.FloatField(
- read_only=True, help_text="Hard bounces at this provider on this date, divided by emails sent to it (0-1)."
- )
-
-
class IspSendingHealthSerializer(serializers.Serializer):
"""How one mailbox provider treated this project's email, from AWS SES's own delivery data."""
@@ -2609,6 +2589,16 @@ class IspSendingHealthSerializer(serializers.Serializer):
"when the underlying metric could not be loaded from AWS."
),
)
+ transient_bounce_rate = serializers.FloatField(
+ read_only=True,
+ allow_null=True,
+ help_text=(
+ "Soft (transient) bounces at this provider, divided by emails sent to it (0-1). These "
+ "are deferrals the provider may accept on a retry, such as a full mailbox, greylisting "
+ "or rate limiting, so they are counted apart from permanent bounces. Null when the "
+ "underlying metric could not be loaded from AWS."
+ ),
+ )
complaint_rate = serializers.FloatField(
read_only=True,
allow_null=True,
@@ -2618,20 +2608,21 @@ class IspSendingHealthSerializer(serializers.Serializer):
"or nothing was delivered — and also when the metric could not be loaded from AWS."
),
)
- unavailable = serializers.ListField(
- child=serializers.CharField(),
+ complaint_base = serializers.IntegerField(
read_only=True,
help_text=(
- "Rates AWS did not return for this provider, from `delivery`, `bounce` and `complaint`. "
- "A rate named here is missing, not zero, and the UI says so rather than showing a number."
+ "Deliveries the provider reports complaints for, which is what `complaint_rate` "
+ "divides by. Far smaller than `emails_sent`, so a caller deciding whether the rate "
+ "rests on enough volume has to weigh it against this. Zero when there is no base."
),
)
- daily = IspDailyPointSerializer(
- many=True,
+ unavailable = serializers.ListField(
+ child=serializers.CharField(),
read_only=True,
help_text=(
- "Sending history for this provider, oldest first, so a drop can be dated rather than "
- "averaged into the window. Dates this provider received nothing are omitted."
+ "Rates AWS did not return for this provider, from `delivery`, `bounce`, "
+ "`transient_bounce` and `complaint`. "
+ "A rate named here is missing, not zero, and the UI says so rather than showing a number."
),
)
diff --git a/products/workflows/backend/api/test/test_email_reputation.py b/products/workflows/backend/api/test/test_email_reputation.py
index c1b6f4f37fa2..8618cdb5f33c 100644
--- a/products/workflows/backend/api/test/test_email_reputation.py
+++ b/products/workflows/backend/api/test/test_email_reputation.py
@@ -17,7 +17,7 @@ from posthog.models.user import User
from products.access_control.backend.models.access_control import AccessControl
from products.workflows.backend.models import HogFlow, HogFlowBatchJob
from products.workflows.backend.models.team_workflows_config import TeamWorkflowsConfig
-from products.workflows.backend.providers.ses import IspDailyPoint, IspSendingMetrics
+from products.workflows.backend.providers.ses import IspSendingMetrics
class TestEmailReputationAPI(APIBaseTest):
@@ -310,16 +310,18 @@ class TestEmailReputationAPI(APIBaseTest):
emails_sent=900,
delivery_rate=0.97,
bounce_rate=0.01,
+ transient_bounce_rate=0.02,
complaint_rate=None,
- daily=(IspDailyPoint(date="2026-08-01", emails_sent=900, delivery_rate=0.97, bounce_rate=0.01),),
+ complaint_base=0,
),
IspSendingMetrics(
isp="Yahoo",
emails_sent=100,
delivery_rate=0.99,
bounce_rate=0.0,
+ transient_bounce_rate=0.0,
complaint_rate=0.002,
- daily=(),
+ complaint_base=50,
),
],
)
@@ -330,27 +332,22 @@ class TestEmailReputationAPI(APIBaseTest):
"emails_sent": 900,
"delivery_rate": 0.97,
"bounce_rate": 0.01,
- # Null rather than 0 — Gmail runs no feedback loop, so a complaint rate would be
+ "transient_bounce_rate": 0.02,
+ # Null rather than 0: Gmail runs no feedback loop, so a complaint rate would be
# a number we can't actually measure.
"complaint_rate": None,
+ "complaint_base": 0,
"unavailable": [],
- "daily": [
- {
- "date": "2026-08-01",
- "emails_sent": 900,
- "delivery_rate": 0.97,
- "bounce_rate": 0.01,
- }
- ],
},
{
"isp": "Yahoo",
"emails_sent": 100,
"delivery_rate": 0.99,
"bounce_rate": 0.0,
+ "transient_bounce_rate": 0.0,
"complaint_rate": 0.002,
+ "complaint_base": 50,
"unavailable": [],
- "daily": [],
},
]
@@ -426,8 +423,9 @@ class TestEmailReputationAPI(APIBaseTest):
emails_sent=900,
delivery_rate=0.97,
bounce_rate=0.01,
+ transient_bounce_rate=0.0,
complaint_rate=None,
- daily=(),
+ complaint_base=0,
)
],
)
@@ -479,8 +477,9 @@ class TestEmailReputationAPI(APIBaseTest):
emails_sent=90,
delivery_rate=0.99,
bounce_rate=0.01,
+ transient_bounce_rate=0.0,
complaint_rate=None,
- daily=(),
+ complaint_base=0,
)
],
isp_flag_enabled=False,
@@ -537,8 +536,9 @@ class TestEmailReputationAccessControl(APIBaseTest):
emails_sent=100,
delivery_rate=0.9,
bounce_rate=0.05,
+ transient_bounce_rate=0.0,
complaint_rate=None,
- daily=(),
+ complaint_base=0,
)
]
with (
diff --git a/products/workflows/backend/providers/ses.py b/products/workflows/backend/providers/ses.py
index 547e8b373026..4b7d1a96c689 100644
--- a/products/workflows/backend/providers/ses.py
+++ b/products/workflows/backend/providers/ses.py
@@ -28,7 +28,16 @@ logger = logging.getLogger(__name__)
# DELIVERY_COMPLAINT is the complaint denominator rather than SEND, because AWS defines it as
# deliveries excluding recipients at ISPs it has no feedback-loop agreement with.
-ISP_METRICS: tuple[str, ...] = ("SEND", "DELIVERY", "PERMANENT_BOUNCE", "COMPLAINT", "DELIVERY_COMPLAINT")
+# TRANSIENT_BOUNCE is queried because without it a provider that defers rather than rejects reads
+# as a low delivery rate with no bounces, and nothing accounts for the difference.
+ISP_METRICS: tuple[str, ...] = (
+ "SEND",
+ "DELIVERY",
+ "PERMANENT_BOUNCE",
+ "TRANSIENT_BOUNCE",
+ "COMPLAINT",
+ "DELIVERY_COMPLAINT",
+)
# Subject for the identity-wide queries, which carry no ISP dimension. They give the denominator
# the per-provider rows are subtracted from.
@@ -56,14 +65,6 @@ METRIC_CALL_WORST_CASE_SECONDS = METRIC_CONNECT_TIMEOUT_SECONDS + METRIC_READ_TI
METRIC_QUERY_BUDGET_SECONDS = 20
-@frozen
-class IspDailyPoint:
- date: str
- emails_sent: int
- delivery_rate: float
- bounce_rate: float
-
-
@frozen
class IspSendingMetrics:
isp: str
@@ -73,11 +74,14 @@ class IspSendingMetrics:
# reads as a healthy provider. Unknown is reported as unknown rather than as a number.
delivery_rate: float | None
bounce_rate: float | None
+ transient_bounce_rate: float | None
# Also None when the provider runs no feedback loop, or when nothing was delivered to measure
# complaints against: both are "no rate exists", as against "we could not load it".
complaint_rate: float | None
- # Oldest bucket first. Buckets SES returned nothing for are absent rather than zero-filled.
- daily: tuple[IspDailyPoint, ...]
+ # The deliveries complaint_rate divides by, which is far smaller than emails_sent. A caller
+ # judging whether the rate rests on enough volume has to weigh it against this, not against
+ # what was sent.
+ complaint_base: int
# Rates whose metric AWS did not return, so the reader can be told the number is missing rather
# than shown one. A null rate that is not listed here has no value to state at all.
unavailable: tuple[str, ...] = ()
@@ -162,8 +166,10 @@ def _isp_rows_from_series(isps: Sequence[str], series: IspMetricSeries) -> list[
continue
delivered_by_date = buckets.get(IspMetric(isp=isp, metric="DELIVERY"), {})
bounced_by_date = buckets.get(IspMetric(isp=isp, metric="PERMANENT_BOUNCE"), {})
+ deferred_by_date = buckets.get(IspMetric(isp=isp, metric="TRANSIENT_BOUNCE"), {})
delivery_failed = IspMetric(isp=isp, metric="DELIVERY") in failed
bounce_failed = IspMetric(isp=isp, metric="PERMANENT_BOUNCE") in failed
+ transient_failed = IspMetric(isp=isp, metric="TRANSIENT_BOUNCE") in failed
complaint_failed = (
IspMetric(isp=isp, metric="COMPLAINT") in failed
or IspMetric(isp=isp, metric="DELIVERY_COMPLAINT") in failed
@@ -177,6 +183,9 @@ def _isp_rows_from_series(isps: Sequence[str], series: IspMetricSeries) -> list[
# denominator at the boundary. Clamp, as the project-wide rates do.
delivery_rate=None if delivery_failed else min(1.0, sum(delivered_by_date.values()) / emails_sent),
bounce_rate=None if bounce_failed else min(1.0, sum(bounced_by_date.values()) / emails_sent),
+ transient_bounce_rate=(
+ None if transient_failed else min(1.0, sum(deferred_by_date.values()) / emails_sent)
+ ),
complaint_rate=(
None
if complaint_failed or not complaint_base
@@ -184,31 +193,17 @@ def _isp_rows_from_series(isps: Sequence[str], series: IspMetricSeries) -> list[
1.0, sum(buckets.get(IspMetric(isp=isp, metric="COMPLAINT"), {}).values()) / complaint_base
)
),
- # The trend is a delivery-rate series, so a failed DELIVERY query leaves nothing
- # to draw. An empty series renders no line rather than a flat one at zero.
+ complaint_base=0 if complaint_failed else complaint_base,
unavailable=tuple(
name
for name, missing in (
("delivery", delivery_failed),
("bounce", bounce_failed),
+ ("transient_bounce", transient_failed),
("complaint", complaint_failed),
)
if missing
),
- daily=()
- if delivery_failed
- else tuple(
- IspDailyPoint(
- date=date,
- emails_sent=sent,
- delivery_rate=min(1.0, delivered_by_date.get(date, 0) / sent),
- bounce_rate=0.0 if bounce_failed else min(1.0, bounced_by_date.get(date, 0) / sent),
- )
- # A rate over zero sends is undefined, and zero-filling draws a cliff in
- # the trend that never happened.
- for date, sent in sorted(sent_by_date.items())
- if sent > 0
- ),
)
)
@@ -254,24 +249,18 @@ def _other_provider_row(isps: Sequence[str], series: IspMetricSeries) -> IspSend
delivered_by_date = remainder("DELIVERY")
bounced_by_date = remainder("PERMANENT_BOUNCE")
+ deferred_by_date = remainder("TRANSIENT_BOUNCE")
complaint_base = sum(remainder("DELIVERY_COMPLAINT").values())
return IspSendingMetrics(
isp=ISP_OTHER,
emails_sent=emails_sent,
delivery_rate=min(1.0, sum(delivered_by_date.values()) / emails_sent),
bounce_rate=min(1.0, sum(bounced_by_date.values()) / emails_sent),
+ transient_bounce_rate=min(1.0, sum(deferred_by_date.values()) / emails_sent),
complaint_rate=(
None if not complaint_base else min(1.0, sum(remainder("COMPLAINT").values()) / complaint_base)
),
- daily=tuple(
- IspDailyPoint(
- date=date,
- emails_sent=sent,
- delivery_rate=min(1.0, delivered_by_date.get(date, 0) / sent),
- bounce_rate=min(1.0, bounced_by_date.get(date, 0) / sent),
- )
- for date, sent in sorted(sent_by_date.items())
- ),
+ complaint_base=complaint_base,
)
@@ -857,11 +846,11 @@ class SESProvider:
Run one batch, reissuing it per provider if SES refuses the whole request.
SES validates dimension values per request, so one name it will not accept fails every
- query sent alongside it. Almost every batch carries two providers, and a subject is keyed
- by provider and metric with no domain, so failing the batch would drop a provider SES does
+ query sent alongside it. A batch carries several providers, and a subject is keyed by
+ provider and metric with no domain, so failing the batch would drop a provider SES does
accept from the whole breakdown rather than from this request. Reissuing keeps it, and
- costs the extra calls only when a name is bad. A provider is never split across two
- groups, because ISP_METRICS divides METRIC_QUERY_BATCH_SIZE.
+ costs the extra calls only when a name is bad. Grouping by provider rather than by a fixed
+ count keeps each retry whole even when a batch boundary splits a provider.
"""
try:
return IspBatchAnswer(
@@ -874,7 +863,10 @@ class SESProvider:
responses: list[Mapping[str, Any]] = []
rejected: set[IspMetric] = set()
- for group in batched(batch, len(ISP_METRICS), strict=False):
+ by_provider: dict[str, list[dict[str, Any]]] = {}
+ for query in batch:
+ by_provider.setdefault(plan.subjects[query["Id"]].isp, []).append(query)
+ for group in by_provider.values():
if monotonic() + METRIC_CALL_WORST_CASE_SECONDS > deadline:
raise TimeoutError(
f"SES metric queries exceeded {METRIC_QUERY_BUDGET_SECONDS}s splitting a rejected batch"
diff --git a/products/workflows/backend/test/test_ses_provider.py b/products/workflows/backend/test/test_ses_provider.py
index 60de53a18223..7ed89b38ede0 100644
--- a/products/workflows/backend/test/test_ses_provider.py
+++ b/products/workflows/backend/test/test_ses_provider.py
@@ -640,9 +640,7 @@ class TestGetIdentityIspMetrics(TestCase):
self.mock_client.batch_get_metric_data.side_effect = lambda Queries: respond(Queries)
- def test_daily_series_is_ordered_and_merged_across_domains(self):
- # Two domains reporting the same days have to land in one bucket per day, or the trend
- # draws each domain as its own point and every rate is computed against half the sends.
+ def test_counts_are_summed_across_domains(self):
self._serve_series(
{
("Gmail", "SEND"): {"2026-08-02": 50, "2026-08-01": 100},
@@ -654,10 +652,8 @@ class TestGetIdentityIspMetrics(TestCase):
[TEST_DOMAIN, "other.posthog.com"], window_days=30, isps=["Gmail"]
)
- assert [(point.date, point.emails_sent, point.delivery_rate) for point in rows[0].daily] == [
- ("2026-08-01", 200, 0.95),
- ("2026-08-02", 100, 0.2),
- ]
+ assert rows[0].emails_sent == 300
+ assert rows[0].delivery_rate == 0.7
def test_a_partial_query_failure_leaves_the_other_metrics_intact(self):
# SES reports per-query failures in Errors while still returning Results. Logging one used
@@ -694,15 +690,14 @@ class TestGetIdentityIspMetrics(TestCase):
assert rows[0].delivery_rate is None
assert rows[0].bounce_rate is None
assert rows[0].complaint_rate is None
- assert set(rows[0].unavailable) == {"delivery", "bounce", "complaint"}
- # No delivery series means no trend to draw, rather than a line flat at zero.
- assert rows[0].daily == ()
+ assert rows[0].transient_bounce_rate is None
+ assert set(rows[0].unavailable) == {"delivery", "bounce", "transient_bounce", "complaint"}
def test_a_provider_ses_rejects_does_not_take_its_batch_mates_with_it(self):
# SES validates dimension values per request, so a name it will not accept fails every
- # query sent with it. Five metrics per provider means a ten-query batch carries two, and a
- # subject is keyed by provider and metric with no domain, so failing the batch dropped a
- # good provider from every domain rather than from the one request.
+ # query sent with it. A subject is keyed by provider and metric with no domain, so failing
+ # the batch dropped a good provider from every domain rather than from the one request.
+ # Six metrics do not divide the ten-query batch, so a rejected name also straddles two.
def respond(Queries):
if any(_isp_of(query) == "Mail.ru" for query in Queries):
raise ClientError({"Error": {"Code": "BadRequestException"}}, "BatchGetMetricData")
@@ -724,18 +719,6 @@ class TestGetIdentityIspMetrics(TestCase):
assert any("SES rejected a metric query" in line for line in logs.output)
assert [row.isp for row in rows] == ["Gmail", "Yahoo"]
- def test_daily_series_skips_buckets_with_no_sends(self):
- self._serve_series(
- {
- ("Gmail", "SEND"): {"2026-08-01": 10, "2026-08-02": 0},
- ("Gmail", "DELIVERY"): {"2026-08-01": 9, "2026-08-02": 0},
- }
- )
-
- rows = self.provider.get_identity_isp_metrics([TEST_DOMAIN], window_days=30, isps=["Gmail"])
-
- assert [point.date for point in rows[0].daily] == ["2026-08-01"]
-
@parameterized.expand(
[
# A provider that reports complaints: the rate is complaints over the deliveries it
@@ -761,6 +744,24 @@ class TestGetIdentityIspMetrics(TestCase):
rows = self.provider.get_identity_isp_metrics([TEST_DOMAIN], window_days=30, isps=["Gmail"])
assert [row.complaint_rate for row in rows] == [expected]
+ # The base travels with the rate: a caller weighing whether the rate rests on enough
+ # volume has to use it, since emails_sent is far larger and would clear any floor.
+ assert [row.complaint_base for row in rows] == [delivery_complaint]
+
+ def test_soft_rejections_are_reported_apart_from_permanent_bounces(self):
+ self._serve(
+ {
+ ("Icloud", "SEND"): 100,
+ ("Icloud", "DELIVERY"): 92,
+ ("Icloud", "PERMANENT_BOUNCE"): 1,
+ ("Icloud", "TRANSIENT_BOUNCE"): 7,
+ }
+ )
+
+ rows = self.provider.get_identity_isp_metrics([TEST_DOMAIN], window_days=30, isps=["Icloud"])
+
+ assert rows[0].bounce_rate == 0.01
+ assert rows[0].transient_bounce_rate == 0.07
def test_counts_are_summed_across_the_projects_sending_domains(self):
# Each domain is queried separately because EMAIL_IDENTITY is per verified domain, but a
@@ -782,11 +783,11 @@ class TestGetIdentityIspMetrics(TestCase):
self.provider.get_identity_isp_metrics([TEST_DOMAIN], window_days=30, isps=["Gmail", "Yahoo", "Outlook"])
batches = [kwargs["Queries"] for _, kwargs in self.mock_client.batch_get_metric_data.call_args_list]
- # 3 providers plus the identity-wide totals, times 5 metrics, is 20 queries. SES rejects a
+ # 3 providers plus the identity-wide totals, times 6 metrics, is 24 queries. SES rejects a
# batch of more than ten.
- assert [len(batch) for batch in batches] == [10, 10]
+ assert [len(batch) for batch in batches] == [10, 10, 4]
sent = {(_isp_of(query), query["Metric"]) for batch in batches for query in batch}
- assert len(sent) == 20
+ assert len(sent) == 24
def test_the_domain_cap_keeps_the_domains_that_actually_sent(self):
# The cap used to take the first few domains in id order, which is the order they were
diff --git a/products/workflows/frontend/Workflows/Reputation/WorkflowsReputation.stories.tsx b/products/workflows/frontend/Workflows/Reputation/WorkflowsReputation.stories.tsx
index b7ba55366ff8..e799f7850983 100644
--- a/products/workflows/frontend/Workflows/Reputation/WorkflowsReputation.stories.tsx
+++ b/products/workflows/frontend/Workflows/Reputation/WorkflowsReputation.stories.tsx
@@ -10,72 +10,85 @@ import { WorkflowsReputation } from './WorkflowsReputation'
const reputationEndpoint = '/api/projects/:team_id/hog_flows/reputation'
-// A fortnight where Gmail starts filtering us halfway through while everyone else stays fine.
-// This is the shape the project-wide rates hide, so it's what the stories are built around.
-function gmailSeries(): TeamEmailReputationResponseApi['isps'][number]['daily'] {
- return Array.from({ length: 14 }, (_, day) => {
- const filtered = day >= 7
- return {
- date: `2026-08-${String(day + 1).padStart(2, '0')}`,
- emails_sent: 6000,
- delivery_rate: filtered ? 0.42 : 0.97,
- bounce_rate: 0.008,
- }
- })
-}
-
-function steadySeries(deliveryRate: number): TeamEmailReputationResponseApi['isps'][number]['daily'] {
- return Array.from({ length: 14 }, (_, day) => ({
- date: `2026-08-${String(day + 1).padStart(2, '0')}`,
- emails_sent: 900,
- delivery_rate: deliveryRate,
- bounce_rate: 0.004,
- }))
-}
-
const baseResponse: TeamEmailReputationResponseApi = {
aws: { health: 'healthy', sending_status: 'ENABLED', findings: [] },
reputation: { bounce_rate: 0.0062, complaint_rate: 0.0001, emails_sent: 115025 },
- workflows: [],
+ workflows: [
+ {
+ hog_flow_id: '0199c0de-0000-7000-8000-000000000001',
+ hog_flow_name: 'Weekly digest',
+ emails_sent: 42000,
+ bounce_rate: 0.006,
+ complaint_rate: 0.0012,
+ email_sending_paused: false,
+ email_sending_paused_at: null,
+ email_sending_paused_reason: '',
+ },
+ {
+ // Under the complaint floor: 0.56% here is one complaint in 180 sends, so the rate
+ // shows without a verdict. The bounce rate clears its own, much lower, floor.
+ hog_flow_id: '0199c0de-0000-7000-8000-000000000002',
+ hog_flow_name: 'Trial nudge',
+ emails_sent: 180,
+ bounce_rate: 0.011,
+ complaint_rate: 0.0056,
+ email_sending_paused: false,
+ email_sending_paused_at: null,
+ email_sending_paused_reason: '',
+ },
+ ],
isps: [
{
isp: 'Gmail',
emails_sent: 84000,
delivery_rate: 0.69,
bounce_rate: 0.008,
+ transient_bounce_rate: 0.29,
// Gmail runs no feedback loop, so a complaint rate here would be unmeasurable.
complaint_rate: null,
+ complaint_base: 0,
unavailable: [],
- daily: gmailSeries(),
},
{
isp: 'ExchangeOnline',
emails_sent: 12600,
delivery_rate: 0.98,
bounce_rate: 0.004,
+ transient_bounce_rate: 0.012,
complaint_rate: 0.0004,
+ complaint_base: 11800,
unavailable: [],
- daily: steadySeries(0.98),
},
{
isp: 'Icloud',
emails_sent: 8100,
- // Steady, but steadily poor: the case an auto-scaled axis would draw as a flat line
- // indistinguishable from a healthy provider.
delivery_rate: 0.45,
bounce_rate: 0.012,
+ transient_bounce_rate: 0.53,
complaint_rate: null,
+ complaint_base: 0,
unavailable: [],
- daily: steadySeries(0.45),
},
{
isp: 'Yahoo',
emails_sent: 6300,
delivery_rate: 0.96,
bounce_rate: 0.006,
+ transient_bounce_rate: 0.03,
complaint_rate: 0.0011,
+ complaint_base: 900,
+ unavailable: [],
+ },
+ {
+ // Too little volume to rate: one bounce here would read as 12.5%.
+ isp: 'Aol',
+ emails_sent: 8,
+ delivery_rate: 1,
+ bounce_rate: 0,
+ transient_bounce_rate: 0,
+ complaint_rate: 0,
+ complaint_base: 8,
unavailable: [],
- daily: steadySeries(0.96),
},
],
isp_shared_domains: [],
diff --git a/products/workflows/frontend/Workflows/Reputation/WorkflowsReputation.tsx b/products/workflows/frontend/Workflows/Reputation/WorkflowsReputation.tsx
index 39850a38ed61..fbf2922c55e1 100644
--- a/products/workflows/frontend/Workflows/Reputation/WorkflowsReputation.tsx
+++ b/products/workflows/frontend/Workflows/Reputation/WorkflowsReputation.tsx
@@ -2,7 +2,6 @@ import { useActions, useValues } from 'kea'
import { LemonBanner, LemonInput, LemonTable, LemonTag, LemonTagType, Link, Tooltip } from '@posthog/lemon-ui'
-import { Sparkline } from 'lib/components/Sparkline'
import { LemonProgress } from 'lib/lemon-ui/LemonProgress'
import { humanFriendlyNumber, percentage } from 'lib/utils/numbers'
import { urls } from 'scenes/urls'
@@ -47,6 +46,12 @@ const RATE_THRESHOLDS = {
type RateLevel = 'healthy' | 'elevated' | 'high'
+// Below this much volume one event on its own clears the elevated line, so a tag would be
+// reporting noise: one bounce in 20 sends reads as 5%.
+function minimumVolumeToClassify(kind: 'bounce' | 'complaint'): number {
+ return Math.ceil(1 / RATE_THRESHOLDS[kind].elevated)
+}
+
function classifyRate(rate: number, kind: 'bounce' | 'complaint'): RateLevel {
const thresholds = RATE_THRESHOLDS[kind]
if (rate >= thresholds.high) {
@@ -81,10 +86,31 @@ function MissingRate({ reason }: { reason: 'unavailable' | 'no-rate' }): JSX.Ele
)
}
-function RateCell({ rate, kind }: { rate: number; kind: 'bounce' | 'complaint' }): JSX.Element {
+function RateCell({
+ rate,
+ kind,
+ // What the rate divides by, which differs per kind: sends for bounces, and for complaints the
+ // far smaller set of deliveries the provider reports them for.
+ volume,
+}: {
+ rate: number
+ kind: 'bounce' | 'complaint'
+ volume: number
+}): JSX.Element {
+ const label = kind === 'bounce' ? 'bounce rate' : 'spam complaint rate'
+ const minimumVolume = minimumVolumeToClassify(kind)
+ if (volume < minimumVolume) {
+ const noun = kind === 'bounce' ? 'emails sent' : 'deliveries this provider reports complaints for'
+ return (
+ <Tooltip
+ title={`Too little volume to judge the ${label}. Under ${humanFriendlyNumber(minimumVolume)} ${noun}, one ${kind === 'bounce' ? 'bounce' : 'complaint'} on its own would put this above ${formatRate(RATE_THRESHOLDS[kind].elevated)}.`}
+ >
+ <span className="tabular-nums text-secondary cursor-default">{formatRate(rate)}</span>
+ </Tooltip>
+ )
+ }
const level = classifyRate(rate, kind)
const tag = RATE_LEVEL_TAG[level]
- const label = kind === 'bounce' ? 'bounce rate' : 'spam complaint rate'
const highPct = formatRate(RATE_THRESHOLDS[kind].high)
const elevatedPct = formatRate(RATE_THRESHOLDS[kind].elevated)
const tooltip =
@@ -172,9 +198,6 @@ function AwsFindings({ aws }: { aws: AwsTenantReputationApi }): JSX.Element | nu
)
}
-// A single point is a reading, not a trend, so the column stays empty until there are two.
-const MIN_TREND_POINTS = 2
-
// SES names providers as one capitalized word, which is not how people write most of them. Only
// the names that read wrong are listed; anything absent is shown as SES reports it, so a provider
// added to SES_ISP_DIMENSIONS still renders without a matching entry here. `__other__` is the
@@ -190,57 +213,21 @@ function ispDisplayName(isp: string): string {
return ISP_DISPLAY_NAMES[isp] ?? isp
}
-// Every row is drawn against the same dates: the days any provider sent on. A provider only appears
-// on its own send days, so without this each row stretches its own handful of dates across the full
-// width — a provider whose last send was two weeks ago ends level with one that sent yesterday, and
-// a ten-day gap draws like a one-day gap.
-function trendDates(isps: readonly IspSendingHealthApi[]): string[] {
- return [...new Set(isps.flatMap((isp) => isp.daily.map((point) => point.date)))].sort()
-}
-
-// NaN rather than 0 for a day with no sends to this provider: the renderer breaks the line at a
-// non-finite value, so the gap reads as "nothing sent" instead of as a drop to zero.
-function alignToDates(isp: IspSendingHealthApi, dates: string[]): number[] {
- const byDate = new Map(isp.daily.map((point) => [point.date, point.delivery_rate * 100]))
- return dates.map((date) => byDate.get(date) ?? Number.NaN)
-}
-
-function DeliveryTrend({ isp, dates }: { isp: IspSendingHealthApi; dates: string[] }): JSX.Element {
- // An empty box of the same size rather than nothing: a provider with too few points to draw
- // would otherwise collapse its row, and the table's rows would step up and down the column.
- if (isp.daily.length < MIN_TREND_POINTS) {
- return <div className="h-8 w-28" aria-hidden />
- }
- return (
- <Sparkline
- data={alignToDates(isp, dates)}
- labels={dates}
- name={`${ispDisplayName(isp.isp)} delivery rate (%)`}
- type="line"
- renderTooltipValue={(value) => `${value.toFixed(1)}%`}
- // Fixed 0-100 rather than auto-scaled per row: these are read against each other, and
- // an auto-scaled axis draws a steady 40% provider identically to a steady 98% one.
- valueDomain={{ min: 0, max: 100 }}
- // Sizes Sparkline's own container: without a height it grows to fill the table cell
- // and the chart bleeds across rows.
- className="h-8 w-28"
- />
- )
-}
-
function IspBreakdown({
isps,
sharedDomains,
+ emailsSent,
}: {
isps: readonly IspSendingHealthApi[]
sharedDomains: readonly string[]
+ /** The card's own total, to reconcile against. Null when the project sent no workflow email. */
+ emailsSent: number | null
}): JSX.Element | null {
// The API returns [] unless the flag and access checks pass on its side, so gating on isps alone
// keeps one decision. A second client flag check can bucket differently and hide returned rows.
if (isps.length === 0) {
return null
}
- const dates = trendDates(isps)
return (
<div className="mt-4 space-y-2" data-attr="workflows-reputation-isp-breakdown">
<MetricLabel
@@ -282,20 +269,29 @@ function IspBreakdown({
),
},
{
- title: 'Delivery trend',
- key: 'delivery_trend',
- tooltip: 'Every provider is drawn on the same 0-100% axis, so rows can be compared by height.',
- render: (_, row: IspSendingHealthApi) => <DeliveryTrend isp={row} dates={dates} />,
- },
- {
- title: 'Bounce rate',
+ title: 'Hard bounce rate',
key: 'bounce_rate',
+ tooltip:
+ 'Permanent rejections: the address does not exist, or the provider refused the mail outright.',
align: 'right',
render: (_, row: IspSendingHealthApi) =>
row.bounce_rate === null ? (
<MissingRate reason="unavailable" />
) : (
- <RateCell rate={row.bounce_rate} kind="bounce" />
+ <RateCell rate={row.bounce_rate} kind="bounce" volume={row.emails_sent} />
+ ),
+ },
+ {
+ title: 'Soft bounce rate',
+ key: 'transient_bounce_rate',
+ tooltip:
+ 'Temporary rejections the provider may accept on a retry, such as a full mailbox, rate limiting, or a provider holding mail from a sender it does not recognize yet. These are why a delivery rate can fall short without any hard bounces.',
+ align: 'right',
+ render: (_, row: IspSendingHealthApi) =>
+ row.transient_bounce_rate === null ? (
+ <MissingRate reason="unavailable" />
+ ) : (
+ <span className="tabular-nums">{formatRate(row.transient_bounce_rate)}</span>
),
},
{
@@ -308,7 +304,7 @@ function IspBreakdown({
reason={row.unavailable?.includes('complaint') ? 'unavailable' : 'no-rate'}
/>
) : (
- <RateCell rate={row.complaint_rate} kind="complaint" />
+ <RateCell rate={row.complaint_rate} kind="complaint" volume={row.complaint_base} />
),
},
{
@@ -319,6 +315,32 @@ function IspBreakdown({
},
]}
/>
+ {sharedDomains.length === 0 && <IspCoverage isps={isps} emailsSent={emailsSent} />}
+ </div>
+ )
+}
+
+// The card counts every workflow email sent; the table counts what AWS attributed to the verified
+// domains. Different populations, and the table is routinely the smaller one.
+//
+// Only sound while no domain is shared. A shared domain puts another project's mail in the table
+// but not in the card, so the two stop being comparable and the caller withholds this.
+function IspCoverage({
+ isps,
+ emailsSent,
+}: {
+ isps: readonly IspSendingHealthApi[]
+ emailsSent: number | null
+}): JSX.Element | null {
+ const attributed = isps.reduce((total, isp) => total + isp.emails_sent, 0)
+ if (emailsSent === null || attributed >= emailsSent) {
+ return null
+ }
+ return (
+ <div className="text-secondary text-xs" data-attr="workflows-reputation-isp-coverage">
+ Covers {humanFriendlyNumber(attributed)} of the {humanFriendlyNumber(emailsSent)} emails this project sent.
+ The rest went out from a domain this breakdown does not cover, or your email provider has not reported on it
+ yet.
</div>
)
}
@@ -380,7 +402,7 @@ function TeamRatesCard({
</div>
)}
{aws && <AwsFindings aws={aws} />}
- <IspBreakdown isps={isps} sharedDomains={sharedDomains} />
+ <IspBreakdown isps={isps} sharedDomains={sharedDomains} emailsSent={reputation?.emails_sent ?? null} />
{withheldDomains.length > 0 && (
<div className="text-secondary text-xs mt-3" data-attr="workflows-reputation-isp-withheld">
{withheldDomains.join(', ')} {withheldDomains.length > 1 ? 'are' : 'is'} left out of the provider
@@ -540,7 +562,7 @@ export function WorkflowsReputation(): JSX.Element {
key: 'bounce_rate',
align: 'right',
render: (_, snapshot: WorkflowEmailSendingRatesApi) => (
- <RateCell rate={snapshot.bounce_rate} kind="bounce" />
+ <RateCell rate={snapshot.bounce_rate} kind="bounce" volume={snapshot.emails_sent} />
),
},
{
@@ -548,7 +570,7 @@ export function WorkflowsReputation(): JSX.Element {
key: 'complaint_rate',
align: 'right',
render: (_, snapshot: WorkflowEmailSendingRatesApi) => (
- <RateCell rate={snapshot.complaint_rate} kind="complaint" />
+ <RateCell rate={snapshot.complaint_rate} kind="complaint" volume={snapshot.emails_sent} />
),
},
{
diff --git a/products/workflows/frontend/generated/api.schemas.ts b/products/workflows/frontend/generated/api.schemas.ts
index 8bc813d53394..83179de94b9b 100644
--- a/products/workflows/frontend/generated/api.schemas.ts
+++ b/products/workflows/frontend/generated/api.schemas.ts
@@ -1602,20 +1602,6 @@ export interface WorkflowEmailSendingRatesApi {
readonly email_sending_paused_reason: string
}
-/**
- * One bucket of a provider's sending history.
- */
-export interface IspDailyPointApi {
- /** Bucket date, as an ISO 8601 calendar date. */
- readonly date: string
- /** Emails sent to this provider on this date. */
- readonly emails_sent: number
- /** Emails this provider accepted on this date, divided by emails sent to it (0-1). */
- readonly delivery_rate: number
- /** Hard bounces at this provider on this date, divided by emails sent to it (0-1). */
- readonly bounce_rate: number
-}
-
/**
* How one mailbox provider treated this project's email, from AWS SES's own delivery data.
*/
@@ -1634,15 +1620,20 @@ export interface IspSendingHealthApi {
* @nullable
*/
readonly bounce_rate: number | null
+ /**
+ * Soft (transient) bounces at this provider, divided by emails sent to it (0-1). These are deferrals the provider may accept on a retry, such as a full mailbox, greylisting or rate limiting, so they are counted apart from permanent bounces. Null when the underlying metric could not be loaded from AWS.
+ * @nullable
+ */
+ readonly transient_bounce_rate: number | null
/**
* Spam complaints from this provider, divided by the deliveries it reports complaints for (0-1). Null when there is no rate to state — the provider runs no feedback loop, or nothing was delivered — and also when the metric could not be loaded from AWS.
* @nullable
*/
readonly complaint_rate: number | null
- /** Rates AWS did not return for this provider, from `delivery`, `bounce` and `complaint`. A rate named here is missing, not zero, and the UI says so rather than showing a number. */
+ /** Deliveries the provider reports complaints for, which is what `complaint_rate` divides by. Far smaller than `emails_sent`, so a caller deciding whether the rate rests on enough volume has to weigh it against this. Zero when there is no base. */
+ readonly complaint_base: number
+ /** Rates AWS did not return for this provider, from `delivery`, `bounce`, `transient_bounce` and `complaint`. A rate named here is missing, not zero, and the UI says so rather than showing a number. */
readonly unavailable: readonly string[]
- /** Sending history for this provider, oldest first, so a drop can be dated rather than averaged into the window. Dates this provider received nothing are omitted. */
- readonly daily: readonly IspDailyPointApi[]
}
/**
diff --git a/services/mcp/src/api/generated.ts b/services/mcp/src/api/generated.ts
index e662742fe1a4..3091166c3d0c 100644
--- a/services/mcp/src/api/generated.ts
+++ b/services/mcp/src/api/generated.ts
@@ -49276,20 +49276,6 @@ export namespace Schemas {
identifier: string;
}
- /**
- * One bucket of a provider's sending history.
- */
- export interface IspDailyPoint {
- /** Bucket date, as an ISO 8601 calendar date. */
- readonly date: string;
- /** Emails sent to this provider on this date. */
- readonly emails_sent: number;
- /** Emails this provider accepted on this date, divided by emails sent to it (0-1). */
- readonly delivery_rate: number;
- /** Hard bounces at this provider on this date, divided by emails sent to it (0-1). */
- readonly bounce_rate: number;
- }
-
/**
* How one mailbox provider treated this project's email, from AWS SES's own delivery data.
*/
@@ -49308,15 +49294,20 @@ export namespace Schemas {
* @nullable
*/
readonly bounce_rate: number | null;
+ /**
+ * Soft (transient) bounces at this provider, divided by emails sent to it (0-1). These are deferrals the provider may accept on a retry, such as a full mailbox, greylisting or rate limiting, so they are counted apart from permanent bounces. Null when the underlying metric could not be loaded from AWS.
+ * @nullable
+ */
+ readonly transient_bounce_rate: number | null;
/**
* Spam complaints from this provider, divided by the deliveries it reports complaints for (0-1). Null when there is no rate to state — the provider runs no feedback loop, or nothing was delivered — and also when the metric could not be loaded from AWS.
* @nullable
*/
readonly complaint_rate: number | null;
- /** Rates AWS did not return for this provider, from `delivery`, `bounce` and `complaint`. A rate named here is missing, not zero, and the UI says so rather than showing a number. */
+ /** Deliveries the provider reports complaints for, which is what `complaint_rate` divides by. Far smaller than `emails_sent`, so a caller deciding whether the rate rests on enough volume has to weigh it against this. Zero when there is no base. */
+ readonly complaint_base: number;
+ /** Rates AWS did not return for this provider, from `delivery`, `bounce`, `transient_bounce` and `complaint`. A rate named here is missing, not zero, and the UI says so rather than showing a number. */
readonly unavailable: readonly string[];
- /** Sending history for this provider, oldest first, so a drop can be dated rather than averaged into the window. Dates this provider received nothing are omitted. */
- readonly daily: readonly IspDailyPoint[];
}
export interface JiraIssueSignalExtra {