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!

use plan -> none

Blue Mouse7182d1370040
diff --git a/src/analytics/analytics.service.ts b/src/analytics/analytics.service.ts
index 0c7675a75..f2d97f900 100644
--- a/src/analytics/analytics.service.ts
+++ b/src/analytics/analytics.service.ts
@@ -316,10 +316,11 @@ export class AnalyticsService {
this.checkIpBlacklist(project, ip)
- if (!project.active)
+ if (!project.active) {
throw new BadRequestException(
'Incoming analytics is disabled for this project',
)
+ }
if (!isSelfhosted) {
const count = await this.projectService.getRedisCount(project.admin.id)
diff --git a/src/user/entities/user.entity.ts b/src/user/entities/user.entity.ts
index 48e36f1c3..0964c3414 100644
--- a/src/user/entities/user.entity.ts
+++ b/src/user/entities/user.entity.ts
@@ -16,6 +16,7 @@ import { Complaint } from '../../marketplace/complaints/entities/complaint.entit
import { RefreshToken } from './refresh-token.entity'
export enum PlanCode {
+ none = 'none',
free = 'free',
trial = 'trial',
hobby = 'hobby',
@@ -25,6 +26,15 @@ export enum PlanCode {
}
export const ACCOUNT_PLANS = {
+ [PlanCode.none]: {
+ id: PlanCode.none,
+ displayName: 'No plan',
+ monthlyUsageLimit: 0,
+ maxProjects: 0,
+ maxAlerts: 0,
+ maxApiKeyRequestsPerHour: 0,
+ legacy: false,
+ },
[PlanCode.free]: {
id: PlanCode.free,
displayName: 'Free plan',
@@ -152,11 +162,6 @@ export class User {
@Column({ default: false })
isActive: boolean
- // true -> the user is on an active trial subscription or is a paying customer
- // false -> trial has expired without receiving a payment or user cancelled subscription
- @Column({ default: false })
- isPaymentActive: boolean
-
@Column({ type: 'timestamp', nullable: true })
trialEndDate: Date
diff --git a/src/user/user.controller.ts b/src/user/user.controller.ts
index cad812de9..42fbf41ac 100644
--- a/src/user/user.controller.ts
+++ b/src/user/user.controller.ts
@@ -37,7 +37,6 @@ import {
MAX_EMAIL_REQUESTS,
PlanCode,
Theme,
- TimeFormat,
} from './entities/user.entity'
import { Roles } from '../auth/decorators/roles.decorator'
import { Pagination } from '../common/pagination/pagination'
@@ -236,7 +235,7 @@ export class UserController {
throw new BadRequestException(`User with id ${id} does not exist`)
}
- if (user.planCode !== PlanCode.free) {
+ if (user.planCode !== PlanCode.free && user.planCode !== PlanCode.trial) {
throw new BadRequestException('cancelSubFirst')
}
@@ -274,7 +273,7 @@ export class UserController {
select: ['id', 'planCode'],
})
- if (user.planCode !== PlanCode.free) {
+ if (user.planCode !== PlanCode.free && user.planCode !== PlanCode.trial) {
throw new BadRequestException('cancelSubFirst')
}
@@ -566,6 +565,7 @@ export class UserController {
'twoFactorAuthenticationSecret',
'isTwoFactorAuthenticationEnabled',
'isTelegramChatIdConfirmed',
+ 'trialEndDate',
])
await this.userService.update(id, userToUpdate)
diff --git a/src/webhook/webhook.controller.ts b/src/webhook/webhook.controller.ts
index c1ea34cd6..9ac50188f 100644
--- a/src/webhook/webhook.controller.ts
+++ b/src/webhook/webhook.controller.ts
@@ -96,7 +96,6 @@ export class WebhookController {
billingFrequency: monthlyBilling
? BillingFrequency.Monthly
: BillingFrequency.Yearly,
- isPaymentActive: true,
}
if (uid) {
@@ -114,8 +113,7 @@ export class WebhookController {
const { subscription_id } = body
await this.userService.updateBySubID(subscription_id, {
- // planCode: PlanCode.free,
- isPaymentActive: false,
+ planCode: PlanCode.none,
billingFrequency: BillingFrequency.Monthly,
})