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!

fixed issue with type selection

Blue Mousece2c0a1e9b7f
diff --git a/apps/production/src/analytics/analytics.service.ts b/apps/production/src/analytics/analytics.service.ts
index ec8df530c..7b0a67985 100644
--- a/apps/production/src/analytics/analytics.service.ts
+++ b/apps/production/src/analytics/analytics.service.ts
@@ -789,9 +789,15 @@ export class AnalyticsService {
}
async getFilters(pid: string, type: string): Promise<Array<string>> {
- const query = `SELECT {type:String} FROM analytics WHERE pid={pid:FixedString(12)} AND {type:String} IS NOT NULL GROUP BY {type:String}`
+ if (!_includes(cols, type)) {
+ throw new UnprocessableEntityException(
+ `The provided type (${type}) is incorrect`,
+ )
+ }
+
+ const query = `SELECT ${type} FROM analytics WHERE pid={pid:FixedString(12)} AND ${type} IS NOT NULL GROUP BY ${type}`
const results = await clickhouse
- .query(query, { params: { pid, type } })
+ .query(query, { params: { pid } })
.toPromise()
return _map(results, type)