Skip to content

Commit e2ab4af

Browse files
committed
Merge branch 'performance' into dev
2 parents 580008c + ce9e241 commit e2ab4af

File tree

24 files changed

+1028
-8
lines changed

24 files changed

+1028
-8
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
-- Create Performance
2+
CREATE TABLE umami.website_performance
3+
(
4+
website_id UUID,
5+
session_id UUID,
6+
visit_id UUID,
7+
url_path String,
8+
lcp Nullable(Decimal(10, 1)),
9+
inp Nullable(Decimal(10, 1)),
10+
cls Nullable(Decimal(10, 4)),
11+
fcp Nullable(Decimal(10, 1)),
12+
ttfb Nullable(Decimal(10, 1)),
13+
created_at DateTime('UTC')
14+
)
15+
ENGINE = MergeTree
16+
PARTITION BY toYYYYMM(created_at)
17+
ORDER BY (website_id, toStartOfHour(created_at), session_id)
18+
SETTINGS index_granularity = 8192;
19+
20+
-- Performance hourly aggregation
21+
CREATE TABLE umami.website_performance_hourly
22+
(
23+
website_id UUID,
24+
url_path String,
25+
lcp_p50 AggregateFunction(quantile(0.5), Nullable(Decimal(10, 1))),
26+
lcp_p75 AggregateFunction(quantile(0.75), Nullable(Decimal(10, 1))),
27+
lcp_p95 AggregateFunction(quantile(0.95), Nullable(Decimal(10, 1))),
28+
inp_p50 AggregateFunction(quantile(0.5), Nullable(Decimal(10, 1))),
29+
inp_p75 AggregateFunction(quantile(0.75), Nullable(Decimal(10, 1))),
30+
inp_p95 AggregateFunction(quantile(0.95), Nullable(Decimal(10, 1))),
31+
cls_p50 AggregateFunction(quantile(0.5), Nullable(Decimal(10, 4))),
32+
cls_p75 AggregateFunction(quantile(0.75), Nullable(Decimal(10, 4))),
33+
cls_p95 AggregateFunction(quantile(0.95), Nullable(Decimal(10, 4))),
34+
fcp_p50 AggregateFunction(quantile(0.5), Nullable(Decimal(10, 1))),
35+
fcp_p75 AggregateFunction(quantile(0.75), Nullable(Decimal(10, 1))),
36+
fcp_p95 AggregateFunction(quantile(0.95), Nullable(Decimal(10, 1))),
37+
ttfb_p50 AggregateFunction(quantile(0.5), Nullable(Decimal(10, 1))),
38+
ttfb_p75 AggregateFunction(quantile(0.75), Nullable(Decimal(10, 1))),
39+
ttfb_p95 AggregateFunction(quantile(0.95), Nullable(Decimal(10, 1))),
40+
sample_count SimpleAggregateFunction(sum, UInt64),
41+
created_at DateTime('UTC')
42+
)
43+
ENGINE = AggregatingMergeTree
44+
PARTITION BY toYYYYMM(created_at)
45+
ORDER BY (website_id, toStartOfHour(created_at), url_path)
46+
SETTINGS index_granularity = 8192;
47+
48+
CREATE MATERIALIZED VIEW umami.website_performance_hourly_mv
49+
TO umami.website_performance_hourly
50+
AS
51+
SELECT
52+
website_id,
53+
url_path,
54+
quantileState(0.5)(lcp) as lcp_p50,
55+
quantileState(0.75)(lcp) as lcp_p75,
56+
quantileState(0.95)(lcp) as lcp_p95,
57+
quantileState(0.5)(inp) as inp_p50,
58+
quantileState(0.75)(inp) as inp_p75,
59+
quantileState(0.95)(inp) as inp_p95,
60+
quantileState(0.5)(cls) as cls_p50,
61+
quantileState(0.75)(cls) as cls_p75,
62+
quantileState(0.95)(cls) as cls_p95,
63+
quantileState(0.5)(fcp) as fcp_p50,
64+
quantileState(0.75)(fcp) as fcp_p75,
65+
quantileState(0.95)(fcp) as fcp_p95,
66+
quantileState(0.5)(ttfb) as ttfb_p50,
67+
quantileState(0.75)(ttfb) as ttfb_p75,
68+
quantileState(0.95)(ttfb) as ttfb_p95,
69+
count() as sample_count,
70+
toStartOfHour(created_at) as created_at
71+
FROM umami.website_performance
72+
GROUP BY website_id, url_path, toStartOfHour(created_at);
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
-- CreateTable
2+
CREATE TABLE "performance" (
3+
"performance_id" UUID NOT NULL,
4+
"website_id" UUID NOT NULL,
5+
"session_id" UUID NOT NULL,
6+
"visit_id" UUID NOT NULL,
7+
"url_path" VARCHAR(500) NOT NULL,
8+
"lcp" DECIMAL(10,1),
9+
"inp" DECIMAL(10,1),
10+
"cls" DECIMAL(10,4),
11+
"fcp" DECIMAL(10,1),
12+
"ttfb" DECIMAL(10,1),
13+
"created_at" TIMESTAMPTZ(6) DEFAULT CURRENT_TIMESTAMP,
14+
15+
CONSTRAINT "performance_pkey" PRIMARY KEY ("performance_id")
16+
);
17+
18+
-- CreateIndex
19+
CREATE INDEX "performance_website_id_idx" ON "performance"("website_id");
20+
21+
-- CreateIndex
22+
CREATE INDEX "performance_session_id_idx" ON "performance"("session_id");
23+
24+
-- CreateIndex
25+
CREATE INDEX "performance_website_id_created_at_idx" ON "performance"("website_id", "created_at");
26+
27+
-- CreateIndex
28+
CREATE INDEX "performance_website_id_url_path_created_at_idx" ON "performance"("website_id", "url_path", "created_at");

prisma/schema.prisma

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ model Session {
4747
4848
websiteEvents WebsiteEvent[]
4949
sessionData SessionData[]
50+
performance Performance[]
5051
revenue Revenue[]
5152
5253
@@index([createdAt])
@@ -78,11 +79,12 @@ model Website {
7879
user User? @relation("user", fields: [userId], references: [id])
7980
createUser User? @relation("createUser", fields: [createdBy], references: [id])
8081
team Team? @relation(fields: [teamId], references: [id])
81-
eventData EventData[]
82-
reports Report[]
83-
revenue Revenue[]
84-
segments Segment[]
85-
sessionData SessionData[]
82+
eventData EventData[]
83+
performance Performance[]
84+
reports Report[]
85+
revenue Revenue[]
86+
segments Segment[]
87+
sessionData SessionData[]
8688
8789
@@index([userId])
8890
@@index([teamId])
@@ -338,6 +340,29 @@ model Board {
338340
@@map("board")
339341
}
340342

343+
model Performance {
344+
id String @id() @map("performance_id") @db.Uuid
345+
websiteId String @map("website_id") @db.Uuid
346+
sessionId String @map("session_id") @db.Uuid
347+
visitId String @map("visit_id") @db.Uuid
348+
urlPath String @map("url_path") @db.VarChar(500)
349+
lcp Decimal? @db.Decimal(10, 1)
350+
inp Decimal? @db.Decimal(10, 1)
351+
cls Decimal? @db.Decimal(10, 4)
352+
fcp Decimal? @db.Decimal(10, 1)
353+
ttfb Decimal? @db.Decimal(10, 1)
354+
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamptz(6)
355+
356+
website Website @relation(fields: [websiteId], references: [id])
357+
session Session @relation(fields: [sessionId], references: [id])
358+
359+
@@index([websiteId])
360+
@@index([sessionId])
361+
@@index([websiteId, createdAt])
362+
@@index([websiteId, urlPath, createdAt])
363+
@@map("performance")
364+
}
365+
341366
model Share {
342367
id String @id() @map("share_id") @db.Uuid
343368
entityId String @map("entity_id") @db.Uuid

public/intl/messages/en-US.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
"cities": "Cities",
4545
"city": "City",
4646
"clear-all": "Clear all",
47+
"cls": "CLS",
4748
"cohort": "Cohort",
4849
"cohorts": "Cohorts",
4950
"compare": "Compare",
@@ -114,6 +115,7 @@
114115
"exists": "Exists",
115116
"exit": "Exit page",
116117
"false": "False",
118+
"fcp": "FCP",
117119
"field": "Field",
118120
"fields": "Fields",
119121
"filter": "Filter",
@@ -127,6 +129,7 @@
127129
"funnels": "Funnels",
128130
"goal": "Goal",
129131
"goals": "Goals",
132+
"good": "Good",
130133
"goals-description": "Track your goals for pageviews and events.",
131134
"greater-than": "Greater than",
132135
"greater-than-equals": "Greater than or equals",
@@ -138,6 +141,7 @@
138141
"insight": "Insight",
139142
"insights": "Insights",
140143
"insights-description": "Dive deeper into your data by using segments and filters.",
144+
"inp": "INP",
141145
"invalid-url": "Invalid URL",
142146
"is": "Is",
143147
"is-false": "Is false",
@@ -158,6 +162,7 @@
158162
"last-hours": "Last {x} hours",
159163
"last-months": "Last {x} months",
160164
"last-seen": "Last seen",
165+
"lcp": "LCP",
161166
"leave": "Leave",
162167
"leave-team": "Leave team",
163168
"less-than": "Less than",
@@ -186,6 +191,7 @@
186191
"my-account": "My account",
187192
"my-websites": "My websites",
188193
"name": "Name",
194+
"needs-improvement": "Needs improvement",
189195
"new-password": "New password",
190196
"none": "None",
191197
"number-of-records": "{x} {x, plural, one {record} other {records}}",
@@ -212,8 +218,10 @@
212218
"password": "Password",
213219
"path": "Path",
214220
"paths": "Paths",
221+
"performance": "Performance",
215222
"pixel": "Pixel",
216223
"pixels": "Pixels",
224+
"poor": "Poor",
217225
"powered-by": "Powered by {name}",
218226
"preferences": "Preferences",
219227
"previous": "Previous",
@@ -250,6 +258,7 @@
250258
"save": "Save",
251259
"save-cohort": "Save cohort",
252260
"save-segment": "Save segment",
261+
"sample-size": "Sample size",
253262
"screen": "Screen",
254263
"screens": "Screens",
255264
"search": "Search",
@@ -308,6 +317,7 @@
308317
"transfer": "Transfer",
309318
"transfer-website": "Transfer website",
310319
"true": "True",
320+
"ttfb": "TTFB",
311321
"type": "Type",
312322
"unique": "Unique",
313323
"unique-events": "Unique events",
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.sampleCount {
2+
color: var(--base-color-text-secondary);
3+
}

0 commit comments

Comments
 (0)