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

This commit is contained in:
Mike Cao 2025-02-13 19:30:06 -08:00
commit 0793407b0b
4 changed files with 15 additions and 14 deletions

View file

@ -29,6 +29,7 @@ export async function GET(request: Request) {
export async function POST(request: Request) { export async function POST(request: Request) {
const schema = z.object({ const schema = z.object({
currency: z.string(),
...reportParms, ...reportParms,
timezone: timezoneParam, timezone: timezoneParam,
}); });

View file

@ -131,35 +131,35 @@ function getChannels(data: { domain: string; query: string; visitors: number }[]
for (const { domain, query, visitors } of data) { for (const { domain, query, visitors } of data) {
if (!domain && !query) { if (!domain && !query) {
channels.direct += visitors; channels.direct += Number(visitors);
} }
const prefix = /utm_medium=(.*cp.*|ppc|retargeting|paid.*)/.test(query) ? 'paid' : 'organic'; const prefix = /utm_medium=(.*cp.*|ppc|retargeting|paid.*)/.test(query) ? 'paid' : 'organic';
if (SEARCH_DOMAINS.some(match(domain)) || /utm_medium=organic/.test(query)) { if (SEARCH_DOMAINS.some(match(domain)) || /utm_medium=organic/.test(query)) {
channels[`${prefix}Search`] += visitors; channels[`${prefix}Search`] += Number(visitors);
} else if ( } else if (
SOCIAL_DOMAINS.some(match(domain)) || SOCIAL_DOMAINS.some(match(domain)) ||
/utm_medium=(social|social-network|social-media|sm|social network|social media)/.test(query) /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)) { } else if (EMAIL_DOMAINS.some(match(domain)) || /utm_medium=(.*e[-_ ]?mail.*)/.test(query)) {
channels.email += visitors; channels.email += Number(visitors);
} else if ( } else if (
SHOPPING_DOMAINS.some(match(domain)) || SHOPPING_DOMAINS.some(match(domain)) ||
/utm_campaign=(.*(([^a-df-z]|^)shop|shopping).*)/.test(query) /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)) { } 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))) { } else if (PAID_AD_PARAMS.some(match(query))) {
channels.paidAds += visitors; channels.paidAds += Number(visitors);
} else if (/utm_medium=(referral|app|link)/.test(query)) { } else if (/utm_medium=(referral|app|link)/.test(query)) {
channels.referral += visitors; channels.referral += Number(visitors);
} else if (/utm_medium=affiliate/.test(query)) { } else if (/utm_medium=affiliate/.test(query)) {
channels.affiliate += visitors; channels.affiliate += Number(visitors);
} else if (/utm_(source|medium)=sms/.test(query)) { } else if (/utm_(source|medium)=sms/.test(query)) {
channels.sms += visitors; channels.sms += Number(visitors);
} }
} }

View file

@ -14,12 +14,12 @@ export function WebsiteSelect({
onSelect?: (key: any) => void; onSelect?: (key: any) => void;
}) { }) {
const { formatMessage, labels, messages } = useMessages(); const { formatMessage, labels, messages } = useMessages();
const [query, setQuery] = useState(''); const [search, setSearch] = useState('');
const [selectedId, setSelectedId] = useState<Key>(websiteId); const [selectedId, setSelectedId] = useState<Key>(websiteId);
const { data: website } = useWebsite(selectedId as string); const { data: website } = useWebsite(selectedId as string);
const queryResult = useWebsites({ teamId }, { query, pageSize: 5 }); const queryResult = useWebsites({ teamId }, { search, pageSize: 5 });
const renderValue = () => { const renderValue = () => {
return website?.name; return website?.name;
@ -35,7 +35,7 @@ export function WebsiteSelect({
}; };
const handleSearch = (value: string) => { const handleSearch = (value: string) => {
setQuery(value); setSearch(value);
}; };
return ( return (

View file

@ -29,7 +29,7 @@ async function relationalQuery(
from website_event e from website_event e
join session_data d join session_data d
on d.session_id = e.session_id on d.session_id = e.session_id
where e.website_id = {{websiteId:uuid}} where e.website_id = {{websiteId::uuid}}
and e.created_at between {{startDate}} and {{endDate}} and e.created_at between {{startDate}} and {{endDate}}
${filterQuery} ${filterQuery}
group by 1 group by 1