Skip to content

Commit eb360b2

Browse files
committed
feat: better performance
1 parent 3595e07 commit eb360b2

File tree

7 files changed

+48
-240
lines changed

7 files changed

+48
-240
lines changed

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

Lines changed: 28 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
1212
'COUNT(DISTINCT anonymous_id) as visitors',
1313
'AVG(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as avg_load_time',
1414
'quantile(0.50)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p50_load_time',
15-
'quantile(0.75)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p75_load_time',
16-
'quantile(0.90)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p90_load_time',
17-
'quantile(0.95)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p95_load_time',
18-
'quantile(0.99)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p99_load_time',
1915
'AVG(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as avg_ttfb',
20-
'quantile(0.95)(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as p95_ttfb',
21-
'quantile(0.99)(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as p99_ttfb',
2216
'AVG(CASE WHEN dom_ready_time > 0 THEN dom_ready_time ELSE NULL END) as avg_dom_ready_time',
2317
'AVG(CASE WHEN render_time > 0 THEN render_time ELSE NULL END) as avg_render_time',
2418
'COUNT(*) as pageviews',
@@ -27,7 +21,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
2721
groupBy: [
2822
"decodeURLComponent(CASE WHEN trimRight(path(path), '/') = '' THEN '/' ELSE trimRight(path(path), '/') END)",
2923
],
30-
orderBy: 'p95_load_time DESC',
24+
orderBy: 'p50_load_time DESC',
3125
limit: 100,
3226
timeField: 'time',
3327
customizable: true,
@@ -38,10 +32,8 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
3832
"CONCAT(browser_name, ' ', browser_version) as name",
3933
'COUNT(DISTINCT anonymous_id) as visitors',
4034
'AVG(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as avg_load_time',
41-
'quantile(0.95)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p95_load_time',
42-
'quantile(0.99)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p99_load_time',
35+
'quantile(0.50)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p50_load_time',
4336
'AVG(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as avg_ttfb',
44-
'quantile(0.95)(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as p95_ttfb',
4537
'AVG(CASE WHEN dom_ready_time > 0 THEN dom_ready_time ELSE NULL END) as avg_dom_ready_time',
4638
'AVG(CASE WHEN render_time > 0 THEN render_time ELSE NULL END) as avg_render_time',
4739
'COUNT(*) as pageviews',
@@ -54,7 +46,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
5446
'load_time > 0',
5547
],
5648
groupBy: ['browser_name', 'browser_version'],
57-
orderBy: 'p95_load_time DESC',
49+
orderBy: 'p50_load_time DESC',
5850
limit: 100,
5951
timeField: 'time',
6052
customizable: true,
@@ -66,17 +58,15 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
6658
'country as name',
6759
'COUNT(DISTINCT anonymous_id) as visitors',
6860
'AVG(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as avg_load_time',
69-
'quantile(0.95)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p95_load_time',
70-
'quantile(0.99)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p99_load_time',
61+
'quantile(0.50)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p50_load_time',
7162
'AVG(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as avg_ttfb',
72-
'quantile(0.95)(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as p95_ttfb',
7363
'AVG(CASE WHEN dom_ready_time > 0 THEN dom_ready_time ELSE NULL END) as avg_dom_ready_time',
7464
'AVG(CASE WHEN render_time > 0 THEN render_time ELSE NULL END) as avg_render_time',
7565
'COUNT(*) as pageviews',
7666
],
7767
where: ["event_name = 'screen_view'", "country != ''", 'load_time > 0'],
7868
groupBy: ['country'],
79-
orderBy: 'p95_load_time DESC',
69+
orderBy: 'p50_load_time DESC',
8070
limit: 100,
8171
timeField: 'time',
8272
customizable: true,
@@ -89,17 +79,15 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
8979
'os_name as name',
9080
'COUNT(DISTINCT anonymous_id) as visitors',
9181
'AVG(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as avg_load_time',
92-
'quantile(0.95)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p95_load_time',
93-
'quantile(0.99)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p99_load_time',
82+
'quantile(0.50)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p50_load_time',
9483
'AVG(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as avg_ttfb',
95-
'quantile(0.95)(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as p95_ttfb',
9684
'AVG(CASE WHEN dom_ready_time > 0 THEN dom_ready_time ELSE NULL END) as avg_dom_ready_time',
9785
'AVG(CASE WHEN render_time > 0 THEN render_time ELSE NULL END) as avg_render_time',
9886
'COUNT(*) as pageviews',
9987
],
10088
where: ["event_name = 'screen_view'", "os_name != ''", 'load_time > 0'],
10189
groupBy: ['os_name'],
102-
orderBy: 'p95_load_time DESC',
90+
orderBy: 'p50_load_time DESC',
10391
limit: 100,
10492
timeField: 'time',
10593
customizable: true,
@@ -111,17 +99,15 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
11199
"CONCAT(region, ', ', country) as name",
112100
'COUNT(DISTINCT anonymous_id) as visitors',
113101
'AVG(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as avg_load_time',
114-
'quantile(0.95)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p95_load_time',
115-
'quantile(0.99)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p99_load_time',
102+
'quantile(0.50)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p50_load_time',
116103
'AVG(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as avg_ttfb',
117-
'quantile(0.95)(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as p95_ttfb',
118104
'AVG(CASE WHEN dom_ready_time > 0 THEN dom_ready_time ELSE NULL END) as avg_dom_ready_time',
119105
'AVG(CASE WHEN render_time > 0 THEN render_time ELSE NULL END) as avg_render_time',
120106
'COUNT(*) as pageviews',
121107
],
122108
where: ["event_name = 'screen_view'", "region != ''", 'load_time > 0'],
123109
groupBy: ['region', 'country'],
124-
orderBy: 'p95_load_time DESC',
110+
orderBy: 'p50_load_time DESC',
125111
limit: 100,
126112
timeField: 'time',
127113
customizable: true,
@@ -133,10 +119,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
133119
'toDate(time) as date',
134120
'AVG(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as avg_load_time',
135121
'quantile(0.50)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p50_load_time',
136-
'quantile(0.95)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p95_load_time',
137-
'quantile(0.99)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p99_load_time',
138122
'AVG(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as avg_ttfb',
139-
'quantile(0.95)(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as p95_ttfb',
140123
'AVG(CASE WHEN dom_ready_time > 0 THEN dom_ready_time ELSE NULL END) as avg_dom_ready_time',
141124
'AVG(CASE WHEN render_time > 0 THEN render_time ELSE NULL END) as avg_render_time',
142125
'COUNT(*) as pageviews',
@@ -154,8 +137,6 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
154137
'toDate(time) as date',
155138
'AVG(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as avg_load_time',
156139
'quantile(0.50)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p50_load_time',
157-
'quantile(0.95)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p95_load_time',
158-
'quantile(0.99)(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as p99_load_time',
159140
'COUNT(*) as pageviews',
160141
],
161142
where: ["event_name = 'screen_view'", 'load_time > 0'],
@@ -172,35 +153,19 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
172153
'COUNT(DISTINCT anonymous_id) as visitors',
173154
'AVG(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as avg_fcp',
174155
'quantile(0.50)(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as p50_fcp',
175-
'quantile(0.75)(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as p75_fcp',
176-
'quantile(0.90)(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as p90_fcp',
177-
'quantile(0.95)(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as p95_fcp',
178-
'quantile(0.99)(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as p99_fcp',
179156
'AVG(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as avg_lcp',
180157
'quantile(0.50)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p50_lcp',
181-
'quantile(0.75)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p75_lcp',
182-
'quantile(0.90)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p90_lcp',
183-
'quantile(0.95)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p95_lcp',
184-
'quantile(0.99)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p99_lcp',
185158
'AVG(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as avg_cls',
186159
'quantile(0.50)(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as p50_cls',
187-
'quantile(0.75)(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as p75_cls',
188-
'quantile(0.90)(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as p90_cls',
189-
'quantile(0.95)(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as p95_cls',
190-
'quantile(0.99)(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as p99_cls',
191160
'AVG(CASE WHEN fid > 0 THEN fid ELSE NULL END) as avg_fid',
192-
'quantile(0.95)(CASE WHEN fid > 0 THEN fid ELSE NULL END) as p95_fid',
193-
'quantile(0.99)(CASE WHEN fid > 0 THEN fid ELSE NULL END) as p99_fid',
194161
'AVG(CASE WHEN inp > 0 THEN inp ELSE NULL END) as avg_inp',
195-
'quantile(0.95)(CASE WHEN inp > 0 THEN inp ELSE NULL END) as p95_inp',
196-
'quantile(0.99)(CASE WHEN inp > 0 THEN inp ELSE NULL END) as p99_inp',
197162
'COUNT(*) as measurements',
198163
],
199164
where: ["path != ''"],
200165
groupBy: [
201166
"decodeURLComponent(CASE WHEN trimRight(path(path), '/') = '' THEN '/' ELSE trimRight(path(path), '/') END)",
202167
],
203-
orderBy: 'p95_lcp DESC',
168+
orderBy: 'p50_lcp DESC',
204169
limit: 100,
205170
timeField: 'timestamp',
206171
customizable: true,
@@ -212,18 +177,13 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
212177
"CONCAT(browser_name, ' ', browser_version) as name",
213178
'COUNT(DISTINCT anonymous_id) as visitors',
214179
'AVG(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as avg_fcp',
215-
'quantile(0.95)(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as p95_fcp',
216-
'quantile(0.99)(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as p99_fcp',
180+
'quantile(0.50)(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as p50_fcp',
217181
'AVG(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as avg_lcp',
218-
'quantile(0.95)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p95_lcp',
219-
'quantile(0.99)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p99_lcp',
182+
'quantile(0.50)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p50_lcp',
220183
'AVG(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as avg_cls',
221-
'quantile(0.95)(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as p95_cls',
222-
'quantile(0.99)(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as p99_cls',
184+
'quantile(0.50)(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as p50_cls',
223185
'AVG(CASE WHEN fid > 0 THEN fid ELSE NULL END) as avg_fid',
224-
'quantile(0.95)(CASE WHEN fid > 0 THEN fid ELSE NULL END) as p95_fid',
225186
'AVG(CASE WHEN inp > 0 THEN inp ELSE NULL END) as avg_inp',
226-
'quantile(0.95)(CASE WHEN inp > 0 THEN inp ELSE NULL END) as p95_inp',
227187
'COUNT(*) as measurements',
228188
],
229189
where: [
@@ -232,7 +192,7 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
232192
'browser_version IS NOT NULL',
233193
],
234194
groupBy: ['browser_name', 'browser_version'],
235-
orderBy: 'p95_lcp DESC',
195+
orderBy: 'p50_lcp DESC',
236196
limit: 100,
237197
timeField: 'timestamp',
238198
customizable: true,
@@ -244,21 +204,18 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
244204
'country as name',
245205
'COUNT(DISTINCT anonymous_id) as visitors',
246206
'AVG(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as avg_fcp',
247-
'quantile(0.95)(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as p95_fcp',
207+
'quantile(0.50)(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as p50_fcp',
248208
'AVG(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as avg_lcp',
249-
'quantile(0.95)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p95_lcp',
250-
'quantile(0.99)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p99_lcp',
209+
'quantile(0.50)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p50_lcp',
251210
'AVG(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as avg_cls',
252-
'quantile(0.95)(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as p95_cls',
211+
'quantile(0.50)(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as p50_cls',
253212
'AVG(CASE WHEN fid > 0 THEN fid ELSE NULL END) as avg_fid',
254-
'quantile(0.95)(CASE WHEN fid > 0 THEN fid ELSE NULL END) as p95_fid',
255213
'AVG(CASE WHEN inp > 0 THEN inp ELSE NULL END) as avg_inp',
256-
'quantile(0.95)(CASE WHEN inp > 0 THEN inp ELSE NULL END) as p95_inp',
257214
'COUNT(*) as measurements',
258215
],
259216
where: ["country != ''"],
260217
groupBy: ['country'],
261-
orderBy: 'p95_lcp DESC',
218+
orderBy: 'p50_lcp DESC',
262219
limit: 100,
263220
timeField: 'timestamp',
264221
customizable: true,
@@ -271,21 +228,18 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
271228
'os_name as name',
272229
'COUNT(DISTINCT anonymous_id) as visitors',
273230
'AVG(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as avg_fcp',
274-
'quantile(0.95)(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as p95_fcp',
231+
'quantile(0.50)(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as p50_fcp',
275232
'AVG(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as avg_lcp',
276-
'quantile(0.95)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p95_lcp',
277-
'quantile(0.99)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p99_lcp',
233+
'quantile(0.50)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p50_lcp',
278234
'AVG(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as avg_cls',
279-
'quantile(0.95)(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as p95_cls',
235+
'quantile(0.50)(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as p50_cls',
280236
'AVG(CASE WHEN fid > 0 THEN fid ELSE NULL END) as avg_fid',
281-
'quantile(0.95)(CASE WHEN fid > 0 THEN fid ELSE NULL END) as p95_fid',
282237
'AVG(CASE WHEN inp > 0 THEN inp ELSE NULL END) as avg_inp',
283-
'quantile(0.95)(CASE WHEN inp > 0 THEN inp ELSE NULL END) as p95_inp',
284238
'COUNT(*) as measurements',
285239
],
286240
where: ["os_name != ''"],
287241
groupBy: ['os_name'],
288-
orderBy: 'p95_lcp DESC',
242+
orderBy: 'p50_lcp DESC',
289243
limit: 100,
290244
timeField: 'timestamp',
291245
customizable: true,
@@ -297,21 +251,18 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
297251
"CONCAT(region, ', ', country) as name",
298252
'COUNT(DISTINCT anonymous_id) as visitors',
299253
'AVG(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as avg_fcp',
300-
'quantile(0.95)(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as p95_fcp',
254+
'quantile(0.50)(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as p50_fcp',
301255
'AVG(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as avg_lcp',
302-
'quantile(0.95)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p95_lcp',
303-
'quantile(0.99)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p99_lcp',
256+
'quantile(0.50)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p50_lcp',
304257
'AVG(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as avg_cls',
305-
'quantile(0.95)(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as p95_cls',
258+
'quantile(0.50)(CASE WHEN cls IS NOT NULL THEN cls ELSE NULL END) as p50_cls',
306259
'AVG(CASE WHEN fid > 0 THEN fid ELSE NULL END) as avg_fid',
307-
'quantile(0.95)(CASE WHEN fid > 0 THEN fid ELSE NULL END) as p95_fid',
308260
'AVG(CASE WHEN inp > 0 THEN inp ELSE NULL END) as avg_inp',
309-
'quantile(0.95)(CASE WHEN inp > 0 THEN inp ELSE NULL END) as p95_inp',
310261
'COUNT(*) as measurements',
311262
],
312263
where: ["region != ''"],
313264
groupBy: ['region', 'country'],
314-
orderBy: 'p95_lcp DESC',
265+
orderBy: 'p50_lcp DESC',
315266
limit: 100,
316267
timeField: 'timestamp',
317268
customizable: true,
@@ -324,18 +275,14 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
324275
'toDate(timestamp) as date',
325276
'AVG(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as avg_fcp',
326277
'quantile(0.50)(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as p50_fcp',
327-
'quantile(0.95)(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as p95_fcp',
328278
'AVG(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as avg_lcp',
329279
'quantile(0.50)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p50_lcp',
330-
'quantile(0.95)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p95_lcp',
331-
'quantile(0.99)(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as p99_lcp',
332280
'AVG(CASE WHEN cls > 0 THEN cls ELSE NULL END) as avg_cls',
333281
'quantile(0.50)(CASE WHEN cls > 0 THEN cls ELSE NULL END) as p50_cls',
334-
'quantile(0.95)(CASE WHEN cls > 0 THEN cls ELSE NULL END) as p95_cls',
335282
'AVG(CASE WHEN fid > 0 THEN fid ELSE NULL END) as avg_fid',
336-
'quantile(0.95)(CASE WHEN fid > 0 THEN fid ELSE NULL END) as p95_fid',
283+
'quantile(0.50)(CASE WHEN fid > 0 THEN fid ELSE NULL END) as p50_fid',
337284
'AVG(CASE WHEN inp > 0 THEN inp ELSE NULL END) as avg_inp',
338-
'quantile(0.95)(CASE WHEN inp > 0 THEN inp ELSE NULL END) as p95_inp',
285+
'quantile(0.50)(CASE WHEN inp > 0 THEN inp ELSE NULL END) as p50_inp',
339286
'COUNT(*) as measurements',
340287
],
341288
where: [],

apps/api/src/schemas/query-schemas.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const DynamicQueryRequestSchema = t.Object({
5252
t.Literal('day'),
5353
])
5454
),
55-
groupBy: t.Optional(t.String()),
55+
groupBy: t.Optional(t.Union([t.String(), t.Array(t.String())])),
5656
startDate: t.Optional(t.String()),
5757
endDate: t.Optional(t.String()),
5858
timeZone: t.Optional(t.String()),
@@ -100,7 +100,7 @@ export type DynamicQueryRequestType = {
100100
page?: number;
101101
filters?: FilterType[];
102102
granularity?: 'hourly' | 'daily' | 'hour' | 'day';
103-
groupBy?: string;
103+
groupBy?: string | string[];
104104
startDate?: string;
105105
endDate?: string;
106106
timeZone?: string;

apps/dashboard/app/(main)/websites/[id]/_components/tabs/performance-tab.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,6 @@ export function WebsitePerformanceTab({
526526

527527
return (
528528
<div className="space-y-4">
529-
{/* Core Web Vitals Chart */}
530529
<WebVitalsChart
531530
data={
532531
processedData.webVitalsTimeSeries as {
@@ -540,7 +539,6 @@ export function WebsitePerformanceTab({
540539
webVitalsTabs={webVitalsTabs}
541540
/>
542541

543-
{/* Performance Overview */}
544542
<div className="rounded border bg-muted/20 p-4">
545543
<div className="mb-4 flex items-start gap-2">
546544
<LightningIcon className="mt-0.5 h-4 w-4 flex-shrink-0 text-primary" />

apps/dashboard/app/(main)/websites/[id]/_components/tabs/performance/_components/web-vitals-chart.tsx

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,9 @@ export function WebVitalsChart({
8888
const chartData = hasData
8989
? data.map((item) => {
9090
const result: Record<string, unknown> = { date: item.date };
91-
// Add all percentiles for the selected metric
91+
// Add avg and p50 for the selected metric
9292
result[`avg_${selectedMetric}`] = item[`avg_${selectedMetric}`];
9393
result[`p50_${selectedMetric}`] = item[`p50_${selectedMetric}`];
94-
result[`p75_${selectedMetric}`] = item[`p75_${selectedMetric}`];
95-
result[`p90_${selectedMetric}`] = item[`p90_${selectedMetric}`];
96-
result[`p95_${selectedMetric}`] = item[`p95_${selectedMetric}`];
97-
result[`p99_${selectedMetric}`] = item[`p99_${selectedMetric}`];
9894
return result;
9995
})
10096
: [];
@@ -122,10 +118,10 @@ export function WebVitalsChart({
122118
<div className="grid grid-cols-2 gap-3 md:grid-cols-4">
123119
{WEB_VITALS_METRICS.map((metric) => {
124120
const isSelected = selectedMetric === metric.key;
125-
const p95Value = hasData
126-
? (latestData?.[`p95_${metric.key}`] as number | undefined)
121+
const p50Value = hasData
122+
? (latestData?.[`p50_${metric.key}`] as number | undefined)
127123
: undefined;
128-
const status = p95Value ? getStatus(p95Value, metric) : null;
124+
const status = p50Value ? getStatus(p50Value, metric) : null;
129125

130126
return (
131127
<button
@@ -157,10 +153,10 @@ export function WebVitalsChart({
157153
<div className="mb-1 h-6 rounded bg-muted" />
158154
<div className="h-4 w-16 rounded bg-muted" />
159155
</div>
160-
) : p95Value ? (
156+
) : p50Value ? (
161157
<div>
162158
<div className="font-mono font-semibold text-base">
163-
{Math.round(p95Value)}ms
159+
{Math.round(p50Value)}ms
164160
</div>
165161
{status && (
166162
<div className={`font-medium text-xs ${status.color}`}>

0 commit comments

Comments
 (0)