Updated realtime data fetch.

This commit is contained in:
Mike Cao 2024-08-20 23:58:20 -07:00
parent 04e0b33622
commit e35c11c3d6
9 changed files with 126 additions and 87 deletions

View file

@ -10,7 +10,6 @@ import { safeDecodeURI } from 'next-basics';
import { useContext, useMemo, useState } from 'react';
import { Icon, SearchField, StatusLight, Text } from 'react-basics';
import { FixedSizeList } from 'react-window';
import thenby from 'thenby';
import { WebsiteContext } from '../WebsiteProvider';
import styles from './RealtimeLog.module.css';
@ -141,15 +140,7 @@ export function RealtimeLog({ data }: { data: RealtimeData }) {
return [];
}
const { events, visitors } = data;
let logs = [
...events.map(e => ({
__type: e.eventName ? TYPE_EVENT : TYPE_PAGEVIEW,
...e,
})),
...visitors.map(v => ({ __type: TYPE_SESSION, ...v })),
].sort(thenby.firstBy('createdAt', -1));
let logs = data.events;
if (search) {
logs = logs.filter(({ eventName, urlPath, browser, os, country, device }) => {