Skip to content

Commit cea0abe

Browse files
authored
Merge pull request #24 from databuddy-analytics/staging
Staging
2 parents b84d7b4 + e509ad6 commit cea0abe

File tree

23 files changed

+228
-97
lines changed

23 files changed

+228
-97
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ node_modules
1111
.env.development.local
1212
.env.test.local
1313
.env.production.local
14-
14+
.vscode
1515
# Rules
1616
Rules
1717

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.tsdk": "node_modules\\typescript\\lib"
3+
}

apps/api/biome.json

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,21 @@
88
},
99
"files": {
1010
"ignoreUnknown": false,
11-
"includes": ["**"]
11+
"includes": [
12+
"**"
13+
]
1214
},
1315
"formatter": {
1416
"enabled": true,
1517
"indentStyle": "tab"
1618
},
17-
"assist": { "actions": { "source": { "organizeImports": "on" } } },
19+
"assist": {
20+
"actions": {
21+
"source": {
22+
"organizeImports": "off"
23+
}
24+
}
25+
},
1826
"linter": {
1927
"enabled": true,
2028
"rules": {
@@ -26,4 +34,4 @@
2634
"quoteStyle": "double"
2735
}
2836
}
29-
}
37+
}

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

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { Analytics } from "../../types/tables";
12
import type { SimpleQueryConfig } from "../types";
23

34
export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
45
browser_name: {
5-
table: 'analytics.events',
6+
table: Analytics.events,
67
fields: [
78
'browser_name as name',
89
'COUNT(*) as pageviews',
@@ -19,7 +20,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
1920
},
2021

2122
os_name: {
22-
table: 'analytics.events',
23+
table: Analytics.events,
2324
fields: [
2425
'os_name as name',
2526
'COUNT(*) as pageviews',
@@ -36,7 +37,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
3637
},
3738

3839
screen_resolution: {
39-
table: 'analytics.events',
40+
table: Analytics.events,
4041
fields: [
4142
'screen_resolution as name',
4243
'COUNT(*) as pageviews',
@@ -52,7 +53,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
5253
},
5354

5455
connection_type: {
55-
table: 'analytics.events',
56+
table: Analytics.events,
5657
fields: [
5758
'connection_type as name',
5859
'COUNT(*) as pageviews',
@@ -68,7 +69,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
6869
},
6970

7071
browsers_grouped: {
71-
table: 'analytics.events',
72+
table: Analytics.events,
7273
fields: [
7374
'CONCAT(browser_name, \' \', browser_version) as name',
7475
'browser_name',
@@ -92,7 +93,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
9293
},
9394

9495
device_types: {
95-
table: 'analytics.events',
96+
table: Analytics.events,
9697
fields: [
9798
'screen_resolution as name',
9899
'COUNT(*) as pageviews',
@@ -110,7 +111,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
110111
},
111112

112113
browsers: {
113-
table: 'analytics.events',
114+
table: Analytics.events,
114115
fields: [
115116
'browser_name as name',
116117
'COUNT(*) as pageviews',
@@ -127,7 +128,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
127128
},
128129

129130
browser_versions: {
130-
table: 'analytics.events',
131+
table: Analytics.events,
131132
fields: [
132133
'CONCAT(browser_name, \' \', browser_version) as name',
133134
'COUNT(*) as pageviews',
@@ -143,7 +144,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
143144
},
144145

145146
operating_systems: {
146-
table: 'analytics.events',
147+
table: Analytics.events,
147148
fields: [
148149
'os_name as name',
149150
'COUNT(*) as pageviews',
@@ -160,7 +161,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
160161
},
161162

162163
os_versions: {
163-
table: 'analytics.events',
164+
table: Analytics.events,
164165
fields: [
165166
'CONCAT(os_name, \' \', os_version) as name',
166167
'COUNT(*) as pageviews',
@@ -176,7 +177,7 @@ export const DevicesBuilders: Record<string, SimpleQueryConfig> = {
176177
},
177178

178179
screen_resolutions: {
179-
table: 'analytics.events',
180+
table: Analytics.events,
180181
fields: [
181182
'screen_resolution as name',
182183
'COUNT(*) as pageviews',

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import type { SimpleQueryConfig } from "../types";
2+
import { Analytics } from "../../types/tables";
23

3-
export const ErrorsBuilders: Record<string, SimpleQueryConfig> = {
4+
export const ErrorsBuilders: Record<string, SimpleQueryConfig<typeof Analytics.errors>> = {
45
recent_errors: {
5-
table: 'analytics.errors',
6+
table: Analytics.errors,
67
fields: [
78
'message as error_message',
89
'stack as error_stack',
@@ -23,7 +24,7 @@ export const ErrorsBuilders: Record<string, SimpleQueryConfig> = {
2324
},
2425

2526
error_types: {
26-
table: 'analytics.errors',
27+
table: Analytics.errors,
2728
fields: [
2829
'message as name',
2930
'COUNT(*) as count',
@@ -40,7 +41,7 @@ export const ErrorsBuilders: Record<string, SimpleQueryConfig> = {
4041
},
4142

4243
error_trends: {
43-
table: 'analytics.errors',
44+
table: Analytics.errors,
4445
fields: [
4546
'toDate(timestamp) as date',
4647
'COUNT(*) as errors',
@@ -54,7 +55,7 @@ export const ErrorsBuilders: Record<string, SimpleQueryConfig> = {
5455
},
5556

5657
errors_by_page: {
57-
table: 'analytics.errors',
58+
table: Analytics.errors,
5859
fields: [
5960
'path as name',
6061
'COUNT(*) as errors',
@@ -70,7 +71,7 @@ export const ErrorsBuilders: Record<string, SimpleQueryConfig> = {
7071
},
7172

7273
error_frequency: {
73-
table: 'analytics.errors',
74+
table: Analytics.errors,
7475
fields: [
7576
'toDate(timestamp) as date',
7677
'COUNT(*) as count'

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import type { SimpleQueryConfig } from "../types";
2+
import { Analytics } from "../../types/tables";
23

3-
export const GeoBuilders: Record<string, SimpleQueryConfig> = {
4+
export const GeoBuilders: Record<string, SimpleQueryConfig<typeof Analytics.events>> = {
45
country: {
5-
table: 'analytics.events',
6+
table: Analytics.events,
67
fields: [
78
'country as name',
89
'COUNT(*) as pageviews',
@@ -20,7 +21,7 @@ export const GeoBuilders: Record<string, SimpleQueryConfig> = {
2021
},
2122

2223
region: {
23-
table: 'analytics.events',
24+
table: Analytics.events,
2425
fields: [
2526
'region as name',
2627
'COUNT(*) as pageviews',
@@ -37,7 +38,7 @@ export const GeoBuilders: Record<string, SimpleQueryConfig> = {
3738
},
3839

3940
timezone: {
40-
table: 'analytics.events',
41+
table: Analytics.events,
4142
fields: [
4243
'timezone as name',
4344
'COUNT(*) as pageviews',
@@ -54,7 +55,7 @@ export const GeoBuilders: Record<string, SimpleQueryConfig> = {
5455
},
5556

5657
language: {
57-
table: 'analytics.events',
58+
table: Analytics.events,
5859
fields: [
5960
'language as name',
6061
'COUNT(*) as pageviews',
@@ -71,7 +72,7 @@ export const GeoBuilders: Record<string, SimpleQueryConfig> = {
7172
},
7273

7374
city: {
74-
table: 'analytics.events',
75+
table: Analytics.events,
7576
fields: [
7677
'city as name',
7778
'COUNT(*) as pageviews',

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import type { SimpleQueryConfig } from "../types";
2+
import { Analytics } from "../../types/tables";
23

3-
export const PagesBuilders: Record<string, SimpleQueryConfig> = {
4+
export const PagesBuilders: Record<string, SimpleQueryConfig<typeof Analytics.events>> = {
45
top_pages: {
5-
table: 'analytics.events',
6+
table: Analytics.events,
67
fields: [
78
'path(path) as name',
89
'COUNT(*) as pageviews',
@@ -19,7 +20,7 @@ export const PagesBuilders: Record<string, SimpleQueryConfig> = {
1920
},
2021

2122
entry_pages: {
22-
table: 'analytics.events',
23+
table: Analytics.events,
2324
fields: [
2425
'entry_page as name',
2526
'COUNT(*) as pageviews',
@@ -79,7 +80,7 @@ export const PagesBuilders: Record<string, SimpleQueryConfig> = {
7980
},
8081

8182
exit_pages: {
82-
table: 'analytics.events',
83+
table: Analytics.events,
8384
fields: [
8485
'path as name',
8586
'COUNT(DISTINCT session_id) as pageviews',
@@ -149,7 +150,7 @@ export const PagesBuilders: Record<string, SimpleQueryConfig> = {
149150
},
150151

151152
page_performance: {
152-
table: 'analytics.events',
153+
table: Analytics.events,
153154
fields: [
154155
'path(path) as name',
155156
'COUNT(*) as pageviews',

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
import { Analytics } from "../../types/tables";
12
import type { SimpleQueryConfig } from "../types";
23

34
export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
45
performance_metrics: {
5-
table: 'analytics.events',
6+
table: Analytics.events,
67
fields: [
78
'AVG(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as avg_load_time',
89
'AVG(CASE WHEN dom_ready_time > 0 THEN dom_ready_time ELSE NULL END) as avg_dom_ready_time',
@@ -20,7 +21,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
2021
},
2122

2223
slow_pages: {
23-
table: 'analytics.events',
24+
table: Analytics.events,
2425
fields: [
2526
'path(path) as name',
2627
'COUNT(DISTINCT anonymous_id) as visitors',
@@ -43,7 +44,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
4344
},
4445

4546
performance_by_device: {
46-
table: 'analytics.events',
47+
table: Analytics.events,
4748
fields: [
4849
'device_type as name',
4950
'COUNT(DISTINCT anonymous_id) as visitors',
@@ -66,7 +67,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
6667
},
6768

6869
performance_by_browser: {
69-
table: 'analytics.events',
70+
table: Analytics.events,
7071
fields: [
7172
'CONCAT(browser_name, \' \', browser_version) as name',
7273
'COUNT(DISTINCT anonymous_id) as visitors',
@@ -95,7 +96,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
9596
},
9697

9798
performance_by_country: {
98-
table: 'analytics.events',
99+
table: Analytics.events,
99100
fields: [
100101
'country as name',
101102
'COUNT(DISTINCT anonymous_id) as visitors',
@@ -119,7 +120,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
119120
},
120121

121122
performance_by_os: {
122-
table: 'analytics.events',
123+
table: Analytics.events,
123124
fields: [
124125
'os_name as name',
125126
'COUNT(DISTINCT anonymous_id) as visitors',
@@ -142,7 +143,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
142143
},
143144

144145
performance_by_region: {
145-
table: 'analytics.events',
146+
table: Analytics.events,
146147
fields: [
147148
'CONCAT(region, \', \', country) as name',
148149
'COUNT(DISTINCT anonymous_id) as visitors',
@@ -165,7 +166,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
165166
},
166167

167168
performance_time_series: {
168-
table: 'analytics.events',
169+
table: Analytics.events,
169170
fields: [
170171
'toDate(time) as date',
171172
'AVG(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as avg_load_time',

0 commit comments

Comments
 (0)