Balance Alerts
site-insight-balance-alert sends a low-balance push notification when a user’s newly linked main account is below their configured threshold and they are float-eligible. It consumes new_account events (txn-service.feeder) tapped to SQS — see Events. The message detail is a Transactions Service account (user_id, is_main, balances).
Flow
Messages in a batch are processed concurrently; each account runs the Guards in order and stops silently at the first that applies.
-
Evaluate the
availablebalance, orcurrentwhenavailableis zero. -
Take the per-user lock in the
lockstable (schema); released when the message finishes. -
Read the
alertentity and apply the cooldown guard. -
Read
low_balance_alertfromuser-balance-settings(schema) and apply the opt-out and threshold guards. -
Call Underwriting
FloatRequestwith amount 0 and apply the eligibility guard. -
Write the
alertentity (alert_sent: true, balances, threshold). -
When
NOTIFICATION_FLAGis true, dispatch thelow_balance_alertSegment event withnew_available_balanceandnew_current_balancein dollars. Metricinsight.balance.alerts.
Source: pkg/balance-alert/processor.go
Guards
| Guard | Skip when |
|---|---|
Disregard |
Balance above $50.00, account is not |
Cooldown |
|
Opted out |
|
Above threshold |
Balance above |
Not eligible |
Underwriting |
Source: pkg/balance-alert/models.go, pkg/balance-alert/processor.go
Any error (lock, DynamoDB, settings, Underwriting, Segment) fails the batch item; the message retries up to 5 times before the DLQ. The alert row is written before the Segment call, so the cooldown applies even if delivery fails.