mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Added lib/types.
This commit is contained in:
parent
06bebadbb9
commit
4781a0cc8c
12 changed files with 247 additions and 242 deletions
|
|
@ -3,7 +3,7 @@ import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
|
|||
import prisma from 'lib/prisma';
|
||||
import cache from 'lib/cache';
|
||||
import { WebsiteMetric } from 'interface/api/models';
|
||||
import { UmamiApi } from 'lib/constants';
|
||||
import { EventType } from 'lib/types';
|
||||
|
||||
export async function getEventData(
|
||||
...args: [
|
||||
|
|
@ -47,7 +47,7 @@ async function relationalQuery(
|
|||
from website_event
|
||||
where website_id ='${websiteId}'
|
||||
and created_at between $1 and $2
|
||||
and event_type = ${UmamiApi.EventType.Event}
|
||||
and event_type = ${EventType.Event}
|
||||
${eventName ? `and eventName = ${eventName}` : ''}
|
||||
${
|
||||
Object.keys(filters).length > 0
|
||||
|
|
@ -80,7 +80,7 @@ async function clickhouseQuery(
|
|||
from event
|
||||
where website_id = $1
|
||||
and rev_id = $2
|
||||
and event_type = ${UmamiApi.EventType.Event}
|
||||
and event_type = ${EventType.Event}
|
||||
${eventName ? `and eventName = ${eventName}` : ''}
|
||||
and ${getBetweenDates('created_at', startDate, endDate)}
|
||||
${
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import clickhouse from 'lib/clickhouse';
|
|||
import { runQuery, CLICKHOUSE, PRISMA } from 'lib/db';
|
||||
import cache from 'lib/cache';
|
||||
import { WebsiteEventMetric } from 'interface/api/models';
|
||||
import { UmamiApi } from 'lib/constants';
|
||||
import { EventType } from 'lib/types';
|
||||
|
||||
export async function getEventMetrics(
|
||||
...args: [
|
||||
|
|
@ -56,7 +56,7 @@ async function relationalQuery(
|
|||
from website_event
|
||||
where website_id='${websiteId}'
|
||||
and created_at between $1 and $2
|
||||
and event_type = ${UmamiApi.EventType.Event}
|
||||
and event_type = ${EventType.Event}
|
||||
${getFilterQuery(filters, params)}
|
||||
group by 1, 2
|
||||
order by 2`,
|
||||
|
|
@ -95,7 +95,7 @@ async function clickhouseQuery(
|
|||
from event
|
||||
where website_id = $1
|
||||
and rev_id = $2
|
||||
and event_type = ${UmamiApi.EventType.Event}
|
||||
and event_type = ${EventType.Event}
|
||||
and ${getBetweenDates('created_at', startDate, endDate)}
|
||||
${getFilterQuery(filters, params)}
|
||||
group by x, t
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import kafka from 'lib/kafka';
|
|||
import prisma from 'lib/prisma';
|
||||
import { uuid } from 'lib/crypto';
|
||||
import cache from 'lib/cache';
|
||||
import { UmamiApi } from 'lib/constants';
|
||||
import { EventType } from 'lib/types';
|
||||
|
||||
export async function saveEvent(args: {
|
||||
id: string;
|
||||
|
|
@ -43,7 +43,7 @@ async function relationalQuery(data: {
|
|||
sessionId,
|
||||
url: url?.substring(0, URL_LENGTH),
|
||||
referrer: referrer?.substring(0, URL_LENGTH),
|
||||
eventType: UmamiApi.EventType.Event,
|
||||
eventType: EventType.Event,
|
||||
eventName: eventName?.substring(0, EVENT_NAME_LENGTH),
|
||||
eventData,
|
||||
};
|
||||
|
|
@ -77,7 +77,7 @@ async function clickhouseQuery(data: {
|
|||
session_id: sessionId,
|
||||
event_id: uuid(),
|
||||
url: url?.substring(0, URL_LENGTH),
|
||||
event_type: UmamiApi.EventType.Event,
|
||||
event_type: EventType.Event,
|
||||
event_name: eventName?.substring(0, EVENT_NAME_LENGTH),
|
||||
event_data: eventData ? JSON.stringify(eventData) : null,
|
||||
rev_id: website?.revId || 0,
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ import clickhouse from 'lib/clickhouse';
|
|||
import { runQuery, CLICKHOUSE, PRISMA } from 'lib/db';
|
||||
import cache from 'lib/cache';
|
||||
import { Prisma } from '@prisma/client';
|
||||
import { UmamiApi } from 'lib/constants';
|
||||
import { EventType } from 'lib/types';
|
||||
|
||||
export async function getPageviewMetrics(
|
||||
...args: [
|
||||
|
|
@ -43,7 +43,7 @@ async function relationalQuery(
|
|||
${joinSession}
|
||||
where website_id='${websiteId}'
|
||||
and website_event.created_at between $1 and $2
|
||||
and event_type = ${UmamiApi.EventType.Pageview}
|
||||
and event_type = ${EventType.Pageview}
|
||||
${filterQuery}
|
||||
group by 1
|
||||
order by 2 desc`,
|
||||
|
|
@ -71,7 +71,7 @@ async function clickhouseQuery(
|
|||
from event
|
||||
where website_id = $1
|
||||
and rev_id = $2
|
||||
and event_type = ${UmamiApi.EventType.Pageview}
|
||||
and event_type = ${EventType.Pageview}
|
||||
${column !== 'event_name' ? `and event_name = ''` : `and event_name != ''`}
|
||||
and ${getBetweenDates('created_at', startDate, endDate)}
|
||||
${filterQuery}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import cache from 'lib/cache';
|
|||
import clickhouse from 'lib/clickhouse';
|
||||
import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
|
||||
import prisma from 'lib/prisma';
|
||||
import { UmamiApi } from 'lib/constants';
|
||||
import { EventType } from 'lib/types';
|
||||
|
||||
export async function getPageviewStats(
|
||||
...args: [
|
||||
|
|
@ -56,7 +56,7 @@ async function relationalQuery(
|
|||
${joinSession}
|
||||
where website.website_id='${websiteId}'
|
||||
and pageview.created_at between $1 and $2
|
||||
and event_type = ${UmamiApi.EventType.Pageview}
|
||||
and event_type = ${EventType.Pageview}
|
||||
${filterQuery}
|
||||
group by 1`,
|
||||
params,
|
||||
|
|
@ -92,7 +92,7 @@ async function clickhouseQuery(
|
|||
from event
|
||||
where website_id = $1
|
||||
and rev_id = $2
|
||||
and event_type = ${UmamiApi.EventType.Pageview}
|
||||
and event_type = ${EventType.Pageview}
|
||||
and ${getBetweenDates('created_at', startDate, endDate)}
|
||||
${filterQuery}
|
||||
group by t) g
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ import kafka from 'lib/kafka';
|
|||
import prisma from 'lib/prisma';
|
||||
import cache from 'lib/cache';
|
||||
import { uuid } from 'lib/crypto';
|
||||
import { UmamiApi } from 'lib/constants';
|
||||
import { EventType } from 'lib/types';
|
||||
|
||||
export async function savePageView(args: {
|
||||
id: string;
|
||||
|
|
@ -40,7 +40,7 @@ async function relationalQuery(data: {
|
|||
sessionId,
|
||||
url: url?.substring(0, URL_LENGTH),
|
||||
referrer: referrer?.substring(0, URL_LENGTH),
|
||||
eventType: UmamiApi.EventType.Pageview,
|
||||
eventType: EventType.Pageview,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
|
@ -58,7 +58,7 @@ async function clickhouseQuery(data) {
|
|||
rev_id: website?.revId || 0,
|
||||
created_at: getDateFormat(new Date()),
|
||||
country: country ? country : null,
|
||||
event_type: UmamiApi.EventType.Pageview,
|
||||
event_type: EventType.Pageview,
|
||||
...args,
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue