mirror of
https://github.com/umami-software/umami.git
synced 2026-02-10 07:37:11 +01:00
Fixed chart rendering when using date nav buttons.
This commit is contained in:
parent
1649992654
commit
7b5591a3ce
18 changed files with 177 additions and 320 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import { useMemo } from 'react';
|
||||
import { LoadingPanel } from '@/components/common/LoadingPanel';
|
||||
import { PageviewsChart } from '@/components/metrics/PageviewsChart';
|
||||
import { useWebsitePageviewsQuery } from '@/components/hooks/queries/useWebsitePageviewsQuery';
|
||||
import { useDateRange } from '@/components/hooks';
|
||||
|
|
@ -12,7 +13,7 @@ export function WebsiteChart({
|
|||
}) {
|
||||
const { dateRange, dateCompare } = useDateRange(websiteId);
|
||||
const { startDate, endDate, unit, value } = dateRange;
|
||||
const { data, isLoading } = useWebsitePageviewsQuery(
|
||||
const { data, isLoading, error } = useWebsitePageviewsQuery(
|
||||
websiteId,
|
||||
compareMode ? dateCompare : undefined,
|
||||
);
|
||||
|
|
@ -46,13 +47,14 @@ export function WebsiteChart({
|
|||
}, [data, startDate, endDate, unit]);
|
||||
|
||||
return (
|
||||
<PageviewsChart
|
||||
data={chartData}
|
||||
minDate={startDate.toISOString()}
|
||||
maxDate={endDate.toISOString()}
|
||||
unit={unit}
|
||||
isLoading={isLoading}
|
||||
isAllTime={value === 'all'}
|
||||
/>
|
||||
<LoadingPanel isLoading={isLoading} error={error}>
|
||||
<PageviewsChart
|
||||
key={value}
|
||||
data={chartData}
|
||||
minDate={value === 'all' ? undefined : startDate}
|
||||
maxDate={endDate}
|
||||
unit={unit}
|
||||
/>
|
||||
</LoadingPanel>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ export function SessionProperties({ websiteId }: { websiteId: string }) {
|
|||
: null;
|
||||
|
||||
return (
|
||||
<LoadingPanel isLoading={isLoading} isFetched={isFetched} data={data} error={error}>
|
||||
<LoadingPanel isLoading={isLoading} isFetched={isFetched} error={error}>
|
||||
<div className={styles.container}>
|
||||
<DataTable data={data} className={styles.table}>
|
||||
<DataColumn id="propertyName" label={formatMessage(labels.property)}>
|
||||
|
|
@ -45,7 +45,7 @@ export function SessionProperties({ websiteId }: { websiteId: string }) {
|
|||
{propertyName && (
|
||||
<div className={styles.chart}>
|
||||
<div className={styles.title}>{propertyName}</div>
|
||||
<PieChart key={propertyName} type="doughnut" data={chartData} />
|
||||
<PieChart key={propertyName} type="doughnut" chartData={chartData} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import { getDayOfWeekAsDate } from '@/lib/date';
|
|||
import { Focusable, Tooltip, TooltipTrigger } from '@umami/react-zen';
|
||||
|
||||
export function SessionsWeekly({ websiteId }: { websiteId: string }) {
|
||||
const { data, ...props } = useWebsiteSessionsWeeklyQuery(websiteId);
|
||||
const { data, isLoading, error } = useWebsiteSessionsWeeklyQuery(websiteId);
|
||||
const { dateLocale } = useLocale();
|
||||
const { labels, formatMessage } = useMessages();
|
||||
const { weekStartsOn } = dateLocale.options;
|
||||
|
|
@ -36,7 +36,7 @@ export function SessionsWeekly({ websiteId }: { websiteId: string }) {
|
|||
: [];
|
||||
|
||||
return (
|
||||
<LoadingPanel {...(props as any)} data={data}>
|
||||
<LoadingPanel isEmpty={!data?.length} isLoading={isLoading} error={error}>
|
||||
<Grid columns="repeat(8, 1fr)" gap>
|
||||
<Grid rows="repeat(25, 20px)" gap="1">
|
||||
<Row> </Row>
|
||||
|
|
|
|||
|
|
@ -1,21 +0,0 @@
|
|||
.timeline {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.row {
|
||||
display: grid;
|
||||
grid-template-columns: max-content max-content 1fr;
|
||||
align-items: center;
|
||||
gap: 20px;
|
||||
}
|
||||
|
||||
.time {
|
||||
color: var(--font-color200);
|
||||
width: 150px;
|
||||
}
|
||||
|
||||
.header {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
|
@ -1,9 +1,8 @@
|
|||
import { isSameDay } from 'date-fns';
|
||||
import { Loading, Icon, StatusLight } from '@umami/react-zen';
|
||||
import { Bolt, Eye } from '@/components/icons';
|
||||
import { Icon, StatusLight, Column, Row, Heading, Text, Button } from '@umami/react-zen';
|
||||
import { LoadingPanel } from '@/components/common/LoadingPanel';
|
||||
import { Bolt, Eye, FileText } from '@/components/icons';
|
||||
import { useSessionActivityQuery, useTimezone } from '@/components/hooks';
|
||||
import styles from './SessionActivity.module.css';
|
||||
import { Fragment } from 'react';
|
||||
|
||||
export function SessionActivity({
|
||||
websiteId,
|
||||
|
|
@ -17,37 +16,46 @@ export function SessionActivity({
|
|||
endDate: Date;
|
||||
}) {
|
||||
const { formatTimezoneDate } = useTimezone();
|
||||
const { data, isLoading } = useSessionActivityQuery(websiteId, sessionId, startDate, endDate);
|
||||
|
||||
if (isLoading) {
|
||||
return <Loading position="page" />;
|
||||
}
|
||||
|
||||
const { data, isLoading, error } = useSessionActivityQuery(
|
||||
websiteId,
|
||||
sessionId,
|
||||
startDate,
|
||||
endDate,
|
||||
);
|
||||
let lastDay = null;
|
||||
|
||||
return (
|
||||
<div className={styles.timeline}>
|
||||
{data.map(({ id, createdAt, urlPath, eventName, visitId }) => {
|
||||
const showHeader = !lastDay || !isSameDay(new Date(lastDay), new Date(createdAt));
|
||||
lastDay = createdAt;
|
||||
<LoadingPanel isEmpty={!data?.length} isLoading={isLoading} error={error}>
|
||||
<Column gap>
|
||||
{data?.map(({ eventId, createdAt, urlPath, eventName, visitId, hasData }) => {
|
||||
const showHeader = !lastDay || !isSameDay(new Date(lastDay), new Date(createdAt));
|
||||
lastDay = createdAt;
|
||||
|
||||
return (
|
||||
<Fragment key={id}>
|
||||
{showHeader && (
|
||||
<div className={styles.header}>{formatTimezoneDate(createdAt, 'PPPP')}</div>
|
||||
)}
|
||||
<div className={styles.row}>
|
||||
<div className={styles.time}>
|
||||
return (
|
||||
<Column key={eventId} gap>
|
||||
{showHeader && <Heading size="2">{formatTimezoneDate(createdAt, 'PPPP')}</Heading>}
|
||||
<Row alignItems="center" gap="6" height="40px">
|
||||
<StatusLight color={`#${visitId?.substring(0, 6)}`}>
|
||||
{formatTimezoneDate(createdAt, 'pp')}
|
||||
</StatusLight>
|
||||
</div>
|
||||
<Icon>{eventName ? <Bolt /> : <Eye />}</Icon>
|
||||
<div>{eventName || urlPath}</div>
|
||||
</div>
|
||||
</Fragment>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
<Row alignItems="center" gap>
|
||||
<Icon>{eventName ? <Bolt /> : <Eye />}</Icon>
|
||||
<Text>{eventName || urlPath}</Text>
|
||||
{hasData > 0 && (
|
||||
<Button variant="quiet">
|
||||
<Row alignItems="center" gap>
|
||||
<Icon>
|
||||
<FileText />
|
||||
</Icon>
|
||||
</Row>
|
||||
</Button>
|
||||
)}
|
||||
</Row>
|
||||
</Row>
|
||||
</Column>
|
||||
);
|
||||
})}
|
||||
</Column>
|
||||
</LoadingPanel>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,10 +30,10 @@ export interface BarChartProps extends ChartProps {
|
|||
YAxisType?: string;
|
||||
minDate?: Date;
|
||||
maxDate?: Date;
|
||||
isAllTime?: boolean;
|
||||
}
|
||||
|
||||
export function BarChart({
|
||||
chartData,
|
||||
renderXLabel,
|
||||
renderYLabel,
|
||||
unit,
|
||||
|
|
@ -43,7 +43,6 @@ export function BarChart({
|
|||
minDate,
|
||||
maxDate,
|
||||
currency,
|
||||
isAllTime,
|
||||
...props
|
||||
}: BarChartProps) {
|
||||
const [tooltip, setTooltip] = useState(null);
|
||||
|
|
@ -51,14 +50,14 @@ export function BarChart({
|
|||
const { locale } = useLocale();
|
||||
const { colors } = useMemo(() => getThemeColors(theme), [theme]);
|
||||
|
||||
const options: any = useMemo(() => {
|
||||
const chartOptions: any = useMemo(() => {
|
||||
return {
|
||||
__id: new Date().getTime(),
|
||||
scales: {
|
||||
x: {
|
||||
type: XAxisType,
|
||||
stacked: true,
|
||||
min: isAllTime ? '' : minDate,
|
||||
min: minDate,
|
||||
max: maxDate,
|
||||
time: {
|
||||
unit,
|
||||
|
|
@ -94,7 +93,7 @@ export function BarChart({
|
|||
},
|
||||
},
|
||||
};
|
||||
}, [colors, unit, stacked, renderXLabel, renderYLabel]);
|
||||
}, [chartData, colors, unit, stacked, renderXLabel, renderYLabel]);
|
||||
|
||||
const handleTooltip = ({ tooltip }: { tooltip: any }) => {
|
||||
const { opacity, labelColors, dataPoints } = tooltip;
|
||||
|
|
@ -121,9 +120,9 @@ export function BarChart({
|
|||
<Chart
|
||||
{...props}
|
||||
type="bar"
|
||||
chartOptions={options}
|
||||
chartData={chartData}
|
||||
chartOptions={chartOptions}
|
||||
onTooltip={handleTooltip}
|
||||
height="400px"
|
||||
/>
|
||||
{tooltip && <ChartTooltip {...tooltip} />}
|
||||
</>
|
||||
|
|
|
|||
|
|
@ -1,29 +1,25 @@
|
|||
import { useState, useRef, useEffect, useMemo } from 'react';
|
||||
import { Loading, Box, Column, BoxProps } from '@umami/react-zen';
|
||||
import ChartJS, { LegendItem, ChartOptions } from 'chart.js/auto';
|
||||
import { Box, Column, BoxProps } from '@umami/react-zen';
|
||||
import ChartJS, { LegendItem, ChartOptions, ChartData, UpdateMode } from 'chart.js/auto';
|
||||
import { Legend } from '@/components/metrics/Legend';
|
||||
import { DEFAULT_ANIMATION_DURATION } from '@/lib/constants';
|
||||
|
||||
ChartJS.defaults.font.family = 'Inter';
|
||||
|
||||
export interface ChartProps extends BoxProps {
|
||||
type?: 'bar' | 'bubble' | 'doughnut' | 'pie' | 'line' | 'polarArea' | 'radar' | 'scatter';
|
||||
data?: object;
|
||||
isLoading?: boolean;
|
||||
animationDuration?: number;
|
||||
updateMode?: string;
|
||||
onCreate?: (chart: any) => void;
|
||||
onUpdate?: (chart: any) => void;
|
||||
onTooltip?: (model: any) => void;
|
||||
chartData?: ChartData & { focusLabel?: string };
|
||||
chartOptions?: ChartOptions;
|
||||
updateMode?: UpdateMode;
|
||||
animationDuration?: number;
|
||||
onTooltip?: (model: any) => void;
|
||||
}
|
||||
|
||||
export function Chart({
|
||||
type,
|
||||
data,
|
||||
isLoading = false,
|
||||
chartData,
|
||||
animationDuration = DEFAULT_ANIMATION_DURATION,
|
||||
updateMode,
|
||||
onCreate,
|
||||
onUpdate,
|
||||
onTooltip,
|
||||
chartOptions,
|
||||
...props
|
||||
|
|
@ -59,53 +55,6 @@ export function Chart({
|
|||
};
|
||||
}, [chartOptions]);
|
||||
|
||||
const createChart = (data: any) => {
|
||||
ChartJS.defaults.font.family = 'Inter';
|
||||
|
||||
chart.current = new ChartJS(canvas.current, {
|
||||
type,
|
||||
data,
|
||||
options,
|
||||
});
|
||||
|
||||
onCreate?.(chart.current);
|
||||
|
||||
setLegendItems(chart.current.legend.legendItems);
|
||||
};
|
||||
|
||||
const updateChart = (data: any) => {
|
||||
if (data.datasets) {
|
||||
if (data.datasets.length === chart.current.data.datasets.length) {
|
||||
chart.current.data.datasets.forEach((dataset: { data: any }, index: string | number) => {
|
||||
if (data?.datasets[index]) {
|
||||
dataset.data = data?.datasets[index]?.data;
|
||||
|
||||
if (chart.current.legend.legendItems[index]) {
|
||||
chart.current.legend.legendItems[index].text = data.datasets[index]?.label;
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
chart.current.data.datasets = data.datasets;
|
||||
}
|
||||
}
|
||||
|
||||
if (data.focusLabel !== null) {
|
||||
chart.current.data.datasets.forEach(ds => {
|
||||
ds.hidden = data.focusLabel ? ds.label !== data.focusLabel : false;
|
||||
});
|
||||
}
|
||||
|
||||
chart.current.options = options;
|
||||
|
||||
// Allow config changes before update
|
||||
onUpdate?.(chart.current);
|
||||
|
||||
chart.current.update(updateMode);
|
||||
|
||||
setLegendItems(chart.current.legend.legendItems);
|
||||
};
|
||||
|
||||
const handleLegendClick = (item: LegendItem) => {
|
||||
if (type === 'bar') {
|
||||
const { datasetIndex } = item;
|
||||
|
|
@ -127,20 +76,47 @@ export function Chart({
|
|||
setLegendItems(chart.current.legend.legendItems);
|
||||
};
|
||||
|
||||
// Create chart
|
||||
useEffect(() => {
|
||||
if (data) {
|
||||
if (!chart.current) {
|
||||
createChart(data);
|
||||
} else {
|
||||
updateChart(data);
|
||||
}
|
||||
if (canvas.current) {
|
||||
chart.current = new ChartJS(canvas.current, {
|
||||
type,
|
||||
data: chartData,
|
||||
options,
|
||||
});
|
||||
|
||||
setLegendItems(chart.current.legend.legendItems);
|
||||
}
|
||||
}, [data, options]);
|
||||
|
||||
return () => {
|
||||
chart.current?.destroy();
|
||||
};
|
||||
}, []);
|
||||
|
||||
// Update chart
|
||||
useEffect(() => {
|
||||
if (chart.current && chartData) {
|
||||
// Replace labels and datasets *in-place*
|
||||
chart.current.data.labels = chartData.labels;
|
||||
chart.current.data.datasets = chartData.datasets;
|
||||
|
||||
if (chartData.focusLabel !== null) {
|
||||
chart.current.data.datasets.forEach((ds: { hidden: boolean; label: any }) => {
|
||||
ds.hidden = chartData.focusLabel ? ds.label !== chartData.focusLabel : false;
|
||||
});
|
||||
}
|
||||
|
||||
chart.current.options = options;
|
||||
|
||||
chart.current.update(updateMode);
|
||||
|
||||
setLegendItems(chart.current.legend.legendItems);
|
||||
}
|
||||
}, [chartData, options, updateMode]);
|
||||
|
||||
return (
|
||||
<Column gap="6">
|
||||
<Box {...props}>
|
||||
{isLoading && <Loading position="page" icon="dots" />}
|
||||
<canvas ref={canvas} />
|
||||
</Box>
|
||||
<Legend items={legendItems} onClick={handleLegendClick} />
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
import { ReactNode } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { Button } from '@umami/react-zen';
|
||||
import { Button, ButtonProps } from '@umami/react-zen';
|
||||
import { useLocale } from '@/components/hooks';
|
||||
|
||||
export interface LinkButtonProps {
|
||||
export interface LinkButtonProps extends ButtonProps {
|
||||
href: string;
|
||||
target?: string;
|
||||
scroll?: boolean;
|
||||
|
|
|
|||
|
|
@ -6,12 +6,15 @@ export {
|
|||
ChevronRight as Chevron,
|
||||
Clock,
|
||||
Copy,
|
||||
Database,
|
||||
Download,
|
||||
Edit,
|
||||
Ellipsis,
|
||||
Eye,
|
||||
ExternalLink,
|
||||
File,
|
||||
FileJson,
|
||||
FileText,
|
||||
Globe,
|
||||
Grid2X2,
|
||||
KeyRound,
|
||||
|
|
@ -25,6 +28,7 @@ export {
|
|||
Minimize,
|
||||
Moon,
|
||||
MoreHorizontal as More,
|
||||
Paperclip,
|
||||
PanelLeft,
|
||||
Plus,
|
||||
RefreshCw as Refresh,
|
||||
|
|
|
|||
|
|
@ -88,6 +88,7 @@ export function ReportEditButton({
|
|||
title={formatMessage(labels.delete)}
|
||||
onConfirm={handleDelete}
|
||||
onCancel={handleClose}
|
||||
isDanger
|
||||
>
|
||||
<Row gap="1">
|
||||
{formatMessage(messages.confirmDelete, { target: <b key={name}>{name}</b> })}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ export function WebsiteDateFilter({
|
|||
};
|
||||
|
||||
const handleIncrement = (increment: number) => {
|
||||
router.push(renderUrl({ increment }));
|
||||
router.push(renderUrl({ offset: offset + increment }));
|
||||
saveDateRange(getOffsetDateRange(dateRange, increment));
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,26 +1,26 @@
|
|||
import { useMemo, useState, useEffect } from 'react';
|
||||
import { colord } from 'colord';
|
||||
import { BarChart } from '@/components/charts/BarChart';
|
||||
import { BarChart, BarChartProps } from '@/components/charts/BarChart';
|
||||
import { useDateRange, useLocale, useWebsiteEventsSeriesQuery } from '@/components/hooks';
|
||||
import { renderDateLabels } from '@/lib/charts';
|
||||
import { CHART_COLORS } from '@/lib/constants';
|
||||
import { LoadingPanel } from '@/components/common/LoadingPanel';
|
||||
|
||||
export interface EventsChartProps {
|
||||
export interface EventsChartProps extends BarChartProps {
|
||||
websiteId: string;
|
||||
className?: string;
|
||||
focusLabel?: string;
|
||||
}
|
||||
|
||||
export function EventsChart({ websiteId, className, focusLabel }: EventsChartProps) {
|
||||
export function EventsChart({ websiteId, focusLabel }: EventsChartProps) {
|
||||
const {
|
||||
dateRange: { startDate, endDate, unit, value },
|
||||
} = useDateRange(websiteId);
|
||||
const { locale } = useLocale();
|
||||
const { data, isLoading } = useWebsiteEventsSeriesQuery(websiteId);
|
||||
const { data, isLoading, error } = useWebsiteEventsSeriesQuery(websiteId);
|
||||
const [label, setLabel] = useState<string>(focusLabel);
|
||||
|
||||
const chartData = useMemo(() => {
|
||||
if (!data) return [];
|
||||
const chartData: any = useMemo(() => {
|
||||
if (!data) return;
|
||||
|
||||
const map = (data as any[]).reduce((obj, { x, t, y }) => {
|
||||
if (!obj[x]) {
|
||||
|
|
@ -55,16 +55,18 @@ export function EventsChart({ websiteId, className, focusLabel }: EventsChartPro
|
|||
}, [focusLabel]);
|
||||
|
||||
return (
|
||||
<BarChart
|
||||
minDate={startDate}
|
||||
maxDate={endDate}
|
||||
className={className}
|
||||
data={chartData}
|
||||
unit={unit}
|
||||
stacked={true}
|
||||
renderXLabel={renderDateLabels(unit, locale)}
|
||||
isLoading={isLoading}
|
||||
isAllTime={value === 'all'}
|
||||
/>
|
||||
<LoadingPanel isLoading={isLoading} error={error}>
|
||||
{chartData && (
|
||||
<BarChart
|
||||
chartData={chartData}
|
||||
minDate={value === 'all' ? undefined : startDate}
|
||||
maxDate={endDate}
|
||||
unit={unit}
|
||||
stacked={true}
|
||||
renderXLabel={renderDateLabels(unit, locale)}
|
||||
height="400px"
|
||||
/>
|
||||
)}
|
||||
</LoadingPanel>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -96,13 +96,20 @@ const AnimatedRow = ({
|
|||
}) => {
|
||||
const props = useSpring({
|
||||
width: percent,
|
||||
y: value,
|
||||
y: !isNaN(value) ? value : 0,
|
||||
from: { width: 0, y: 0 },
|
||||
config: animate ? config.default : { duration: 0 },
|
||||
});
|
||||
|
||||
return (
|
||||
<Grid columns="1fr 50px 50px" paddingLeft="2" alignItems="center" hoverBackgroundColor="2" gap>
|
||||
<Grid
|
||||
columns="1fr 50px 50px"
|
||||
paddingLeft="2"
|
||||
alignItems="center"
|
||||
hoverBackgroundColor="2"
|
||||
borderRadius
|
||||
gap
|
||||
>
|
||||
<Row alignItems="center">
|
||||
<Text>{label}</Text>
|
||||
</Row>
|
||||
|
|
|
|||
|
|
@ -15,26 +15,16 @@ export interface PageviewsChartProps extends BarChartProps {
|
|||
};
|
||||
};
|
||||
unit: string;
|
||||
isLoading?: boolean;
|
||||
isAllTime?: boolean;
|
||||
}
|
||||
|
||||
export function PageviewsChart({
|
||||
data,
|
||||
unit,
|
||||
isLoading,
|
||||
isAllTime,
|
||||
...props
|
||||
}: PageviewsChartProps) {
|
||||
export function PageviewsChart({ data, unit, ...props }: PageviewsChartProps) {
|
||||
const { formatMessage, labels } = useMessages();
|
||||
const { theme } = useTheme();
|
||||
const { locale } = useLocale();
|
||||
const { colors } = useMemo(() => getThemeColors(theme), [theme]);
|
||||
|
||||
const chartData = useMemo(() => {
|
||||
if (!data) {
|
||||
return {};
|
||||
}
|
||||
const chartData: any = useMemo(() => {
|
||||
if (!data) return;
|
||||
|
||||
return {
|
||||
__id: new Date().getTime(),
|
||||
|
|
@ -84,11 +74,10 @@ export function PageviewsChart({
|
|||
return (
|
||||
<BarChart
|
||||
{...props}
|
||||
data={chartData}
|
||||
chartData={chartData}
|
||||
unit={unit}
|
||||
isLoading={isLoading}
|
||||
isAllTime={isAllTime}
|
||||
renderXLabel={renderXLabel}
|
||||
height="400px"
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,8 +38,8 @@ export function RealtimeChart({ data, unit, ...props }: RealtimeChartProps) {
|
|||
return (
|
||||
<PageviewsChart
|
||||
{...props}
|
||||
minDate={startDate.toISOString()}
|
||||
maxDate={endDate.toISOString()}
|
||||
minDate={startDate}
|
||||
maxDate={endDate}
|
||||
unit={unit}
|
||||
data={chartData}
|
||||
animationDuration={animationDuration}
|
||||
|
|
|
|||
|
|
@ -46,12 +46,13 @@ async function clickhouseQuery(
|
|||
event_id as eventId,
|
||||
event_type as eventType,
|
||||
event_name as eventName,
|
||||
visit_id as visitId
|
||||
from website_event
|
||||
where website_id = {websiteId:UUID}
|
||||
and session_id = {sessionId:UUID}
|
||||
and created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
order by created_at desc
|
||||
visit_id as visitId,
|
||||
event_id IN (SELECT event_id FROM event_data) AS hasData
|
||||
from website_event e
|
||||
where e.website_id = {websiteId:UUID}
|
||||
and e.session_id = {sessionId:UUID}
|
||||
and e.created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||
order by e.created_at desc
|
||||
limit 500
|
||||
`,
|
||||
{ websiteId, sessionId, startDate, endDate },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue