Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions supabase/migrations/20261106120000_email_send_log_reason.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
-- Record why a POST /api/emails attempt was rejected or failed (recoupable/app#1949 F2).
--
-- 59% of logged sends were `rejected` with nothing to say why: the rejected
-- path stored only the raw body, and the earlier `error` column was dropped in
-- 20260630211500 because nothing filled it. `reason` is written by api
-- `logEmailAttempt` on the rejected and send_failed paths as a short code
-- followed by detail, e.g. `recipient_not_allowed: a@example.com`, so the
-- rejection rate can be grouped by cause. Null for successful sends.

ALTER TABLE public.email_send_log ADD COLUMN IF NOT EXISTS reason TEXT;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3: reason combines the cause code and the per-send detail (such as a recipient address) in one free-text value. A plain GROUP BY reason will split rejections by recipient, not by cause. Consider separate reason_code and reason_detail columns, or document the split_part(reason, ': ', 1) grouping for analysts. The column is not yet populated, so changing it now is cheap.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At supabase/migrations/20261106120000_email_send_log_reason.sql, line 10:

<comment>`reason` combines the cause code and the per-send detail (such as a recipient address) in one free-text value. A plain `GROUP BY reason` will split rejections by recipient, not by cause. Consider separate `reason_code` and `reason_detail` columns, or document the `split_part(reason, ': ', 1)` grouping for analysts. The column is not yet populated, so changing it now is cheap.</comment>

<file context>
@@ -0,0 +1,10 @@
+-- followed by detail, e.g. `recipient_not_allowed: a@example.com`, so the
+-- rejection rate can be grouped by cause. Null for successful sends.
+
+ALTER TABLE public.email_send_log ADD COLUMN IF NOT EXISTS reason TEXT;
</file context>

Loading