-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tag migrations and update send / saveEvent
- Loading branch information
1 parent
6ce9a8c
commit bffb98c
Showing
7 changed files
with
102 additions
and
1 deletion.
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 |
---|---|---|
@@ -0,0 +1,78 @@ | ||
-- add tag column | ||
ALTER TABLE umami.website_event ADD COLUMN "tag" String AFTER "event_name"; | ||
ALTER TABLE umami.website_event_stats_hourly ADD COLUMN "tag" String AFTER "max_time"; | ||
|
||
-- update materialized view | ||
DROP TABLE umami.website_event_stats_hourly_mv; | ||
|
||
CREATE MATERIALIZED VIEW umami.website_event_stats_hourly_mv | ||
TO umami.website_event_stats_hourly | ||
AS | ||
SELECT | ||
website_id, | ||
session_id, | ||
visit_id, | ||
hostname, | ||
browser, | ||
os, | ||
device, | ||
screen, | ||
language, | ||
country, | ||
subdivision1, | ||
city, | ||
entry_url, | ||
exit_url, | ||
url_paths as url_path, | ||
url_query, | ||
referrer_domain, | ||
page_title, | ||
event_type, | ||
event_name, | ||
views, | ||
min_time, | ||
max_time, | ||
tag, | ||
timestamp as created_at | ||
FROM (SELECT | ||
website_id, | ||
session_id, | ||
visit_id, | ||
hostname, | ||
browser, | ||
os, | ||
device, | ||
screen, | ||
language, | ||
country, | ||
subdivision1, | ||
city, | ||
argMinState(url_path, created_at) entry_url, | ||
argMaxState(url_path, created_at) exit_url, | ||
arrayFilter(x -> x != '', groupArray(url_path)) as url_paths, | ||
arrayFilter(x -> x != '', groupArray(url_query)) url_query, | ||
arrayFilter(x -> x != '', groupArray(referrer_domain)) referrer_domain, | ||
arrayFilter(x -> x != '', groupArray(page_title)) page_title, | ||
event_type, | ||
if(event_type = 2, groupArray(event_name), []) event_name, | ||
sumIf(1, event_type = 1) views, | ||
min(created_at) min_time, | ||
max(created_at) max_time, | ||
tag, | ||
toStartOfHour(created_at) timestamp | ||
FROM umami.website_event | ||
GROUP BY website_id, | ||
session_id, | ||
visit_id, | ||
hostname, | ||
browser, | ||
os, | ||
device, | ||
screen, | ||
language, | ||
country, | ||
subdivision1, | ||
city, | ||
event_type, | ||
tag, | ||
timestamp); |
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,5 @@ | ||
-- AlterTable | ||
ALTER TABLE `website_event` ADD COLUMN `tag` VARCHAR(50) NULL; | ||
|
||
-- CreateIndex | ||
CREATE INDEX `website_event_website_id_created_at_tag_idx` ON `website_event`(`website_id`, `created_at`, `tag`); |
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,5 @@ | ||
-- AlterTable | ||
ALTER TABLE "website_event" ADD COLUMN "tag" VARCHAR(50); | ||
|
||
-- CreateIndex | ||
CREATE INDEX "website_event_website_id_created_at_tag_idx" ON "website_event"("website_id", "created_at", "tag"); |
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