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!

fix: filtering for not properly encoded pages

Blue Mouse4e5f522bfab0
diff --git a/apps/production/src/analytics/analytics.service.ts b/apps/production/src/analytics/analytics.service.ts
index a190538dc..a745d23bd 100644
--- a/apps/production/src/analytics/analytics.service.ts
+++ b/apps/production/src/analytics/analytics.service.ts
@@ -11,6 +11,7 @@ import * as _isArray from 'lodash/isArray'
import * as _reduce from 'lodash/reduce'
import * as _keys from 'lodash/keys'
import * as _last from 'lodash/last'
+import * as _replace from 'lodash/replace'
import * as _some from 'lodash/some'
import * as _find from 'lodash/find'
import * as _now from 'lodash/now'
@@ -832,10 +833,22 @@ export class AnalyticsService {
if (_isArray(filter)) {
for (const f of filter) {
- res.push({ filter: f, isExclusive })
+ let encoded = f
+
+ if (column === 'pg' && f !== null) {
+ encoded = _replace(encodeURIComponent(f), /%2F/g, '/')
+ }
+
+ res.push({ filter: encoded, isExclusive })
}
} else {
- res.push({ filter, isExclusive })
+ let encoded = filter
+
+ if (column === 'pg' && filter !== null) {
+ encoded = _replace(encodeURIComponent(filter), /%2F/g, '/')
+ }
+
+ res.push({ filter: encoded, isExclusive })
}
if (prev[column]) {
diff --git a/apps/selfhosted/src/analytics/analytics.service.ts b/apps/selfhosted/src/analytics/analytics.service.ts
index ddb5dca79..66db8afa0 100644
--- a/apps/selfhosted/src/analytics/analytics.service.ts
+++ b/apps/selfhosted/src/analytics/analytics.service.ts
@@ -7,6 +7,7 @@ import * as _includes from 'lodash/includes'
import * as _map from 'lodash/map'
import * as _toUpper from 'lodash/toUpper'
import * as _join from 'lodash/join'
+import * as _replace from 'lodash/replace'
import * as _last from 'lodash/last'
import * as _some from 'lodash/some'
import * as _find from 'lodash/find'
@@ -736,10 +737,22 @@ export class AnalyticsService {
if (_isArray(filter)) {
for (const f of filter) {
- res.push({ filter: f, isExclusive })
+ let encoded = f
+
+ if (column === 'pg' && f !== null) {
+ encoded = _replace(encodeURIComponent(f), /%2F/g, '/')
+ }
+
+ res.push({ filter: encoded, isExclusive })
}
} else {
- res.push({ filter, isExclusive })
+ let encoded = filter
+
+ if (column === 'pg' && filter !== null) {
+ encoded = _replace(encodeURIComponent(filter), /%2F/g, '/')
+ }
+
+ res.push({ filter: encoded, isExclusive })
}
if (prev[column]) {