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!

Add Enum type to the View DTO and Entity

Yehor Dremliuha45735fbf0b39
diff --git a/apps/production/src/project/dto/create-project-view.dto.ts b/apps/production/src/project/dto/create-project-view.dto.ts
index 05a5f29ad..e83ae8c0f 100644
--- a/apps/production/src/project/dto/create-project-view.dto.ts
+++ b/apps/production/src/project/dto/create-project-view.dto.ts
@@ -1,9 +1,13 @@
import { ApiProperty } from '@nestjs/swagger'
+import { ProjectViewType } from '../entity/project-view.entity'
export class CreateProjectViewDto {
@ApiProperty()
name: string
+ @ApiProperty({ description: 'Type of the view', enum: ProjectViewType })
+ type: ProjectViewType
+
@ApiProperty({ description: 'Page the user viewed (/hello)', nullable: true })
pg: string | null
diff --git a/apps/production/src/project/entity/project-view.entity.ts b/apps/production/src/project/entity/project-view.entity.ts
index b7b19ee4b..182a9751f 100644
--- a/apps/production/src/project/entity/project-view.entity.ts
+++ b/apps/production/src/project/entity/project-view.entity.ts
@@ -10,6 +10,11 @@ import {
import { ApiProperty } from '@nestjs/swagger'
import { Project } from './project.entity'
+export enum ProjectViewType {
+ TRAFFIC = 'traffic',
+ PERFORMANCE = 'performance',
+}
+
@Entity('project_views')
export class ProjectViewEntity {
@ApiProperty()
@@ -20,6 +25,10 @@ export class ProjectViewEntity {
@Column('varchar')
name: string
+ @ApiProperty({ enum: ProjectViewType })
+ @Column('enum', { enum: ProjectViewType })
+ type: ProjectViewType
+
@ApiProperty()
@Column()
projectId: string