Skip to content

Commit 4191a6f

Browse files
authored
Merge branch 'main' into fix/custom-events
2 parents f002031 + 472a061 commit 4191a6f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+5542
-165
lines changed

.github/workflows/test.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Tests
2+
3+
on:
4+
push:
5+
branches: [main, staging]
6+
pull_request:
7+
branches: [main, staging]
8+
9+
jobs:
10+
test:
11+
name: Run Tests
12+
runs-on: ubuntu-latest
13+
14+
services:
15+
postgres:
16+
image: postgres:16
17+
env:
18+
POSTGRES_USER: postgres
19+
POSTGRES_PASSWORD: postgres
20+
POSTGRES_DB: databuddy_test
21+
ports:
22+
- 5432:5432
23+
options: >-
24+
--health-cmd pg_isready
25+
--health-interval 10s
26+
--health-timeout 5s
27+
--health-retries 5
28+
29+
redis:
30+
image: redis:7-alpine
31+
ports:
32+
- 6379:6379
33+
options: >-
34+
--health-cmd "redis-cli ping"
35+
--health-interval 10s
36+
--health-timeout 5s
37+
--health-retries 5
38+
39+
clickhouse:
40+
image: clickhouse/clickhouse-server:latest
41+
ports:
42+
- 8123:8123
43+
- 9000:9000
44+
env:
45+
CLICKHOUSE_DB: databuddy_test
46+
options: >-
47+
--health-cmd "clickhouse-client --query 'SELECT 1'"
48+
--health-interval 10s
49+
--health-timeout 5s
50+
--health-retries 5
51+
52+
steps:
53+
- name: Checkout repository
54+
uses: actions/checkout@v4
55+
56+
- name: Setup Bun
57+
uses: oven-sh/setup-bun@v2
58+
with:
59+
bun-version: latest
60+
61+
- name: Install dependencies
62+
run: bun install --frozen-lockfile
63+
64+
- name: Run tests
65+
env:
66+
# Database URLs
67+
DATABASE_URL: postgresql://postgres:postgres@localhost:5432/databuddy_test
68+
POSTGRES_URL: postgresql://postgres:postgres@localhost:5432/databuddy_test
69+
70+
# Redis URL
71+
REDIS_URL: redis://localhost:6379
72+
REDIS_HOST: localhost
73+
REDIS_PORT: 6379
74+
75+
# ClickHouse URLs
76+
CLICKHOUSE_URL: http://localhost:8123
77+
CLICKHOUSE_HOST: localhost
78+
CLICKHOUSE_PORT: 8123
79+
CLICKHOUSE_DATABASE: databuddy_test
80+
81+
# Test environment
82+
NODE_ENV: test
83+
84+
# Auth secrets (use dummy values for tests)
85+
AUTH_SECRET: test-auth-secret-for-ci-testing-only
86+
NEXTAUTH_SECRET: test-auth-secret-for-ci-testing-only
87+
88+
# API keys (use dummy values for tests)
89+
EMAIL_API_KEY: test-email-api-key
90+
IP_HASH_SALT: test-ip-hash-salt
91+
92+
run: bun test
93+
94+
- name: Upload coverage reports
95+
if: always()
96+
uses: codecov/codecov-action@v4
97+
with:
98+
files: ./coverage/coverage-final.json
99+
fail_ci_if_error: false
100+
token: ${{ secrets.CODECOV_TOKEN }}
101+

apps/api/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@databuddy/redis": "workspace:*",
2121
"@databuddy/rpc": "workspace:*",
2222
"@databuddy/shared": "workspace:*",
23+
"@databuddy/sdk": "workspace:*",
2324
"@elysiajs/cors": "^1.3.3",
2425
"@elysiajs/trpc": "^1.1.0",
2526
"@logtail/edge": "^0.5.5",

apps/api/src/lib/databuddy.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { Databuddy } from '@databuddy/sdk/node';
2+
3+
const databuddy = new Databuddy({
4+
clientId: '3ed1fce1-5a56-4cb6-a977-66864f6d18e3',
5+
});
6+
7+
export { databuddy };

apps/api/src/routes/query.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
DynamicQueryRequestSchema,
1414
type DynamicQueryRequestType,
1515
} from '../schemas';
16+
import { databuddy } from '../lib/databuddy';
1617

1718
interface QueryParams {
1819
start_date?: string;
@@ -213,6 +214,13 @@ export const query = new Elysia({ prefix: '/v1/query' })
213214
: null;
214215

215216
const result = compileQuery(body as QueryRequest, websiteDomain);
217+
databuddy.track({
218+
name: 'compile_query',
219+
properties: {
220+
website_id,
221+
website_domain: websiteDomain,
222+
},
223+
});
216224
return {
217225
success: true,
218226
...result,

apps/api/tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"compilerOptions": {
33
"lib": ["ESNext"],
44
"target": "ESNext",
5-
"module": "Preserve",
5+
"module": "esnext",
66
"moduleDetection": "force",
77
"jsx": "react-jsx",
88
"allowJs": true,

apps/basket/package.json

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
"packageManager": "[email protected]",
55
"scripts": {
66
"dev": "bun --watch run src/index.ts --port 3002",
7-
"start": "bun run src/index.ts --port 3002"
7+
"start": "bun run src/index.ts --port 3002",
8+
"test": "bun test",
9+
"test:watch": "bun test --watch",
10+
"test:routes": "bun test src/routes/*.test.ts",
11+
"test:utils": "bun test src/utils/*.test.ts",
12+
"test:coverage": "bun test --coverage"
813
},
914
"dependencies": {
1015
"@clickhouse/client": "catalog:",

0 commit comments

Comments
 (0)