Skip to content

Commit 74cc507

Browse files
brendanhsentrymchen-sentry
authored andcommitted
chore(billing): Reference startDate when filtering active product trials (#108720)
required for getsentry/getsentry#19137 Allows us to schedule product trials in the future
1 parent 392e0e0 commit 74cc507

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

static/gsApp/utils/billing.spec.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,20 @@ describe('getActiveProductTrial', () => {
941941
expect(replay_pt).toBeNull();
942942
});
943943

944+
it('returns null when trial is isStarted but startDate is in the future', () => {
945+
const trials: ProductTrial[] = [
946+
{
947+
category: DataCategory.SPANS,
948+
isStarted: true,
949+
reasonCode: 4001,
950+
startDate: moment().utc().add(5, 'days').format(),
951+
endDate: moment().utc().add(35, 'days').format(),
952+
},
953+
];
954+
const pt = getActiveProductTrial(trials, DataCategory.SPANS);
955+
expect(pt).toBeNull();
956+
});
957+
944958
it('returns null trial when no trials for category', () => {
945959
const pt = getProductTrial(TEST_TRIALS, DataCategory.ATTACHMENTS);
946960
expect(pt).toBeNull();

static/gsApp/utils/billing.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -693,7 +693,8 @@ export function getActiveProductTrial(
693693
pt =>
694694
pt.category === category &&
695695
pt.isStarted &&
696-
getDaysSinceDate(pt.endDate ?? '') <= 0
696+
getDaysSinceDate(pt.endDate ?? '') <= 0 &&
697+
getDaysSinceDate(pt.startDate ?? '') >= 0
697698
)
698699
.sort((a, b) => b.endDate?.localeCompare(a.endDate ?? '') || 0);
699700

0 commit comments

Comments
 (0)