session replay updates. add clickhouse implementation, filters, tables

This commit is contained in:
Francis Cao committed 2026-03-03 12:47:27 -08:00
1 parent e9ac09ec5d
commit 5e68661c5d
23 files changed
+359 -150

No files matched your search

@@ -86,14 +86,14 @@ export function EventsTable(props: DataTableProps) {
</TypeIcon>
)}
</DataColumn>
<DataColumn id="device" label={t(labels.device)} width="120px">
<DataColumn id="device" label={t(labels.device)} width="140px">
{(row: any) => (
<TypeIcon type="device" value={row.device}>
{formatValue(row.device, 'device')}
</TypeIcon>
)}
</DataColumn>
<DataColumn id="created" width="160px" align="end">
<DataColumn id="created" width="140px" label={t(labels.created)}>
{(row: any) => <DateDistance date={new Date(row.createdAt)} />}
</DataColumn>
</DataTable>
@@ -1,5 +1,6 @@
'use client';
import { Column } from '@umami/react-zen';
import { SessionModal } from '@/app/(main)/websites/[websiteId]/sessions/SessionModal';
import { WebsiteControls } from '@/app/(main)/websites/[websiteId]/WebsiteControls';
import { Panel } from '@/components/common/Panel';
import { ReplaysDataTable } from './ReplaysDataTable';
@@ -11,6 +12,7 @@ export function ReplaysPage({ websiteId }: { websiteId: string }) {
<Panel>
<ReplaysDataTable websiteId={websiteId} />
</Panel>
<SessionModal websiteId={websiteId} />
</Column>
);
}
@@ -4,7 +4,7 @@ import Link from 'next/link';
import { Avatar } from '@/components/common/Avatar';
import { DateDistance } from '@/components/common/DateDistance';
import { TypeIcon } from '@/components/common/TypeIcon';
import { useFormat, useMessages } from '@/components/hooks';
import { useFormat, useMessages, useNavigation } from '@/components/hooks';
function formatDuration(ms: number) {
const seconds = Math.floor(ms / 1000);
@@ -16,38 +16,51 @@ function formatDuration(ms: number) {
export function ReplaysTable({ websiteId, ...props }: DataTableProps & { websiteId: string }) {
const { t, labels } = useMessages();
const { formatValue } = useFormat();
const { updateParams } = useNavigation();
return (
<DataTable {...props}>
<DataColumn id="id" label={t(labels.session)} width="100px">
{(row: any) => <Avatar seed={row.id} size={32} />}
{(row: any) => (
<Link href={updateParams({ session: row.id })}>
<Avatar seed={row.id} size={32} />
</Link>
)}
</DataColumn>
<DataColumn id="duration" label={t(labels.duration)} width="100px">
{(row: any) => formatDuration(row.duration || 0)}
</DataColumn>
<DataColumn id="eventCount" label={t(labels.events)} width="80px" />
<DataColumn id="country" label={t(labels.country)}>
<DataColumn id="eventCount" label={t(labels.actions)} width="80px" />
<DataColumn id="location" label={t(labels.location)}>
{(row: any) => (
<TypeIcon type="country" value={row.country}>
{row.city ? `${row.city}, ` : ''}
{formatValue(row.country, 'country')}
</TypeIcon>
)}
</DataColumn>
<DataColumn id="browser" label={t(labels.browser)}>
<DataColumn id="browser" label={t(labels.browser)} width="140px">
{(row: any) => (
<TypeIcon type="browser" value={row.browser}>
{formatValue(row.browser, 'browser')}
</TypeIcon>
)}
</DataColumn>
<DataColumn id="os" label={t(labels.os)}>
<DataColumn id="os" label={t(labels.os)} width="140px">
{(row: any) => (
<TypeIcon type="os" value={row.os}>
{formatValue(row.os, 'os')}
</TypeIcon>
)}
</DataColumn>
<DataColumn id="createdAt" label={t(labels.recordedAt)}>
<DataColumn id="device" label={t(labels.device)} width="140px">
{(row: any) => (
<TypeIcon type="device" value={row.device}>
{formatValue(row.device, 'device')}
</TypeIcon>
)}
</DataColumn>
<DataColumn id="createdAt" label={t(labels.recordedAt)} width="140px">
{(row: any) => <DateDistance date={new Date(row.createdAt)} />}
</DataColumn>
<DataColumn id="play" label="" width="80px">
@@ -27,7 +27,7 @@ export function ReplayPlayback({ websiteId, sessionId }: { websiteId: string; se
<Column>
<Text weight="bold">{t(labels.replay)}</Text>
<Text color="muted">
{replay.eventCount} {t(labels.events).toLowerCase()}
{replay.eventCount} {t(labels.actions).toLowerCase()}
</Text>
</Column>
</Row>
@@ -11,21 +11,6 @@ export function ReplayPlayer({ events }: { events: any[] }) {
useEffect(() => {
if (!containerRef.current || !events?.length) return;
// Debug: log event info
const typeCounts: Record<number, number> = {};
events.forEach((e: any) => {
typeCounts[e.type] = (typeCounts[e.type] || 0) + 1;
});
const timestamps = events.map((e: any) => e.timestamp).filter(Boolean);
console.log('[ReplayPlayer] Events:', events.length, 'Types:', typeCounts);
console.log(
'[ReplayPlayer] Time range:',
timestamps.length
? `${Math.min(...timestamps)} - ${Math.max(...timestamps)} (${Math.max(...timestamps) - Math.min(...timestamps)}ms)`
: 'no timestamps',
);
console.log('[ReplayPlayer] First 3 events:', events.slice(0, 3));
// Dynamically import rrweb-player to avoid SSR issues
import('rrweb-player').then(mod => {
const RRWebPlayer = mod.default;
@@ -36,7 +21,7 @@ export function ReplayPlayer({ events }: { events: any[] }) {
}
playerRef.current = new RRWebPlayer({
target: containerRef.current!,
target: containerRef.current,
props: {
events,
width: 1024,
@@ -21,36 +21,37 @@ export function SessionsTable(props: DataTableProps) {
</DataColumn>
<DataColumn id="visits" label={t(labels.visits)} width="80px" />
<DataColumn id="views" label={t(labels.views)} width="80px" />
<DataColumn id="country" label={t(labels.country)}>
<DataColumn id="events" label={t(labels.events)} width="80px" />
<DataColumn id="location" label={t(labels.location)}>
{(row: any) => (
<TypeIcon type="country" value={row.country}>
{row.city ? `${row.city}, ` : ''}
{formatValue(row.country, 'country')}
</TypeIcon>
)}
</DataColumn>
<DataColumn id="city" label={t(labels.city)} />
<DataColumn id="browser" label={t(labels.browser)}>
<DataColumn id="browser" label={t(labels.browser)} width="140px">
{(row: any) => (
<TypeIcon type="browser" value={row.browser}>
{formatValue(row.browser, 'browser')}
</TypeIcon>
)}
</DataColumn>
<DataColumn id="os" label={t(labels.os)}>
<DataColumn id="os" label={t(labels.os)} width="140px">
{(row: any) => (
<TypeIcon type="os" value={row.os}>
{formatValue(row.os, 'os')}
</TypeIcon>
)}
</DataColumn>
<DataColumn id="device" label={t(labels.device)}>
<DataColumn id="device" label={t(labels.device)} width="140px">
{(row: any) => (
<TypeIcon type="device" value={row.device}>
{formatValue(row.device, 'device')}
</TypeIcon>
)}
</DataColumn>
<DataColumn id="lastAt" label={t(labels.lastSeen)}>
<DataColumn id="lastAt" label={t(labels.lastSeen)} width="140px">
{(row: any) => <DateDistance date={new Date(row.createdAt)} />}
</DataColumn>
</DataTable>