Fixed visitor calculation.

This commit is contained in:
Mike Cao 2023-02-17 22:17:29 -08:00
parent 802c262cd9
commit 8ecc6400ef

View File

@ -33,9 +33,16 @@ export default function RealtimeChart({ data, unit, ...props }) {
return { pageviews: [], sessions: [] };
}
const visitors = data.sessions?.reduce((arr, val) => {
if (!arr.find(({ sessionId }) => sessionId === val.sessionId)) {
return arr.concat(val);
}
return arr;
}, []);
return {
pageviews: getDateArray(mapData(data.pageviews), startDate, endDate, unit),
sessions: getDateArray(mapData(data.sessions), startDate, endDate, unit),
sessions: getDateArray(mapData(visitors), startDate, endDate, unit),
};
}, [data, startDate, endDate, unit]);