📈 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
Move project ID validation to DTOs
Blue Mouse3ced264b00a1
diff --git a/backend/apps/production/src/analytics/analytics.controller.ts b/backend/apps/production/src/analytics/analytics.controller.tsindex 4c9f619ba..5fe27cd80 100644--- a/backend/apps/production/src/analytics/analytics.controller.ts+++ b/backend/apps/production/src/analytics/analytics.controller.ts@@ -44,8 +44,8 @@ import { VALID_PERIODS } from './decorators/validate-period.decorator'import { CurrentUserId } from '../auth/decorators/current-user-id.decorator'import { DEFAULT_TIMEZONE } from '../user/entities/user.entity'import { RolesGuard } from '../auth/guards/roles.guard'-import { PageviewsDTO } from './dto/pageviews.dto'-import { EventsDTO } from './dto/events.dto'+import { PageviewsDto } from './dto/pageviews.dto'+import { EventsDto } from './dto/events.dto'import { GetDataDto, ChartRenderMode } from './dto/getData.dto'import { GetCustomEventMetadata } from './dto/get-custom-event-meta.dto'import { GetPagePropertyMetaDto } from './dto/get-page-property-meta.dto'@@ -77,10 +77,10 @@ import {import { GetSessionsDto } from './dto/get-sessions.dto'import { GetMonitorDataDto } from './dto/get-monitor-data.dto'import { GetSessionDto } from './dto/get-session.dto'-import { ErrorDTO } from './dto/error.dto'+import { ErrorDto } from './dto/error.dto'import { GetErrorsDto } from './dto/get-errors.dto'import { GetErrorDto } from './dto/get-error.dto'-import { PatchStatusDTO } from './dto/patch-status.dto'+import { PatchStatusDto } from './dto/patch-status.dto'import {customEventTransformer,errorEventTransformer,@@ -94,6 +94,8 @@ import {} from '../project/dto/create-project-view.dto'import { extensions } from './utils/ua-parser'import { GetOverallStatsDto } from './dto/get-overall-stats.dto'+import { NoscriptDto } from './dto/noscript.dto'+import { LiveVisitorsDto } from './dto/live-visitors.dto'dayjs.extend(utc)dayjs.extend(dayjsTimezone)@@ -243,7 +245,6 @@ export class AnalyticsController {mode = ChartRenderMode.PERIODICAL,metrics,} = data- this.analyticsService.validatePID(pid)await this.analyticsService.checkProjectAccess(pid,@@ -410,7 +411,6 @@ export class AnalyticsController {pages,funnelId,} = data- this.analyticsService.validatePID(pid)await this.analyticsService.checkProjectAccess(pid,@@ -473,7 +473,6 @@ export class AnalyticsController {@Headers() headers: { 'x-password'?: string },): Promise<ReturnType<typeof this.analyticsService.getCustomEventMetadata>> {const { pid } = data- this.analyticsService.validatePID(pid)await this.analyticsService.checkProjectAccess(pid,@@ -494,7 +493,6 @@ export class AnalyticsController {@Headers() headers: { 'x-password'?: string },): Promise<ReturnType<typeof this.analyticsService.getPagePropertyMeta>> {const { pid } = data- this.analyticsService.validatePID(pid)await this.analyticsService.checkProjectAccess(pid,@@ -515,7 +513,6 @@ export class AnalyticsController {@Headers() headers: { 'x-password'?: string },) {const { pid, type } = data- this.analyticsService.validatePID(pid)await this.analyticsService.checkProjectAccess(pid,@@ -536,7 +533,6 @@ export class AnalyticsController {@Headers() headers: { 'x-password'?: string },) {const { pid, type } = data- this.analyticsService.validatePID(pid)await this.analyticsService.checkProjectAccess(pid,@@ -566,7 +562,6 @@ export class AnalyticsController {timezone = DEFAULT_TIMEZONE,mode = ChartRenderMode.PERIODICAL,} = data- this.analyticsService.validatePID(pid)const [filtersQuery, filtersParams, appliedFilters, customEVFilterApplied] =this.analyticsService.getFiltersQuery(filters, DataType.ANALYTICS)@@ -630,7 +625,6 @@ export class AnalyticsController {timezone = DEFAULT_TIMEZONE,measure = DEFAULT_MEASURE,} = data- this.analyticsService.validatePID(pid)this.analyticsService.checkIfPerfMeasureIsValid(measure)@@ -720,7 +714,6 @@ export class AnalyticsController {timezone = DEFAULT_TIMEZONE,measure = DEFAULT_MEASURE,} = data- this.analyticsService.validatePID(pid)this.analyticsService.checkIfPerfMeasureIsValid(measure)@@ -785,7 +778,6 @@ export class AnalyticsController {@Headers() headers: { 'x-password'?: string },): Promise<IUserFlow | { appliedFilters: any[] }> {const { pid, period, from, to, timezone = DEFAULT_TIMEZONE, filters } = data- this.analyticsService.validatePID(pid)await this.analyticsService.checkProjectAccess(pid,@@ -855,7 +847,6 @@ export class AnalyticsController {const pidsArray = getPIDsArray(pids, pid)const validationPromises = _map(pidsArray, async currentPID => {- this.analyticsService.validatePID(currentPID)await this.analyticsService.checkProjectAccess(currentPID,uid,@@ -896,7 +887,6 @@ export class AnalyticsController {const pidsArray = getPIDsArray(pids, pid)const validationPromises = _map(pidsArray, async currentPID => {- this.analyticsService.validatePID(currentPID)await this.analyticsService.checkProjectAccess(currentPID, uid)await this.analyticsService.checkBillingAccess(currentPID)@@ -940,7 +930,6 @@ export class AnalyticsController {}const validationPromises = _map(pidsArray, async currentPID => {- this.analyticsService.validatePID(currentPID)await this.analyticsService.checkProjectAccess(currentPID,uid,@@ -997,7 +986,6 @@ export class AnalyticsController {const pidsArray = getPIDsArray(pids, pid)const validationPromises = _map(pidsArray, async currentPID => {- this.analyticsService.validatePID(currentPID)await this.analyticsService.checkProjectAccess(currentPID,uid,@@ -1029,13 +1017,12 @@ export class AnalyticsController {@Get('liveVisitors')@Auth([], true, true)async getLiveVisitors(- @Query() queryParams,+ @Query() queryParams: LiveVisitorsDto,@CurrentUserId() uid: string,@Headers() headers: { 'x-password'?: string },): Promise<object> {const { pid } = queryParams- this.analyticsService.validatePID(pid)await this.analyticsService.checkProjectAccess(pid,uid,@@ -1084,7 +1071,7 @@ export class AnalyticsController {@Post('error')@Public()- async logError(@Body() errorDTO: ErrorDTO, @Headers() headers, @Ip() reqIP) {+ async logError(@Body() errorDTO: ErrorDto, @Headers() headers, @Ip() reqIP) {const { 'user-agent': userAgent, origin } = headersconst ip = getIPFromHeaders(headers, true) || reqIP || ''@@ -1141,7 +1128,7 @@ export class AnalyticsController {@Patch('error-status')@Auth([], true, true)async patchStatus(- @Body() statusDTO: PatchStatusDTO,+ @Body() statusDTO: PatchStatusDto,@CurrentUserId() uid: string,@Headers() headers,@Ip() reqIP,@@ -1151,7 +1138,6 @@ export class AnalyticsController {await checkRateLimit(ip, 'error-status', 100, 1800)- this.analyticsService.validatePID(pid)await this.analyticsService.checkManageAccess(pid, uid)await this.analyticsService.checkBillingAccess(pid)@@ -1165,7 +1151,7 @@ export class AnalyticsController {@Post('custom')@Public()async logCustom(- @Body() eventsDTO: EventsDTO,+ @Body() eventsDTO: EventsDto,@Headers() headers,@Ip() reqIP,) {@@ -1246,7 +1232,7 @@ export class AnalyticsController {@Post('hb')@Auth([], true, true)async heartbeat(- @Body() logDTO: PageviewsDTO,+ @Body() logDTO: PageviewsDto,@Headers() headers,@Ip() reqIP,) {@@ -1272,7 +1258,7 @@ export class AnalyticsController {// Log pageview event@Post()@Public()- async log(@Body() logDTO: PageviewsDTO, @Headers() headers, @Ip() reqIP) {+ async log(@Body() logDTO: PageviewsDto, @Headers() headers, @Ip() reqIP) {const { 'user-agent': userAgent, origin } = headersconst ip = getIPFromHeaders(headers, true) || reqIP || ''@@ -1391,7 +1377,7 @@ export class AnalyticsController {@Header('Cross-Origin-Resource-Policy', 'cross-origin')@Public()async noscript(- @Query() data,+ @Query() data: NoscriptDto,@Headers() headers,@Ip() reqIP,@Response() res,@@ -1406,7 +1392,7 @@ export class AnalyticsController {return res.end(TRANSPARENT_GIF_BUFFER, 'binary')}- const logDTO: PageviewsDTO = {+ const logDTO: PageviewsDto = {pid,}@@ -1476,7 +1462,6 @@ export class AnalyticsController {@Headers() headers: { 'x-password'?: string },) {const { pid, period, from, to, filters, timezone = DEFAULT_TIMEZONE } = data- this.analyticsService.validatePID(pid)await this.analyticsService.checkProjectAccess(pid,@@ -1568,8 +1553,6 @@ export class AnalyticsController {timezone = DEFAULT_TIMEZONE,} = parameters- this.analyticsService.validatePID(pid)-await this.analyticsService.checkProjectAccess(pid,uid,@@ -1615,8 +1598,6 @@ export class AnalyticsController {timezone = DEFAULT_TIMEZONE,} = parameters- this.analyticsService.validatePID(pid)-await this.analyticsService.checkProjectAccess(pid,userId,@@ -1702,7 +1683,6 @@ export class AnalyticsController {timezone = DEFAULT_TIMEZONE,options,} = data- this.analyticsService.validatePID(pid)await this.analyticsService.checkProjectAccess(pid,@@ -1793,7 +1773,6 @@ export class AnalyticsController {to,//} = data- this.analyticsService.validatePID(pid)await this.analyticsService.checkProjectAccess(pid,@@ -1855,7 +1834,6 @@ export class AnalyticsController {timezone = DEFAULT_TIMEZONE,//} = data- this.analyticsService.validatePID(pid)await this.analyticsService.checkProjectAccess(pid,@@ -1893,7 +1871,6 @@ export class AnalyticsController {timezone = DEFAULT_TIMEZONE,customEvents,} = data- this.analyticsService.validatePID(pid)await this.analyticsService.checkProjectAccess(pid,diff --git a/backend/apps/production/src/analytics/analytics.service.ts b/backend/apps/production/src/analytics/analytics.service.tsindex e0b81e9e1..ef02ebaee 100644--- a/backend/apps/production/src/analytics/analytics.service.ts+++ b/backend/apps/production/src/analytics/analytics.service.ts@@ -43,7 +43,6 @@ import { isbot } from 'isbot'import { DEFAULT_TIMEZONE } from '../user/entities/user.entity'import {redis,- isValidPID,UNIQUE_SESSION_LIFE_TIME,REDIS_SESSION_SALT_KEY,TRAFFIC_COLUMNS,@@ -66,8 +65,8 @@ import {millisecondsToSeconds,sumArrays,} from '../common/utils'-import { PageviewsDTO } from './dto/pageviews.dto'-import { EventsDTO } from './dto/events.dto'+import { PageviewsDto } from './dto/pageviews.dto'+import { EventsDto } from './dto/events.dto'import { ProjectService } from '../project/project.service'import { UserService } from '../user/user.service'import { BotsProtectionLevel, Project } from '../project/entity/project.entity'@@ -101,7 +100,7 @@ import {ICustomEvent,BirdseyeCHUptimeResponse,} from './interfaces'-import { ErrorDTO } from './dto/error.dto'+import { ErrorDto } from './dto/error.dto'import { GetPagePropertyMetaDto } from './dto/get-page-property-meta.dto'import { ProjectViewCustomEventMetaValueType } from '../project/entity/project-view-custom-event.entity'import { ProjectViewCustomEventDto } from '../project/dto/create-project-view.dto'@@ -422,29 +421,12 @@ export class AnalyticsService {}}- validatePID(pid: string): void {- if (_isEmpty(pid)) {- throw new BadRequestException('The Project ID (pid) has to be provided')- }-- if (!isValidPID(pid)) {- throw new BadRequestException(- 'The provided Project ID (pid) is incorrect',- )- }- }-async validate(- logDTO: PageviewsDTO | EventsDTO | ErrorDTO,+ logDTO: PageviewsDto | EventsDto | ErrorDto,origin: string,ip?: string,): Promise<string | null> {- if (_isEmpty(logDTO)) {- throw new BadRequestException('The request cannot be empty')- }-const { pid } = logDTO- this.validatePID(pid)// 'tz' does not need validation as it's based on getCountryForTimezone detectionconst { lc } = logDTO@@ -488,16 +470,11 @@ export class AnalyticsService {}async validateHeartbeat(- logDTO: PageviewsDTO,+ logDTO: PageviewsDto,origin: string,ip?: string,): Promise<string | null> {- if (_isEmpty(logDTO)) {- throw new BadRequestException('The request cannot be empty')- }-const { pid } = logDTO- this.validatePID(pid)const project = await this.projectService.getRedisProject(pid)@@ -1311,12 +1288,6 @@ export class AnalyticsService {)const promises = pids.map(async pid => {- if (!isValidPID(pid)) {- throw new BadRequestException(- `The provided Project ID (${pid}) is incorrect`,- )- }-try {if (period === 'all') {const queryAll = `SELECT count(*) AS all FROM captcha WHERE pid = {pid:FixedString(12)} ${filtersQuery}`@@ -1629,12 +1600,6 @@ export class AnalyticsService {this.getFiltersQuery(filters, DataType.ANALYTICS)const promises = pids.map(async pid => {- if (!isValidPID(pid)) {- throw new BadRequestException(- `The provided Project ID (${pid}) is incorrect`,- )- }-try {if (period === 'all') {let queryAll = `SELECT count(*) AS all, countIf(unique=1) AS unique, avgIf(sdur, sdur IS NOT NULL AND analytics.unique=1) AS sdur FROM analytics WHERE pid = {pid:FixedString(12)} ${filtersQuery}`@@ -1830,12 +1795,6 @@ export class AnalyticsService {.join(', ')const promises = pids.map(async pid => {- if (!isValidPID(pid)) {- throw new BadRequestException(- `The provided Project ID (${pid}) is incorrect`,- )- }-try {if (period === 'all') {const queryAll = `SELECT ${columnSelectors} FROM performance WHERE pid = {pid:FixedString(12)} ${filtersQuery}`@@ -3954,7 +3913,7 @@ export class AnalyticsService {}}- getErrorID(errorDTO: ErrorDTO): string {+ getErrorID(errorDTO: ErrorDto): string {const { name, message, colno, lineno, filename } = errorDTOreturn hash(`${name}${message}${colno}${lineno}${filename}`).substring(diff --git a/backend/apps/production/src/analytics/dto/error.dto.ts b/backend/apps/production/src/analytics/dto/error.dto.tsindex efa35255e..d1e644523 100644--- a/backend/apps/production/src/analytics/dto/error.dto.ts+++ b/backend/apps/production/src/analytics/dto/error.dto.ts@@ -9,7 +9,7 @@ import {} from 'class-validator'import { PID_REGEX } from '../../common/constants'-export class ErrorDTO {+export class ErrorDto {@ApiProperty({example: 'aUn1quEid-3',required: true,@@ -17,7 +17,7 @@ export class ErrorDTO {})@IsNotEmpty()@Matches(PID_REGEX, {- message: 'Incorrect project ID format.',+ message: 'The provided Project ID (pid) is incorrect',})pid: stringdiff --git a/backend/apps/production/src/analytics/dto/events.dto.ts b/backend/apps/production/src/analytics/dto/events.dto.tsindex 7b5a14a99..cdaf5c403 100644--- a/backend/apps/production/src/analytics/dto/events.dto.ts+++ b/backend/apps/production/src/analytics/dto/events.dto.ts@@ -11,6 +11,7 @@ import {Validate,Matches,} from 'class-validator'+import { PID_REGEX } from '../../common/constants'export const MAX_METADATA_KEYS = 20export const MAX_METADATA_VALUE_LENGTH = 1000@@ -48,13 +49,14 @@ export class MetadataValueType implements ValidatorConstraintInterface {}}-export class EventsDTO {+export class EventsDto {@ApiProperty({example: 'aUn1quEid-3',required: true,description: 'The project ID',})@IsNotEmpty()+ @Matches(PID_REGEX, { message: 'The provided Project ID (pid) is incorrect' })pid: string@ApiProperty({diff --git a/backend/apps/production/src/analytics/dto/get-filters.dto.ts b/backend/apps/production/src/analytics/dto/get-filters.dto.tsindex 408bf0fc5..2f1e599ad 100644--- a/backend/apps/production/src/analytics/dto/get-filters.dto.ts+++ b/backend/apps/production/src/analytics/dto/get-filters.dto.ts@@ -1,5 +1,6 @@import { ApiProperty } from '@nestjs/swagger'-import { IsNotEmpty } from 'class-validator'+import { IsNotEmpty, Matches } from 'class-validator'+import { PID_REGEX } from '../../common/constants'export class GetFiltersDto {@ApiProperty({@@ -8,6 +9,7 @@ export class GetFiltersDto {description: 'The project ID',})@IsNotEmpty()+ @Matches(PID_REGEX, { message: 'The provided Project ID (pid) is incorrect' })pid: string@ApiProperty({diff --git a/backend/apps/production/src/analytics/dto/get-monitor-data.dto.ts b/backend/apps/production/src/analytics/dto/get-monitor-data.dto.tsindex b69cf01b4..3d3b19f24 100644--- a/backend/apps/production/src/analytics/dto/get-monitor-data.dto.ts+++ b/backend/apps/production/src/analytics/dto/get-monitor-data.dto.ts@@ -1,12 +1,18 @@import { ApiProperty } from '@nestjs/swagger'-import { IsEnum, IsNotEmpty, IsOptional } from 'class-validator'+import { IsEnum, IsNotEmpty, IsOptional, Matches } from 'class-validator'import { DEFAULT_TIMEZONE } from '../../user/entities/user.entity'import { TimeBucketType } from './getData.dto'import { ValidatePeriod } from '../decorators/validate-period.decorator'+import { PID_REGEX } from '../../common/constants'export class GetMonitorDataDto {- @ApiProperty()+ @ApiProperty({+ example: 'aUn1quEid-3',+ required: true,+ description: 'The project ID',+ })@IsNotEmpty()+ @Matches(PID_REGEX, { message: 'The provided Project ID (pid) is incorrect' })pid: string@ApiProperty()diff --git a/backend/apps/production/src/analytics/dto/get-overall-stats.dto.ts b/backend/apps/production/src/analytics/dto/get-overall-stats.dto.tsindex 1b644086c..80b008912 100644--- a/backend/apps/production/src/analytics/dto/get-overall-stats.dto.ts+++ b/backend/apps/production/src/analytics/dto/get-overall-stats.dto.ts@@ -1,19 +1,23 @@import { ApiProperty } from '@nestjs/swagger'-import { IsOptional, IsString, ValidateIf } from 'class-validator'+import { IsOptional, IsString, Matches, ValidateIf } from 'class-validator'import { DEFAULT_TIMEZONE } from '../../user/entities/user.entity'import { ValidatePeriod } from '../decorators/validate-period.decorator'+import { PID_REGEX } from '../../common/constants'export class GetOverallStatsDto {@ApiProperty({ description: 'Array of project IDs', required: false })@ValidateIf(o => o.pids || !o.pid)@IsOptional()- @IsString({ each: true })+ @Matches(PID_REGEX, {+ message: 'One of the provided Project IDs (pids) is incorrect',+ each: true,+ })pids?: string[]@ApiProperty({ description: 'Single project ID', required: false })@ValidateIf(o => !o.pids || o.pid)@IsOptional()- @IsString()+ @Matches(PID_REGEX, { message: 'The provided Project ID (pid) is incorrect' })pid?: string@ApiProperty({ required: false })diff --git a/backend/apps/production/src/analytics/dto/get-session.dto.ts b/backend/apps/production/src/analytics/dto/get-session.dto.tsindex 9782d45fd..5d5c59bb4 100644--- a/backend/apps/production/src/analytics/dto/get-session.dto.ts+++ b/backend/apps/production/src/analytics/dto/get-session.dto.ts@@ -1,11 +1,17 @@import { ApiProperty } from '@nestjs/swagger'-import { IsNotEmpty } from 'class-validator'+import { IsNotEmpty, Matches } from 'class-validator'import { DEFAULT_TIMEZONE } from '../../user/entities/user.entity'+import { PID_REGEX } from '../../common/constants'// eslint-disable-next-line @typescript-eslint/naming-conventionexport class GetSessionDto {- @ApiProperty()+ @ApiProperty({+ example: 'aUn1quEid-3',+ required: true,+ description: 'The project ID',+ })@IsNotEmpty()+ @Matches(PID_REGEX, { message: 'The provided Project ID (pid) is incorrect' })pid: string@ApiProperty()diff --git a/backend/apps/production/src/analytics/dto/get-uptime-birdseye.dto.ts b/backend/apps/production/src/analytics/dto/get-uptime-birdseye.dto.tsindex 806ebebf9..8c623f386 100644--- a/backend/apps/production/src/analytics/dto/get-uptime-birdseye.dto.ts+++ b/backend/apps/production/src/analytics/dto/get-uptime-birdseye.dto.ts@@ -1,11 +1,17 @@import { ApiProperty } from '@nestjs/swagger'-import { IsNotEmpty, IsOptional } from 'class-validator'+import { IsNotEmpty, IsOptional, Matches } from 'class-validator'import { DEFAULT_TIMEZONE } from '../../user/entities/user.entity'import { ValidatePeriod } from '../decorators/validate-period.decorator'+import { PID_REGEX } from '../../common/constants'export class GetUptimeBirdseyeDto {- @ApiProperty()+ @ApiProperty({+ example: 'aUn1quEid-3',+ required: true,+ description: 'The project ID',+ })@IsNotEmpty()+ @Matches(PID_REGEX, { message: 'The provided Project ID (pid) is incorrect' })pid: string@ApiProperty({ required: false })diff --git a/backend/apps/production/src/analytics/dto/getData.dto.ts b/backend/apps/production/src/analytics/dto/getData.dto.tsindex 8fa4a22da..745defa11 100644--- a/backend/apps/production/src/analytics/dto/getData.dto.ts+++ b/backend/apps/production/src/analytics/dto/getData.dto.ts@@ -1,7 +1,8 @@import { ApiProperty } from '@nestjs/swagger'-import { IsNotEmpty, IsOptional, IsEnum } from 'class-validator'+import { IsNotEmpty, IsOptional, IsEnum, Matches } from 'class-validator'import { DEFAULT_TIMEZONE } from '../../user/entities/user.entity'import { ValidatePeriod } from '../decorators/validate-period.decorator'+import { PID_REGEX } from '../../common/constants'export enum TimeBucketType {MINUTE = 'minute',@@ -18,8 +19,13 @@ export enum ChartRenderMode {// eslint-disable-next-line @typescript-eslint/naming-conventionexport class GetDataDto {- @ApiProperty()+ @ApiProperty({+ example: 'aUn1quEid-3',+ required: true,+ description: 'The project ID',+ })@IsNotEmpty()+ @Matches(PID_REGEX, { message: 'The provided Project ID (pid) is incorrect' })pid: string@ApiProperty({ required: false })diff --git a/backend/apps/production/src/analytics/dto/getFunnels.dto.ts b/backend/apps/production/src/analytics/dto/getFunnels.dto.tsindex ae21a7323..6e8229d36 100644--- a/backend/apps/production/src/analytics/dto/getFunnels.dto.ts+++ b/backend/apps/production/src/analytics/dto/getFunnels.dto.ts@@ -1,11 +1,17 @@import { ApiProperty } from '@nestjs/swagger'-import { IsNotEmpty, IsOptional } from 'class-validator'+import { IsNotEmpty, IsOptional, Matches } from 'class-validator'import { DEFAULT_TIMEZONE } from '../../user/entities/user.entity'import { ValidatePeriod } from '../decorators/validate-period.decorator'+import { PID_REGEX } from '../../common/constants'export class GetFunnelsDto {- @ApiProperty()+ @ApiProperty({+ example: 'aUn1quEid-3',+ required: true,+ description: 'The project ID',+ })@IsNotEmpty()+ @Matches(PID_REGEX, { message: 'The provided Project ID (pid) is incorrect' })pid: string@ApiProperty({ required: false })diff --git a/backend/apps/production/src/analytics/dto/getUserFlow.dto.ts b/backend/apps/production/src/analytics/dto/getUserFlow.dto.tsindex e6e17ec74..015d6eab2 100644--- a/backend/apps/production/src/analytics/dto/getUserFlow.dto.ts+++ b/backend/apps/production/src/analytics/dto/getUserFlow.dto.ts@@ -1,12 +1,18 @@import { ApiProperty } from '@nestjs/swagger'-import { IsNotEmpty, IsOptional } from 'class-validator'+import { IsNotEmpty, IsOptional, Matches } from 'class-validator'import { DEFAULT_TIMEZONE } from '../../user/entities/user.entity'import { ValidatePeriod } from '../decorators/validate-period.decorator'+import { PID_REGEX } from '../../common/constants'// eslint-disable-next-line @typescript-eslint/naming-conventionexport class GetUserFlowDto {- @ApiProperty()+ @ApiProperty({+ example: 'aUn1quEid-3',+ required: true,+ description: 'The project ID',+ })@IsNotEmpty()+ @Matches(PID_REGEX, { message: 'The provided Project ID (pid) is incorrect' })pid: string@ApiProperty({ required: false })diff --git a/backend/apps/production/src/analytics/dto/live-visitors.dto.ts b/backend/apps/production/src/analytics/dto/live-visitors.dto.tsnew file mode 100644index 000000000..72969a0ee--- /dev/null+++ b/backend/apps/production/src/analytics/dto/live-visitors.dto.ts@@ -0,0 +1,14 @@+import { IsNotEmpty, Matches } from 'class-validator'+import { ApiProperty } from '@nestjs/swagger'+import { PID_REGEX } from '../../common/constants'++export class LiveVisitorsDto {+ @ApiProperty({+ example: 'aUn1quEid-3',+ required: true,+ description: 'The project ID',+ })+ @IsNotEmpty()+ @Matches(PID_REGEX, { message: 'The provided Project ID (pid) is incorrect' })+ pid: string+}diff --git a/backend/apps/production/src/analytics/dto/noscript.dto.ts b/backend/apps/production/src/analytics/dto/noscript.dto.tsnew file mode 100644index 000000000..9470df6fa--- /dev/null+++ b/backend/apps/production/src/analytics/dto/noscript.dto.ts@@ -0,0 +1,14 @@+import { IsNotEmpty, Matches } from 'class-validator'+import { ApiProperty } from '@nestjs/swagger'+import { PID_REGEX } from '../../common/constants'++export class NoscriptDto {+ @ApiProperty({+ example: 'aUn1quEid-3',+ required: true,+ description: 'The project ID',+ })+ @IsNotEmpty()+ @Matches(PID_REGEX, { message: 'The provided Project ID (pid) is incorrect' })+ pid: string+}diff --git a/backend/apps/production/src/analytics/dto/pageviews.dto.ts b/backend/apps/production/src/analytics/dto/pageviews.dto.tsindex c350819cd..b08793ac2 100644--- a/backend/apps/production/src/analytics/dto/pageviews.dto.ts+++ b/backend/apps/production/src/analytics/dto/pageviews.dto.ts@@ -1,5 +1,11 @@import { ApiProperty } from '@nestjs/swagger'-import { IsNotEmpty, IsObject, IsOptional, Validate } from 'class-validator'+import {+ IsNotEmpty,+ IsObject,+ IsOptional,+ Matches,+ Validate,+} from 'class-validator'import {MAX_METADATA_KEYS,@@ -8,14 +14,16 @@ import {MetadataValueType,MetadataSizeLimit,} from './events.dto'+import { PID_REGEX } from '../../common/constants'-export class PageviewsDTO {+export class PageviewsDto {@ApiProperty({example: 'aUn1quEid-3',required: true,description: 'The project ID',})@IsNotEmpty()+ @Matches(PID_REGEX, { message: 'The provided Project ID (pid) is incorrect' })pid: string// Tracking metricsdiff --git a/backend/apps/production/src/analytics/dto/patch-status.dto.ts b/backend/apps/production/src/analytics/dto/patch-status.dto.tsindex 2da498d93..44a8dc921 100644--- a/backend/apps/production/src/analytics/dto/patch-status.dto.ts+++ b/backend/apps/production/src/analytics/dto/patch-status.dto.ts@@ -9,7 +9,7 @@ import {} from 'class-validator'import { PID_REGEX } from '../../common/constants'-export class PatchStatusDTO {+export class PatchStatusDto {@ApiProperty({example: 'aUn1quEid-3',required: true,@@ -17,7 +17,7 @@ export class PatchStatusDTO {})@IsNotEmpty()@Matches(PID_REGEX, {- message: 'Incorrect project ID format.',+ message: 'The provided Project ID (pid) is incorrect',})pid: string