📈 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
remove some unused vars
Blue Mouseea1821ea145e
diff --git a/apps/production/src/analytics/analytics.controller.ts b/apps/production/src/analytics/analytics.controller.tsindex 390a80687..c30e377d6 100644--- a/apps/production/src/analytics/analytics.controller.ts+++ b/apps/production/src/analytics/analytics.controller.ts@@ -54,9 +54,8 @@ import {HEARTBEAT_SID_LIFE_TIME,REDIS_USERS_COUNT_KEY,REDIS_PROJECTS_COUNT_KEY,- REDIS_PAGEVIEWS_COUNT_KEY,+ REDIS_EVENTS_COUNT_KEY,REDIS_SESSION_SALT_KEY,- REDIS_PERFORMANCE_COUNT_KEY,clickhouse,} from '../common/constants'import { BotDetection } from '../common/decorators/bot-detection.decorator'@@ -655,23 +654,18 @@ export class AnalyticsController {const exists = await redis.exists(REDIS_USERS_COUNT_KEY,REDIS_PROJECTS_COUNT_KEY,- REDIS_PAGEVIEWS_COUNT_KEY,- REDIS_PERFORMANCE_COUNT_KEY,+ REDIS_EVENTS_COUNT_KEY,)if (exists) {const users = _toNumber(await redis.get(REDIS_USERS_COUNT_KEY))const projects = _toNumber(await redis.get(REDIS_PROJECTS_COUNT_KEY))- const pageviews = _toNumber(await redis.get(REDIS_PAGEVIEWS_COUNT_KEY))- const performance = _toNumber(- await redis.get(REDIS_PERFORMANCE_COUNT_KEY),- )+ const events = _toNumber(await redis.get(REDIS_EVENTS_COUNT_KEY))return {users,projects,- pageviews,- performance,+ events,}}diff --git a/apps/production/src/common/constants.ts b/apps/production/src/common/constants.tsindex 49462ac45..17c981b33 100644--- a/apps/production/src/common/constants.ts+++ b/apps/production/src/common/constants.ts@@ -68,8 +68,7 @@ const REDIS_LOG_CUSTOM_CACHE_KEY = 'log_custom_cache_v2'const REDIS_SESSION_SALT_KEY = 'log_salt' // is updated every 24 hoursconst REDIS_USERS_COUNT_KEY = 'stats:users_count'const REDIS_PROJECTS_COUNT_KEY = 'stats:projects_count'-const REDIS_PAGEVIEWS_COUNT_KEY = 'stats:pageviews'-const REDIS_PERFORMANCE_COUNT_KEY = 'stats:performance'+const REDIS_EVENTS_COUNT_KEY = 'stats:events'const REDIS_SSO_UUID = 'sso:uuid'// Captcha service@@ -117,7 +116,7 @@ export {HEARTBEAT_SID_LIFE_TIME,REDIS_USERS_COUNT_KEY,REDIS_PROJECTS_COUNT_KEY,- REDIS_PAGEVIEWS_COUNT_KEY,+ REDIS_EVENTS_COUNT_KEY,SEND_WARNING_AT_PERC,PROJECT_INVITE_EXPIRE,TWO_FACTOR_AUTHENTICATION_APP_NAME,@@ -125,7 +124,6 @@ export {isNewRelicEnabled,ORIGINS_REGEX,REDIS_LOG_PERF_CACHE_KEY,- REDIS_PERFORMANCE_COUNT_KEY,CAPTCHA_SALT,CAPTCHA_ENCRYPTION_KEY,isDevelopment,diff --git a/apps/production/src/task-manager/task-manager.service.ts b/apps/production/src/task-manager/task-manager.service.tsindex b8be1783e..61deae793 100644--- a/apps/production/src/task-manager/task-manager.service.ts+++ b/apps/production/src/task-manager/task-manager.service.ts@@ -39,11 +39,10 @@ import {REDIS_SESSION_SALT_KEY,REDIS_USERS_COUNT_KEY,REDIS_PROJECTS_COUNT_KEY,- REDIS_PAGEVIEWS_COUNT_KEY,+ REDIS_EVENTS_COUNT_KEY,REDIS_LOG_PERF_CACHE_KEY,SEND_WARNING_AT_PERC,PROJECT_INVITE_EXPIRE,- REDIS_PERFORMANCE_COUNT_KEY,REDIS_LOG_CAPTCHA_CACHE_KEY,} from '../common/constants'import { getRandomTip } from '../common/utils'@@ -517,29 +516,27 @@ export class TaskManagerService {@Cron(CronExpression.EVERY_10_MINUTES)async getGeneralStats(): Promise<object> {- const PVquery = 'SELECT count(*) from analytics'- const CEquery = 'SELECT count(*) from customEV'- const PFquery = 'SELECT count(*) from performance'+ const trafficQuery = 'SELECT count(*) FROM analytics'+ const customEVQuery = 'SELECT count(*) FROM customEV'+ const performanceQuery = 'SELECT count(*) FROM performance'+ const captchaQuery = 'SELECT count(*) FROM captcha'const users = await this.userService.count()const projects = await this.projectService.count()- const pageviews =- (await clickhouse.query(PVquery).toPromise())[0]['count()'] +- (await clickhouse.query(CEquery).toPromise())[0]['count()']- const performance = (await clickhouse.query(PFquery).toPromise())[0][- 'count()'- ]+ const events =+ (await clickhouse.query(trafficQuery).toPromise())[0]['count()'] ++ (await clickhouse.query(customEVQuery).toPromise())[0]['count()'] ++ (await clickhouse.query(performanceQuery).toPromise())[0]['count()'] ++ (await clickhouse.query(captchaQuery).toPromise())[0]['count()']await redis.set(REDIS_USERS_COUNT_KEY, users, 'EX', 630)await redis.set(REDIS_PROJECTS_COUNT_KEY, projects, 'EX', 630)- await redis.set(REDIS_PAGEVIEWS_COUNT_KEY, pageviews, 'EX', 630)- await redis.set(REDIS_PERFORMANCE_COUNT_KEY, performance, 'EX', 630)+ await redis.set(REDIS_EVENTS_COUNT_KEY, events, 'EX', 630)return {users,projects,- pageviews,- performance,+ events,}}diff --git a/apps/selfhosted/src/common/constants.ts b/apps/selfhosted/src/common/constants.tsindex f6e34239e..1285c4caf 100644--- a/apps/selfhosted/src/common/constants.ts+++ b/apps/selfhosted/src/common/constants.ts@@ -70,8 +70,6 @@ const REDIS_LOG_CUSTOM_CACHE_KEY = 'log_custom_cache_v2'const REDIS_SESSION_SALT_KEY = 'log_salt' // is updated every 24 hoursconst REDIS_USERS_COUNT_KEY = 'stats:users_count'const REDIS_PROJECTS_COUNT_KEY = 'stats:projects_count'-const REDIS_PAGEVIEWS_COUNT_KEY = 'stats:pageviews'-const REDIS_PERFORMANCE_COUNT_KEY = 'stats:performance'// 3600 sec -> 1 hourconst redisProjectCacheTimeout = 3600@@ -100,11 +98,9 @@ export {SELFHOSTED_UUID,REDIS_USERS_COUNT_KEY,REDIS_PROJECTS_COUNT_KEY,- REDIS_PAGEVIEWS_COUNT_KEY,IP_REGEX,ORIGINS_REGEX,REDIS_LOG_PERF_CACHE_KEY,- REDIS_PERFORMANCE_COUNT_KEY,isDevelopment,DEFAULT_SELFHOSTED_UUID,JWT_ACCESS_TOKEN_SECRET,