📈 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
usage info -> errors
Blue Mousecbbcbed5f5e0
diff --git a/apps/production/src/project/project.service.ts b/apps/production/src/project/project.service.tsindex 2cd1cd0ab..b4d2559d6 100644--- a/apps/production/src/project/project.service.ts+++ b/apps/production/src/project/project.service.ts@@ -96,6 +96,7 @@ const DEFAULT_USAGE_INFO = {traffic: 0,customEvents: 0,captcha: 0,+ errors: 0,}export const deleteProjectRedis = async (id: string) => {@@ -734,39 +735,42 @@ export class ProjectService {return DEFAULT_USAGE_INFO}- const countEVQuery = `SELECT COUNT() FROM analytics WHERE pid IN (${_join(- _map(pids, el => `'${el.id}'`),- ',',- )}) AND created BETWEEN '${monthStart}' AND '${monthEnd}'`- const countCustomEVQuery = `SELECT COUNT() FROM customEV WHERE pid IN (${_join(- _map(pids, el => `'${el.id}'`),- ',',- )}) AND created BETWEEN '${monthStart}' AND '${monthEnd}'`- const countCaptchaQuery = `SELECT COUNT() FROM captcha WHERE pid IN (${_join(- _map(pids, el => `'${el.id}'`),- ',',- )}) AND created BETWEEN '${monthStart}' AND '${monthEnd}'`+ const selector = `+ WHERE pid IN (${_join(+ _map(pids, el => `'${el.id}'`),+ ',',+ )})+ AND created BETWEEN '${monthStart}' AND '${monthEnd}'+ `++ const countEVQuery = `SELECT count() FROM analytics ${selector}`+ const countCustomEVQuery = `SELECT count() FROM customEV ${selector}`+ const countCaptchaQuery = `SELECT count() FROM captcha ${selector}`+ const countErrorsQuery = `SELECT count() FROM errors ${selector}`const promises = [clickhouse.query(countEVQuery).toPromise(),clickhouse.query(countCustomEVQuery).toPromise(),clickhouse.query(countCaptchaQuery).toPromise(),+ clickhouse.query(countErrorsQuery).toPromise(),]- const [rawTraffic, rawCustomEvents, rawCaptcha] =+ const [rawTraffic, rawCustomEvents, rawCaptcha, rawErrors] =await Promise.all(promises)const traffic = rawTraffic[0]['count()']const customEvents = rawCustomEvents[0]['count()']const captcha = rawCaptcha[0]['count()']+ const errors = rawErrors[0]['count()']- const total = traffic + customEvents + captcha+ const total = traffic + customEvents + captcha + errorsinfo = {total,traffic,customEvents,captcha,+ errors,}await redis.set(diff --git a/apps/production/src/task-manager/task-manager.service.ts b/apps/production/src/task-manager/task-manager.service.tsindex 1e6e0ba8b..1d8a54d79 100644--- a/apps/production/src/task-manager/task-manager.service.ts+++ b/apps/production/src/task-manager/task-manager.service.ts@@ -103,7 +103,7 @@ const getQueryCondition = (condition: QueryCondition): string => {return ''}-// TODO: Check custom events & CAPTCHA events as well+// TODO: Check custom events, CAPTCHA events and errors as wellconst generatePlanUsageQuery = (users: User[],getDate: (user?: User) => string,diff --git a/apps/production/src/user/interfaces/usage-info.ts b/apps/production/src/user/interfaces/usage-info.tsindex 5c88c839a..3020f52ee 100644--- a/apps/production/src/user/interfaces/usage-info.ts+++ b/apps/production/src/user/interfaces/usage-info.ts@@ -3,10 +3,12 @@ export interface IUsageInfoRedis {traffic: numbercustomEvents: numbercaptcha: number+ errors: number}export interface IUsageInfo extends IUsageInfoRedis {trafficPerc: numbercustomEventsPerc: numbercaptchaPerc: number+ errorsPerc: number}diff --git a/apps/production/src/user/user.controller.ts b/apps/production/src/user/user.controller.tsindex fa9f98d71..5a6b8f13c 100644--- a/apps/production/src/user/user.controller.ts+++ b/apps/production/src/user/user.controller.ts@@ -868,6 +868,7 @@ export class UserController {trafficPerc: _round((rawInfo.traffic / rawInfo.total) * 100, 2),customEventsPerc: _round((rawInfo.customEvents / rawInfo.total) * 100, 2),captchaPerc: _round((rawInfo.captcha / rawInfo.total) * 100, 2),+ errorsPerc: _round((rawInfo.errors / rawInfo.total) * 100, 2),}return info