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!

(feature) Anonymous pages (#186)

Andrii Romasiunf13d74615726
diff --git a/apps/production/src/analytics/analytics.service.ts b/apps/production/src/analytics/analytics.service.ts
index 48a46b370..d8bbf3073 100644
--- a/apps/production/src/analytics/analytics.service.ts
+++ b/apps/production/src/analytics/analytics.service.ts
@@ -208,6 +208,10 @@ const generateParamsQuery = (
const columnsQuery = columns.join(', ')
if (isPerformance) {
+ if (col === 'pg') {
+ return `SELECT ${columnsQuery}, round(divide(avg(pageLoad), 1000), 2) as count ${subQuery} GROUP BY ${columnsQuery}`
+ }
+
return `SELECT ${columnsQuery}, round(divide(avg(pageLoad), 1000), 2) as count ${subQuery} AND ${col} IS NOT NULL GROUP BY ${columnsQuery}`
}
@@ -219,7 +223,11 @@ const generateParamsQuery = (
return `SELECT ${columnsQuery}, count(*) as count ${subQuery} AND ${col} IS NOT NULL GROUP BY ${columnsQuery}`
}
- if (col === 'pg' || isPageInclusiveFilterSet) {
+ if (col === 'pg') {
+ return `SELECT ${columnsQuery}, count(*) as count ${subQuery} GROUP BY ${columnsQuery}`
+ }
+
+ if (isPageInclusiveFilterSet) {
return `SELECT ${columnsQuery}, count(*) as count ${subQuery} AND ${col} IS NOT NULL GROUP BY ${columnsQuery}`
}
@@ -789,6 +797,12 @@ export class AnalyticsService {
const param = `qf_${col}_${f}`
+ if (filter === null) {
+ query += `${column} IS ${isExclusive ? 'NOT' : ''} NULL`
+ params[param] = filter
+ continue
+ }
+
query += `${isExclusive ? 'NOT ' : ''}${column} = {${param}:String}`
params[param] = filter
diff --git a/apps/production/src/project/project.service.ts b/apps/production/src/project/project.service.ts
index ae48620ee..332bc28e7 100644
--- a/apps/production/src/project/project.service.ts
+++ b/apps/production/src/project/project.service.ts
@@ -479,9 +479,7 @@ export class ProjectService {
return null
}
- throw new ForbiddenException(
- `You are not allowed to view '${project?.name}' project`,
- )
+ throw new ForbiddenException('You are not allowed to view this project')
}
allowedToManage(
diff --git a/apps/selfhosted/src/analytics/analytics.service.ts b/apps/selfhosted/src/analytics/analytics.service.ts
index 7de478980..2c2400764 100644
--- a/apps/selfhosted/src/analytics/analytics.service.ts
+++ b/apps/selfhosted/src/analytics/analytics.service.ts
@@ -201,6 +201,10 @@ const generateParamsQuery = (
const columnsQuery = columns.join(', ')
if (isPerformance) {
+ if (col === 'pg') {
+ return `SELECT ${columnsQuery}, round(divide(avg(pageLoad), 1000), 2) as count ${subQuery} GROUP BY ${columnsQuery}`
+ }
+
return `SELECT ${columnsQuery}, round(divide(avg(pageLoad), 1000), 2) as count ${subQuery} AND ${col} IS NOT NULL GROUP BY ${columnsQuery}`
}
@@ -208,7 +212,11 @@ const generateParamsQuery = (
return `SELECT ${columnsQuery}, count(*) as count ${subQuery} AND ${col} IS NOT NULL GROUP BY ${columnsQuery}`
}
- if (col === 'pg' || isPageInclusiveFilterSet) {
+ if (col === 'pg') {
+ return `SELECT ${columnsQuery}, count(*) as count ${subQuery} GROUP BY ${columnsQuery}`
+ }
+
+ if (isPageInclusiveFilterSet) {
return `SELECT ${columnsQuery}, count(*) as count ${subQuery} AND ${col} IS NOT NULL GROUP BY ${columnsQuery}`
}
@@ -753,6 +761,12 @@ export class AnalyticsService {
const param = `qf_${col}_${f}`
+ if (filter === null) {
+ query += `${column} IS ${isExclusive ? 'NOT' : ''} NULL`
+ params[param] = filter
+ continue
+ }
+
query += `${isExclusive ? 'NOT ' : ''}${column} = {${param}:String}`
params[param] = filter
diff --git a/apps/selfhosted/src/project/project.service.ts b/apps/selfhosted/src/project/project.service.ts
index b29891b04..2530d564a 100644
--- a/apps/selfhosted/src/project/project.service.ts
+++ b/apps/selfhosted/src/project/project.service.ts
@@ -83,9 +83,7 @@ export class ProjectService {
return null
}
- throw new ForbiddenException(
- `You are not allowed to view "${project?.name}" project`,
- )
+ throw new ForbiddenException('You are not allowed to view this project')
}
isPIDUnique(projects: Array<object>, pid: string): boolean {