mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Compare commits
No commits in common. "64a6379c3c13842bd1b609a44caf0caf88c412eb" and "227201a73c276182abfa33c2870e1a6c8118b7d6" have entirely different histories.
64a6379c3c
...
227201a73c
12 changed files with 65 additions and 116 deletions
|
|
@ -16,7 +16,7 @@ export function App({ children }) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
window.location.href = `${process.env.basePath || ''}/login`;
|
window.location.href = '/login';
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,24 +1,11 @@
|
||||||
import {
|
import { DataTable, DataColumn, Row, Text, DataTableProps, IconLabel } from '@umami/react-zen';
|
||||||
DataTable,
|
|
||||||
DataColumn,
|
|
||||||
Row,
|
|
||||||
Text,
|
|
||||||
DataTableProps,
|
|
||||||
IconLabel,
|
|
||||||
Button,
|
|
||||||
Dialog,
|
|
||||||
DialogTrigger,
|
|
||||||
Icon,
|
|
||||||
Popover,
|
|
||||||
} from '@umami/react-zen';
|
|
||||||
import { useFormat, useMessages, useNavigation } from '@/components/hooks';
|
import { useFormat, useMessages, useNavigation } from '@/components/hooks';
|
||||||
import { Avatar } from '@/components/common/Avatar';
|
import { Avatar } from '@/components/common/Avatar';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { Eye, FileText } from '@/components/icons';
|
import { Eye } from '@/components/icons';
|
||||||
import { Lightning } from '@/components/svg';
|
import { Lightning } from '@/components/svg';
|
||||||
import { DateDistance } from '@/components/common/DateDistance';
|
import { DateDistance } from '@/components/common/DateDistance';
|
||||||
import { TypeIcon } from '@/components/common/TypeIcon';
|
import { TypeIcon } from '@/components/common/TypeIcon';
|
||||||
import { EventData } from '@/components/metrics/EventData';
|
|
||||||
|
|
||||||
export function EventsTable(props: DataTableProps) {
|
export function EventsTable(props: DataTableProps) {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
@ -45,7 +32,6 @@ export function EventsTable(props: DataTableProps) {
|
||||||
>
|
>
|
||||||
{row.eventName || row.urlPath}
|
{row.eventName || row.urlPath}
|
||||||
</Text>
|
</Text>
|
||||||
{row.hasData > 0 && <PropertiesButton websiteId={row.websiteId} eventId={row.id} />}
|
|
||||||
</Row>
|
</Row>
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
|
|
@ -86,22 +72,3 @@ export function EventsTable(props: DataTableProps) {
|
||||||
</DataTable>
|
</DataTable>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const PropertiesButton = props => {
|
|
||||||
return (
|
|
||||||
<DialogTrigger>
|
|
||||||
<Button variant="quiet">
|
|
||||||
<Row alignItems="center" gap>
|
|
||||||
<Icon>
|
|
||||||
<FileText />
|
|
||||||
</Icon>
|
|
||||||
</Row>
|
|
||||||
</Button>
|
|
||||||
<Popover placement="right">
|
|
||||||
<Dialog>
|
|
||||||
<EventData {...props} />
|
|
||||||
</Dialog>
|
|
||||||
</Popover>
|
|
||||||
</DialogTrigger>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,6 @@ import {
|
||||||
useCountryNames,
|
useCountryNames,
|
||||||
useLocale,
|
useLocale,
|
||||||
useMessages,
|
useMessages,
|
||||||
useMobile,
|
|
||||||
useNavigation,
|
useNavigation,
|
||||||
useTimezone,
|
useTimezone,
|
||||||
useWebsite,
|
useWebsite,
|
||||||
|
|
@ -41,7 +40,6 @@ export function RealtimeLog({ data }: { data: any }) {
|
||||||
const { countryNames } = useCountryNames(locale);
|
const { countryNames } = useCountryNames(locale);
|
||||||
const [filter, setFilter] = useState(TYPE_ALL);
|
const [filter, setFilter] = useState(TYPE_ALL);
|
||||||
const { updateParams } = useNavigation();
|
const { updateParams } = useNavigation();
|
||||||
const { isPhone } = useMobile();
|
|
||||||
|
|
||||||
const buttons = [
|
const buttons = [
|
||||||
{
|
{
|
||||||
|
|
@ -125,18 +123,12 @@ export function RealtimeLog({ data }: { data: any }) {
|
||||||
const row = logs[index];
|
const row = logs[index];
|
||||||
return (
|
return (
|
||||||
<Row alignItems="center" style={style} gap>
|
<Row alignItems="center" style={style} gap>
|
||||||
<Row minWidth="30px">
|
|
||||||
<Link href={updateParams({ session: row.sessionId })}>
|
<Link href={updateParams({ session: row.sessionId })}>
|
||||||
<Avatar seed={row.sessionId} size={32} />
|
<Avatar seed={row.sessionId} size={32} />
|
||||||
</Link>
|
</Link>
|
||||||
</Row>
|
<Row width="100px">{getTime(row)}</Row>
|
||||||
<Row minWidth="100px">
|
|
||||||
<Text wrap="nowrap">{getTime(row)}</Text>
|
|
||||||
</Row>
|
|
||||||
<IconLabel icon={getIcon(row)}>
|
<IconLabel icon={getIcon(row)}>
|
||||||
<Text style={{ maxWidth: isPhone ? '400px' : null }} truncate>
|
<Text>{getDetail(row)}</Text>
|
||||||
{getDetail(row)}
|
|
||||||
</Text>
|
|
||||||
</IconLabel>
|
</IconLabel>
|
||||||
</Row>
|
</Row>
|
||||||
);
|
);
|
||||||
|
|
@ -176,22 +168,10 @@ export function RealtimeLog({ data }: { data: any }) {
|
||||||
return (
|
return (
|
||||||
<Column gap>
|
<Column gap>
|
||||||
<Heading size="2">{formatMessage(labels.activity)}</Heading>
|
<Heading size="2">{formatMessage(labels.activity)}</Heading>
|
||||||
{isPhone ? (
|
|
||||||
<>
|
|
||||||
<Row>
|
|
||||||
<SearchField value={search} onSearch={setSearch} />
|
|
||||||
</Row>
|
|
||||||
<Row>
|
|
||||||
<FilterButtons items={buttons} value={filter} onChange={setFilter} />
|
|
||||||
</Row>
|
|
||||||
</>
|
|
||||||
) : (
|
|
||||||
<Row alignItems="center" justifyContent="space-between">
|
<Row alignItems="center" justifyContent="space-between">
|
||||||
<SearchField value={search} onSearch={setSearch} />
|
<SearchField value={search} onSearch={setSearch} />
|
||||||
<FilterButtons items={buttons} value={filter} onChange={setFilter} />
|
<FilterButtons items={buttons} value={filter} onChange={setFilter} />
|
||||||
</Row>
|
</Row>
|
||||||
)}
|
|
||||||
|
|
||||||
<Column>
|
<Column>
|
||||||
{logs?.length === 0 && <Empty />}
|
{logs?.length === 0 && <Empty />}
|
||||||
{logs?.length > 0 && (
|
{logs?.length > 0 && (
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ import { PageBody } from '@/components/common/PageBody';
|
||||||
import { Panel } from '@/components/common/Panel';
|
import { Panel } from '@/components/common/Panel';
|
||||||
import { RealtimeChart } from '@/components/metrics/RealtimeChart';
|
import { RealtimeChart } from '@/components/metrics/RealtimeChart';
|
||||||
import { WorldMap } from '@/components/metrics/WorldMap';
|
import { WorldMap } from '@/components/metrics/WorldMap';
|
||||||
import { useMobile, useRealtimeQuery } from '@/components/hooks';
|
import { useRealtimeQuery } from '@/components/hooks';
|
||||||
import { RealtimeLog } from './RealtimeLog';
|
import { RealtimeLog } from './RealtimeLog';
|
||||||
import { RealtimeHeader } from './RealtimeHeader';
|
import { RealtimeHeader } from './RealtimeHeader';
|
||||||
import { RealtimePaths } from './RealtimePaths';
|
import { RealtimePaths } from './RealtimePaths';
|
||||||
|
|
@ -16,7 +16,6 @@ import { percentFilter } from '@/lib/filters';
|
||||||
|
|
||||||
export function RealtimePage({ websiteId }: { websiteId: string }) {
|
export function RealtimePage({ websiteId }: { websiteId: string }) {
|
||||||
const { data, isLoading, error } = useRealtimeQuery(websiteId);
|
const { data, isLoading, error } = useRealtimeQuery(websiteId);
|
||||||
const { isMobile } = useMobile();
|
|
||||||
|
|
||||||
if (isLoading || error) {
|
if (isLoading || error) {
|
||||||
return <PageBody isLoading={isLoading} error={error} />;
|
return <PageBody isLoading={isLoading} error={error} />;
|
||||||
|
|
@ -49,7 +48,7 @@ export function RealtimePage({ websiteId }: { websiteId: string }) {
|
||||||
<Panel>
|
<Panel>
|
||||||
<RealtimeCountries data={countries} />
|
<RealtimeCountries data={countries} />
|
||||||
</Panel>
|
</Panel>
|
||||||
<Panel gridColumn={isMobile ? null : 'span 2'} padding="0">
|
<Panel gridColumn="span 2" padding="0">
|
||||||
<WorldMap data={countries} />
|
<WorldMap data={countries} />
|
||||||
</Panel>
|
</Panel>
|
||||||
</GridRow>
|
</GridRow>
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ import {
|
||||||
import { LoadingPanel } from '@/components/common/LoadingPanel';
|
import { LoadingPanel } from '@/components/common/LoadingPanel';
|
||||||
import { Eye, FileText } from '@/components/icons';
|
import { Eye, FileText } from '@/components/icons';
|
||||||
import { Lightning } from '@/components/svg';
|
import { Lightning } from '@/components/svg';
|
||||||
import { useMessages, useMobile, useSessionActivityQuery, useTimezone } from '@/components/hooks';
|
import { useMessages, useSessionActivityQuery, useTimezone } from '@/components/hooks';
|
||||||
import { EventData } from '@/components/metrics/EventData';
|
import { EventData } from '@/components/metrics/EventData';
|
||||||
|
|
||||||
export function SessionActivity({
|
export function SessionActivity({
|
||||||
|
|
@ -36,7 +36,6 @@ export function SessionActivity({
|
||||||
startDate,
|
startDate,
|
||||||
endDate,
|
endDate,
|
||||||
);
|
);
|
||||||
const { isMobile } = useMobile();
|
|
||||||
let lastDay = null;
|
let lastDay = null;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
@ -51,16 +50,16 @@ export function SessionActivity({
|
||||||
{showHeader && <Heading size="1">{formatTimezoneDate(createdAt, 'PPPP')}</Heading>}
|
{showHeader && <Heading size="1">{formatTimezoneDate(createdAt, 'PPPP')}</Heading>}
|
||||||
<Row alignItems="center" gap="6" height="40px">
|
<Row alignItems="center" gap="6" height="40px">
|
||||||
<StatusLight color={`#${visitId?.substring(0, 6)}`}>
|
<StatusLight color={`#${visitId?.substring(0, 6)}`}>
|
||||||
<Text wrap="nowrap">{formatTimezoneDate(createdAt, 'pp')}</Text>
|
{formatTimezoneDate(createdAt, 'pp')}
|
||||||
</StatusLight>
|
</StatusLight>
|
||||||
<Row alignItems="center" gap="2">
|
<Row alignItems="center" gap="2">
|
||||||
<Icon>{eventName ? <Lightning /> : <Eye />}</Icon>
|
<Icon>{eventName ? <Lightning /> : <Eye />}</Icon>
|
||||||
<Text wrap="nowrap">
|
<Text>
|
||||||
{eventName
|
{eventName
|
||||||
? formatMessage(labels.triggeredEvent)
|
? formatMessage(labels.triggeredEvent)
|
||||||
: formatMessage(labels.viewedPage)}
|
: formatMessage(labels.viewedPage)}
|
||||||
</Text>
|
</Text>
|
||||||
<Text weight="bold" style={{ maxWidth: isMobile ? '400px' : null }} truncate>
|
<Text weight="bold" style={{ maxWidth: '400px' }} truncate>
|
||||||
{eventName || urlPath}
|
{eventName || urlPath}
|
||||||
</Text>
|
</Text>
|
||||||
{hasData > 0 && <PropertiesButton websiteId={websiteId} eventId={eventId} />}
|
{hasData > 0 && <PropertiesButton websiteId={websiteId} eventId={eventId} />}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ export function LogoutPage() {
|
||||||
async function logout() {
|
async function logout() {
|
||||||
await post('/auth/logout');
|
await post('/auth/logout');
|
||||||
|
|
||||||
window.location.href = `${process.env.basePath || ''}/login`;
|
window.location.href = '/login';
|
||||||
}
|
}
|
||||||
|
|
||||||
removeClientAuthToken();
|
removeClientAuthToken();
|
||||||
|
|
|
||||||
|
|
@ -57,7 +57,7 @@ export function ListTable({
|
||||||
showPercentage={showPercentage}
|
showPercentage={showPercentage}
|
||||||
change={renderChange ? renderChange(row, index) : null}
|
change={renderChange ? renderChange(row, index) : null}
|
||||||
currency={currency}
|
currency={currency}
|
||||||
isPhone={isPhone}
|
isMobile={isPhone}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
@ -101,7 +101,7 @@ const AnimatedRow = ({
|
||||||
animate,
|
animate,
|
||||||
showPercentage = true,
|
showPercentage = true,
|
||||||
currency,
|
currency,
|
||||||
isPhone,
|
isMobile,
|
||||||
}) => {
|
}) => {
|
||||||
const props = useSpring({
|
const props = useSpring({
|
||||||
width: percent,
|
width: percent,
|
||||||
|
|
@ -120,7 +120,7 @@ const AnimatedRow = ({
|
||||||
gap
|
gap
|
||||||
>
|
>
|
||||||
<Row alignItems="center">
|
<Row alignItems="center">
|
||||||
<Text truncate={true} style={{ maxWidth: isPhone ? '200px' : '400px' }}>
|
<Text truncate={true} style={{ maxWidth: isMobile ? '200px' : '400px' }}>
|
||||||
{label}
|
{label}
|
||||||
</Text>
|
</Text>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
|
||||||
|
|
@ -19,20 +19,20 @@ async function relationalQuery(websiteId: string, eventId: string) {
|
||||||
|
|
||||||
return rawQuery(
|
return rawQuery(
|
||||||
`
|
`
|
||||||
select event_data.website_id as "websiteId",
|
select website_id as "websiteId",
|
||||||
event_data.website_event_id as "eventId",
|
session_id as "sessionId",
|
||||||
website_event.event_name as "eventName",
|
event_id as "eventId",
|
||||||
event_data.data_key as "dataKey",
|
url_path as "urlPath",
|
||||||
event_data.string_value as "stringValue",
|
event_name as "eventName",
|
||||||
event_data.number_value as "numberValue",
|
data_key as "dataKey",
|
||||||
event_data.date_value as "dateValue",
|
string_value as "stringValue",
|
||||||
event_data.data_type as "dataType",
|
number_value as "numberValue",
|
||||||
event_data.created_at as "createdAt"
|
date_value as "dateValue",
|
||||||
|
data_type as "dataType",
|
||||||
|
created_at as "createdAt"
|
||||||
from event_data
|
from event_data
|
||||||
join website_event on website_event.event_id = event_data.website_event_id
|
website_id = {{websiteId::uuid}}
|
||||||
and website_event.website_id = {{websiteId::uuid}}
|
event_id = {{eventId::uuid}}
|
||||||
where event_data.website_id = {{websiteId::uuid}}
|
|
||||||
and event_data.website_event_id = {{eventId::uuid}}
|
|
||||||
`,
|
`,
|
||||||
{ websiteId, eventId },
|
{ websiteId, eventId },
|
||||||
FUNCTION_NAME,
|
FUNCTION_NAME,
|
||||||
|
|
@ -45,7 +45,9 @@ async function clickhouseQuery(websiteId: string, eventId: string): Promise<Even
|
||||||
return rawQuery(
|
return rawQuery(
|
||||||
`
|
`
|
||||||
select website_id as websiteId,
|
select website_id as websiteId,
|
||||||
|
session_id as sessionId,
|
||||||
event_id as eventId,
|
event_id as eventId,
|
||||||
|
url_path as urlPath,
|
||||||
event_name as eventName,
|
event_name as eventName,
|
||||||
data_key as dataKey,
|
data_key as dataKey,
|
||||||
string_value as stringValue,
|
string_value as stringValue,
|
||||||
|
|
|
||||||
|
|
@ -45,11 +45,7 @@ async function relationalQuery(websiteId: string, filters: QueryFilters) {
|
||||||
browser as browser,
|
browser as browser,
|
||||||
page_title as "pageTitle",
|
page_title as "pageTitle",
|
||||||
website_event.event_type as "eventType",
|
website_event.event_type as "eventType",
|
||||||
website_event.event_name as "eventName",
|
website_event.event_name as "eventName"
|
||||||
event_id IN (select website_event_id
|
|
||||||
from event_data
|
|
||||||
where website_id = {{websiteId::uuid}}
|
|
||||||
and created_at between {{startDate}} and {{endDate}}) AS "hasData"
|
|
||||||
from website_event
|
from website_event
|
||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
join session on session.session_id = website_event.session_id
|
join session on session.session_id = website_event.session_id
|
||||||
|
|
|
||||||
|
|
@ -36,11 +36,11 @@ async function relationalQuery(
|
||||||
return rawQuery(
|
return rawQuery(
|
||||||
`
|
`
|
||||||
select
|
select
|
||||||
cast(coalesce(sum(t.c), 0) as bigint) as "pageviews",
|
sum(t.c) as "pageviews",
|
||||||
count(distinct t.session_id) as "visitors",
|
count(distinct t.session_id) as "visitors",
|
||||||
count(distinct t.visit_id) as "visits",
|
count(distinct t.visit_id) as "visits",
|
||||||
coalesce(sum(case when t.c = 1 then 1 else 0 end), 0) as "bounces",
|
sum(case when t.c = 1 then 1 else 0 end) as "bounces",
|
||||||
cast(coalesce(sum(${getTimestampDiffSQL('t.min_time', 't.max_time')}), 0) as bigint) as "totaltime"
|
sum(${getTimestampDiffSQL('t.min_time', 't.max_time')}) as "totaltime"
|
||||||
from (
|
from (
|
||||||
select
|
select
|
||||||
website_event.session_id,
|
website_event.session_id,
|
||||||
|
|
|
||||||
|
|
@ -41,15 +41,6 @@ async function relationalQuery(
|
||||||
currency,
|
currency,
|
||||||
});
|
});
|
||||||
|
|
||||||
const joinQuery = filterQuery
|
|
||||||
? `join website_event
|
|
||||||
on website_event.website_id = revenue.website_id
|
|
||||||
and website_event.session_id = revenue.session_id
|
|
||||||
and website_event.event_id = revenue.event_id
|
|
||||||
and website_event.website_id = {{websiteId::uuid}}
|
|
||||||
and website_event.created_at between {{startDate}} and {{endDate}}`
|
|
||||||
: '';
|
|
||||||
|
|
||||||
const chart = await rawQuery(
|
const chart = await rawQuery(
|
||||||
`
|
`
|
||||||
select
|
select
|
||||||
|
|
@ -57,12 +48,17 @@ async function relationalQuery(
|
||||||
${getDateSQL('revenue.created_at', unit, timezone)} t,
|
${getDateSQL('revenue.created_at', unit, timezone)} t,
|
||||||
sum(revenue.revenue) y
|
sum(revenue.revenue) y
|
||||||
from revenue
|
from revenue
|
||||||
${joinQuery}
|
join website_event
|
||||||
|
on website_event.website_id = revenue.website_id
|
||||||
|
and website_event.session_id = revenue.session_id
|
||||||
|
and website_event.event_id = revenue.event_id
|
||||||
|
and website_event.website_id = {{websiteId::uuid}}
|
||||||
|
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
${joinSessionQuery}
|
${joinSessionQuery}
|
||||||
where revenue.website_id = {{websiteId::uuid}}
|
where revenue.website_id = {{websiteId::uuid}}
|
||||||
and revenue.created_at between {{startDate}} and {{endDate}}
|
and revenue.created_at between {{startDate}} and {{endDate}}
|
||||||
and revenue.currency ilike {{currency}}
|
and revenue.currency like {{currency}}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
group by x, t
|
group by x, t
|
||||||
order by t
|
order by t
|
||||||
|
|
@ -76,14 +72,19 @@ async function relationalQuery(
|
||||||
session.country as name,
|
session.country as name,
|
||||||
sum(revenue) value
|
sum(revenue) value
|
||||||
from revenue
|
from revenue
|
||||||
${joinQuery}
|
join website_event
|
||||||
|
on website_event.website_id = revenue.website_id
|
||||||
|
and website_event.session_id = revenue.session_id
|
||||||
|
and website_event.event_id = revenue.event_id
|
||||||
|
and website_event.website_id = {{websiteId::uuid}}
|
||||||
|
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||||
join session
|
join session
|
||||||
on session.website_id = revenue.website_id
|
on session.website_id = revenue.website_id
|
||||||
and session.session_id = revenue.session_id
|
and session.session_id = revenue.session_id
|
||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
where revenue.website_id = {{websiteId::uuid}}
|
where revenue.website_id = {{websiteId::uuid}}
|
||||||
and revenue.created_at between {{startDate}} and {{endDate}}
|
and revenue.created_at between {{startDate}} and {{endDate}}
|
||||||
and revenue.currency ilike {{currency}}
|
and revenue.currency = {{currency}}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
group by session.country
|
group by session.country
|
||||||
`,
|
`,
|
||||||
|
|
@ -97,18 +98,23 @@ async function relationalQuery(
|
||||||
count(distinct revenue.event_id) as count,
|
count(distinct revenue.event_id) as count,
|
||||||
count(distinct revenue.session_id) as unique_count
|
count(distinct revenue.session_id) as unique_count
|
||||||
from revenue
|
from revenue
|
||||||
${joinQuery}
|
join website_event
|
||||||
|
on website_event.website_id = revenue.website_id
|
||||||
|
and website_event.session_id = revenue.session_id
|
||||||
|
and website_event.event_id = revenue.event_id
|
||||||
|
and website_event.website_id = {{websiteId::uuid}}
|
||||||
|
and website_event.created_at between {{startDate}} and {{endDate}}
|
||||||
${cohortQuery}
|
${cohortQuery}
|
||||||
${joinSessionQuery}
|
${joinSessionQuery}
|
||||||
where revenue.website_id = {{websiteId::uuid}}
|
where revenue.website_id = {{websiteId::uuid}}
|
||||||
and revenue.created_at between {{startDate}} and {{endDate}}
|
and revenue.created_at between {{startDate}} and {{endDate}}
|
||||||
and revenue.currency ilike {{currency}}
|
and revenue.currency = {{currency}}
|
||||||
${filterQuery}
|
${filterQuery}
|
||||||
`,
|
`,
|
||||||
queryParams,
|
queryParams,
|
||||||
).then(result => result?.[0]);
|
).then(result => result?.[0]);
|
||||||
|
|
||||||
total.average = total.count > 0 ? Number(total.sum) / Number(total.count) : 0;
|
total.average = total.count > 0 ? total.sum / total.count : 0;
|
||||||
|
|
||||||
return { chart, country, total };
|
return { chart, country, total };
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,10 +29,10 @@ async function relationalQuery(websiteId: string, sessionId: string, filters: Qu
|
||||||
event_type as "eventType",
|
event_type as "eventType",
|
||||||
event_name as "eventName",
|
event_name as "eventName",
|
||||||
visit_id as "visitId",
|
visit_id as "visitId",
|
||||||
event_id IN (select website_event_id
|
event_id IN (select event_id
|
||||||
from event_data
|
from event_data
|
||||||
where website_id = {{websiteId::uuid}}
|
where website_id = {{websiteId::uuid}}
|
||||||
and created_at between {{startDate}} and {{endDate}}) AS "hasData"
|
and session_id = {{sessionId::uuid}}) AS "hasData"
|
||||||
from website_event
|
from website_event
|
||||||
where website_id = {{websiteId::uuid}}
|
where website_id = {{websiteId::uuid}}
|
||||||
and session_id = {{sessionId::uuid}}
|
and session_id = {{sessionId::uuid}}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue