Merge remote-tracking branch 'origin/dev' into dev

This commit is contained in:
Brian Cao 2023-03-30 10:46:01 -07:00
commit e4c801e823
10 changed files with 26 additions and 43 deletions

View File

@ -1,38 +1,16 @@
import { useState } from 'react';
import FilterLink from 'components/common/FilterLink';
import FilterButtons from 'components/common/FilterButtons';
import { urlFilter } from 'lib/filters';
import MetricsTable from './MetricsTable';
import { FILTER_COMBINED, FILTER_RAW } from 'lib/constants';
import useMessages from 'hooks/useMessages';
const filters = {
[FILTER_RAW]: null,
[FILTER_COMBINED]: urlFilter,
};
export default function PagesTable({ websiteId, showFilters, ...props }) {
const [filter, setFilter] = useState(FILTER_COMBINED);
export default function PagesTable({ websiteId, ...props }) {
const { formatMessage, labels } = useMessages();
const buttons = [
{
label: formatMessage(labels.filterCombined),
key: FILTER_COMBINED,
},
{
label: formatMessage(labels.filterRaw),
key: FILTER_RAW,
},
];
const renderLink = ({ x: url }) => {
return <FilterLink id="url" value={url} />;
};
return (
<>
{showFilters && <FilterButtons items={buttons} selectedKey={filter} onSelect={setFilter} />}
<MetricsTable
title={formatMessage(labels.pages)}
type="url"

View File

@ -24,12 +24,12 @@
min-height: 90px;
margin-bottom: 20px;
background: var(--base50);
z-index: var(--z-index300);
}
.sticky {
position: sticky;
top: -1px;
z-index: 2;
}
.isSticky {

View File

@ -10,23 +10,21 @@ import TrackingCode from 'components/pages/settings/websites/TrackingCode';
import ShareUrl from 'components/pages/settings/websites/ShareUrl';
import useApi from 'hooks/useApi';
import useMessages from 'hooks/useMessages';
import useConfig from 'hooks/useConfig';
export default function WebsiteSettings({ websiteId }) {
const router = useRouter();
const { formatMessage, labels, messages } = useMessages();
const [values, setValues] = useState(null);
const [tab, setTab] = useState('details');
const { openExternal } = useConfig();
const { get, useQuery } = useApi();
const { toast, showToast } = useToast();
const { data, isLoading } = useQuery(
['website', websiteId],
() => {
if (websiteId) {
return get(`/websites/${websiteId}`);
}
},
{ cacheTime: 0 },
() => get(`/websites/${websiteId}`),
{ enabled: !!websiteId, cacheTime: 0 },
);
const [values, setValues] = useState(null);
const [tab, setTab] = useState('details');
const handleSave = data => {
showToast({ message: formatMessage(messages.saved), variant: 'success' });
@ -58,7 +56,7 @@ export default function WebsiteSettings({ websiteId }) {
</Breadcrumbs>
}
>
<Link href={`/analytics/websites/${websiteId}`} target="_blank">
<Link href={`/websites/${websiteId}`} target={openExternal ? '_blank' : null}>
<Button variant="primary">
<Icon>
<Icons.External />

View File

@ -13,9 +13,11 @@ import {
Flexbox,
} from 'react-basics';
import useMessages from 'hooks/useMessages';
import useConfig from 'hooks/useConfig';
export default function WebsitesTable({ data = [] }) {
const { formatMessage, labels } = useMessages();
const { openExternal } = useConfig();
const columns = [
{ name: 'name', label: formatMessage(labels.name), style: { flex: 2 } },
@ -48,7 +50,7 @@ export default function WebsitesTable({ data = [] }) {
<Text>{formatMessage(labels.edit)}</Text>
</Button>
</Link>
<Link href={`/websites/${id}`}>
<Link href={`/websites/${id}`} target={openExternal ? '_blank' : null}>
<Button>
<Icon>
<Icons.External />

View File

@ -190,8 +190,8 @@ function parseFilters(filters: any = {}, params: any = {}) {
async function rawQuery(query, params = {}) {
if (process.env.LOG_QUERY) {
log(query);
log(params);
log('QUERY:\n', query);
log('PARAMETERS:\n', params);
}
await connect();

View File

@ -50,7 +50,7 @@ export const percentFilter = data => {
export const paramFilter = data => {
const map = data.reduce((obj, { x, y }) => {
try {
const searchParams = new URLSearchParams(x.split('?')[1]);
const searchParams = new URLSearchParams(x);
for (const [key, value] of searchParams) {
if (!obj[key]) {

View File

@ -96,6 +96,10 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
let [referrerPath, referrerQuery] = referrer?.split('?') || [];
let referrerDomain;
if (!urlPath) {
urlPath = '/';
}
if (referrerPath.startsWith('http')) {
const refUrl = new URL(referrer);
referrerPath = refUrl.pathname;
@ -104,7 +108,7 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
}
if (process.env.REMOVE_TRAILING_SLASH) {
urlPath = urlPath.replace(/\/$/, '');
urlPath = urlPath.replace(/.+\/$/, '');
}
await saveEvent({

View File

@ -89,6 +89,7 @@ export default async (
subdivision1,
subdivision2,
city,
query,
} = req.query;
if (req.method === 'GET') {
@ -162,7 +163,7 @@ export default async (
subdivision2: type !== 'subdivision2' ? subdivision2 : undefined,
city: type !== 'city' ? city : undefined,
eventUrl: type !== 'url' && table === 'event' ? url : undefined,
query: type === 'query' && table !== 'event' ? true : undefined,
query: type !== 'query' && table !== 'event' ? query : undefined,
};
const data = await getPageviewMetrics(websiteId, {

View File

@ -58,7 +58,7 @@ async function relationalQuery(
${filterQuery}
group by 1
order by 2 desc
limit 200`,
limit 100`,
params,
);
}
@ -93,7 +93,7 @@ async function clickhouseQuery(
${filterQuery}
group by x
order by y desc
limit 200`,
limit 100`,
params,
);
}

View File

@ -44,7 +44,7 @@ async function relationalQuery(
)
group by 1
order by 2 desc
limit 200`,
limit 100`,
params,
);
}
@ -70,7 +70,7 @@ async function clickhouseQuery(
${filterQuery}
group by x
order by y desc
limit 200`,
limit 100`,
params,
);
}