diff --git a/src/app/(main)/websites/[websiteId]/realtime/RealtimePaths.tsx b/src/app/(main)/websites/[websiteId]/realtime/RealtimePaths.tsx
index e69d9e645..2a91e01ee 100644
--- a/src/app/(main)/websites/[websiteId]/realtime/RealtimePaths.tsx
+++ b/src/app/(main)/websites/[websiteId]/realtime/RealtimePaths.tsx
@@ -1,4 +1,4 @@
-import thenby from 'thenby';
+import { firstBy } from 'thenby';
import { useMessages, useWebsite } from '@/components/hooks';
import { ListTable } from '@/components/metrics/ListTable';
import { percentFilter } from '@/lib/filters';
@@ -26,7 +26,7 @@ export function RealtimePaths({ data }: { data: any }) {
y: urls[key],
};
})
- .sort(thenby.firstBy('y', -1))
+ .sort(firstBy('y', -1))
.slice(0, limit),
);
diff --git a/src/app/(main)/websites/[websiteId]/realtime/RealtimeReferrers.tsx b/src/app/(main)/websites/[websiteId]/realtime/RealtimeReferrers.tsx
index fa2a56b9f..e2d2305b0 100644
--- a/src/app/(main)/websites/[websiteId]/realtime/RealtimeReferrers.tsx
+++ b/src/app/(main)/websites/[websiteId]/realtime/RealtimeReferrers.tsx
@@ -1,7 +1,7 @@
-import thenby from 'thenby';
import { useMessages, useWebsite } from '@/components/hooks';
import { ListTable } from '@/components/metrics/ListTable';
import { percentFilter } from '@/lib/filters';
+import { firstBy } from 'thenby';
export function RealtimeReferrers({ data }: { data: any }) {
const website = useWebsite();
@@ -26,7 +26,7 @@ export function RealtimeReferrers({ data }: { data: any }) {
y: referrers[key],
};
})
- .sort(thenby.firstBy('y', -1))
+ .sort(firstBy('y', -1))
.slice(0, limit),
);
diff --git a/src/app/(main)/websites/[websiteId]/replays/ReplayFilterButton.tsx b/src/app/(main)/websites/[websiteId]/replays/ReplayFilterButton.tsx
new file mode 100644
index 000000000..da9b1d8b0
--- /dev/null
+++ b/src/app/(main)/websites/[websiteId]/replays/ReplayFilterButton.tsx
@@ -0,0 +1,96 @@
+'use client';
+
+import { Button, Column, Label, Row, Text, TextField } from '@umami/react-zen';
+import { useState } from 'react';
+import { useMessages, useNavigation } from '@/components/hooks';
+import { ListFilter } from '@/components/icons';
+import { DialogButton } from '@/components/input/DialogButton';
+
+const DEFAULT_MIN_DURATION = '5';
+
+function getMinDurationValue(value: unknown) {
+ if (value === '0') {
+ return '';
+ }
+
+ if (typeof value !== 'string' || !/^\d+$/.test(value)) {
+ return DEFAULT_MIN_DURATION;
+ }
+
+ return Number(value) > 0 ? value : DEFAULT_MIN_DURATION;
+}
+
+function ReplayFilterForm({
+ minDuration,
+ onClose,
+}: {
+ minDuration: string;
+ onClose?: () => void;
+}) {
+ const { t, labels, messages } = useMessages();
+ const { router, updateParams } = useNavigation();
+ const [value, setValue] = useState(minDuration);
+
+ const handleChange = (nextValue: string) => {
+ if (/^\d*$/.test(nextValue)) {
+ setValue(nextValue);
+ }
+ };
+
+ const handleReset = () => {
+ setValue(DEFAULT_MIN_DURATION);
+ };
+
+ const handleApply = () => {
+ const nextValue = value ? Number(value) : 0;
+
+ router.push(
+ updateParams({
+ minDuration: nextValue > 0 ? nextValue : 0,
+ page: 1,
+ }),
+ );
+
+ onClose?.();
+ };
+
+ return (
+
+
+
+ {t(messages.replayMinDurationDescription)}
+
+
+
+
+
+
+
+
+
+
+ );
+}
+
+export function ReplayFilterButton() {
+ const { t, labels } = useMessages();
+ const { query } = useNavigation();
+ const minDuration = getMinDurationValue(query.minDuration);
+ const title = `${t(labels.replay)} ${t(labels.filter)}`;
+ const label = minDuration ? `${title} (${minDuration}s+)` : title;
+
+ return (
+
} label={label} title={title} variant="outline">
+ {({ close }) =>
}
+
+ );
+}
diff --git a/src/app/(main)/websites/[websiteId]/replays/ReplaysDataTable.tsx b/src/app/(main)/websites/[websiteId]/replays/ReplaysDataTable.tsx
index 6d047081d..3047b0b73 100644
--- a/src/app/(main)/websites/[websiteId]/replays/ReplaysDataTable.tsx
+++ b/src/app/(main)/websites/[websiteId]/replays/ReplaysDataTable.tsx
@@ -1,12 +1,25 @@
import { DataGrid } from '@/components/common/DataGrid';
-import { useReplaysQuery } from '@/components/hooks';
+import { useNavigation, useReplaysQuery } from '@/components/hooks';
+import { ReplayFilterButton } from './ReplayFilterButton';
import { ReplaysTable } from './ReplaysTable';
+const DEFAULT_MIN_DURATION = 5;
+
export function ReplaysDataTable({ websiteId }: { websiteId: string }) {
- const queryResult = useReplaysQuery(websiteId);
+ const { query } = useNavigation();
+ const minDuration =
+ typeof query.minDuration === 'string' && /^\d+$/.test(query.minDuration)
+ ? query.minDuration
+ : String(DEFAULT_MIN_DURATION);
+ const queryResult = useReplaysQuery(websiteId, { minDuration });
return (
-
+ }
+ >
{({ data }) => {
return ;
}}
diff --git a/src/app/(main)/websites/[websiteId]/replays/[replayId]/ReplayPlayer.tsx b/src/app/(main)/websites/[websiteId]/replays/[replayId]/ReplayPlayer.tsx
index 960f8e4a0..b413b9c06 100644
--- a/src/app/(main)/websites/[websiteId]/replays/[replayId]/ReplayPlayer.tsx
+++ b/src/app/(main)/websites/[websiteId]/replays/[replayId]/ReplayPlayer.tsx
@@ -8,6 +8,21 @@ import 'rrweb-player/dist/style.css';
const DEFAULT_REPLAY_ASPECT_RATIO = 9 / 16;
+function destroyReplayPlayer(player: { $destroy?: () => void } | null) {
+ if (!player) {
+ return;
+ }
+
+ try {
+ player.$destroy?.();
+ } catch (error) {
+ // rrweb-player alpha teardown can throw after it loses its inner replayer instance.
+ if (!(error instanceof TypeError) || !error.message.includes('pause is not a function')) {
+ throw error;
+ }
+ }
+}
+
export function ReplayPlayer({ events }: { events: any[] }) {
const playerRootRef = useRef(null);
const playerRef = useRef(null);
@@ -34,7 +49,7 @@ export function ReplayPlayer({ events }: { events: any[] }) {
setPlayerError(false);
if (playerRef.current) {
- playerRef.current.$destroy?.();
+ destroyReplayPlayer(playerRef.current);
playerRef.current = null;
}
@@ -89,7 +104,7 @@ export function ReplayPlayer({ events }: { events: any[] }) {
cancelled = true;
if (playerRef.current) {
- playerRef.current.$destroy?.();
+ destroyReplayPlayer(playerRef.current);
playerRef.current = null;
}
diff --git a/src/app/api/auth/logout/route.test.ts b/src/app/api/auth/logout/route.test.ts
index c9bcfd8b4..d90df11da 100644
--- a/src/app/api/auth/logout/route.test.ts
+++ b/src/app/api/auth/logout/route.test.ts
@@ -20,7 +20,7 @@ vi.mock('@/lib/response', () => ({
ok: () => new Response(null, { status: 200 }),
}));
-const redisMock = redis as {
+const redisMock = redis as unknown as {
enabled: boolean;
client: {
del: ReturnType;
diff --git a/src/app/api/websites/[websiteId]/replays/route.ts b/src/app/api/websites/[websiteId]/replays/route.ts
index d464fc42b..324aa9920 100644
--- a/src/app/api/websites/[websiteId]/replays/route.ts
+++ b/src/app/api/websites/[websiteId]/replays/route.ts
@@ -1,6 +1,6 @@
import { getQueryFilters, parseRequest } from '@/lib/request';
import { json, unauthorized } from '@/lib/response';
-import { filterParams, pagingParams, searchParams, withDateRange } from '@/lib/schema';
+import { filterParams, pagingParams, replayParams, searchParams, withDateRange } from '@/lib/schema';
import { canViewAuthenticatedWebsite } from '@/permissions';
import { getSessionReplays } from '@/queries/sql';
@@ -10,6 +10,7 @@ export async function GET(
) {
const schema = withDateRange({
...filterParams,
+ ...replayParams,
...pagingParams,
...searchParams,
});
diff --git a/src/components/common/CopyButton.tsx b/src/components/common/CopyButton.tsx
index f719c229c..e00cc3e2e 100644
--- a/src/components/common/CopyButton.tsx
+++ b/src/components/common/CopyButton.tsx
@@ -32,7 +32,7 @@ export function CopyButton({ value, label = 'Copy' }: { value: string; label?: s
};
return (
-