Commit f1e5758
committed
feat(balances): measure usage alerts per basis and fire on usage limits
Move alert firing into balances/usageAlerts/check as resolve → measure →
wasThresholdCrossed → send. Balance bases read the breakdown for their
denominator; usage_limit alerts read the usage-window counter of the cap
that shares their feature and filter, both sides at one now so a rolled
window measures 0 before the event. The webhook carries basis, filter and
a balance or usage_limit block, and the idempotency key includes basis,
filter and window start.
Entity subjects keep customer-scope usage window rows after deduction so
a cap inherited from the customer can fire on an entity track.1 parent 22e1b56 commit f1e5758
33 files changed
Lines changed: 2174 additions & 408 deletions
File tree
- server
- src/internal/balances
- trackWebhooks
- usageAlerts/check
- measure
- resolve
- send
- types
- utils
- deductionV2
- usageWindows
- tests
- integration/balances
- track/usage-alerts
- utils/usage-alert-utils
- unit
- balances
- trackWebhooks
- usageAlerts
- billing
Lines changed: 0 additions & 305 deletions
This file was deleted.
Lines changed: 6 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
12 | | - | |
13 | 13 | | |
14 | 14 | | |
15 | 15 | | |
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
| 25 | + | |
25 | 26 | | |
26 | 27 | | |
27 | 28 | | |
| |||
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| 36 | + | |
35 | 37 | | |
36 | 38 | | |
37 | 39 | | |
| |||
61 | 63 | | |
62 | 64 | | |
63 | 65 | | |
| 66 | + | |
| 67 | + | |
64 | 68 | | |
65 | 69 | | |
| 70 | + | |
66 | 71 | | |
67 | 72 | | |
68 | 73 | | |
| |||
0 commit comments