Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion modules/billing/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ e.g. `500 * (1 - 80/100) = 99.99999999999997`, silently missing an exact boundar
comparing the debit's own pre/post balance, and emits `billing.extras.balance_threshold_crossed`
(`{ organizationId, threshold, remaining, planId }`). `billing.email.js` sends a
credit-warning (80%) or credit-exhausted (100%) email off of it.
The subjects use `billing.alerts.balanceUnit` as a plural unit word (default `'credits'`); set it
The subjects use `billing.alerts.balanceUnit` as the unit word, plural or not (default `'credits'`); set it
when your templates speak in another unit, so subject and body agree.

- **Stateless — no `alertedAtN` field.** The weekly `alertedAt80`/`alertedAt100` fields
Expand Down
2 changes: 1 addition & 1 deletion modules/billing/billing.email.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const setupBillingEmails = () => {
{
to: email,
subject: isWarning
? `${appName} — your ${unit} are running low`
? `${appName} — you are running low on ${unit}`
: `${appName} — you are out of ${unit}`,
template: isWarning ? 'billing-credit-warning' : 'billing-credit-exhausted',
params: {
Expand Down
2 changes: 1 addition & 1 deletion modules/billing/config/billing.development.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const config = {
},
alerts: {
thresholdPercents: [80, 100],
// Plural unit word in the balance-alert mail subjects ("your credits are running low").
// Unit word in the balance-alert mail subjects ("you are running low on credits").
balanceUnit: 'credits',
},
events: {
Expand Down
4 changes: 2 additions & 2 deletions modules/billing/tests/billing.init.email-alerts.unit.tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ describe('billing.email setupBillingEmails listeners:', () => {
expect(mockMailer.sendMail).toHaveBeenCalledWith(
expect.objectContaining({
to: 'owner@test.com',
subject: 'MyApp — your credits are running low',
subject: 'MyApp — you are running low on credits',
template: 'billing-credit-warning',
params: expect.objectContaining({ remaining: 100 }),
}),
Expand Down Expand Up @@ -422,7 +422,7 @@ describe('billing.email setupBillingEmails listeners:', () => {
await new Promise((r) => setImmediate(r));

expect(mockMailer.sendMail).toHaveBeenCalledWith(
expect.objectContaining({ subject: 'MyApp — your tokens are running low' }),
expect.objectContaining({ subject: 'MyApp — you are running low on tokens' }),
);
expect(mockMailer.sendMail).toHaveBeenCalledWith(
expect.objectContaining({ subject: 'MyApp — you are out of tokens' }),
Expand Down
Loading