📈 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
Minor security improvements
Blue Moused6c16fa76f58
diff --git a/backend/apps/cloud/src/analytics/analytics.service.ts b/backend/apps/cloud/src/analytics/analytics.service.tsindex a55aba40d..4a7a717c4 100644--- a/backend/apps/cloud/src/analytics/analytics.service.ts+++ b/backend/apps/cloud/src/analytics/analytics.service.ts@@ -4569,13 +4569,13 @@ export class AnalyticsService {AND profileId = {profileId:String}GROUP BY pgORDER BY count DESC- LIMIT ${limit}+ LIMIT {limit:UInt32}`const { data } = await clickhouse.query({query,- query_params: { pid, profileId },+ query_params: { pid, profileId, limit: Number(limit) },}).then(resultSet => resultSet.json())diff --git a/backend/apps/cloud/src/analytics/dto/error.dto.ts b/backend/apps/cloud/src/analytics/dto/error.dto.tsindex 73b0f3493..4b9c785ed 100644--- a/backend/apps/cloud/src/analytics/dto/error.dto.ts+++ b/backend/apps/cloud/src/analytics/dto/error.dto.ts@@ -36,9 +36,11 @@ export class ErrorDto {example: 'user_12345',description:'Optional profile ID for long-term user tracking. If not provided, one will be auto-generated.',+ maxLength: 256,})@IsOptional()@IsString()+ @MaxLength(256)profileId?: string// Tracking metricsdiff --git a/backend/apps/cloud/src/analytics/dto/events.dto.ts b/backend/apps/cloud/src/analytics/dto/events.dto.tsindex 3d897b4c6..92089a249 100644--- a/backend/apps/cloud/src/analytics/dto/events.dto.ts+++ b/backend/apps/cloud/src/analytics/dto/events.dto.ts@@ -6,6 +6,8 @@ import {IsNotEmpty,IsOptional,IsObject,+ IsString,+ MaxLength,ValidatorConstraint,ValidatorConstraintInterface,Validate,@@ -91,8 +93,11 @@ export class EventsDto {example: 'user_12345',description:'Optional profile ID for long-term user tracking. If not provided, one will be auto-generated.',+ maxLength: 256,})@IsOptional()+ @IsString()+ @MaxLength(256)profileId?: string@ApiProperty({diff --git a/backend/apps/cloud/src/analytics/dto/get-errors.dto.ts b/backend/apps/cloud/src/analytics/dto/get-errors.dto.tsindex 202912d1c..369729ba0 100644--- a/backend/apps/cloud/src/analytics/dto/get-errors.dto.ts+++ b/backend/apps/cloud/src/analytics/dto/get-errors.dto.ts@@ -1,6 +1,6 @@import { PickType, ApiProperty } from '@nestjs/swagger'import { Type } from 'class-transformer'-import { IsInt, Min } from 'class-validator'+import { IsInt, Min, Max } from 'class-validator'import { GetDataDto } from './getData.dto'export class GetErrorsDto extends PickType(GetDataDto, [@@ -14,6 +14,7 @@ export class GetErrorsDto extends PickType(GetDataDto, [@Type(() => Number)@IsInt()@Min(0)+ @Max(150)take: number@Type(() => Number)diff --git a/backend/apps/cloud/src/analytics/dto/get-profile.dto.ts b/backend/apps/cloud/src/analytics/dto/get-profile.dto.tsindex 6579fa9f5..3dd7e511d 100644--- a/backend/apps/cloud/src/analytics/dto/get-profile.dto.ts+++ b/backend/apps/cloud/src/analytics/dto/get-profile.dto.ts@@ -1,6 +1,6 @@import { ApiProperty, PickType } from '@nestjs/swagger'import { Type } from 'class-transformer'-import { IsNotEmpty, IsOptional, Matches, IsInt, Min } from 'class-validator'+import { IsNotEmpty, IsOptional, IsString, Matches, MaxLength, IsInt, Min, Max } from 'class-validator'import { DEFAULT_TIMEZONE } from '../../user/entities/user.entity'import { PID_REGEX } from '../../common/constants'import { ValidatePeriod } from '../decorators/validate-period.decorator'@@ -19,8 +19,11 @@ export class GetProfileDto {@ApiProperty({required: true,description: 'The profile ID',+ maxLength: 256,})@IsNotEmpty()+ @IsString()+ @MaxLength(256)profileId: string@ApiProperty({@@ -53,8 +56,11 @@ export class GetProfileSessionsDto extends PickType(GetDataDto, [@ApiProperty({required: true,description: 'The profile ID',+ maxLength: 256,})@IsNotEmpty()+ @IsString()+ @MaxLength(256)profileId: string@ApiProperty({ required: false, default: 30 })@@ -62,6 +68,7 @@ export class GetProfileSessionsDto extends PickType(GetDataDto, [@Type(() => Number)@IsInt()@Min(0)+ @Max(150)take?: number@ApiProperty({ required: false, default: 0 })diff --git a/backend/apps/cloud/src/analytics/dto/get-profiles.dto.ts b/backend/apps/cloud/src/analytics/dto/get-profiles.dto.tsindex eeae7de3b..3591ff196 100644--- a/backend/apps/cloud/src/analytics/dto/get-profiles.dto.ts+++ b/backend/apps/cloud/src/analytics/dto/get-profiles.dto.ts@@ -1,6 +1,6 @@import { ApiProperty, PickType } from '@nestjs/swagger'import { Type } from 'class-transformer'-import { IsOptional, IsIn, IsInt, Min } from 'class-validator'+import { IsOptional, IsIn, IsInt, Min, Max } from 'class-validator'import { GetDataDto } from './getData.dto'export class GetProfilesDto extends PickType(GetDataDto, [@@ -16,6 +16,7 @@ export class GetProfilesDto extends PickType(GetDataDto, [@Type(() => Number)@IsInt()@Min(0)+ @Max(150)take?: number@ApiProperty({ required: false, default: 0 })diff --git a/backend/apps/cloud/src/analytics/dto/get-sessions.dto.ts b/backend/apps/cloud/src/analytics/dto/get-sessions.dto.tsindex c2afe3c3a..75fa27950 100644--- a/backend/apps/cloud/src/analytics/dto/get-sessions.dto.ts+++ b/backend/apps/cloud/src/analytics/dto/get-sessions.dto.ts@@ -1,6 +1,6 @@import { PickType } from '@nestjs/swagger'import { Type } from 'class-transformer'-import { IsInt, Min } from 'class-validator'+import { IsInt, Min, Max } from 'class-validator'import { GetDataDto } from './getData.dto'export class GetSessionsDto extends PickType(GetDataDto, [@@ -14,6 +14,7 @@ export class GetSessionsDto extends PickType(GetDataDto, [@Type(() => Number)@IsInt()@Min(0)+ @Max(150)take: number@Type(() => Number)diff --git a/backend/apps/cloud/src/analytics/dto/pageviews.dto.ts b/backend/apps/cloud/src/analytics/dto/pageviews.dto.tsindex cd3b44fb2..854907131 100644--- a/backend/apps/cloud/src/analytics/dto/pageviews.dto.ts+++ b/backend/apps/cloud/src/analytics/dto/pageviews.dto.ts@@ -3,7 +3,9 @@ import {IsNotEmpty,IsObject,IsOptional,+ IsString,Matches,+ MaxLength,Validate,} from 'class-validator'import { Transform } from 'class-transformer'@@ -32,8 +34,11 @@ export class PageviewsDto {example: 'user_12345',description:'Optional profile ID for long-term user tracking. If not provided, one will be auto-generated.',+ maxLength: 256,})@IsOptional()+ @IsString()+ @MaxLength(256)profileId?: string// Tracking metricsdiff --git a/backend/apps/community/src/analytics/dto/error.dto.ts b/backend/apps/community/src/analytics/dto/error.dto.tsindex 73b0f3493..4b9c785ed 100644--- a/backend/apps/community/src/analytics/dto/error.dto.ts+++ b/backend/apps/community/src/analytics/dto/error.dto.ts@@ -36,9 +36,11 @@ export class ErrorDto {example: 'user_12345',description:'Optional profile ID for long-term user tracking. If not provided, one will be auto-generated.',+ maxLength: 256,})@IsOptional()@IsString()+ @MaxLength(256)profileId?: string// Tracking metricsdiff --git a/backend/apps/community/src/analytics/dto/events.dto.ts b/backend/apps/community/src/analytics/dto/events.dto.tsindex 3d897b4c6..92089a249 100644--- a/backend/apps/community/src/analytics/dto/events.dto.ts+++ b/backend/apps/community/src/analytics/dto/events.dto.ts@@ -6,6 +6,8 @@ import {IsNotEmpty,IsOptional,IsObject,+ IsString,+ MaxLength,ValidatorConstraint,ValidatorConstraintInterface,Validate,@@ -91,8 +93,11 @@ export class EventsDto {example: 'user_12345',description:'Optional profile ID for long-term user tracking. If not provided, one will be auto-generated.',+ maxLength: 256,})@IsOptional()+ @IsString()+ @MaxLength(256)profileId?: string@ApiProperty({diff --git a/backend/apps/community/src/analytics/dto/get-errors.dto.ts b/backend/apps/community/src/analytics/dto/get-errors.dto.tsindex 202912d1c..369729ba0 100644--- a/backend/apps/community/src/analytics/dto/get-errors.dto.ts+++ b/backend/apps/community/src/analytics/dto/get-errors.dto.ts@@ -1,6 +1,6 @@import { PickType, ApiProperty } from '@nestjs/swagger'import { Type } from 'class-transformer'-import { IsInt, Min } from 'class-validator'+import { IsInt, Min, Max } from 'class-validator'import { GetDataDto } from './getData.dto'export class GetErrorsDto extends PickType(GetDataDto, [@@ -14,6 +14,7 @@ export class GetErrorsDto extends PickType(GetDataDto, [@Type(() => Number)@IsInt()@Min(0)+ @Max(150)take: number@Type(() => Number)diff --git a/backend/apps/community/src/analytics/dto/get-sessions.dto.ts b/backend/apps/community/src/analytics/dto/get-sessions.dto.tsindex c2afe3c3a..75fa27950 100644--- a/backend/apps/community/src/analytics/dto/get-sessions.dto.ts+++ b/backend/apps/community/src/analytics/dto/get-sessions.dto.ts@@ -1,6 +1,6 @@import { PickType } from '@nestjs/swagger'import { Type } from 'class-transformer'-import { IsInt, Min } from 'class-validator'+import { IsInt, Min, Max } from 'class-validator'import { GetDataDto } from './getData.dto'export class GetSessionsDto extends PickType(GetDataDto, [@@ -14,6 +14,7 @@ export class GetSessionsDto extends PickType(GetDataDto, [@Type(() => Number)@IsInt()@Min(0)+ @Max(150)take: number@Type(() => Number)diff --git a/backend/apps/community/src/analytics/dto/pageviews.dto.ts b/backend/apps/community/src/analytics/dto/pageviews.dto.tsindex cd3b44fb2..854907131 100644--- a/backend/apps/community/src/analytics/dto/pageviews.dto.ts+++ b/backend/apps/community/src/analytics/dto/pageviews.dto.ts@@ -3,7 +3,9 @@ import {IsNotEmpty,IsObject,IsOptional,+ IsString,Matches,+ MaxLength,Validate,} from 'class-validator'import { Transform } from 'class-transformer'@@ -32,8 +34,11 @@ export class PageviewsDto {example: 'user_12345',description:'Optional profile ID for long-term user tracking. If not provided, one will be auto-generated.',+ maxLength: 256,})@IsOptional()+ @IsString()+ @MaxLength(256)profileId?: string// Tracking metrics