Updates to insights, event data, telemetry.

This commit is contained in:
Mike Cao 2023-07-23 13:18:01 -07:00
parent 39562d4a64
commit e4bd314bd6
44 changed files with 413 additions and 278 deletions

View file

@ -1,7 +1,7 @@
import { Prisma, Team, TeamWebsite } from '@prisma/client';
import prisma from 'lib/prisma';
import { uuid } from 'lib/crypto';
import { ROLES } from 'lib/constants';
import { uuid } from 'next-basics';
export async function getTeam(where: Prisma.TeamWhereInput): Promise<Team> {
return prisma.client.team.findFirst({

View file

@ -1,5 +1,5 @@
import { Prisma, TeamUser } from '@prisma/client';
import { uuid } from 'lib/crypto';
import { uuid } from 'next-basics';
import prisma from 'lib/prisma';
export async function getTeamUserById(teamUserId: string): Promise<TeamUser> {

View file

@ -1,6 +1,6 @@
import { Prisma, Team, TeamUser, TeamWebsite, Website } from '@prisma/client';
import { ROLES } from 'lib/constants';
import { uuid } from 'lib/crypto';
import { uuid } from 'next-basics';
import prisma from 'lib/prisma';
export async function getTeamWebsite(

View file

@ -0,0 +1,119 @@
import { buildSql } from 'lib/sql';
import prisma from 'lib/prisma';
import clickhouse from 'lib/clickhouse';
import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
import { WebsiteEventDataFields } from 'lib/types';
import { loadWebsite } from 'lib/query';
import { DEFAULT_RESET_DATE } from 'lib/constants';
export async function getEventDataEvents(
...args: [
websiteId: string,
startDate: Date,
endDate: Date,
filters: { field?: string; event?: string },
]
): Promise<WebsiteEventDataFields[]> {
return runQuery({
[PRISMA]: () => relationalQuery(...args),
[CLICKHOUSE]: () => clickhouseQuery(...args),
});
}
async function relationalQuery(
websiteId: string,
startDate: Date,
endDate: Date,
filters: { field?: string; event?: string },
) {
const { toUuid, rawQuery } = prisma;
const website = await loadWebsite(websiteId);
const resetDate = new Date(website?.resetAt || DEFAULT_RESET_DATE);
const { field, event } = filters;
if (field) {
if (event) {
return rawQuery(
`select ed.event_key as field,
ed.string_value as value,
count(ed.*) as total
from event_data as ed
inner join website_event as we
on we.event_id = ed.website_event_id
where ed.website_id = $1${toUuid()}
and ed.event_key = $2
and ed.created_at >= $3
and ed.created_at between $4 and $5
and we.event_name = $6
group by ed.event_key, ed.string_value
order by 3 desc, 2 desc, 1 asc
`,
[websiteId, field, resetDate, startDate, endDate, event] as any,
);
}
return rawQuery(
`select event_key as field,
string_value as value,
count(*) as total
from event_data
where website_id = $1${toUuid()}
and event_key = $2
and created_at >= $3
and created_at between $4 and $5
group by event_key, string_value
order by 3 desc, 2 desc, 1 asc
`,
[websiteId, field, resetDate, startDate, endDate] as any,
);
}
}
async function clickhouseQuery(
websiteId: string,
startDate: Date,
endDate: Date,
filters: { field?: string; event?: string },
) {
const { rawQuery } = clickhouse;
const website = await loadWebsite(websiteId);
const resetDate = new Date(website?.resetAt || DEFAULT_RESET_DATE);
const { event } = filters;
if (event) {
return rawQuery(
`select
event_name as event,
event_key as field,
data_type as type,
string_value as value,
count(*) as total
from event_data
where website_id = {websiteId:UUID}
and created_at >= {resetDate:DateTime}
and created_at between {startDate:DateTime} and {endDate:DateTime}
and event_name = {event:String}
group by event_key, data_type, string_value, event_name
order by 1 asc, 2 asc, 3 asc, 4 desc
limit 100`,
{ websiteId, resetDate, startDate, endDate, event },
);
}
return rawQuery(
`select
event_name as event,
event_key as field,
data_type as type,
count(*) as total
from event_data
where website_id = {websiteId:UUID}
and created_at >= {resetDate:DateTime}
and created_at between {startDate:DateTime} and {endDate:DateTime}
group by event_key, data_type, event_name
order by 1 asc, 2 asc
limit 100
`,
{ websiteId, resetDate, startDate, endDate },
);
}

View file

@ -3,17 +3,10 @@ import clickhouse from 'lib/clickhouse';
import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
import { WebsiteEventDataFields } from 'lib/types';
import { loadWebsite } from 'lib/query';
import { DEFAULT_CREATED_AT } from 'lib/constants';
import { DEFAULT_RESET_DATE } from 'lib/constants';
export async function getEventDataFields(
...args: [
websiteId: string,
startDate: Date,
endDate: Date,
field?: string,
event?: string,
withEventNames?: boolean,
]
...args: [websiteId: string, startDate: Date, endDate: Date, field?: string]
): Promise<WebsiteEventDataFields[]> {
return runQuery({
[PRISMA]: () => relationalQuery(...args),
@ -21,37 +14,12 @@ export async function getEventDataFields(
});
}
async function relationalQuery(
websiteId: string,
startDate: Date,
endDate: Date,
field: string,
event: string,
withEventNames: boolean,
) {
async function relationalQuery(websiteId: string, startDate: Date, endDate: Date, field: string) {
const { toUuid, rawQuery } = prisma;
const website = await loadWebsite(websiteId);
const resetDate = new Date(website?.resetAt || DEFAULT_CREATED_AT);
const resetDate = new Date(website?.resetAt || DEFAULT_RESET_DATE);
if (field) {
if (event) {
return rawQuery(
`select ed.event_key as field,
ed.string_value as value,
count(ed.*) as total
from event_data as ed
join website_event as e on e.event_id = ed.website_event_id
where ed.website_id = $1${toUuid()}
and ed.event_key = $2
and ed.created_at >= $3
and ed.created_at between $4 and $5
and e.event_name = $6
group by ed.event_key, ed.string_value
order by 3 desc, 2 desc, 1 asc
`,
[websiteId, field, resetDate, startDate, endDate, event] as any,
);
}
return rawQuery(
`select event_key as field,
string_value as value,
@ -63,30 +31,12 @@ async function relationalQuery(
and created_at between $4 and $5
group by event_key, string_value
order by 3 desc, 2 desc, 1 asc
limit 100
`,
[websiteId, field, resetDate, startDate, endDate] as any,
);
}
if (withEventNames) {
return rawQuery(
`select
ed.event_key as field,
ed.data_type as type,
count(ed.*) as total,
e.event_name as event
from event_data as ed
join website_event as e on e.event_id = ed.website_event_id
where ed.website_id = $1${toUuid()}
and ed.created_at >= $2
and ed.created_at between $3 and $4
group by e.event_name, ed.event_key, ed.data_type
order by 3 desc, 2 asc, 1 asc
`,
[websiteId, resetDate, startDate, endDate] as any,
);
}
return rawQuery(
`select
event_key as field,
@ -98,43 +48,18 @@ async function relationalQuery(
and created_at between $3 and $4
group by event_key, data_type
order by 3 desc, 2 asc, 1 asc
limit 100
`,
[websiteId, resetDate, startDate, endDate] as any,
);
}
async function clickhouseQuery(
websiteId: string,
startDate: Date,
endDate: Date,
field: string,
event: string,
withEventNames: boolean,
) {
const { rawQuery, getDateFormat, getBetweenDates } = clickhouse;
async function clickhouseQuery(websiteId: string, startDate: Date, endDate: Date, field: string) {
const { rawQuery, getDateFormat } = clickhouse;
const website = await loadWebsite(websiteId);
const resetDate = new Date(website?.resetAt || DEFAULT_CREATED_AT);
const resetDate = new Date(website?.resetAt || DEFAULT_RESET_DATE);
if (field) {
if (event) {
return rawQuery(
`select
ed.event_key as field,
ed.string_value as value,
count(ed.*) as total
from event_data as ed
join website_event as e on e.event_id = ed.website_event_id
where ed.website_id = {websiteId:UUID}
and ed.event_key = {field:String}
and ed.created_at >= ${getDateFormat(resetDate)}
and ${getBetweenDates('ed.created_at', startDate, endDate)}
and e.event_name = {event:String}
group by event_key, string_value
order by 3 desc, 2 desc, 1 asc
`,
{ websiteId, field, event },
);
}
return rawQuery(
`select
event_key as field,
@ -144,33 +69,15 @@ async function clickhouseQuery(
where website_id = {websiteId:UUID}
and event_key = {field:String}
and created_at >= ${getDateFormat(resetDate)}
and ${getBetweenDates('created_at', startDate, endDate)}
and created_at between ${getDateFormat(startDate)} and ${getDateFormat(endDate)}
group by event_key, string_value
order by 3 desc, 2 desc, 1 asc
limit 100
`,
{ websiteId, field },
);
}
if (withEventNames) {
return rawQuery(
`select
ed.event_key as field,
ed.data_type as type,
count(ed.*) as total,
e.event_name as event
from event_data as ed
join website_event as e on e.event_id = ed.website_event_id
where ed.website_id = {websiteId:UUID}
and ed.created_at >= ${getDateFormat(resetDate)}
and ${getBetweenDates('ed.created_at', startDate, endDate)}
group by e.event_name, ed.event_key, ed.data_type
order by 3 desc, 2 asc, 1 asc
`,
[websiteId, resetDate, startDate, endDate] as any,
);
}
return rawQuery(
`select
event_key as field,
@ -179,9 +86,10 @@ async function clickhouseQuery(
from event_data
where website_id = {websiteId:UUID}
and created_at >= ${getDateFormat(resetDate)}
and ${getBetweenDates('created_at', startDate, endDate)}
and created_at between ${getDateFormat(startDate)} and ${getDateFormat(endDate)}
group by event_key, data_type
order by 3 desc, 2 asc, 1 asc
limit 100
`,
{ websiteId },
);

View file

@ -9,7 +9,7 @@ export function getEventDataUsage(...args: [websiteIds: string[], startDate: Dat
}
function relationalQuery(websiteIds: string[], startDate: Date, endDate: Date) {
throw new Error('Not Implemented');
throw new Error('Not implemented.');
}
function clickhouseQuery(websiteIds: string[], startDate: Date, endDate: Date) {

View file

@ -1,6 +1,6 @@
import { Prisma } from '@prisma/client';
import { DATA_TYPE } from 'lib/constants';
import { uuid } from 'lib/crypto';
import { uuid } from 'next-basics';
import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
import { flattenJSON } from 'lib/dynamicData';
import kafka from 'lib/kafka';

View file

@ -2,7 +2,7 @@ import prisma from 'lib/prisma';
import clickhouse from 'lib/clickhouse';
import { runQuery, CLICKHOUSE, PRISMA } from 'lib/db';
import { WebsiteEventMetric } from 'lib/types';
import { DEFAULT_CREATED_AT, EVENT_TYPE } from 'lib/constants';
import { DEFAULT_RESET_DATE, EVENT_TYPE } from 'lib/constants';
import { loadWebsite } from 'lib/query';
export async function getEventMetrics(
@ -47,7 +47,7 @@ async function relationalQuery(
) {
const { toUuid, rawQuery, getDateQuery, getFilterQuery } = prisma;
const website = await loadWebsite(websiteId);
const resetDate = new Date(website?.resetAt || DEFAULT_CREATED_AT);
const resetDate = new Date(website?.resetAt || DEFAULT_RESET_DATE);
const params: any = [websiteId, resetDate, startDate, endDate];
const filterQuery = getFilterQuery(filters, params);
@ -87,9 +87,9 @@ async function clickhouseQuery(
};
},
) {
const { rawQuery, getDateQuery, getDateFormat, getBetweenDates, getFilterQuery } = clickhouse;
const { rawQuery, getDateQuery, getDateFormat, getFilterQuery } = clickhouse;
const website = await loadWebsite(websiteId);
const resetDate = new Date(website?.resetAt || DEFAULT_CREATED_AT);
const resetDate = new Date(website?.resetAt || DEFAULT_RESET_DATE);
const params = { websiteId };
return rawQuery(
@ -101,7 +101,7 @@ async function clickhouseQuery(
where website_id = {websiteId:UUID}
and event_type = ${EVENT_TYPE.customEvent}
and created_at >= ${getDateFormat(resetDate)}
and ${getBetweenDates('created_at', startDate, endDate)}
and created_at between ${getDateFormat(startDate)} and ${getDateFormat(endDate)}
${getFilterQuery(filters, params)}
group by x, t
order by t`,

View file

@ -9,7 +9,7 @@ export function getEventUsage(...args: [websiteIds: string[], startDate: Date, e
}
function relationalQuery(websiteIds: string[], startDate: Date, endDate: Date) {
throw new Error('Not Implemented');
throw new Error('Not implemented.');
}
function clickhouseQuery(websiteIds: string[], startDate: Date, endDate: Date) {

View file

@ -2,7 +2,7 @@ import { EVENT_NAME_LENGTH, URL_LENGTH, EVENT_TYPE } from 'lib/constants';
import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
import kafka from 'lib/kafka';
import prisma from 'lib/prisma';
import { uuid } from 'lib/crypto';
import { uuid } from 'next-basics';
import { saveEventData } from 'queries/analytics/eventData/saveEventData';
export async function saveEvent(args: {

View file

@ -1,7 +1,7 @@
import prisma from 'lib/prisma';
import clickhouse from 'lib/clickhouse';
import { runQuery, CLICKHOUSE, PRISMA } from 'lib/db';
import { DEFAULT_CREATED_AT, EVENT_TYPE } from 'lib/constants';
import { DEFAULT_RESET_DATE, EVENT_TYPE } from 'lib/constants';
import { loadWebsite } from 'lib/query';
export async function getPageviewMetrics(
@ -33,7 +33,7 @@ async function relationalQuery(
const { startDate, endDate, filters = {}, column } = criteria;
const { rawQuery, parseFilters, toUuid } = prisma;
const website = await loadWebsite(websiteId);
const resetDate = new Date(website?.resetAt || DEFAULT_CREATED_AT);
const resetDate = new Date(website?.resetAt || DEFAULT_RESET_DATE);
const params: any = [
websiteId,
resetDate,
@ -45,7 +45,8 @@ async function relationalQuery(
let excludeDomain = '';
if (column === 'referrer_domain') {
excludeDomain = 'and (website_event.referrer_domain != $6 or website_event.referrer_domain is null)';
excludeDomain =
'and (website_event.referrer_domain != $6 or website_event.referrer_domain is null)';
params.push(website.domain);
}
@ -78,9 +79,9 @@ async function clickhouseQuery(
},
) {
const { startDate, endDate, filters = {}, column } = criteria;
const { rawQuery, getDateFormat, parseFilters, getBetweenDates } = clickhouse;
const { rawQuery, getDateFormat, parseFilters } = clickhouse;
const website = await loadWebsite(websiteId);
const resetDate = new Date(website?.resetAt || DEFAULT_CREATED_AT);
const resetDate = new Date(website?.resetAt || DEFAULT_RESET_DATE);
const params = {
websiteId,
eventType: column === 'event_name' ? EVENT_TYPE.customEvent : EVENT_TYPE.pageView,
@ -102,7 +103,7 @@ async function clickhouseQuery(
where website_id = {websiteId:UUID}
and event_type = {eventType:UInt32}
and created_at >= ${getDateFormat(resetDate)}
and ${getBetweenDates('created_at', startDate, endDate)}
and created_at between ${getDateFormat(startDate)} and ${getDateFormat(endDate)}
${excludeDomain}
${filterQuery}
group by x

View file

@ -1,7 +1,7 @@
import clickhouse from 'lib/clickhouse';
import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
import prisma from 'lib/prisma';
import { DEFAULT_CREATED_AT, EVENT_TYPE } from 'lib/constants';
import { DEFAULT_RESET_DATE, EVENT_TYPE } from 'lib/constants';
import { loadWebsite } from 'lib/query';
export async function getPageviewStats(
@ -47,7 +47,7 @@ async function relationalQuery(
} = criteria;
const { toUuid, getDateQuery, parseFilters, rawQuery } = prisma;
const website = await loadWebsite(websiteId);
const resetDate = new Date(website?.resetAt || DEFAULT_CREATED_AT);
const resetDate = new Date(website?.resetAt || DEFAULT_RESET_DATE);
const params: any = [websiteId, resetDate, startDate, endDate];
const { filterQuery, joinSession } = parseFilters(filters, params);
@ -86,16 +86,9 @@ async function clickhouseQuery(
count = '*',
filters = {},
} = criteria;
const {
parseFilters,
getDateFormat,
rawQuery,
getDateStringQuery,
getDateQuery,
getBetweenDates,
} = clickhouse;
const { parseFilters, getDateFormat, rawQuery, getDateStringQuery, getDateQuery } = clickhouse;
const website = await loadWebsite(websiteId);
const resetDate = new Date(website?.resetAt || DEFAULT_CREATED_AT);
const resetDate = new Date(website?.resetAt || DEFAULT_RESET_DATE);
const params = { websiteId };
const { filterQuery } = parseFilters(filters, params);
@ -111,7 +104,7 @@ async function clickhouseQuery(
where website_id = {websiteId:UUID}
and event_type = ${EVENT_TYPE.pageView}
and created_at >= ${getDateFormat(resetDate)}
and ${getBetweenDates('created_at', startDate, endDate)}
and created_at between ${getDateFormat(startDate)} and ${getDateFormat(endDate)}
${filterQuery}
group by t) g
order by t`,

View file

@ -2,7 +2,7 @@ import clickhouse from 'lib/clickhouse';
import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
import prisma from 'lib/prisma';
export async function getPageviewFunnel(
export async function getFunnel(
...args: [
websiteId: string,
criteria: {
@ -76,14 +76,8 @@ async function clickhouseQuery(
}[]
> {
const { windowMinutes, startDate, endDate, urls } = criteria;
const { rawQuery, getBetweenDates, getFunnelQuery } = clickhouse;
const { columnsQuery, conditionQuery, urlParams } = getFunnelQuery(urls);
const params = {
websiteId,
window: windowMinutes * 60,
...urlParams,
};
const { rawQuery, getFunnelQuery } = clickhouse;
const { columnsQuery, urlParams } = getFunnelQuery(urls);
return rawQuery<{ level: number; count: number }[]>(
`
@ -98,13 +92,19 @@ async function clickhouseQuery(
) AS level
FROM website_event
WHERE website_id = {websiteId:UUID}
and ${getBetweenDates('created_at', startDate, endDate)}
AND created_at BETWEEN {startDate:DateTime} AND {endDate:DateTime}
GROUP BY 1
)
GROUP BY level
ORDER BY level ASC;
`,
params,
{
websiteId,
startDate,
endDate,
window: windowMinutes * 60,
...urlParams,
},
).then(results => {
return urls.map((a, i) => ({
x: a,

View file

@ -0,0 +1,42 @@
import { CLICKHOUSE, PRISMA, runQuery } from 'lib/db';
import prisma from 'lib/prisma';
import clickhouse from 'lib/clickhouse';
export interface GetInsightsCriteria {
startDate: Date;
endDate: Date;
fields: string[];
filters: string[];
groups: string[];
}
export async function getInsights(...args: [websiteId: string, criteria: GetInsightsCriteria]) {
return runQuery({
[PRISMA]: () => relationalQuery(...args),
[CLICKHOUSE]: () => clickhouseQuery(...args),
});
}
async function relationalQuery(
websiteId: string,
criteria: GetInsightsCriteria,
): Promise<
{
x: string;
y: number;
}[]
> {
return null;
}
async function clickhouseQuery(
websiteId: string,
criteria: GetInsightsCriteria,
): Promise<
{
x: string;
y: number;
}[]
> {
return null;
}

View file

@ -1,7 +1,7 @@
import prisma from 'lib/prisma';
import clickhouse from 'lib/clickhouse';
import { runQuery, CLICKHOUSE, PRISMA } from 'lib/db';
import { DEFAULT_CREATED_AT, EVENT_TYPE } from 'lib/constants';
import { DEFAULT_RESET_DATE, EVENT_TYPE } from 'lib/constants';
import { loadWebsite } from 'lib/query';
export async function getSessionMetrics(
@ -21,7 +21,7 @@ async function relationalQuery(
criteria: { startDate: Date; endDate: Date; column: string; filters: object },
) {
const website = await loadWebsite(websiteId);
const resetDate = new Date(website?.resetAt || DEFAULT_CREATED_AT);
const resetDate = new Date(website?.resetAt || DEFAULT_RESET_DATE);
const { startDate, endDate, column, filters = {} } = criteria;
const { toUuid, parseFilters, rawQuery } = prisma;
const params: any = [websiteId, resetDate, startDate, endDate];
@ -53,9 +53,9 @@ async function clickhouseQuery(
data: { startDate: Date; endDate: Date; column: string; filters: object },
) {
const { startDate, endDate, column, filters = {} } = data;
const { getDateFormat, parseFilters, getBetweenDates, rawQuery } = clickhouse;
const { getDateFormat, parseFilters, rawQuery } = clickhouse;
const website = await loadWebsite(websiteId);
const resetDate = new Date(website?.resetAt || DEFAULT_CREATED_AT);
const resetDate = new Date(website?.resetAt || DEFAULT_RESET_DATE);
const params = { websiteId };
const { filterQuery } = parseFilters(filters, params);
@ -65,7 +65,7 @@ async function clickhouseQuery(
where website_id = {websiteId:UUID}
and event_type = ${EVENT_TYPE.pageView}
and created_at >= ${getDateFormat(resetDate)}
and ${getBetweenDates('created_at', startDate, endDate)}
and created_at between ${getDateFormat(startDate)} and ${getDateFormat(endDate)}
${filterQuery}
group by x
order by y desc

View file

@ -1,5 +1,5 @@
import { DATA_TYPE } from 'lib/constants';
import { uuid } from 'lib/crypto';
import { uuid } from 'next-basics';
import { flattenJSON } from 'lib/dynamicData';
import prisma from 'lib/prisma';
import { DynamicData } from 'lib/types';

View file

@ -1,6 +1,5 @@
import { md5 } from 'lib/crypto';
import { getSessions } from '../session/getSessions';
import { getEvents } from '../event/getEvents';
import { md5 } from 'next-basics';
import { getSessions, getEvents } from 'queries';
import { EVENT_TYPE } from 'lib/constants';
export async function getRealtimeData(websiteId, time) {
@ -20,7 +19,7 @@ export async function getRealtimeData(websiteId, time) {
};
return {
pageviews: decorate('pageview', pageviews),
pageviews: decorate('pageviews', pageviews),
sessions: decorate('session', sessions),
events: decorate('event', events),
timestamp: Date.now(),

View file

@ -1,7 +1,7 @@
import prisma from 'lib/prisma';
import clickhouse from 'lib/clickhouse';
import { runQuery, CLICKHOUSE, PRISMA } from 'lib/db';
import { DEFAULT_CREATED_AT, EVENT_TYPE } from 'lib/constants';
import { DEFAULT_RESET_DATE, EVENT_TYPE } from 'lib/constants';
import { loadWebsite } from 'lib/query';
export async function getWebsiteStats(
@ -23,7 +23,7 @@ async function relationalQuery(
const { startDate, endDate, filters = {} } = criteria;
const { toUuid, getDateQuery, getTimestampInterval, parseFilters, rawQuery } = prisma;
const website = await loadWebsite(websiteId);
const resetDate = new Date(website?.resetAt || DEFAULT_CREATED_AT);
const resetDate = new Date(website?.resetAt || DEFAULT_RESET_DATE);
const params: any = [websiteId, resetDate, startDate, endDate];
const { filterQuery, joinSession } = parseFilters(filters, params);
@ -57,9 +57,9 @@ async function clickhouseQuery(
criteria: { startDate: Date; endDate: Date; filters: object },
) {
const { startDate, endDate, filters = {} } = criteria;
const { rawQuery, getDateFormat, getDateQuery, getBetweenDates, parseFilters } = clickhouse;
const { rawQuery, getDateFormat, getDateQuery, parseFilters } = clickhouse;
const website = await loadWebsite(websiteId);
const resetDate = new Date(website?.resetAt || DEFAULT_CREATED_AT);
const resetDate = new Date(website?.resetAt || DEFAULT_RESET_DATE);
const params = { websiteId };
const { filterQuery } = parseFilters(filters, params);
@ -79,7 +79,7 @@ async function clickhouseQuery(
where event_type = ${EVENT_TYPE.pageView}
and website_id = {websiteId:UUID}
and created_at >= ${getDateFormat(resetDate)}
and ${getBetweenDates('created_at', startDate, endDate)}
and created_at between ${getDateFormat(startDate)} and ${getDateFormat(endDate)}
${filterQuery}
group by session_id, time_series
) t;`,

View file

@ -3,19 +3,21 @@ export * from './admin/teamUser';
export * from './admin/user';
export * from './admin/report';
export * from './admin/website';
export * from './analytics/event/getEventMetrics';
export * from './analytics/event/getEventUsage';
export * from './analytics/event/getEvents';
export * from './analytics/events/getEventMetrics';
export * from './analytics/events/getEventUsage';
export * from './analytics/events/getEvents';
export * from './analytics/eventData/getEventDataEvents';
export * from './analytics/eventData/getEventDataFields';
export * from './analytics/eventData/getEventDataUsage';
export * from './analytics/event/saveEvent';
export * from './analytics/pageview/getPageviewFunnel';
export * from './analytics/pageview/getPageviewMetrics';
export * from './analytics/pageview/getPageviewStats';
export * from './analytics/session/createSession';
export * from './analytics/session/getSession';
export * from './analytics/session/getSessionMetrics';
export * from './analytics/session/getSessions';
export * from './analytics/events/saveEvent';
export * from './analytics/reports/getFunnel';
export * from './analytics/reports/getInsights';
export * from './analytics/pageviews/getPageviewMetrics';
export * from './analytics/pageviews/getPageviewStats';
export * from './analytics/sessions/createSession';
export * from './analytics/sessions/getSession';
export * from './analytics/sessions/getSessionMetrics';
export * from './analytics/sessions/getSessions';
export * from './analytics/stats/getActiveVisitors';
export * from './analytics/stats/getRealtimeData';
export * from './analytics/stats/getWebsiteStats';