mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 18:26:20 +01:00
Merge remote-tracking branch 'origin/dev' into dev
This commit is contained in:
commit
e4c801e823
@ -1,38 +1,16 @@
|
|||||||
import { useState } from 'react';
|
|
||||||
import FilterLink from 'components/common/FilterLink';
|
import FilterLink from 'components/common/FilterLink';
|
||||||
import FilterButtons from 'components/common/FilterButtons';
|
|
||||||
import { urlFilter } from 'lib/filters';
|
|
||||||
import MetricsTable from './MetricsTable';
|
import MetricsTable from './MetricsTable';
|
||||||
import { FILTER_COMBINED, FILTER_RAW } from 'lib/constants';
|
|
||||||
import useMessages from 'hooks/useMessages';
|
import useMessages from 'hooks/useMessages';
|
||||||
|
|
||||||
const filters = {
|
export default function PagesTable({ websiteId, ...props }) {
|
||||||
[FILTER_RAW]: null,
|
|
||||||
[FILTER_COMBINED]: urlFilter,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function PagesTable({ websiteId, showFilters, ...props }) {
|
|
||||||
const [filter, setFilter] = useState(FILTER_COMBINED);
|
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
|
|
||||||
const buttons = [
|
|
||||||
{
|
|
||||||
label: formatMessage(labels.filterCombined),
|
|
||||||
key: FILTER_COMBINED,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: formatMessage(labels.filterRaw),
|
|
||||||
key: FILTER_RAW,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const renderLink = ({ x: url }) => {
|
const renderLink = ({ x: url }) => {
|
||||||
return <FilterLink id="url" value={url} />;
|
return <FilterLink id="url" value={url} />;
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{showFilters && <FilterButtons items={buttons} selectedKey={filter} onSelect={setFilter} />}
|
|
||||||
<MetricsTable
|
<MetricsTable
|
||||||
title={formatMessage(labels.pages)}
|
title={formatMessage(labels.pages)}
|
||||||
type="url"
|
type="url"
|
||||||
|
@ -24,12 +24,12 @@
|
|||||||
min-height: 90px;
|
min-height: 90px;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
background: var(--base50);
|
background: var(--base50);
|
||||||
|
z-index: var(--z-index300);
|
||||||
}
|
}
|
||||||
|
|
||||||
.sticky {
|
.sticky {
|
||||||
position: sticky;
|
position: sticky;
|
||||||
top: -1px;
|
top: -1px;
|
||||||
z-index: 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.isSticky {
|
.isSticky {
|
||||||
|
@ -10,23 +10,21 @@ import TrackingCode from 'components/pages/settings/websites/TrackingCode';
|
|||||||
import ShareUrl from 'components/pages/settings/websites/ShareUrl';
|
import ShareUrl from 'components/pages/settings/websites/ShareUrl';
|
||||||
import useApi from 'hooks/useApi';
|
import useApi from 'hooks/useApi';
|
||||||
import useMessages from 'hooks/useMessages';
|
import useMessages from 'hooks/useMessages';
|
||||||
|
import useConfig from 'hooks/useConfig';
|
||||||
|
|
||||||
export default function WebsiteSettings({ websiteId }) {
|
export default function WebsiteSettings({ websiteId }) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { formatMessage, labels, messages } = useMessages();
|
const { formatMessage, labels, messages } = useMessages();
|
||||||
const [values, setValues] = useState(null);
|
const { openExternal } = useConfig();
|
||||||
const [tab, setTab] = useState('details');
|
|
||||||
const { get, useQuery } = useApi();
|
const { get, useQuery } = useApi();
|
||||||
const { toast, showToast } = useToast();
|
const { toast, showToast } = useToast();
|
||||||
const { data, isLoading } = useQuery(
|
const { data, isLoading } = useQuery(
|
||||||
['website', websiteId],
|
['website', websiteId],
|
||||||
() => {
|
() => get(`/websites/${websiteId}`),
|
||||||
if (websiteId) {
|
{ enabled: !!websiteId, cacheTime: 0 },
|
||||||
return get(`/websites/${websiteId}`);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ cacheTime: 0 },
|
|
||||||
);
|
);
|
||||||
|
const [values, setValues] = useState(null);
|
||||||
|
const [tab, setTab] = useState('details');
|
||||||
|
|
||||||
const handleSave = data => {
|
const handleSave = data => {
|
||||||
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
showToast({ message: formatMessage(messages.saved), variant: 'success' });
|
||||||
@ -58,7 +56,7 @@ export default function WebsiteSettings({ websiteId }) {
|
|||||||
</Breadcrumbs>
|
</Breadcrumbs>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Link href={`/analytics/websites/${websiteId}`} target="_blank">
|
<Link href={`/websites/${websiteId}`} target={openExternal ? '_blank' : null}>
|
||||||
<Button variant="primary">
|
<Button variant="primary">
|
||||||
<Icon>
|
<Icon>
|
||||||
<Icons.External />
|
<Icons.External />
|
||||||
|
@ -13,9 +13,11 @@ import {
|
|||||||
Flexbox,
|
Flexbox,
|
||||||
} from 'react-basics';
|
} from 'react-basics';
|
||||||
import useMessages from 'hooks/useMessages';
|
import useMessages from 'hooks/useMessages';
|
||||||
|
import useConfig from 'hooks/useConfig';
|
||||||
|
|
||||||
export default function WebsitesTable({ data = [] }) {
|
export default function WebsitesTable({ data = [] }) {
|
||||||
const { formatMessage, labels } = useMessages();
|
const { formatMessage, labels } = useMessages();
|
||||||
|
const { openExternal } = useConfig();
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{ name: 'name', label: formatMessage(labels.name), style: { flex: 2 } },
|
{ name: 'name', label: formatMessage(labels.name), style: { flex: 2 } },
|
||||||
@ -48,7 +50,7 @@ export default function WebsitesTable({ data = [] }) {
|
|||||||
<Text>{formatMessage(labels.edit)}</Text>
|
<Text>{formatMessage(labels.edit)}</Text>
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link>
|
||||||
<Link href={`/websites/${id}`}>
|
<Link href={`/websites/${id}`} target={openExternal ? '_blank' : null}>
|
||||||
<Button>
|
<Button>
|
||||||
<Icon>
|
<Icon>
|
||||||
<Icons.External />
|
<Icons.External />
|
||||||
|
@ -190,8 +190,8 @@ function parseFilters(filters: any = {}, params: any = {}) {
|
|||||||
|
|
||||||
async function rawQuery(query, params = {}) {
|
async function rawQuery(query, params = {}) {
|
||||||
if (process.env.LOG_QUERY) {
|
if (process.env.LOG_QUERY) {
|
||||||
log(query);
|
log('QUERY:\n', query);
|
||||||
log(params);
|
log('PARAMETERS:\n', params);
|
||||||
}
|
}
|
||||||
|
|
||||||
await connect();
|
await connect();
|
||||||
|
@ -50,7 +50,7 @@ export const percentFilter = data => {
|
|||||||
export const paramFilter = data => {
|
export const paramFilter = data => {
|
||||||
const map = data.reduce((obj, { x, y }) => {
|
const map = data.reduce((obj, { x, y }) => {
|
||||||
try {
|
try {
|
||||||
const searchParams = new URLSearchParams(x.split('?')[1]);
|
const searchParams = new URLSearchParams(x);
|
||||||
|
|
||||||
for (const [key, value] of searchParams) {
|
for (const [key, value] of searchParams) {
|
||||||
if (!obj[key]) {
|
if (!obj[key]) {
|
||||||
|
@ -96,6 +96,10 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
|||||||
let [referrerPath, referrerQuery] = referrer?.split('?') || [];
|
let [referrerPath, referrerQuery] = referrer?.split('?') || [];
|
||||||
let referrerDomain;
|
let referrerDomain;
|
||||||
|
|
||||||
|
if (!urlPath) {
|
||||||
|
urlPath = '/';
|
||||||
|
}
|
||||||
|
|
||||||
if (referrerPath.startsWith('http')) {
|
if (referrerPath.startsWith('http')) {
|
||||||
const refUrl = new URL(referrer);
|
const refUrl = new URL(referrer);
|
||||||
referrerPath = refUrl.pathname;
|
referrerPath = refUrl.pathname;
|
||||||
@ -104,7 +108,7 @@ export default async (req: NextApiRequestCollect, res: NextApiResponse) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (process.env.REMOVE_TRAILING_SLASH) {
|
if (process.env.REMOVE_TRAILING_SLASH) {
|
||||||
urlPath = urlPath.replace(/\/$/, '');
|
urlPath = urlPath.replace(/.+\/$/, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
await saveEvent({
|
await saveEvent({
|
||||||
|
@ -89,6 +89,7 @@ export default async (
|
|||||||
subdivision1,
|
subdivision1,
|
||||||
subdivision2,
|
subdivision2,
|
||||||
city,
|
city,
|
||||||
|
query,
|
||||||
} = req.query;
|
} = req.query;
|
||||||
|
|
||||||
if (req.method === 'GET') {
|
if (req.method === 'GET') {
|
||||||
@ -162,7 +163,7 @@ export default async (
|
|||||||
subdivision2: type !== 'subdivision2' ? subdivision2 : undefined,
|
subdivision2: type !== 'subdivision2' ? subdivision2 : undefined,
|
||||||
city: type !== 'city' ? city : undefined,
|
city: type !== 'city' ? city : undefined,
|
||||||
eventUrl: type !== 'url' && table === 'event' ? url : 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, {
|
const data = await getPageviewMetrics(websiteId, {
|
||||||
|
@ -58,7 +58,7 @@ async function relationalQuery(
|
|||||||
${filterQuery}
|
${filterQuery}
|
||||||
group by 1
|
group by 1
|
||||||
order by 2 desc
|
order by 2 desc
|
||||||
limit 200`,
|
limit 100`,
|
||||||
params,
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ async function clickhouseQuery(
|
|||||||
${filterQuery}
|
${filterQuery}
|
||||||
group by x
|
group by x
|
||||||
order by y desc
|
order by y desc
|
||||||
limit 200`,
|
limit 100`,
|
||||||
params,
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ async function relationalQuery(
|
|||||||
)
|
)
|
||||||
group by 1
|
group by 1
|
||||||
order by 2 desc
|
order by 2 desc
|
||||||
limit 200`,
|
limit 100`,
|
||||||
params,
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ async function clickhouseQuery(
|
|||||||
${filterQuery}
|
${filterQuery}
|
||||||
group by x
|
group by x
|
||||||
order by y desc
|
order by y desc
|
||||||
limit 200`,
|
limit 100`,
|
||||||
params,
|
params,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user