Throttle low-credit warning emails and add a UI opt-out #411
Labels
No labels
Compat/Breaking
Component/Enclave-Builder
Component/Infrastructure
Deploy/BYOC
Deploy/Full-managed
Deploy/Self-hosted
Interface/API
Interface/CLI
Interface/Git
Interface/Web
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority/Critical
Priority/High
Priority/Low
Priority/Medium
Reviewed/Confirmed
Reviewed/Duplicate
Reviewed/Invalid
Reviewed/Won't Fix
Status/Abandoned
Status/Blocked
Status/Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
public/platform#411
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
When an organization is low on credits, the warning email should be useful without becoming noisy. If the balance remains below the threshold, users should not receive repeated low-credit warning emails more than once per day.
Users should also have a product-visible way to turn off this specific notification if they do not want low-credit warning emails.
Desired behavior
Acceptance criteria
Notes / open questions
Implementation notes from a quick code inspection/discussion:
src/metering/src/balance.rs: low-balance warnings readbilling_config.low_balance_warned_at, send only when it is missing or older than 24h, then update it toNOW().billing_configrow. In that case the current code treats the missing timestamp as eligible to send, then runsUPDATE billing_config SET low_balance_warned_at = NOW() WHERE organization_id = $1, which updates zero rows. The next hourly collection can then send again.initialize_user_accountandcreate_organizationcreate organizations/members but do not appear to create a neutralbilling_configrow.Suggested minimal fix shape:
low_balance_warned_at = NOW()during the backfill to avoid an immediate post-deploy notification wave; otherwise a neutral row with defaults is fine.billing_configrow whenever a new organization is created:organizations.settingsJSONB, defaulting enabled. A true per-user notification preference would be a larger follow-up becausesend_dunning_emailcurrently fans out to all organization member emails.A neutral
billing_configrow means roughly: prepaid mode, no Paddle customer/subscription, no auto-topup, no payment method, no previous low-balance warning timestamp. The credit balance itself lives in ledger/balance tables, not inbilling_config.