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!

set up clickhouse/client integration

Blue Mouse7ce2d036ce87
diff --git a/apps/production/src/common/integrations/clickhouse.ts b/apps/production/src/common/integrations/clickhouse.ts
new file mode 100644
index 000000000..039dd8e04
--- /dev/null
+++ b/apps/production/src/common/integrations/clickhouse.ts
@@ -0,0 +1,21 @@
+import { createClient } from '@clickhouse/client'
+
+const clickhouse = createClient({
+ host: `${process.env.CLICKHOUSE_HOST}:${process.env.CLICKHOUSE_PORT}`,
+ username: process.env.CLICKHOUSE_USER,
+ password: process.env.CLICKHOUSE_PASSWORD,
+ database: process.env.CLICKHOUSE_DATABASE,
+ request_timeout: 60000, // 1 minute
+ clickhouse_settings: {
+ connect_timeout: 60000,
+ date_time_output_format: 'iso',
+ max_download_buffer_size: (10 * 1024 * 1024).toString(),
+ max_download_threads: 32,
+ max_execution_time: 60000,
+ output_format_json_quote_64bit_integers: 0,
+ enable_http_compression: 0,
+ log_queries: 0,
+ },
+})
+
+export { clickhouse }
diff --git a/package.json b/package.json
index 0105643d5..036be44f7 100644
--- a/package.json
+++ b/package.json
@@ -27,6 +27,7 @@
"sentry:sourcemaps": "sentry-cli sourcemaps inject --org my-org-f6 --project swetrix-api ./dist && sentry-cli sourcemaps upload --org my-org-f6 --project swetrix-api ./dist"
},
"dependencies": {
+ "@clickhouse/client": "^1.4.0",
"@faker-js/faker": "^8.4.1",
"@nestjs-modules/mailer": "^2.0.2",
"@nestjs/axios": "^3.0.2",