forked from umami-software/umami
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'umami-software:master' into master
- Loading branch information
Showing
312 changed files
with
12,018 additions
and
5,453 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ node_modules | |
# misc | ||
.DS_Store | ||
.idea | ||
.yarn | ||
*.iml | ||
*.log | ||
.vscode | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
CREATE TABLE umami.website_event_join | ||
( | ||
session_id UUID, | ||
visit_id UUID, | ||
created_at DateTime('UTC') | ||
) | ||
engine = MergeTree | ||
ORDER BY (session_id, created_at) | ||
SETTINGS index_granularity = 8192; | ||
|
||
INSERT INTO umami.website_event_join | ||
SELECT DISTINCT | ||
s.session_id, | ||
generateUUIDv4() visit_id, | ||
s.created_at | ||
FROM (SELECT DISTINCT session_id, | ||
date_trunc('hour', created_at) created_at | ||
FROM website_event) s; | ||
|
||
-- create new table | ||
CREATE TABLE umami.website_event_new | ||
( | ||
website_id UUID, | ||
session_id UUID, | ||
visit_id UUID, | ||
event_id UUID, | ||
hostname LowCardinality(String), | ||
browser LowCardinality(String), | ||
os LowCardinality(String), | ||
device LowCardinality(String), | ||
screen LowCardinality(String), | ||
language LowCardinality(String), | ||
country LowCardinality(String), | ||
subdivision1 LowCardinality(String), | ||
subdivision2 LowCardinality(String), | ||
city String, | ||
url_path String, | ||
url_query String, | ||
referrer_path String, | ||
referrer_query String, | ||
referrer_domain String, | ||
page_title String, | ||
event_type UInt32, | ||
event_name String, | ||
created_at DateTime('UTC'), | ||
job_id UUID | ||
) | ||
engine = MergeTree | ||
ORDER BY (website_id, session_id, created_at) | ||
SETTINGS index_granularity = 8192; | ||
|
||
INSERT INTO umami.website_event_new | ||
SELECT we.website_id, | ||
we.session_id, | ||
j.visit_id, | ||
we.event_id, | ||
we.hostname, | ||
we.browser, | ||
we.os, | ||
we.device, | ||
we.screen, | ||
we.language, | ||
we.country, | ||
we.subdivision1, | ||
we.subdivision2, | ||
we.city, | ||
we.url_path, | ||
we.url_query, | ||
we.referrer_path, | ||
we.referrer_query, | ||
we.referrer_domain, | ||
we.page_title, | ||
we.event_type, | ||
we.event_name, | ||
we.created_at, | ||
we.job_id | ||
FROM umami.website_event we | ||
JOIN umami.website_event_join j | ||
ON we.session_id = j.session_id | ||
and date_trunc('hour', we.created_at) = j.created_at | ||
|
||
RENAME TABLE umami.website_event TO umami.website_event_old; | ||
RENAME TABLE umami.website_event_new TO umami.website_event; | ||
|
||
/* | ||
DROP TABLE umami.website_event_old | ||
DROP TABLE umami.website_event_join | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
CREATE TABLE umami.event_data_new | ||
( | ||
website_id UUID, | ||
session_id UUID, | ||
event_id UUID, | ||
url_path String, | ||
event_name String, | ||
data_key String, | ||
string_value Nullable(String), | ||
number_value Nullable(Decimal64(4)), | ||
date_value Nullable(DateTime('UTC')), | ||
data_type UInt32, | ||
created_at DateTime('UTC'), | ||
job_id Nullable(UUID) | ||
) | ||
engine = MergeTree | ||
ORDER BY (website_id, event_id, data_key, created_at) | ||
SETTINGS index_granularity = 8192; | ||
|
||
INSERT INTO umami.event_data_new | ||
SELECT website_id, | ||
session_id, | ||
event_id, | ||
url_path, | ||
event_name, | ||
event_key, | ||
string_value, | ||
number_value, | ||
date_value, | ||
data_type, | ||
created_at, | ||
NULL | ||
FROM umami.event_data; | ||
|
||
CREATE TABLE umami.session_data | ||
( | ||
website_id UUID, | ||
session_id UUID, | ||
data_key String, | ||
string_value Nullable(String), | ||
number_value Nullable(Decimal64(4)), | ||
date_value Nullable(DateTime('UTC')), | ||
data_type UInt32, | ||
created_at DateTime('UTC'), | ||
job_id Nullable(UUID) | ||
) | ||
engine = MergeTree | ||
ORDER BY (website_id, session_id, data_key, created_at) | ||
SETTINGS index_granularity = 8192; | ||
|
||
RENAME TABLE umami.event_data TO umami.event_data_old; | ||
RENAME TABLE umami.event_data_new TO umami.event_data; | ||
|
||
/* | ||
DROP TABLE umami.event_data_old | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- AlterTable | ||
ALTER TABLE `website_event` ADD COLUMN `visit_id` VARCHAR(36) NULL; | ||
|
||
UPDATE `website_event` we | ||
JOIN (SELECT DISTINCT | ||
s.session_id, | ||
s.visit_time, | ||
BIN_TO_UUID(RANDOM_BYTES(16) & 0xffffffffffff0fff3fffffffffffffff | 0x00000000000040008000000000000000) uuid | ||
FROM (SELECT DISTINCT session_id, | ||
DATE_FORMAT(created_at, '%Y-%m-%d %H:00:00') visit_time | ||
FROM `website_event`) s) a | ||
ON we.session_id = a.session_id and DATE_FORMAT(we.created_at, '%Y-%m-%d %H:00:00') = a.visit_time | ||
SET we.visit_id = a.uuid | ||
WHERE we.visit_id IS NULL; | ||
|
||
ALTER TABLE `website_event` MODIFY `visit_id` VARCHAR(36) NOT NULL; | ||
|
||
-- CreateIndex | ||
CREATE INDEX `website_event_visit_id_idx` ON `website_event`(`visit_id`); | ||
|
||
-- CreateIndex | ||
CREATE INDEX `website_event_website_id_visit_id_created_at_idx` ON `website_event`(`website_id`, `visit_id`, `created_at`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- DropIndex | ||
DROP INDEX `event_data_website_id_created_at_event_key_idx` ON `event_data`; | ||
|
||
-- DropIndex | ||
DROP INDEX `event_data_website_id_website_event_id_created_at_idx` ON `event_data`; | ||
|
||
-- AlterTable | ||
ALTER TABLE `event_data` RENAME COLUMN `event_key` TO `data_key`; | ||
|
||
-- AlterTable | ||
ALTER TABLE `session_data` RENAME COLUMN `event_key` TO `data_key`; | ||
|
||
-- CreateIndex | ||
CREATE INDEX `event_data_website_id_created_at_data_key_idx` ON `event_data`(`website_id`, `created_at`, `data_key`); | ||
|
||
-- CreateIndex | ||
CREATE INDEX `session_data_session_id_created_at_idx` ON `session_data`(`session_id`, `created_at`); | ||
|
||
-- CreateIndex | ||
CREATE INDEX `session_data_website_id_created_at_data_key_idx` ON `session_data`(`website_id`, `created_at`, `data_key`); |
Oops, something went wrong.