📈 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
Added DTO for custom events
Blaumausf63a4bc88596
diff --git a/src/analytics/analytics.controller.ts b/src/analytics/analytics.controller.tsindex 854948424..22593761c 100644--- a/src/analytics/analytics.controller.ts+++ b/src/analytics/analytics.controller.ts@@ -8,7 +8,7 @@ import { UserType } from '../user/entities/user.entity'import { Pagination } from '../common/pagination/pagination'import { Analytics } from './entity/analytics.entity'import { UserService } from '../user/user.service'-import { EventsDTO } from './dto/events.dto'+import { PageviewsDTO } from './dto/pageviews.dto'import { AppLoggerService } from '../logger/logger.service'@ApiTags('Analytics')diff --git a/src/analytics/analytics.service.ts b/src/analytics/analytics.service.tsindex 2392f7374..791a7791b 100644--- a/src/analytics/analytics.service.ts+++ b/src/analytics/analytics.service.ts@@ -4,7 +4,7 @@ import { Repository } from 'typeorm'import { Pagination, PaginationOptionsInterface } from '../common/pagination'import { Analytics } from './entity/analytics.entity'-import { EventsDTO } from './dto/events.dto'+import { PageviewsDTO } from './dto/pageviews.dto'import { ProjectService } from '../project/project.service'@Injectable()@@ -35,11 +35,11 @@ export class AnalyticsService {return this.analyticsRepository.count()}- async create(project: EventsDTO | Analytics): Promise<Analytics> {+ async create(project: PageviewsDTO | Analytics): Promise<Analytics> {return this.analyticsRepository.save(project)}- async update(id: string, eventsDTO: EventsDTO): Promise<any> {+ async update(id: string, eventsDTO: PageviewsDTO): Promise<any> {return this.analyticsRepository.update(id, eventsDTO)}diff --git a/src/analytics/dto/events.dto.ts b/src/analytics/dto/events.dto.tsindex 8079a8367..2791878af 100644--- a/src/analytics/dto/events.dto.ts+++ b/src/analytics/dto/events.dto.ts@@ -11,64 +11,18 @@ export class EventsDTO {pid: string@ApiProperty({- example: 'pageviews',+ example: 'user-subscribed',description: 'Event type'})ev: string// Tracking metrics@ApiProperty({- example: 'UTC+2',- description: 'User\'s timezone'+ example: {+ ref: 'duckduckgo',+ plan: 'gold+',+ },+ description: 'Custom parameters related to the event'})- tz: string-- @ApiProperty({- example: '/articles/my-awesome-article-1',- description: 'A page that user sent data from'- })- pg: string-- @ApiProperty({- example: 'en-GB',- description: 'User\'s locale'- })- lc: string-- @ApiProperty({- example: 'https://example.com',- description: 'The referrer'- })- ref: string-- @ApiProperty({- example: 1920,- description: 'Screen width'- })- sw: number-- @ApiProperty({- example: 'duckduckgo',- description: 'utm_source URL parameter'- })- so: string-- @ApiProperty({- example: 'cpc',- description: 'utm_medium URL parameter'- })- me: string-- @ApiProperty({- example: 'spring_sale',- description: 'utm_campaign URL parameter'- })- ca: string-- // Performance metrics- @ApiProperty({- example: 261,- description: 'Page load time (in milliseconds)'- })- lt: number+ params: object}\ No newline at end of filediff --git a/src/analytics/dto/pageviews.dto.ts b/src/analytics/dto/pageviews.dto.tsnew file mode 100644index 000000000..5332cae38--- /dev/null+++ b/src/analytics/dto/pageviews.dto.ts@@ -0,0 +1,74 @@+import { ApiProperty } from '@nestjs/swagger'+import { IsNotEmpty } from 'class-validator'++export class PageviewsDTO {+ @ApiProperty({+ example: 'aUn1quEid-3',+ required: true,+ description: 'The project ID'+ })+ @IsNotEmpty()+ pid: string++ @ApiProperty({+ example: 'pageviews',+ description: 'Event type'+ })+ ev: string++ // Tracking metrics+ @ApiProperty({+ example: 'UTC+2',+ description: 'User\'s timezone'+ })+ tz: string++ @ApiProperty({+ example: '/articles/my-awesome-article-1',+ description: 'A page that user sent data from'+ })+ pg: string++ @ApiProperty({+ example: 'en-GB',+ description: 'User\'s locale'+ })+ lc: string++ @ApiProperty({+ example: 'https://example.com',+ description: 'The referrer'+ })+ ref: string++ @ApiProperty({+ example: 1920,+ description: 'Screen width'+ })+ sw: number++ @ApiProperty({+ example: 'duckduckgo',+ description: 'utm_source URL parameter'+ })+ so: string++ @ApiProperty({+ example: 'cpc',+ description: 'utm_medium URL parameter'+ })+ me: string++ @ApiProperty({+ example: 'spring_sale',+ description: 'utm_campaign URL parameter'+ })+ ca: string++ // Performance metrics+ @ApiProperty({+ example: 261,+ description: 'Page load time (in milliseconds)'+ })+ lt: number+}\ No newline at end of file