Skip to content

Commit a0db7bc

Browse files
committed
fix: session attribution
1 parent 0066b12 commit a0db7bc

File tree

6 files changed

+42
-22
lines changed

6 files changed

+42
-22
lines changed

apps/api/src/query/builders/pages.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,9 @@ export const PagesBuilders: Record<string, SimpleQueryConfig> = {
112112
sessionAttributionJoin: (alias?: string) => string;
113113
}
114114
) => {
115-
const combinedWhereClause = buildWhereClause(filterConditions);
115+
const combinedWhereClause = filterConditions?.length
116+
? `AND ${filterConditions.join(' AND ')}`
117+
: '';
116118

117119
// Use session attribution if helpers are provided
118120
const sessionAttributionCTE = helpers?.sessionAttributionCTE
@@ -232,7 +234,9 @@ export const PagesBuilders: Record<string, SimpleQueryConfig> = {
232234
sessionAttributionJoin: (alias?: string) => string;
233235
}
234236
) => {
235-
const combinedWhereClause = buildWhereClause(filterConditions);
237+
const combinedWhereClause = filterConditions?.length
238+
? `AND ${filterConditions.join(' AND ')}`
239+
: '';
236240

237241
// Use session attribution if helpers are provided
238242
const sessionAttributionCTE = helpers?.sessionAttributionCTE
@@ -379,7 +383,9 @@ export const PagesBuilders: Record<string, SimpleQueryConfig> = {
379383
sessionAttributionJoin: (alias?: string) => string;
380384
}
381385
) => {
382-
const combinedWhereClause = buildWhereClause(filterConditions);
386+
const combinedWhereClause = filterConditions?.length
387+
? `AND ${filterConditions.join(' AND ')}`
388+
: '';
383389

384390
// Use session attribution if helpers are provided
385391
const sessionAttributionCTE = helpers?.sessionAttributionCTE

apps/api/src/query/builders/profiles.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ export const ProfilesBuilders: Record<string, SimpleQueryConfig> = {
1616
filterConditions?: string[],
1717
filterParams?: Record<string, Filter['value']>
1818
) => {
19-
const combinedWhereClause = buildWhereClause(filterConditions);
19+
const combinedWhereClause = filterConditions?.length
20+
? `AND ${filterConditions.join(' AND ')}`
21+
: '';
2022

2123
return {
2224
sql: `
@@ -358,7 +360,9 @@ export const ProfilesBuilders: Record<string, SimpleQueryConfig> = {
358360
filterConditions?: string[],
359361
filterParams?: Record<string, Filter['value']>
360362
) => {
361-
const combinedWhereClause = buildWhereClause(filterConditions);
363+
const combinedWhereClause = filterConditions?.length
364+
? `AND ${filterConditions.join(' AND ')}`
365+
: '';
362366

363367
return {
364368
sql: `

apps/api/src/query/builders/sessions.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,9 @@ export const SessionsBuilders: Record<string, SimpleQueryConfig> = {
111111
filterConditions?: string[],
112112
filterParams?: Record<string, Filter['value']>
113113
) => {
114-
const combinedWhereClause = buildWhereClause(filterConditions);
114+
const combinedWhereClause = filterConditions?.length
115+
? `AND ${filterConditions.join(' AND ')}`
116+
: '';
115117

116118
return {
117119
sql: `

apps/api/src/query/builders/summary.ts

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,10 @@ export const SummaryBuilders: Record<string, SimpleQueryConfig> = {
7070
sessionAttributionJoin: (alias?: string) => string;
7171
}
7272
) => {
73-
const tz = timezone || 'UTC';
74-
const combinedWhereClause = buildWhereClause(filterConditions);
73+
const tz = timezone || 'UTC';
74+
const combinedWhereClause = filterConditions?.length
75+
? `AND ${filterConditions.join(' AND ')}`
76+
: '';
7577

7678
// Use session attribution if helpers are provided
7779
const sessionAttributionCTE = helpers?.sessionAttributionCTE
@@ -293,9 +295,11 @@ export const SummaryBuilders: Record<string, SimpleQueryConfig> = {
293295
sessionAttributionJoin: (alias?: string) => string;
294296
}
295297
) => {
296-
const tz = timezone || 'UTC';
297-
const isHourly = _granularity === 'hour' || _granularity === 'hourly';
298-
const combinedWhereClause = buildWhereClause(filterConditions);
298+
const tz = timezone || 'UTC';
299+
const isHourly = _granularity === 'hour' || _granularity === 'hourly';
300+
const combinedWhereClause = filterConditions?.length
301+
? `AND ${filterConditions.join(' AND ')}`
302+
: '';
299303

300304
if (isHourly) {
301305
// Use session attribution if helpers are provided
@@ -537,7 +541,9 @@ export const SummaryBuilders: Record<string, SimpleQueryConfig> = {
537541
filterConditions?: string[],
538542
filterParams?: Record<string, Filter['value']>
539543
) => {
540-
const combinedWhereClause = buildWhereClause(filterConditions);
544+
const combinedWhereClause = filterConditions?.length
545+
? `AND ${filterConditions.join(' AND ')}`
546+
: '';
541547
return {
542548
sql: `
543549
SELECT

bun.lock

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,7 @@
488488
"ultracite": "5.3.10",
489489
"vaul": "^1.1.2",
490490
"vitest": "^3.2.4",
491-
"zod": "3.25.76",
491+
"zod": "4.1.12",
492492
},
493493
"packages": {
494494
"@ai-sdk/gateway": ["@ai-sdk/[email protected]", "", { "dependencies": { "@ai-sdk/provider": "2.0.0", "@ai-sdk/provider-utils": "3.0.12", "@vercel/oidc": "3.0.3" }, "peerDependencies": { "zod": "^3.25.76 || ^4.1.8" } }, "sha512-Gj0PuawK7NkZuyYgO/h5kDK/l6hFOjhLdTq3/Lli1FTl47iGmwhH1IZQpAL3Z09BeFYWakcwUmn02ovIm2wy9g=="],
@@ -3223,7 +3223,7 @@
32233223

32243224
"yoga-layout": ["[email protected]", "", {}, "sha512-0LPOt3AxKqMdFBZA3HBAt/t/8vIKq7VaQYbuA8WxCgung+p9TVyKRYdpvCb80HcdTN2NkbIKbhNwKUfm3tQywQ=="],
32253225

3226-
"zod": ["zod@3.25.76", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
3226+
"zod": ["zod@4.1.12", "", {}, "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ=="],
32273227

32283228
"zod-to-json-schema": ["[email protected]", "", { "peerDependencies": { "zod": "^3.24.1" } }, "sha512-h/z3PKvcTcTetyjl1fkj79MHNEjm+HpD6NXheWjzOekY7kV+lwDYnHw+ivHkijnCSMz1yJaWBD9vu/Fcmk+vEg=="],
32293229

@@ -3233,8 +3233,6 @@
32333233

32343234
"@babel/helper-compilation-targets/lru-cache": ["[email protected]", "", { "dependencies": { "yallist": "^3.0.2" } }, "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w=="],
32353235

3236-
"@better-auth/core/zod": ["[email protected]", "", {}, "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ=="],
3237-
32383236
"@databuddy/dashboard/@biomejs/biome": ["@biomejs/[email protected]", "", { "optionalDependencies": { "@biomejs/cli-darwin-arm64": "2.2.2", "@biomejs/cli-darwin-x64": "2.2.2", "@biomejs/cli-linux-arm64": "2.2.2", "@biomejs/cli-linux-arm64-musl": "2.2.2", "@biomejs/cli-linux-x64": "2.2.2", "@biomejs/cli-linux-x64-musl": "2.2.2", "@biomejs/cli-win32-arm64": "2.2.2", "@biomejs/cli-win32-x64": "2.2.2" }, "bin": { "biome": "bin/biome" } }, "sha512-j1omAiQWCkhuLgwpMKisNKnsM6W8Xtt1l0WZmqY/dFj8QPNkIoTvk4tSsi40FaAAkBE1PU0AFG2RWFBWenAn+w=="],
32393237

32403238
"@databuddy/dashboard/ultracite": ["[email protected]", "", { "dependencies": { "@clack/prompts": "^0.11.0", "deepmerge": "^4.3.1", "jsonc-parser": "^3.3.1", "nypm": "^0.6.1", "trpc-cli": "^0.10.2", "vitest": "^3.2.4", "zod": "^4.1.5" }, "bin": { "ultracite": "dist/index.js" } }, "sha512-3eFcYZsI21RJdBkQhS6062NaxE268tx+NxfRzNRMZoJHrAPwLrGS87t9ru4IkUEbVKEElrnUM5TOpH1Z3mZkYQ=="],
@@ -3301,9 +3299,9 @@
33013299

33023300
"accepts/negotiator": ["[email protected]", "", {}, "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg=="],
33033301

3304-
"axios/form-data": ["[email protected]", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "hasown": "^2.0.2", "mime-types": "^2.1.12" } }, "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow=="],
3302+
"autumn-js/zod": ["[email protected]", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
33053303

3306-
"better-auth/zod": ["zod@4.1.12", "", {}, "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ=="],
3304+
"axios/form-data": ["form-data@4.0.4", "", { "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", "es-set-tostringtag": "^2.1.0", "hasown": "^2.0.2", "mime-types": "^2.1.12" } }, "sha512-KrGhL9Q4zjj0kiUt5OO4Mr/A/jlI2jDYs5eHBpYHPcBEVSiipAvn2Ko2HnPe20rmcuuvMHNdZFp+4IlGTMF0Ow=="],
33073305

33083306
"better-call/rou3": ["[email protected]", "", {}, "sha512-OXMmJ3zRk2xeXFGfA3K+EOPHC5u7RDFG7lIOx0X1pdnhUkI8MdVrbV+sNsD80ElpUZ+MRHdyxPnFthq9VHs8uQ=="],
33093307

@@ -3339,6 +3337,10 @@
33393337

33403338
"engine.io/ws": ["[email protected]", "", { "peerDependencies": { "bufferutil": "^4.0.1", "utf-8-validate": ">=5.0.2" }, "optionalPeers": ["bufferutil", "utf-8-validate"] }, "sha512-6XQFvXTkbfUOZOKKILFG1PDK2NDQs4azKQl26T0YS5CxqWLgXajbPZ+h4gZekJyRqFU8pvnbAbbs/3TgRPy+GQ=="],
33413339

3340+
"fumadocs-docgen/zod": ["[email protected]", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
3341+
3342+
"fumadocs-mdx/zod": ["[email protected]", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
3343+
33423344
"gaxios/uuid": ["[email protected]", "", { "bin": { "uuid": "dist/bin/uuid" } }, "sha512-b+1eJOlsR9K8HJpow9Ok3fiWOWSIcIzXodvv0rQjVoOVNpWMpxf1wZNpt4y9h10odCNrqnYp1OBzRktckBe3sA=="],
33433345

33443346
"glob/foreground-child": ["[email protected]", "", { "dependencies": { "cross-spawn": "^7.0.6", "signal-exit": "^4.0.1" } }, "sha512-gIXjKqtFuWEgzFRJA9WCQeSJLZDjgJUOMCMzxtvFq/37KojM1BFGufqsCy0r4qSQmYLsZYMeyRqzIWOMup03sw=="],
@@ -3443,6 +3445,8 @@
34433445

34443446
"topojson-client/commander": ["[email protected]", "", {}, "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ=="],
34453447

3448+
"trpc-cli/zod": ["[email protected]", "", {}, "sha512-gzUt/qt81nXsFGKIFcC3YnfEAx5NkunCfnDlvuBSSFS02bcXu4Lmea0AFIUwbLWxWPx3d9p8S5QoaujKcNQxcQ=="],
3449+
34463450
"tsyringe/tslib": ["[email protected]", "", {}, "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg=="],
34473451

34483452
"vitest/tinyexec": ["[email protected]", "", {}, "sha512-KQQR9yN7R5+OSwaK0XQoj22pwHoTlgYqmUscPYoknOoWCWfj/5/ABTMRi69FrKU5ffPVh5QcFikpWJI/P1ocHA=="],
@@ -3477,8 +3481,6 @@
34773481

34783482
"@databuddy/dashboard/@biomejs/biome/@biomejs/cli-win32-x64": ["@biomejs/[email protected]", "", { "os": "win32", "cpu": "x64" }, "sha512-DAuHhHekGfiGb6lCcsT4UyxQmVwQiBCBUMwVra/dcOSs9q8OhfaZgey51MlekT3p8UwRqtXQfFuEJBhJNdLZwg=="],
34793483

3480-
"@databuddy/dashboard/ultracite/zod": ["[email protected]", "", {}, "sha512-JInaHOamG8pt5+Ey8kGmdcAcg3OL9reK8ltczgHTAwNhMys/6ThXHityHxVV2p3fkw/c+MAvBHFVYHFZDmjMCQ=="],
3481-
34823484
"@databuddy/docs/@biomejs/biome/@biomejs/cli-darwin-arm64": ["@biomejs/[email protected]", "", { "os": "darwin", "cpu": "arm64" }, "sha512-6ePfbCeCPryWu0CXlzsWNZgVz/kBEvHiPyNpmViSt6A2eoDf4kXs3YnwQPzGjy8oBgQulrHcLnJL0nkCh80mlQ=="],
34833485

34843486
"@databuddy/docs/@biomejs/biome/@biomejs/cli-darwin-x64": ["@biomejs/[email protected]", "", { "os": "darwin", "cpu": "x64" }, "sha512-Tn4JmVO+rXsbRslml7FvKaNrlgUeJot++FkvYIhl1OkslVCofAtS35MPlBMhXgKWF9RNr9cwHanrPTUUXcYGag=="],

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
"react": "19.0.0",
4747
"react-dom": "19.0.0",
4848
"next": "^15.3.4",
49-
"typescript": "^5.9.3",
50-
"zod": "3.25.76",
49+
"typescript": "^5.9.3",
50+
"zod": "4.1.12",
5151
"tailwindcss": "^4.1.4",
5252
"autumn-js": "^0.0.101",
5353
"stripe": "^18.2.1",

0 commit comments

Comments
 (0)