Merge pull request #1873 from umami-software/bug/um-250-fix-realtime-data

fix some components in realtime data
This commit is contained in:
Francis Cao 2023-04-07 10:56:42 -07:00 committed by GitHub
commit f38f0c6420
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 71 deletions

View file

@ -57,7 +57,7 @@ export default function RealtimeLog({ data, websiteDomain }) {
const getIcon = ({ __type }) => icons[__type];
const getDetail = log => {
const { __type, eventName, url, browser, os, country, device } = log;
const { __type, eventName, urlPath: url, browser, os, country, device } = log;
if (__type === TYPE_EVENT) {
return (

View file

@ -35,18 +35,14 @@ export default function RealtimeUrls({ websiteDomain, data = {} }) {
if (pageviews) {
const referrers = percentFilter(
pageviews
.reduce((arr, { referrer }) => {
if (referrer?.startsWith('http')) {
const hostname = new URL(referrer).hostname.replace(/^www\./, '');
.reduce((arr, { referrerDomain }) => {
if (referrerDomain) {
const row = arr.find(({ x }) => x === referrerDomain);
if (hostname) {
const row = arr.find(({ x }) => x === hostname);
if (!row) {
arr.push({ x: hostname, y: 1 });
} else {
row.y += 1;
}
if (!row) {
arr.push({ x: referrerDomain, y: 1 });
} else {
row.y += 1;
}
}
return arr;
@ -56,15 +52,13 @@ export default function RealtimeUrls({ websiteDomain, data = {} }) {
const pages = percentFilter(
pageviews
.reduce((arr, { url }) => {
if (url?.startsWith('/')) {
const row = arr.find(({ x }) => x === url);
.reduce((arr, { urlPath }) => {
const row = arr.find(({ x }) => x === urlPath);
if (!row) {
arr.push({ x: url, y: 1 });
} else {
row.y += 1;
}
if (!row) {
arr.push({ x: urlPath, y: 1 });
} else {
row.y += 1;
}
return arr;
}, [])