fix some components in realtime data

This commit is contained in:
Francis Cao 2023-04-06 18:31:16 -07:00
parent 6dd90ce9ca
commit 05ece6a4d0
6 changed files with 21 additions and 67 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,12 +52,12 @@ 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 }) => {
if (urlPath?.startsWith('/')) {
const row = arr.find(({ x }) => x === urlPath);
if (!row) {
arr.push({ x: url, y: 1 });
arr.push({ x: urlPath, y: 1 });
} else {
row.y += 1;
}