Skip to content

Commit 4b8b2e9

Browse files
feat(billing): Convert referral bonuses from monthly recurring to one-time credits, and bump them from 250 -> 500 (#422)
1 parent 20e0b8e commit 4b8b2e9

File tree

15 files changed

+847
-87
lines changed

15 files changed

+847
-87
lines changed

common/src/constants/grant-priorities.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
import type { GrantType } from '@codebuff/common/types/grant'
22

3+
// Lower = consumed first
34
export const GRANT_PRIORITIES: Record<GrantType, number> = {
45
subscription: 10,
56
free: 20,
6-
referral: 30,
7+
referral_legacy: 30, // Legacy recurring referrals (renews monthly, consumed first)
78
ad: 40,
9+
referral: 50, // One-time referrals (never expires, preserved longer)
810
admin: 60,
911
organization: 70,
1012
purchase: 80,

common/src/constants/limits.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const MAX_DATE = new Date(86399999999999)
55
export const BILLING_PERIOD_DAYS = 30
66
export const SESSION_MAX_AGE_SECONDS = 30 * 24 * 60 * 60 // 30 days
77
export const SESSION_TIME_WINDOW_MS = 30 * 60 * 1000 // 30 minutes - used for matching sessions created around fingerprint creation
8-
export const CREDITS_REFERRAL_BONUS = 250
8+
export const CREDITS_REFERRAL_BONUS = 500
99
export const AFFILIATE_USER_REFFERAL_LIMIT = 500
1010

1111
// Default number of free credits granted per cycle

common/src/types/grant.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export type GrantType =
22
| 'free'
33
| 'referral'
4+
| 'referral_legacy'
45
| 'subscription'
56
| 'purchase'
67
| 'admin'
@@ -10,6 +11,7 @@ export type GrantType =
1011
export const GrantTypeValues = [
1112
'free',
1213
'referral',
14+
'referral_legacy',
1315
'subscription',
1416
'purchase',
1517
'admin',

0 commit comments

Comments
 (0)