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!

Added unique param for pageviews

Blue Moused78d6eac35d9
diff --git a/src/analytics/analytics.controller.ts b/src/analytics/analytics.controller.ts
index fb113111d..6033b3a8d 100644
--- a/src/analytics/analytics.controller.ts
+++ b/src/analytics/analytics.controller.ts
@@ -194,8 +194,10 @@ export class AnalyticsController {
const br = ua.browser.name
const os = ua.os.name
dto = analyticsDTO(logDTO.pid, logDTO.pg, dv, br, os, logDTO.lc, logDTO.ref, logDTO.so, logDTO.me, logDTO.ca, logDTO.lt, logDTO.tz, 1)
- } else {
+ } else if (!logDTO.unique) {
dto = analyticsDTO(logDTO.pid, logDTO.pg, 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 'NULL', 0)
+ } else {
+ throw new BadRequestException('Event was not saved because it was not unique while unique only param is provided')
}
// todo: fix: may be vulnerable to sql injection attack
diff --git a/src/analytics/dto/pageviews.dto.ts b/src/analytics/dto/pageviews.dto.ts
index 637f846dd..33e36bc52 100644
--- a/src/analytics/dto/pageviews.dto.ts
+++ b/src/analytics/dto/pageviews.dto.ts
@@ -53,6 +53,12 @@ export class PageviewsDTO {
})
ca: string
+ @ApiProperty({
+ example: false,
+ description: 'If true, only unique events will be saved'
+ })
+ unique: boolean
+
// Performance metrics
@ApiProperty({
example: 261,