heatmaps UI polish, finish feature gate + messaging, overlay bug fixes
This commit is contained in:
1 parent
cd20b3aafd
commit
aa9b6c0ca3
4 files changed
+134
-42
No files matched your search
@@ -160,10 +160,6 @@
|
|||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.heatOverlay {
|
|
||||||
overflow: visible;
|
|
||||||
}
|
|
||||||
|
|
||||||
.canvasLoading {
|
.canvasLoading {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset: 0;
|
inset: 0;
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
import { Column, Grid, Heading, Loading, Row, Switch, Text } from '@umami/react-zen';
|
import { Column, Grid, Heading, Loading, Row, Switch, Text } from '@umami/react-zen';
|
||||||
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
||||||
import { LoadingPanel } from '@/components/common/LoadingPanel';
|
import { LoadingPanel } from '@/components/common/LoadingPanel';
|
||||||
import { useMessages, useResultQuery } from '@/components/hooks';
|
import { useResultQuery } from '@/components/hooks';
|
||||||
import { useReplayQuery } from '@/components/hooks/queries/useReplayQuery';
|
import { useReplayQuery } from '@/components/hooks/queries/useReplayQuery';
|
||||||
import { formatLongNumber } from '@/lib/format';
|
import { formatLongNumber } from '@/lib/format';
|
||||||
import type { HeatmapMode, HeatmapPoint, HeatmapResult, HeatmapSnapshot } from '@/queries/sql';
|
import type { HeatmapMode, HeatmapPoint, HeatmapResult, HeatmapSnapshot } from '@/queries/sql';
|
||||||
@@ -115,6 +115,14 @@ export function Heatmap({ websiteId, urlPath, onUrlPathChange, mode, search }: H
|
|||||||
onUrlPathChange(filteredPages[0].urlPath);
|
onUrlPathChange(filteredPages[0].urlPath);
|
||||||
}, [filteredPages, isLoading, onUrlPathChange, urlPath]);
|
}, [filteredPages, isLoading, onUrlPathChange, urlPath]);
|
||||||
|
|
||||||
|
if (!isLoading && pages.length === 0) {
|
||||||
|
return (
|
||||||
|
<LoadingPanel data={pagesData} isLoading={isLoading} error={error} minHeight="900px">
|
||||||
|
<EmptyState message="No data available." />
|
||||||
|
</LoadingPanel>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LoadingPanel data={pagesData} isLoading={isLoading} error={error} minHeight="900px">
|
<LoadingPanel data={pagesData} isLoading={isLoading} error={error} minHeight="900px">
|
||||||
<Grid columns="320px 12px 1fr" minHeight="900px" className={styles.layoutGrid}>
|
<Grid columns="320px 12px 1fr" minHeight="900px" className={styles.layoutGrid}>
|
||||||
@@ -167,15 +175,11 @@ function PageList({
|
|||||||
mode: HeatmapMode;
|
mode: HeatmapMode;
|
||||||
hasSearch: boolean;
|
hasSearch: boolean;
|
||||||
}) {
|
}) {
|
||||||
const { t, messages } = useMessages();
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column className={styles.pageList} gap="1">
|
<Column className={styles.pageList} gap="1">
|
||||||
<Heading size="lg">Pages</Heading>
|
<Heading size="lg">Pages</Heading>
|
||||||
<Column className={styles.pageListItems} gap="2">
|
<Column className={styles.pageListItems} gap="2">
|
||||||
{pages.length === 0 && (
|
{pages.length === 0 && hasSearch && <Text color="muted">No matching pages</Text>}
|
||||||
<Text color="muted">{hasSearch ? 'No matching pages' : t(messages.noDataAvailable)}</Text>
|
|
||||||
)}
|
|
||||||
{pages.map(p => (
|
{pages.map(p => (
|
||||||
<button
|
<button
|
||||||
key={p.urlPath}
|
key={p.urlPath}
|
||||||
@@ -295,29 +299,29 @@ function HeatmapView({
|
|||||||
onReady={handleSnapshotReady}
|
onReady={handleSnapshotReady}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
{showOverlay && (
|
||||||
|
<div className={styles.overlay}>
|
||||||
|
{visible.map((p, i) => {
|
||||||
|
const intensity = Math.min(1, p.count / maxCount);
|
||||||
|
const size = 24 + intensity * 36;
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
key={`${p.x}-${p.y}-${i}`}
|
||||||
|
className={styles.dot}
|
||||||
|
style={{
|
||||||
|
left: p.x * scale - size / 2,
|
||||||
|
top: p.y * scale - size / 2,
|
||||||
|
width: size,
|
||||||
|
height: size,
|
||||||
|
opacity: 0.25 + intensity * 0.55,
|
||||||
|
}}
|
||||||
|
title={`${p.count} click${p.count === 1 ? '' : 's'}`}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
{showOverlay && (
|
|
||||||
<div className={`${styles.overlay} ${styles.heatOverlay}`}>
|
|
||||||
{visible.map((p, i) => {
|
|
||||||
const intensity = Math.min(1, p.count / maxCount);
|
|
||||||
const size = 24 + intensity * 36;
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
key={`${p.x}-${p.y}-${i}`}
|
|
||||||
className={styles.dot}
|
|
||||||
style={{
|
|
||||||
left: p.x * scale - size / 2,
|
|
||||||
top: p.y * scale - size / 2,
|
|
||||||
width: size,
|
|
||||||
height: size,
|
|
||||||
opacity: 0.25 + intensity * 0.55,
|
|
||||||
}}
|
|
||||||
title={`${p.count} click${p.count === 1 ? '' : 's'}`}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
})}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{snapshot && (
|
{snapshot && (
|
||||||
@@ -560,12 +564,8 @@ function ReplaySnapshot({
|
|||||||
void finalize();
|
void finalize();
|
||||||
});
|
});
|
||||||
|
|
||||||
replayer.on('resize', (dimension: { width?: number; height?: number }) => {
|
replayer.on('resize', () => {
|
||||||
resizeReplayFrame(
|
resizeReplayFrame(replayer, width, height);
|
||||||
replayer,
|
|
||||||
dimension.width && Number.isFinite(dimension.width) ? dimension.width : width,
|
|
||||||
dimension.height && Number.isFinite(dimension.height) ? dimension.height : height,
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
@@ -661,6 +661,12 @@ function resizeReplayFrame(replayer: ReplayInstance, width: number, height: numb
|
|||||||
if (wrapper) {
|
if (wrapper) {
|
||||||
wrapper.style.width = `${width}px`;
|
wrapper.style.width = `${width}px`;
|
||||||
wrapper.style.height = `${height}px`;
|
wrapper.style.height = `${height}px`;
|
||||||
|
wrapper.style.minWidth = `${width}px`;
|
||||||
|
wrapper.style.minHeight = `${height}px`;
|
||||||
|
wrapper.style.maxWidth = `${width}px`;
|
||||||
|
wrapper.style.maxHeight = `${height}px`;
|
||||||
|
wrapper.style.margin = '0';
|
||||||
|
wrapper.style.padding = '0';
|
||||||
wrapper.style.overflow = 'hidden';
|
wrapper.style.overflow = 'hidden';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -669,6 +675,11 @@ function resizeReplayFrame(replayer: ReplayInstance, width: number, height: numb
|
|||||||
iframe.setAttribute('height', String(height));
|
iframe.setAttribute('height', String(height));
|
||||||
iframe.style.width = `${width}px`;
|
iframe.style.width = `${width}px`;
|
||||||
iframe.style.height = `${height}px`;
|
iframe.style.height = `${height}px`;
|
||||||
|
iframe.style.minWidth = `${width}px`;
|
||||||
|
iframe.style.minHeight = `${height}px`;
|
||||||
|
iframe.style.maxWidth = `${width}px`;
|
||||||
|
iframe.style.maxHeight = `${height}px`;
|
||||||
|
iframe.style.margin = '0';
|
||||||
iframe.style.display = 'block';
|
iframe.style.display = 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -678,7 +689,7 @@ function resizeReplayFrame(replayer: ReplayInstance, width: number, height: numb
|
|||||||
function EmptyState({ message }: { message?: string } = {}) {
|
function EmptyState({ message }: { message?: string } = {}) {
|
||||||
return (
|
return (
|
||||||
<Column alignItems="center" justifyContent="center" minHeight="360px" gap>
|
<Column alignItems="center" justifyContent="center" minHeight="360px" gap>
|
||||||
<Heading size="lg">{message ? 'No data' : 'Select a page'}</Heading>
|
{!message && <Heading size="lg">Select a page</Heading>}
|
||||||
<Text color="muted">{message ?? 'Choose a page from the list to view its heatmap.'}</Text>
|
<Text color="muted">{message ?? 'Choose a page from the list to view its heatmap.'}</Text>
|
||||||
</Column>
|
</Column>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
'use client';
|
'use client';
|
||||||
import { Column, Row, SearchField } from '@umami/react-zen';
|
import { Button, Column, Row, SearchField } from '@umami/react-zen';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { WebsiteControls } from '@/app/(main)/websites/[websiteId]/WebsiteControls';
|
import { WebsiteControls } from '@/app/(main)/websites/[websiteId]/WebsiteControls';
|
||||||
|
import { EmptyPlaceholder } from '@/components/common/EmptyPlaceholder';
|
||||||
import { Panel } from '@/components/common/Panel';
|
import { Panel } from '@/components/common/Panel';
|
||||||
import { useMobile } from '@/components/hooks';
|
import { useMessages, useMobile, useSubscription, useWebsite } from '@/components/hooks';
|
||||||
|
import { Flame } from '@/components/icons';
|
||||||
import { FilterButtons } from '@/components/input/FilterButtons';
|
import { FilterButtons } from '@/components/input/FilterButtons';
|
||||||
import type { HeatmapMode } from '@/queries/sql';
|
import type { HeatmapMode } from '@/queries/sql';
|
||||||
import { Heatmap } from './Heatmap';
|
import { Heatmap } from './Heatmap';
|
||||||
@@ -17,12 +19,36 @@ export function HeatmapsPage({ websiteId }: { websiteId: string }) {
|
|||||||
const [mode, setMode] = useState<HeatmapMode>('click');
|
const [mode, setMode] = useState<HeatmapMode>('click');
|
||||||
const [search, setSearch] = useState('');
|
const [search, setSearch] = useState('');
|
||||||
const { isPhone } = useMobile();
|
const { isPhone } = useMobile();
|
||||||
|
const website = useWebsite();
|
||||||
|
const { t, labels, messages } = useMessages();
|
||||||
|
const { hasFeature, cloudMode } = useSubscription(website?.teamId);
|
||||||
|
|
||||||
const buttons = [
|
const buttons = [
|
||||||
{ id: 'click', label: 'Clicks' },
|
{ id: 'click', label: 'Clicks' },
|
||||||
{ id: 'scroll', label: 'Scroll' },
|
{ id: 'scroll', label: 'Scroll' },
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (cloudMode && !hasFeature('replays')) {
|
||||||
|
return (
|
||||||
|
<Column gap="3">
|
||||||
|
<Panel>
|
||||||
|
<EmptyPlaceholder
|
||||||
|
icon={<Flame />}
|
||||||
|
title={t(messages.upgradeRequired, { plan: 'Business' })}
|
||||||
|
description="View click and scroll heatmaps for your pages."
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
variant="primary"
|
||||||
|
onPress={() => window.open(`${process.env.cloudUrl}/settings/billing`, '_blank')}
|
||||||
|
>
|
||||||
|
{t(labels.upgrade)}
|
||||||
|
</Button>
|
||||||
|
</EmptyPlaceholder>
|
||||||
|
</Panel>
|
||||||
|
</Column>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Column gap>
|
<Column gap>
|
||||||
<WebsiteControls websiteId={websiteId} />
|
<WebsiteControls websiteId={websiteId} />
|
||||||
|
|||||||
@@ -80,6 +80,11 @@ interface HeatmapFilterContext {
|
|||||||
queryParams: Record<string, any>;
|
queryParams: Record<string, any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface SnapshotPoint {
|
||||||
|
x: number;
|
||||||
|
y: number;
|
||||||
|
}
|
||||||
|
|
||||||
async function relationalQuery(
|
async function relationalQuery(
|
||||||
websiteId: string,
|
websiteId: string,
|
||||||
parameters: HeatmapParameters,
|
parameters: HeatmapParameters,
|
||||||
@@ -186,6 +191,7 @@ async function relationalQuery(
|
|||||||
endDate,
|
endDate,
|
||||||
viewportW: scroll.viewportW,
|
viewportW: scroll.viewportW,
|
||||||
viewportH: scroll.viewportH,
|
viewportH: scroll.viewportH,
|
||||||
|
point: null,
|
||||||
filterContext,
|
filterContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -226,6 +232,7 @@ async function relationalQuery(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const viewport = pickSnapshotViewport(rawPoints);
|
const viewport = pickSnapshotViewport(rawPoints);
|
||||||
|
const point = pickRepresentativePoint(rawPoints, viewport);
|
||||||
const snapshot = await getRelationalSnapshot(rawQuery, {
|
const snapshot = await getRelationalSnapshot(rawQuery, {
|
||||||
websiteId,
|
websiteId,
|
||||||
eventType,
|
eventType,
|
||||||
@@ -234,6 +241,7 @@ async function relationalQuery(
|
|||||||
endDate,
|
endDate,
|
||||||
viewportW: viewport?.width ?? null,
|
viewportW: viewport?.width ?? null,
|
||||||
viewportH: viewport?.height ?? null,
|
viewportH: viewport?.height ?? null,
|
||||||
|
point,
|
||||||
filterContext,
|
filterContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -250,6 +258,7 @@ async function getRelationalSnapshot(
|
|||||||
endDate,
|
endDate,
|
||||||
viewportW,
|
viewportW,
|
||||||
viewportH,
|
viewportH,
|
||||||
|
point,
|
||||||
filterContext,
|
filterContext,
|
||||||
}: {
|
}: {
|
||||||
websiteId: string;
|
websiteId: string;
|
||||||
@@ -259,6 +268,7 @@ async function getRelationalSnapshot(
|
|||||||
endDate: Date;
|
endDate: Date;
|
||||||
viewportW: number | null;
|
viewportW: number | null;
|
||||||
viewportH: number | null;
|
viewportH: number | null;
|
||||||
|
point: SnapshotPoint | null;
|
||||||
filterContext: HeatmapFilterContext;
|
filterContext: HeatmapFilterContext;
|
||||||
},
|
},
|
||||||
): Promise<HeatmapSnapshot | null> {
|
): Promise<HeatmapSnapshot | null> {
|
||||||
@@ -269,6 +279,12 @@ async function getRelationalSnapshot(
|
|||||||
and h.viewport_h = {{viewportH}}
|
and h.viewport_h = {{viewportH}}
|
||||||
`
|
`
|
||||||
: '';
|
: '';
|
||||||
|
const pointFilter = point
|
||||||
|
? `
|
||||||
|
and h.x = {{pointX}}
|
||||||
|
and h.y = {{pointY}}
|
||||||
|
`
|
||||||
|
: '';
|
||||||
|
|
||||||
const rows: SnapshotRow[] = await rawQuery(
|
const rows: SnapshotRow[] = await rawQuery(
|
||||||
`
|
`
|
||||||
@@ -284,6 +300,7 @@ async function getRelationalSnapshot(
|
|||||||
and h.url_path = {{urlPath}}
|
and h.url_path = {{urlPath}}
|
||||||
and h.created_at between {{startDate}} and {{endDate}}
|
and h.created_at between {{startDate}} and {{endDate}}
|
||||||
${viewportFilter}
|
${viewportFilter}
|
||||||
|
${pointFilter}
|
||||||
group by h.visit_id
|
group by h.visit_id
|
||||||
order by event_count desc, first_seen asc
|
order by event_count desc, first_seen asc
|
||||||
limit 1
|
limit 1
|
||||||
@@ -306,6 +323,7 @@ async function getRelationalSnapshot(
|
|||||||
and h.url_path = {{urlPath}}
|
and h.url_path = {{urlPath}}
|
||||||
and h.created_at between {{startDate}} and {{endDate}}
|
and h.created_at between {{startDate}} and {{endDate}}
|
||||||
${viewportFilter}
|
${viewportFilter}
|
||||||
|
${pointFilter}
|
||||||
order by
|
order by
|
||||||
case when h.replay_chunk_index is null then 1 else 0 end asc,
|
case when h.replay_chunk_index is null then 1 else 0 end asc,
|
||||||
h.replay_chunk_index asc nulls last,
|
h.replay_chunk_index asc nulls last,
|
||||||
@@ -313,7 +331,18 @@ async function getRelationalSnapshot(
|
|||||||
h.created_at asc
|
h.created_at asc
|
||||||
limit 1
|
limit 1
|
||||||
`,
|
`,
|
||||||
{ ...filterContext.queryParams, websiteId, eventType, urlPath, startDate, endDate, viewportW, viewportH },
|
{
|
||||||
|
...filterContext.queryParams,
|
||||||
|
websiteId,
|
||||||
|
eventType,
|
||||||
|
urlPath,
|
||||||
|
startDate,
|
||||||
|
endDate,
|
||||||
|
viewportW,
|
||||||
|
viewportH,
|
||||||
|
pointX: point?.x,
|
||||||
|
pointY: point?.y,
|
||||||
|
},
|
||||||
FUNCTION_NAME,
|
FUNCTION_NAME,
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -438,6 +467,7 @@ async function clickhouseQuery(
|
|||||||
endDate,
|
endDate,
|
||||||
viewportW: scroll.viewportW,
|
viewportW: scroll.viewportW,
|
||||||
viewportH: scroll.viewportH,
|
viewportH: scroll.viewportH,
|
||||||
|
point: null,
|
||||||
filterContext,
|
filterContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -496,6 +526,7 @@ async function clickhouseQuery(
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
const viewport = pickSnapshotViewport(points);
|
const viewport = pickSnapshotViewport(points);
|
||||||
|
const point = pickRepresentativePoint(points, viewport);
|
||||||
const snapshot = await getClickhouseSnapshot(rawQuery, {
|
const snapshot = await getClickhouseSnapshot(rawQuery, {
|
||||||
websiteId,
|
websiteId,
|
||||||
eventType,
|
eventType,
|
||||||
@@ -504,6 +535,7 @@ async function clickhouseQuery(
|
|||||||
endDate,
|
endDate,
|
||||||
viewportW: viewport?.width ?? null,
|
viewportW: viewport?.width ?? null,
|
||||||
viewportH: viewport?.height ?? null,
|
viewportH: viewport?.height ?? null,
|
||||||
|
point,
|
||||||
filterContext,
|
filterContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -520,6 +552,7 @@ async function getClickhouseSnapshot(
|
|||||||
endDate,
|
endDate,
|
||||||
viewportW,
|
viewportW,
|
||||||
viewportH,
|
viewportH,
|
||||||
|
point,
|
||||||
filterContext,
|
filterContext,
|
||||||
}: {
|
}: {
|
||||||
websiteId: string;
|
websiteId: string;
|
||||||
@@ -529,6 +562,7 @@ async function getClickhouseSnapshot(
|
|||||||
endDate: Date;
|
endDate: Date;
|
||||||
viewportW: number | null;
|
viewportW: number | null;
|
||||||
viewportH: number | null;
|
viewportH: number | null;
|
||||||
|
point: SnapshotPoint | null;
|
||||||
filterContext: HeatmapFilterContext;
|
filterContext: HeatmapFilterContext;
|
||||||
},
|
},
|
||||||
): Promise<HeatmapSnapshot | null> {
|
): Promise<HeatmapSnapshot | null> {
|
||||||
@@ -539,6 +573,12 @@ async function getClickhouseSnapshot(
|
|||||||
and h.viewport_h = {viewportH:UInt32}
|
and h.viewport_h = {viewportH:UInt32}
|
||||||
`
|
`
|
||||||
: '';
|
: '';
|
||||||
|
const pointFilter = point
|
||||||
|
? `
|
||||||
|
and h.x = {pointX:UInt32}
|
||||||
|
and h.y = {pointY:UInt32}
|
||||||
|
`
|
||||||
|
: '';
|
||||||
|
|
||||||
const rows = await rawQuery<SnapshotRow[]>(
|
const rows = await rawQuery<SnapshotRow[]>(
|
||||||
`
|
`
|
||||||
@@ -554,6 +594,7 @@ async function getClickhouseSnapshot(
|
|||||||
and h.url_path = {urlPath:String}
|
and h.url_path = {urlPath:String}
|
||||||
and h.created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
and h.created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
${viewportFilter}
|
${viewportFilter}
|
||||||
|
${pointFilter}
|
||||||
group by h.visit_id
|
group by h.visit_id
|
||||||
order by event_count desc, first_seen asc
|
order by event_count desc, first_seen asc
|
||||||
limit 1
|
limit 1
|
||||||
@@ -576,6 +617,7 @@ async function getClickhouseSnapshot(
|
|||||||
and h.url_path = {urlPath:String}
|
and h.url_path = {urlPath:String}
|
||||||
and h.created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
and h.created_at between {startDate:DateTime64} and {endDate:DateTime64}
|
||||||
${viewportFilter}
|
${viewportFilter}
|
||||||
|
${pointFilter}
|
||||||
order by
|
order by
|
||||||
isNull(h.replay_chunk_index) asc,
|
isNull(h.replay_chunk_index) asc,
|
||||||
h.replay_chunk_index asc,
|
h.replay_chunk_index asc,
|
||||||
@@ -592,6 +634,8 @@ async function getClickhouseSnapshot(
|
|||||||
endDate,
|
endDate,
|
||||||
viewportW,
|
viewportW,
|
||||||
viewportH,
|
viewportH,
|
||||||
|
pointX: point?.x,
|
||||||
|
pointY: point?.y,
|
||||||
},
|
},
|
||||||
FUNCTION_NAME,
|
FUNCTION_NAME,
|
||||||
);
|
);
|
||||||
@@ -632,6 +676,21 @@ function pickSnapshotViewport(points: HeatmapPoint[]): { width: number; height:
|
|||||||
return best ? { width: best.width, height: best.height } : null;
|
return best ? { width: best.width, height: best.height } : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function pickRepresentativePoint(
|
||||||
|
points: HeatmapPoint[],
|
||||||
|
viewport: { width: number; height: number } | null,
|
||||||
|
): SnapshotPoint | null {
|
||||||
|
if (!viewport) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const match = points.find(
|
||||||
|
point => point.viewportW === viewport.width && point.viewportH === viewport.height,
|
||||||
|
);
|
||||||
|
|
||||||
|
return match ? { x: match.x, y: match.y } : null;
|
||||||
|
}
|
||||||
|
|
||||||
function mapSnapshot(row?: SnapshotRow | null): HeatmapSnapshot | null {
|
function mapSnapshot(row?: SnapshotRow | null): HeatmapSnapshot | null {
|
||||||
if (!row) {
|
if (!row) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in new issue
Block a user