📈 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
use new clickhouse/client integration
Blue Mouse29fabc3c36c0
diff --git a/apps/production/src/project/project.controller.ts b/apps/production/src/project/project.controller.tsindex ae8cf8426..3e93a450c 100644--- a/apps/production/src/project/project.controller.ts+++ b/apps/production/src/project/project.controller.ts@@ -72,13 +72,13 @@ import { UserService } from '../user/user.service'import { AppLoggerService } from '../logger/logger.service'import {isValidPID,- clickhouse,PROJECT_INVITE_EXPIRE,CAPTCHA_SECRET_KEY_LENGTH,isDevelopment,PRODUCTION_ORIGIN,MAX_FUNNELS,} from '../common/constants'+import { clickhouse } from '../common/integrations/clickhouse'import { generateRandomString } from '../common/utils'import {AddSubscriberParamsDto,@@ -749,12 +749,25 @@ export class ProjectController {this.projectService.allowedToManage(project, uid, user.roles)- const query1 = `ALTER table analytics DELETE WHERE pid='${id}'`- const query2 = `ALTER table customEV DELETE WHERE pid='${id}'`+ const queries = [+ 'ALTER table analytics DELETE WHERE pid={pid:FixedString(12)}',+ 'ALTER table customEV DELETE WHERE pid={pid:FixedString(12)}',+ 'ALTER table performance DELETE WHERE pid={pid:FixedString(12)}',+ 'ALTER table errors DELETE WHERE pid={pid:FixedString(12)}',+ 'ALTER table error_statuses DELETE WHERE pid={pid:FixedString(12)}',+ ]try {- await clickhouse.query(query1).toPromise()- await clickhouse.query(query2).toPromise()+ const promises = _map(queries, async query =>+ clickhouse.query({+ query,+ query_params: {+ pid: id,+ },+ }),+ )++ await Promise.all(promises)return 'Project resetted successfully'} catch (e) {this.logger.error(e)@@ -779,8 +792,6 @@ export class ProjectController {)}- const query = `ALTER table captcha DELETE WHERE pid='${id}'`-const user = await this.userService.findOne(uid)const project = await this.projectService.findOneWhere({ id },@@ -797,7 +808,12 @@ export class ProjectController {this.projectService.allowedToManage(project, uid, user.roles)try {- await clickhouse.query(query).toPromise()+ await clickhouse.query({+ query: 'ALTER table captcha DELETE WHERE pid={pid:FixedString(12)}',+ query_params: {+ pid: id,+ },+ })return 'CAPTCHA project resetted successfully'} catch (e) {this.logger.error(e)@@ -877,10 +893,13 @@ export class ProjectController {this.projectService.allowedToManage(project, uid, user.roles)- const query = `ALTER table captcha DELETE WHERE pid='${id}'`-try {- await clickhouse.query(query).toPromise()+ await clickhouse.query({+ query: 'ALTER table captcha DELETE WHERE pid={pid:FixedString(12)}',+ query_params: {+ pid: id,+ },+ })project.captchaSecretKey = nullproject.isCaptchaEnabled = false@@ -1555,12 +1574,27 @@ export class ProjectController {this.projectService.allowedToManage(project, uid, user.roles)- const query1 = `ALTER table analytics DELETE WHERE pid='${id}'`- const query2 = `ALTER table customEV DELETE WHERE pid='${id}'`+ const queries = [+ 'ALTER table analytics DELETE WHERE pid={pid:FixedString(12)}',+ 'ALTER table customEV DELETE WHERE pid={pid:FixedString(12)}',+ 'ALTER table performance DELETE WHERE pid={pid:FixedString(12)}',+ 'ALTER table errors DELETE WHERE pid={pid:FixedString(12)}',+ 'ALTER table error_statuses DELETE WHERE pid={pid:FixedString(12)}',+ 'ALTER table captcha DELETE WHERE pid={pid:FixedString(12)}',+ ]try {- await clickhouse.query(query1).toPromise()- await clickhouse.query(query2).toPromise()+ const promises = _map(queries, async query =>+ clickhouse.query({+ query,+ query_params: {+ pid: id,+ },+ }),+ )++ await Promise.all(promises)+await deleteProjectRedis(id)} catch (e) {this.logger.error(e)