mirror of
https://github.com/umami-software/umami.git
synced 2026-02-07 22:27:16 +01:00
Merge branch 'dev' into jajaja
This commit is contained in:
commit
cd944e14ce
10 changed files with 68 additions and 75 deletions
|
|
@ -1,13 +1,7 @@
|
|||
import {
|
||||
useFilters,
|
||||
useFormat,
|
||||
useLocale,
|
||||
useMessages,
|
||||
useWebsiteValues,
|
||||
} from '@/components/hooks';
|
||||
import { useMemo, useState } from 'react';
|
||||
import { useFilters, useFormat, useMessages, useWebsiteValues } from '@/components/hooks';
|
||||
import { OPERATORS } from '@/lib/constants';
|
||||
import { isEqualsOperator } from '@/lib/params';
|
||||
import { useMemo, useState } from 'react';
|
||||
import {
|
||||
Button,
|
||||
Dropdown,
|
||||
|
|
@ -61,7 +55,6 @@ export default function FieldFilterEditForm({
|
|||
const [selected, setSelected] = useState(isEquals ? value : '');
|
||||
const { filters } = useFilters();
|
||||
const { formatValue } = useFormat();
|
||||
const { locale } = useLocale();
|
||||
const isDisabled = !operator || (isEquals && !selected) || (!isEquals && !value);
|
||||
const {
|
||||
data: values = [],
|
||||
|
|
@ -86,29 +79,17 @@ export default function FieldFilterEditForm({
|
|||
};
|
||||
|
||||
const formattedValues = useMemo(() => {
|
||||
if (!values) {
|
||||
return {};
|
||||
}
|
||||
const formatted = {};
|
||||
const format = (val: string) => {
|
||||
formatted[val] = formatValue(val, name);
|
||||
return formatted[val];
|
||||
};
|
||||
return values.reduce((obj: { [x: string]: string }, { value }: { value: string }) => {
|
||||
obj[value] = formatValue(value, name);
|
||||
|
||||
if (values?.length !== 1) {
|
||||
const { compare } = new Intl.Collator(locale, { numeric: true });
|
||||
values.sort((a, b) => compare(formatted[a] ?? format(a), formatted[b] ?? format(b)));
|
||||
} else {
|
||||
format(values[0]);
|
||||
}
|
||||
|
||||
return formatted;
|
||||
}, [formatValue, locale, name, values]);
|
||||
return obj;
|
||||
}, {});
|
||||
}, [formatValue, name, values]);
|
||||
|
||||
const filteredValues = useMemo(() => {
|
||||
return value
|
||||
? values.filter((n: string | number) =>
|
||||
formattedValues[n].toLowerCase().includes(value.toLowerCase()),
|
||||
formattedValues[n]?.toLowerCase()?.includes(value.toLowerCase()),
|
||||
)
|
||||
: values;
|
||||
}, [value, formattedValues]);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ export async function GET(request: Request) {
|
|||
|
||||
export async function POST(request: Request) {
|
||||
const schema = z.object({
|
||||
currency: z.string(),
|
||||
...reportParms,
|
||||
timezone: timezoneParam,
|
||||
});
|
||||
|
|
|
|||
|
|
@ -131,35 +131,35 @@ function getChannels(data: { domain: string; query: string; visitors: number }[]
|
|||
|
||||
for (const { domain, query, visitors } of data) {
|
||||
if (!domain && !query) {
|
||||
channels.direct += visitors;
|
||||
channels.direct += Number(visitors);
|
||||
}
|
||||
|
||||
const prefix = /utm_medium=(.*cp.*|ppc|retargeting|paid.*)/.test(query) ? 'paid' : 'organic';
|
||||
|
||||
if (SEARCH_DOMAINS.some(match(domain)) || /utm_medium=organic/.test(query)) {
|
||||
channels[`${prefix}Search`] += visitors;
|
||||
channels[`${prefix}Search`] += Number(visitors);
|
||||
} else if (
|
||||
SOCIAL_DOMAINS.some(match(domain)) ||
|
||||
/utm_medium=(social|social-network|social-media|sm|social network|social media)/.test(query)
|
||||
) {
|
||||
channels[`${prefix}Social`] += visitors;
|
||||
channels[`${prefix}Social`] += Number(visitors);
|
||||
} else if (EMAIL_DOMAINS.some(match(domain)) || /utm_medium=(.*e[-_ ]?mail.*)/.test(query)) {
|
||||
channels.email += visitors;
|
||||
channels.email += Number(visitors);
|
||||
} else if (
|
||||
SHOPPING_DOMAINS.some(match(domain)) ||
|
||||
/utm_campaign=(.*(([^a-df-z]|^)shop|shopping).*)/.test(query)
|
||||
) {
|
||||
channels[`${prefix}Shopping`] += visitors;
|
||||
channels[`${prefix}Shopping`] += Number(visitors);
|
||||
} else if (VIDEO_DOMAINS.some(match(domain)) || /utm_medium=(.*video.*)/.test(query)) {
|
||||
channels[`${prefix}Video`] += visitors;
|
||||
channels[`${prefix}Video`] += Number(visitors);
|
||||
} else if (PAID_AD_PARAMS.some(match(query))) {
|
||||
channels.paidAds += visitors;
|
||||
channels.paidAds += Number(visitors);
|
||||
} else if (/utm_medium=(referral|app|link)/.test(query)) {
|
||||
channels.referral += visitors;
|
||||
channels.referral += Number(visitors);
|
||||
} else if (/utm_medium=affiliate/.test(query)) {
|
||||
channels.affiliate += visitors;
|
||||
channels.affiliate += Number(visitors);
|
||||
} else if (/utm_(source|medium)=sms/.test(query)) {
|
||||
channels.sms += visitors;
|
||||
channels.sms += Number(visitors);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
import { z } from 'zod';
|
||||
import { parseRequest } from '@/lib/request';
|
||||
import { unauthorized, json } from '@/lib/response';
|
||||
import { canViewWebsite } from '@/lib/auth';
|
||||
import { getEventDataEvents } from '@/queries/sql/events/getEventDataEvents';
|
||||
import { parseRequest } from '@/lib/request';
|
||||
import { json, unauthorized } from '@/lib/response';
|
||||
import { getSessionDataValues } from '@/queries';
|
||||
import { z } from 'zod';
|
||||
|
||||
export async function GET(
|
||||
request: Request,
|
||||
|
|
@ -20,7 +20,7 @@ export async function GET(
|
|||
return error();
|
||||
}
|
||||
|
||||
const { startAt, endAt, event } = query;
|
||||
const { startAt, endAt, propertyName } = query;
|
||||
const { websiteId } = await params;
|
||||
|
||||
if (!(await canViewWebsite(auth, websiteId))) {
|
||||
|
|
@ -30,10 +30,10 @@ export async function GET(
|
|||
const startDate = new Date(+startAt);
|
||||
const endDate = new Date(+endAt);
|
||||
|
||||
const data = await getEventDataEvents(websiteId, {
|
||||
const data = await getSessionDataValues(websiteId, {
|
||||
startDate,
|
||||
endDate,
|
||||
event,
|
||||
propertyName,
|
||||
});
|
||||
|
||||
return json(data);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue