Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.
TypeScript analyticsaudience-segmentationchartscohort-analysisgoogle-analyticsproduct-analyticsstatisticsuser-journeyweb-analytics
Merge branch 'dev' into feat/um-66-update-clickhouse-schema-uuid
Brian Caoec6454aead36
diff --cc pages/api/websites/[id]/events.jsindex 93d01ff9a,308e1efc2..d2d5bbe61--- a/pages/api/websites/[id]/events.js+++ b/pages/api/websites/[id]/events.js@@@ -25,9 -24,9 +25,9 @@@ export default async (req, res) =>const startDate = new Date(+start_at);const endDate = new Date(+end_at);- const events = await getEventMetrics(websiteId, startDate, endDate, tz, unit, {+ const events = await getEventMetrics(websiteId, website_uuid, startDate, endDate, tz, unit, {url,- event_name,+ eventName: event_name,});return ok(res, events);diff --cc pages/api/websites/[id]/stats.jsindex 54b4ae756,ee1403f8b..5aeb38109--- a/pages/api/websites/[id]/stats.js+++ b/pages/api/websites/[id]/stats.js@@@ -1,4 -1,4 +1,4 @@@--import { getWebsiteStats } from 'queries';++import { getWebsiteStats, getWebsiteById } from 'queries';import { methodNotAllowed, ok, unauthorized } from 'next-basics';import { allowQuery } from 'lib/auth';import { useCors } from 'lib/middleware';@@@ -11,10 -11,9 +11,10 @@@ export default async (req, res) =>return unauthorized(res);}- const { id, start_at, end_at, url, referrer, os, browser, device, country } = req.query;+ const { website_id, start_at, end_at, url, referrer, os, browser, device, country } = req.query;- const websiteId = +id;- const website_uuid = id;+ const websiteId = +website_id;++ let websiteUuid = (await getWebsiteById(websiteId)).websiteUuid;const startDate = new Date(+start_at);const endDate = new Date(+end_at);@@@ -22,7 -21,7 +22,7 @@@const prevStartDate = new Date(+start_at - distance);const prevEndDate = new Date(+end_at - distance);- const metrics = await getWebsiteStats(websiteId, website_uuid, {- const metrics = await getWebsiteStats(websiteId, {++ const metrics = await getWebsiteStats(websiteUuid, {start_at: startDate,end_at: endDate,filters: {@@@ -34,7 -33,7 +34,7 @@@country,},});- const prevPeriod = await getWebsiteStats(websiteId, website_uuid, {- const prevPeriod = await getWebsiteStats(websiteId, {++ const prevPeriod = await getWebsiteStats(websiteUuid, {start_at: prevStartDate,end_at: prevEndDate,filters: {diff --cc queries/analytics/event/getEventMetrics.jsindex 014b645cc,447e1cc84..1a8f262f1--- a/queries/analytics/event/getEventMetrics.js+++ b/queries/analytics/event/getEventMetrics.js@@@ -36,7 -36,7 +36,8 @@@ async function relationalQuery}async function clickhouseQuery(+ websiteId,+ website_uuid,start_at,end_at,timezone = 'UTC',diff --cc queries/analytics/event/saveEvent.jsindex a319e6461,b5014cd7e..e29482372--- a/queries/analytics/event/saveEvent.js+++ b/queries/analytics/event/saveEvent.js@@@ -32,18 -32,19 +32,21 @@@ async function relationalQuery(websiteI}async function clickhouseQuery(+ websiteId,+ { session: { country, sessionUuid, ...sessionArgs }, eventUuid, url, eventName, eventData },+ website_uuid,- { session: { country, ...sessionArgs }, event_uuid, url, event_name, event_data },) {const { getDateFormat, sendMessage } = kafka;const params = {- event_uuid,+ session_uuid: sessionUuid,+ event_uuid: eventUuid,+ website_id: websiteId,+ website_uuid,created_at: getDateFormat(new Date()),url: url?.substring(0, URL_LENGTH),- event_name: event_name?.substring(0, EVENT_NAME_LENGTH),- event_data: JSON.stringify(event_data),+ event_name: eventName?.substring(0, EVENT_NAME_LENGTH),+ event_data: JSON.stringify(eventData),...sessionArgs,country: country ? country : null,};diff --cc queries/analytics/stats/getActiveVisitors.jsindex 09cfcdfc9,4d1c8beba..e919760a2--- a/queries/analytics/stats/getActiveVisitors.js+++ b/queries/analytics/stats/getActiveVisitors.js@@@ -23,12 -23,12 +23,12 @@@ async function relationalQuery(websiteI);}- async function clickhouseQuery(website_uuid) {+ async function clickhouseQuery(websiteId) {const { rawQuery, getDateFormat } = clickhouse;- const params = [website_uuid];+ const params = [websiteId];return rawQuery(- `select count(distinct session_uuid) x+ `select count(distinct session_id) xfrom eventwhere website_id = $1and created_at >= ${getDateFormat(subMinutes(new Date(), 5))}`,