@@ -32,11 +32,7 @@ import { KiloPassError } from '@/lib/kilo-pass/errors';
3232import { isStripeSubscriptionEnded } from '@/lib/kilo-pass/stripe-subscription-status' ;
3333import { releaseScheduledChangeForSubscription } from '@/lib/kilo-pass/scheduled-change-release' ;
3434import { appendKiloPassAuditLog } from '@/lib/kilo-pass/issuance' ;
35- import {
36- KILO_PASS_FIRST_MONTH_PROMO_BONUS_PERCENT ,
37- KILO_PASS_MONTHLY_FIRST_2_MONTHS_PROMO_CUTOFF ,
38- KILO_PASS_TIER_CONFIG ,
39- } from '@/lib/kilo-pass/constants' ;
35+ import { KILO_PASS_TIER_CONFIG } from '@/lib/kilo-pass/constants' ;
4036import { fromMicrodollars } from '@/lib/utils' ;
4137import { timedUsageQuery } from '@/lib/usage-query' ;
4238import {
@@ -131,10 +127,6 @@ const GetAverageMonthlyUsageLast3MonthsOutputSchema = z.object({
131127 averageMonthlyUsageUsd : z . number ( ) ,
132128} ) ;
133129
134- function isTwoMonthPromoOfferActive ( ) : boolean {
135- return dayjs ( ) . utc ( ) . isBefore ( KILO_PASS_MONTHLY_FIRST_2_MONTHS_PROMO_CUTOFF ) ;
136- }
137-
138130function roundToCents ( usd : number ) : number {
139131 return Math . round ( usd * 100 ) / 100 ;
140132}
@@ -384,7 +376,7 @@ export const kiloPassRouter = createTRPCRouter({
384376 getState : baseProcedure . output ( GetStateOutputSchema ) . query ( async ( { ctx } ) => {
385377 const subscriptionBase = await getKiloPassStateForUser ( db , ctx . user . id ) ;
386378 if ( ! subscriptionBase ) {
387- return { subscription : null , isEligibleForFirstMonthPromo : isTwoMonthPromoOfferActive ( ) } ;
379+ return { subscription : null , isEligibleForFirstMonthPromo : true } ;
388380 }
389381
390382 const stripeCustomerId = ctx . user . stripe_customer_id ;
@@ -478,22 +470,14 @@ export const kiloPassRouter = createTRPCRouter({
478470 currentPeriodBonusCreditsUsd = roundToCents ( usd ) ;
479471 } else {
480472 const streakMonths = Math . max ( 1 , subscriptionBase . currentStreakMonths ) ;
481- const shouldShowFirstMonthPromo =
482- streakMonths === 1 && isFirstTimeSubscriberEver && isTwoMonthPromoOfferActive ( ) ;
483-
484- if ( shouldShowFirstMonthPromo ) {
485- const cents = Math . round ( baseAmountUsd * KILO_PASS_FIRST_MONTH_PROMO_BONUS_PERCENT * 100 ) ;
486- currentPeriodBonusCreditsUsd = cents / 100 ;
487- } else {
488- const bonusPercentApplied = computeMonthlyCadenceBonusPercent ( {
489- tier : subscriptionBase . tier ,
490- streakMonths,
491- isFirstTimeSubscriberEver,
492- subscriptionStartedAtIso : subscriptionBase . startedAt ,
493- } ) ;
494- const cents = Math . round ( baseAmountUsd * bonusPercentApplied * 100 ) ;
495- currentPeriodBonusCreditsUsd = cents / 100 ;
496- }
473+ const bonusPercentApplied = computeMonthlyCadenceBonusPercent ( {
474+ tier : subscriptionBase . tier ,
475+ streakMonths,
476+ isFirstTimeSubscriberEver,
477+ subscriptionStartedAtIso : subscriptionBase . startedAt ,
478+ } ) ;
479+ const cents = Math . round ( baseAmountUsd * bonusPercentApplied * 100 ) ;
480+ currentPeriodBonusCreditsUsd = cents / 100 ;
497481 }
498482
499483 const nowUtc = dayjs ( ) . utc ( ) ;
0 commit comments