WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit 88da20e

Browse files
authored
Merge pull request #2641 from umami-software/analytics
v2.11.0
2 parents 3656234 + 901e948 commit 88da20e

File tree

207 files changed

+4341
-2825
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

207 files changed

+4341
-2825
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ node_modules
2222
# misc
2323
.DS_Store
2424
.idea
25+
.yarn
2526
*.iml
2627
*.log
2728
.vscode

cypress.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,9 @@ export default defineConfig({
44
e2e: {
55
baseUrl: 'http://localhost:3000',
66
},
7+
// default username / password on init
8+
env: {
9+
umami_user: 'admin',
10+
umami_password: 'umami',
11+
},
712
});

cypress/docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ services:
4343
- CYPRESS_umami_user=admin
4444
- CYPRESS_umami_password=umami
4545
volumes:
46-
- ../tsconfig.json:/tsconfig.json
46+
- ./tsconfig.json:/tsconfig.json
4747
- ../cypress.config.ts:/cypress.config.ts
4848
- ./:/cypress
4949
- ../node_modules/:/node_modules
50+
- ../src/lib/crypto.ts:/src/lib/crypto.ts
5051
volumes:
5152
umami-db-data:

cypress/e2e/login.cy.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ describe('Login tests', () => {
66
},
77
() => {
88
cy.visit('/login');
9-
cy.getDataTest('input-username').find('input').type(Cypress.env('umami_user'));
10-
cy.getDataTest('input-password').find('input').type(Cypress.env('umami_password'));
9+
cy.getDataTest('input-username').find('input').click();
10+
cy.getDataTest('input-username').find('input').type(Cypress.env('umami_user'), { delay: 50 });
11+
cy.getDataTest('input-password').find('input').click();
12+
cy.getDataTest('input-password')
13+
.find('input')
14+
.type(Cypress.env('umami_password'), { delay: 50 });
1115
cy.getDataTest('button-submit').click();
1216
cy.url().should('eq', Cypress.config().baseUrl + '/dashboard');
1317
cy.getDataTest('button-profile').click();

cypress/e2e/website.cy.ts

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ describe('Website tests', () => {
1010
cy.visit('/settings/websites');
1111
cy.getDataTest('button-website-add').click();
1212
cy.contains(/Add website/i).should('be.visible');
13-
cy.getDataTest('input-name').find('input').wait(500).type('Add test', { delay: 50 });
14-
cy.getDataTest('input-domain').find('input').wait(500).type('addtest.com', { delay: 50 });
13+
cy.getDataTest('input-name').find('input').click();
14+
cy.getDataTest('input-name').find('input').type('Add test', { delay: 50 });
15+
cy.getDataTest('input-domain').find('input').click();
16+
cy.getDataTest('input-domain').find('input').type('addtest.com', { delay: 50 });
1517
cy.getDataTest('button-submit').click();
1618
cy.get('td[label="Name"]').should('contain.text', 'Add test');
1719
cy.get('td[label="Domain"]').should('contain.text', 'addtest.com');
@@ -26,27 +28,23 @@ describe('Website tests', () => {
2628
cy.deleteWebsite(websiteId);
2729
});
2830
cy.visit('/settings/websites');
29-
cy.contains('Add test').should('not.exist');
31+
cy.contains(/Add test/i).should('not.exist');
3032
});
3133

32-
it.only('Edit a website', () => {
34+
it('Edit a website', () => {
3335
// prep data
3436
cy.addWebsite('Update test', 'updatetest.com');
3537
cy.visit('/settings/websites');
3638

3739
// edit website
3840
cy.getDataTest('link-button-edit').first().click();
3941
cy.contains(/Details/i).should('be.visible');
40-
cy.getDataTest('input-name')
41-
.find('input')
42-
.wait(500)
43-
.clear()
44-
.type('Updated website', { delay: 50 });
45-
cy.getDataTest('input-domain')
46-
.find('input')
47-
.wait(500)
48-
.clear()
49-
.type('updatedwebsite.com', { delay: 50 });
42+
cy.getDataTest('input-name').find('input').click();
43+
cy.getDataTest('input-name').find('input').clear();
44+
cy.getDataTest('input-name').find('input').type('Updated website', { delay: 50 });
45+
cy.getDataTest('input-domain').find('input').click();
46+
cy.getDataTest('input-domain').find('input').clear();
47+
cy.getDataTest('input-domain').find('input').type('updatedwebsite.com', { delay: 50 });
5048
cy.getDataTest('button-submit').click({ force: true });
5149
cy.getDataTest('input-name').find('input').should('have.value', 'Updated website');
5250
cy.getDataTest('input-domain').find('input').should('have.value', 'updatedwebsite.com');
@@ -69,7 +67,7 @@ describe('Website tests', () => {
6967
cy.deleteWebsite(websiteId);
7068
});
7169
cy.visit('/settings/websites');
72-
cy.contains('Add test').should('not.exist');
70+
cy.contains(/Add test/i).should('not.exist');
7371
});
7472

7573
it('Delete a website', () => {
@@ -86,6 +84,6 @@ describe('Website tests', () => {
8684
cy.contains(/Type DELETE in the box below to confirm./i).should('be.visible');
8785
cy.get('input[name="confirm"').type('DELETE');
8886
cy.get('button[type="submit"]').click();
89-
cy.contains('Delete test').should('not.exist');
87+
cy.contains(/Delete test/i).should('not.exist');
9088
});
9189
});
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
CREATE TABLE umami.website_event_join
2+
(
3+
session_id UUID,
4+
visit_id UUID,
5+
created_at DateTime('UTC')
6+
)
7+
engine = MergeTree
8+
ORDER BY (session_id, created_at)
9+
SETTINGS index_granularity = 8192;
10+
11+
INSERT INTO umami.website_event_join
12+
SELECT DISTINCT
13+
s.session_id,
14+
generateUUIDv4() visit_id,
15+
s.created_at
16+
FROM (SELECT DISTINCT session_id,
17+
date_trunc('hour', created_at) created_at
18+
FROM website_event) s;
19+
20+
-- create new table
21+
CREATE TABLE umami.website_event_new
22+
(
23+
website_id UUID,
24+
session_id UUID,
25+
visit_id UUID,
26+
event_id UUID,
27+
hostname LowCardinality(String),
28+
browser LowCardinality(String),
29+
os LowCardinality(String),
30+
device LowCardinality(String),
31+
screen LowCardinality(String),
32+
language LowCardinality(String),
33+
country LowCardinality(String),
34+
subdivision1 LowCardinality(String),
35+
subdivision2 LowCardinality(String),
36+
city String,
37+
url_path String,
38+
url_query String,
39+
referrer_path String,
40+
referrer_query String,
41+
referrer_domain String,
42+
page_title String,
43+
event_type UInt32,
44+
event_name String,
45+
created_at DateTime('UTC'),
46+
job_id UUID
47+
)
48+
engine = MergeTree
49+
ORDER BY (website_id, session_id, created_at)
50+
SETTINGS index_granularity = 8192;
51+
52+
INSERT INTO umami.website_event_new
53+
SELECT we.website_id,
54+
we.session_id,
55+
j.visit_id,
56+
we.event_id,
57+
we.hostname,
58+
we.browser,
59+
we.os,
60+
we.device,
61+
we.screen,
62+
we.language,
63+
we.country,
64+
we.subdivision1,
65+
we.subdivision2,
66+
we.city,
67+
we.url_path,
68+
we.url_query,
69+
we.referrer_path,
70+
we.referrer_query,
71+
we.referrer_domain,
72+
we.page_title,
73+
we.event_type,
74+
we.event_name,
75+
we.created_at,
76+
we.job_id
77+
FROM umami.website_event we
78+
JOIN umami.website_event_join j
79+
ON we.session_id = j.session_id
80+
and date_trunc('hour', we.created_at) = j.created_at
81+
82+
RENAME TABLE umami.website_event TO umami.website_event_old;
83+
RENAME TABLE umami.website_event_new TO umami.website_event;
84+
85+
/*
86+
87+
DROP TABLE umami.website_event_old
88+
DROP TABLE umami.website_event_join
89+
90+
*/

db/clickhouse/schema.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ CREATE TABLE umami.website_event
33
(
44
website_id UUID,
55
session_id UUID,
6+
visit_id UUID,
67
event_id UUID,
78
--sessions
89
hostname LowCardinality(String),
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- AlterTable
2+
ALTER TABLE `website_event` ADD COLUMN `visit_id` VARCHAR(36) NULL;
3+
4+
UPDATE `website_event` we
5+
JOIN (SELECT DISTINCT
6+
s.session_id,
7+
s.visit_time,
8+
BIN_TO_UUID(RANDOM_BYTES(16) & 0xffffffffffff0fff3fffffffffffffff | 0x00000000000040008000000000000000) uuid
9+
FROM (SELECT DISTINCT session_id,
10+
DATE_FORMAT(created_at, '%Y-%m-%d %H:00:00') visit_time
11+
FROM `website_event`) s) a
12+
ON we.session_id = a.session_id and DATE_FORMAT(we.created_at, '%Y-%m-%d %H:00:00') = a.visit_time
13+
SET we.visit_id = a.uuid
14+
WHERE we.visit_id IS NULL;
15+
16+
ALTER TABLE `website_event` MODIFY `visit_id` VARCHAR(36) NOT NULL;
17+
18+
-- CreateIndex
19+
CREATE INDEX `website_event_visit_id_idx` ON `website_event`(`visit_id`);
20+
21+
-- CreateIndex
22+
CREATE INDEX `website_event_website_id_visit_id_created_at_idx` ON `website_event`(`website_id`, `visit_id`, `created_at`);

db/mysql/schema.prisma

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ model WebsiteEvent {
9292
id String @id() @map("event_id") @db.VarChar(36)
9393
websiteId String @map("website_id") @db.VarChar(36)
9494
sessionId String @map("session_id") @db.VarChar(36)
95+
visitId String @map("visit_id") @db.VarChar(36)
9596
createdAt DateTime? @default(now()) @map("created_at") @db.Timestamp(0)
9697
urlPath String @map("url_path") @db.VarChar(500)
9798
urlQuery String? @map("url_query") @db.VarChar(500)
@@ -107,6 +108,7 @@ model WebsiteEvent {
107108
108109
@@index([createdAt])
109110
@@index([sessionId])
111+
@@index([visitId])
110112
@@index([websiteId])
111113
@@index([websiteId, createdAt])
112114
@@index([websiteId, createdAt, urlPath])
@@ -115,6 +117,7 @@ model WebsiteEvent {
115117
@@index([websiteId, createdAt, pageTitle])
116118
@@index([websiteId, createdAt, eventName])
117119
@@index([websiteId, sessionId, createdAt])
120+
@@index([websiteId, visitId, createdAt])
118121
@@map("website_event")
119122
}
120123

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
-- AlterTable
2+
ALTER TABLE "website_event" ADD COLUMN "visit_id" UUID NULL;
3+
4+
UPDATE "website_event" we
5+
SET visit_id = a.uuid
6+
FROM (SELECT DISTINCT
7+
s.session_id,
8+
s.visit_time,
9+
gen_random_uuid() uuid
10+
FROM (SELECT DISTINCT session_id,
11+
date_trunc('hour', created_at) visit_time
12+
FROM "website_event") s) a
13+
WHERE we.session_id = a.session_id
14+
and date_trunc('hour', we.created_at) = a.visit_time;
15+
16+
ALTER TABLE "website_event" ALTER COLUMN "visit_id" SET NOT NULL;
17+
18+
-- CreateIndex
19+
CREATE INDEX "website_event_visit_id_idx" ON "website_event"("visit_id");
20+
21+
-- CreateIndex
22+
CREATE INDEX "website_event_website_id_visit_id_created_at_idx" ON "website_event"("website_id", "visit_id", "created_at");

0 commit comments

Comments
 (0)