📈 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!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
implemented some basic trial logic
Blue Mouse087e977d9f3e
diff --git a/src/auth/auth.service.ts b/src/auth/auth.service.tsindex a750d4631..a3442c4f2 100644--- a/src/auth/auth.service.ts+++ b/src/auth/auth.service.ts@@ -14,7 +14,7 @@ import {import { ActionTokensService } from 'src/action-tokens/action-tokens.service'import { LetterTemplate } from 'src/mailer/letter'import { MailerService } from 'src/mailer/mailer.service'-import { MAX_EMAIL_REQUESTS, User } from 'src/user/entities/user.entity'+import { MAX_EMAIL_REQUESTS, User, TRIAL_DURATION } from 'src/user/entities/user.entity'import { TelegrafContext } from 'src/user/user.controller'import { UserService } from 'src/user/user.service'import { ProjectService } from 'src/project/project.service'@@ -103,6 +103,8 @@ export class AuthService {const user = await this.userService.createUser({email,password: hashedPassword, // Using the password field is incorrect.+ // @ts-ignore+ trialEndDate: dayjs.utc().add(TRIAL_DURATION, 'day').format('YYYY-MM-DD HH:mm:ss'),})await this.sendVerificationEmail(user.id, user.email)diff --git a/src/user/entities/user.entity.ts b/src/user/entities/user.entity.tsindex 01fcd360c..a29430a31 100644--- a/src/user/entities/user.entity.ts+++ b/src/user/entities/user.entity.ts@@ -109,6 +109,8 @@ export const MAX_EMAIL_REQUESTS = 4 // 1 confirmation email on sign up + 3 additexport const DEFAULT_TIMEZONE = 'Etc/GMT'+export const TRIAL_DURATION = 14 // days+@Entity()export class User {@PrimaryGeneratedColumn('uuid')@@ -142,9 +144,12 @@ export class User {// 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: true })+ @Column({ default: false })isPaymentActive: boolean+ @Column({ type: 'timestamp', nullable: true })+ trialEndDate: Date+@Column({type: 'enum',enum: ReportFrequency,diff --git a/src/user/user.service.ts b/src/user/user.service.tsindex f56c1b911..1c20ee7a9 100644--- a/src/user/user.service.ts+++ b/src/user/user.service.ts@@ -161,7 +161,7 @@ export class UserService {return await this.usersRepository.findOne({ email })}- public async createUser(user: Pick<User, 'email' | 'password'>) {+ public async createUser(user: Pick<User, 'email' | 'password' | 'trialEndDate'>) {return await this.usersRepository.save(user)}