Skip to content

Commit d96cf63

Browse files
committed
feat: schema cleanup
1 parent f7764c2 commit d96cf63

File tree

4 files changed

+2
-139
lines changed

4 files changed

+2
-139
lines changed

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

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,24 @@ import { Analytics } from '../../types/tables';
22
import type { SimpleQueryConfig } from '../types';
33

44
export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
5-
performance_metrics: {
6-
table: Analytics.events,
7-
fields: [
8-
'AVG(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as avg_load_time',
9-
'AVG(CASE WHEN dom_ready_time > 0 THEN dom_ready_time ELSE NULL END) as avg_dom_ready_time',
10-
'AVG(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as avg_ttfb',
11-
'AVG(CASE WHEN render_time > 0 THEN render_time ELSE NULL END) as avg_render_time',
12-
'AVG(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as avg_fcp',
13-
'AVG(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as avg_lcp',
14-
'AVG(CASE WHEN cls >= 0 THEN cls ELSE NULL END) as avg_cls',
15-
'COUNT(*) as total_events',
16-
],
17-
where: ["event_name = 'screen_view'"],
18-
timeField: 'time',
19-
customizable: true,
20-
},
21-
225
slow_pages: {
236
table: Analytics.events,
247
fields: [
25-
"trimRight(path(path), '/') as name",
8+
"trimRight(path, '/') as name",
269
'COUNT(DISTINCT anonymous_id) as visitors',
2710
'AVG(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as avg_load_time',
2811
'AVG(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as avg_ttfb',
2912
'AVG(CASE WHEN dom_ready_time > 0 THEN dom_ready_time ELSE NULL END) as avg_dom_ready_time',
3013
'AVG(CASE WHEN render_time > 0 THEN render_time ELSE NULL END) as avg_render_time',
31-
'AVG(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as avg_fcp',
32-
'AVG(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as avg_lcp',
33-
'AVG(CASE WHEN cls >= 0 THEN cls ELSE NULL END) as avg_cls',
3414
'COUNT(*) as pageviews',
3515
],
3616
where: ["event_name = 'screen_view'", "path != ''", 'load_time > 0'],
37-
groupBy: ["trimRight(path(path), '/')"],
38-
orderBy: 'avg_load_time DESC',
39-
limit: 100,
40-
timeField: 'time',
41-
customizable: true,
42-
},
43-
44-
performance_by_device: {
45-
table: Analytics.events,
46-
fields: [
47-
'device_type as name',
48-
'COUNT(DISTINCT anonymous_id) as visitors',
49-
'AVG(CASE WHEN load_time > 0 THEN load_time ELSE NULL END) as avg_load_time',
50-
'AVG(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as avg_ttfb',
51-
'AVG(CASE WHEN dom_ready_time > 0 THEN dom_ready_time ELSE NULL END) as avg_dom_ready_time',
52-
'AVG(CASE WHEN render_time > 0 THEN render_time ELSE NULL END) as avg_render_time',
53-
'AVG(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as avg_fcp',
54-
'AVG(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as avg_lcp',
55-
'AVG(CASE WHEN cls >= 0 THEN cls ELSE NULL END) as avg_cls',
56-
'COUNT(*) as pageviews',
57-
],
58-
where: ["event_name = 'screen_view'", "device_type != ''", 'load_time > 0'],
59-
groupBy: ['device_type'],
17+
groupBy: ["trimRight(path, '/')"],
6018
orderBy: 'avg_load_time DESC',
6119
limit: 100,
6220
timeField: 'time',
6321
customizable: true,
6422
},
65-
6623
performance_by_browser: {
6724
table: Analytics.events,
6825
fields: [
@@ -72,9 +29,6 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
7229
'AVG(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as avg_ttfb',
7330
'AVG(CASE WHEN dom_ready_time > 0 THEN dom_ready_time ELSE NULL END) as avg_dom_ready_time',
7431
'AVG(CASE WHEN render_time > 0 THEN render_time ELSE NULL END) as avg_render_time',
75-
'AVG(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as avg_fcp',
76-
'AVG(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as avg_lcp',
77-
'AVG(CASE WHEN cls >= 0 THEN cls ELSE NULL END) as avg_cls',
7832
'COUNT(*) as pageviews',
7933
],
8034
where: [
@@ -100,9 +54,6 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
10054
'AVG(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as avg_ttfb',
10155
'AVG(CASE WHEN dom_ready_time > 0 THEN dom_ready_time ELSE NULL END) as avg_dom_ready_time',
10256
'AVG(CASE WHEN render_time > 0 THEN render_time ELSE NULL END) as avg_render_time',
103-
'AVG(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as avg_fcp',
104-
'AVG(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as avg_lcp',
105-
'AVG(CASE WHEN cls >= 0 THEN cls ELSE NULL END) as avg_cls',
10657
'COUNT(*) as pageviews',
10758
],
10859
where: ["event_name = 'screen_view'", "country != ''", 'load_time > 0'],
@@ -123,9 +74,6 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
12374
'AVG(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as avg_ttfb',
12475
'AVG(CASE WHEN dom_ready_time > 0 THEN dom_ready_time ELSE NULL END) as avg_dom_ready_time',
12576
'AVG(CASE WHEN render_time > 0 THEN render_time ELSE NULL END) as avg_render_time',
126-
'AVG(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as avg_fcp',
127-
'AVG(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as avg_lcp',
128-
'AVG(CASE WHEN cls >= 0 THEN cls ELSE NULL END) as avg_cls',
12977
'COUNT(*) as pageviews',
13078
],
13179
where: ["event_name = 'screen_view'", "os_name != ''", 'load_time > 0'],
@@ -145,9 +93,6 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
14593
'AVG(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as avg_ttfb',
14694
'AVG(CASE WHEN dom_ready_time > 0 THEN dom_ready_time ELSE NULL END) as avg_dom_ready_time',
14795
'AVG(CASE WHEN render_time > 0 THEN render_time ELSE NULL END) as avg_render_time',
148-
'AVG(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as avg_fcp',
149-
'AVG(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as avg_lcp',
150-
'AVG(CASE WHEN cls >= 0 THEN cls ELSE NULL END) as avg_cls',
15196
'COUNT(*) as pageviews',
15297
],
15398
where: ["event_name = 'screen_view'", "region != ''", 'load_time > 0'],
@@ -166,9 +111,6 @@ export const PerformanceBuilders: Record<string, SimpleQueryConfig> = {
166111
'AVG(CASE WHEN ttfb > 0 THEN ttfb ELSE NULL END) as avg_ttfb',
167112
'AVG(CASE WHEN dom_ready_time > 0 THEN dom_ready_time ELSE NULL END) as avg_dom_ready_time',
168113
'AVG(CASE WHEN render_time > 0 THEN render_time ELSE NULL END) as avg_render_time',
169-
'AVG(CASE WHEN fcp > 0 THEN fcp ELSE NULL END) as avg_fcp',
170-
'AVG(CASE WHEN lcp > 0 THEN lcp ELSE NULL END) as avg_lcp',
171-
'AVG(CASE WHEN cls >= 0 THEN cls ELSE NULL END) as avg_cls',
172114
'COUNT(*) as pageviews',
173115
],
174116
where: ["event_name = 'screen_view'"],

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

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -365,7 +365,6 @@ export function WebsitePerformanceTab({
365365
pages: [],
366366
allPages: [],
367367
countries: [],
368-
devices: [],
369368
browsers: [],
370369
operating_systems: [],
371370
regions: [],
@@ -394,7 +393,6 @@ export function WebsitePerformanceTab({
394393
pages: filteredPages,
395394
allPages,
396395
countries: data.performance_by_country || [],
397-
devices: data.performance_by_device || [],
398396
browsers: data.performance_by_browser || [],
399397
operating_systems: data.performance_by_os || [],
400398
regions: data.performance_by_region || [],
@@ -494,16 +492,6 @@ export function WebsitePerformanceTab({
494492
value: row.name,
495493
}),
496494
},
497-
{
498-
id: 'devices',
499-
label: 'Device Types',
500-
data: processedData.devices,
501-
iconRenderer: getDeviceIcon,
502-
getFilter: (row: any) => ({
503-
field: 'device_type',
504-
value: row.name,
505-
}),
506-
},
507495
{
508496
id: 'browsers',
509497
label: 'Browsers',
@@ -539,9 +527,6 @@ export function WebsitePerformanceTab({
539527
avg_ttfb: number;
540528
avg_dom_ready_time: number;
541529
avg_render_time: number;
542-
avg_fcp: number;
543-
avg_lcp: number;
544-
avg_cls: number;
545530
country_code: string;
546531
},
547532
i: number
@@ -552,9 +537,6 @@ export function WebsitePerformanceTab({
552537
avg_ttfb: item.avg_ttfb,
553538
avg_dom_ready_time: item.avg_dom_ready_time,
554539
avg_render_time: item.avg_render_time,
555-
avg_fcp: item.avg_fcp,
556-
avg_lcp: item.avg_lcp,
557-
avg_cls: item.avg_cls,
558540
country_code: item.country_code,
559541
_uniqueKey: `${config.id}-${i}`,
560542
})

packages/db/src/clickhouse/schema.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -92,13 +92,6 @@ CREATE TABLE IF NOT EXISTS ${ANALYTICS_DATABASE}.events (
9292
9393
value Nullable(String),
9494
95-
error_message Nullable(String),
96-
error_filename Nullable(String),
97-
error_lineno Nullable(Int32),
98-
error_colno Nullable(Int32),
99-
error_stack Nullable(String),
100-
error_type Nullable(String),
101-
10295
properties String,
10396
10497
created_at DateTime64(3, 'UTC')
@@ -518,11 +511,7 @@ export interface AnalyticsEvent {
518511
time_on_page?: number;
519512
scroll_depth?: number;
520513
interaction_count?: number;
521-
exit_intent: number;
522514
page_count: number;
523-
is_bounce: number;
524-
has_exit_intent?: number;
525-
page_size?: number;
526515

527516
// UTM parameters
528517
utm_source?: string;
@@ -537,33 +526,17 @@ export interface AnalyticsEvent {
537526
dom_interactive?: number;
538527
ttfb?: number;
539528
connection_time?: number;
540-
request_time?: number;
541529
render_time?: number;
542530
redirect_time?: number;
543531
domain_lookup_time?: number;
544532

545-
// Web Vitals
546-
fcp?: number;
547-
lcp?: number;
548-
cls?: number;
549-
fid?: number;
550-
inp?: number;
551-
552533
// Link tracking
553534
href?: string;
554535
text?: string;
555536

556537
// Custom event value
557538
value?: string;
558539

559-
// Error tracking
560-
error_message?: string;
561-
error_filename?: string;
562-
error_lineno?: number;
563-
error_colno?: number;
564-
error_stack?: string;
565-
error_type?: string;
566-
567540
// Legacy properties
568541
properties: string;
569542

packages/validation/src/schemas/analytics.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -111,31 +111,12 @@ export const analyticsEventSchema = z.object({
111111
.max(VALIDATION_LIMITS.INTERACTION_COUNT_MAX)
112112
.nullable()
113113
.optional(),
114-
exit_intent: z
115-
.number()
116-
.int()
117-
.max(VALIDATION_LIMITS.EXIT_INTENT_MAX)
118-
.nullable()
119-
.optional(),
120114
page_count: z
121115
.number()
122116
.int()
123117
.max(VALIDATION_LIMITS.PAGE_COUNT_MAX)
124118
.nullable()
125119
.optional(),
126-
is_bounce: z
127-
.number()
128-
.int()
129-
.max(VALIDATION_LIMITS.IS_BOUNCE_MAX)
130-
.nullable()
131-
.optional(),
132-
has_exit_intent: z.boolean().nullable().optional(),
133-
page_size: z
134-
.number()
135-
.int()
136-
.max(VALIDATION_LIMITS.PAGE_SIZE_MAX)
137-
.nullable()
138-
.optional(),
139120
utm_source: z
140121
.string()
141122
.max(VALIDATION_LIMITS.UTM_MAX_LENGTH)
@@ -177,16 +158,6 @@ export const analyticsEventSchema = z.object({
177158
.nullable()
178159
.optional(),
179160
ttfb: z.number().max(VALIDATION_LIMITS.PERFORMANCE_MAX).nullable().optional(),
180-
connection_time: z
181-
.number()
182-
.max(VALIDATION_LIMITS.PERFORMANCE_MAX)
183-
.nullable()
184-
.optional(),
185-
request_time: z
186-
.number()
187-
.max(VALIDATION_LIMITS.PERFORMANCE_MAX)
188-
.nullable()
189-
.optional(),
190161
render_time: z
191162
.number()
192163
.max(VALIDATION_LIMITS.PERFORMANCE_MAX)
@@ -202,11 +173,6 @@ export const analyticsEventSchema = z.object({
202173
.max(VALIDATION_LIMITS.PERFORMANCE_MAX)
203174
.nullable()
204175
.optional(),
205-
fcp: z.number().max(VALIDATION_LIMITS.PERFORMANCE_MAX).nullable().optional(),
206-
lcp: z.number().max(VALIDATION_LIMITS.PERFORMANCE_MAX).nullable().optional(),
207-
cls: z.number().max(VALIDATION_LIMITS.CLS_MAX).nullable().optional(),
208-
fid: z.number().max(VALIDATION_LIMITS.FID_MAX).nullable().optional(),
209-
inp: z.number().max(VALIDATION_LIMITS.INP_MAX).nullable().optional(),
210176
href: z.string().max(VALIDATION_LIMITS.PATH_MAX_LENGTH).nullable().optional(),
211177
text: z.string().max(VALIDATION_LIMITS.TEXT_MAX_LENGTH).nullable().optional(),
212178
value: z

0 commit comments

Comments
 (0)