Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Fix: suggested plancode is [object Object]

Blue Mousef4cf0894013a
diff --git a/apps/production/src/task-manager/task-manager.service.ts b/apps/production/src/task-manager/task-manager.service.ts
index f8949e2bf..b602857d0 100644
--- a/apps/production/src/task-manager/task-manager.service.ts
+++ b/apps/production/src/task-manager/task-manager.service.ts
@@ -458,7 +458,7 @@ export class TaskManagerService {
hitPercentageLimit: _includes(exceedingUserIds, user.id),
percentageLimit: TRAFFIC_SPIKE_ALLOWED_PERCENTAGE * 100,
billingUrl: 'https://swetrix.com/billing',
- suggestedPlanLimit,
+ suggestedPlanLimit: suggestedPlanLimit?.monthlyUsageLimit,
}
await this.mailerService.sendEmail(
@@ -525,7 +525,7 @@ export class TaskManagerService {
thisMonthUsage: usage,
percentageLimit: TRAFFIC_SPIKE_ALLOWED_PERCENTAGE * 100,
billingUrl: 'https://swetrix.com/billing',
- suggestedPlanLimit,
+ suggestedPlanLimit: suggestedPlanLimit?.monthlyUsageLimit,
}
await this.mailerService.sendEmail(
@@ -592,7 +592,7 @@ export class TaskManagerService {
lastMonthUsage: userLastMonthUsage,
percentageLimit: TRAFFIC_SPIKE_ALLOWED_PERCENTAGE * 100,
billingUrl: 'https://swetrix.com/billing',
- suggestedPlanLimit,
+ suggestedPlanLimit: suggestedPlanLimit?.monthlyUsageLimit,
}
await this.mailerService.sendEmail(
diff --git a/apps/production/src/user/entities/user.entity.ts b/apps/production/src/user/entities/user.entity.ts
index e09d7d2c1..58b4b4c1d 100644
--- a/apps/production/src/user/entities/user.entity.ts
+++ b/apps/production/src/user/entities/user.entity.ts
@@ -38,6 +38,15 @@ export enum DashboardBlockReason {
'subscription_cancelled' = 'subscription_cancelled',
}
+interface PlanSignature {
+ id: PlanCode
+ monthlyUsageLimit: number
+ maxAlerts: number
+ legacy: boolean
+ pid?: string
+ ypid?: string
+}
+
export const ACCOUNT_PLANS = {
[PlanCode.none]: {
id: PlanCode.none,
@@ -123,19 +132,23 @@ export const ACCOUNT_PLANS = {
},
}
-export const getNextPlan = (planCode: PlanCode) => {
+export const getNextPlan = (planCode: PlanCode): PlanSignature | undefined => {
const currentLimit = ACCOUNT_PLANS[planCode].monthlyUsageLimit
let nextPlan
- Object.values(ACCOUNT_PLANS).some(plan => {
- if (plan.monthlyUsageLimit > currentLimit) {
- nextPlan = plan
- return true
- }
-
- return false
- })
+ Object.values(ACCOUNT_PLANS)
+ .filter(
+ plan => ![PlanCode.free, PlanCode.trial, PlanCode.none].includes(plan.id),
+ )
+ .some(plan => {
+ if (plan.monthlyUsageLimit > currentLimit) {
+ nextPlan = plan
+ return true
+ }
+
+ return false
+ })
return nextPlan
}