mirror of
https://github.com/umami-software/umami.git
synced 2026-02-04 04:37:11 +01:00
Rename ref to prevent collision with react elements
It seems that, at least in dev mode, 'ref' may incorrectly refer to react elements. Signed-off-by: Kevin Decherf <kevin@kdecherf.com>
This commit is contained in:
parent
2b4ddb5388
commit
ecfc7ea68e
6 changed files with 27 additions and 22 deletions
|
|
@ -49,8 +49,10 @@ export const refFilter = (data, { domain, domainOnly, raw }) => {
|
|||
const regex = new RegExp(`http[s]?://([a-z0-9-]+\\.)*${domain}`);
|
||||
const links = {};
|
||||
|
||||
const isValidRef = ref => {
|
||||
return ref !== '' && ref !== null && !ref.startsWith('/') && !ref.startsWith('#');
|
||||
const isValidRef = referrer => {
|
||||
return (
|
||||
referrer !== '' && referrer !== null && !referrer.startsWith('/') && !referrer.startsWith('#')
|
||||
);
|
||||
};
|
||||
|
||||
const cleanUrl = url => {
|
||||
|
|
@ -71,8 +73,8 @@ export const refFilter = (data, { domain, domainOnly, raw }) => {
|
|||
|
||||
if (protocol.startsWith('http')) {
|
||||
const path = removeTrailingSlash(pathname);
|
||||
const ref = searchParams.get('ref');
|
||||
const query = ref ? `?ref=${ref}` : '';
|
||||
const referrer = searchParams.get('ref');
|
||||
const query = referrer ? `?referrer=${referrer}` : '';
|
||||
|
||||
return removeTrailingSlash(`${removeWWW(hostname)}${path}`) + query;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -335,7 +335,7 @@ export async function getEvents(websites, start_at) {
|
|||
|
||||
export function getWebsiteStats(website_id, start_at, end_at, filters = {}) {
|
||||
const params = [website_id, start_at, end_at];
|
||||
const { url, ref } = filters;
|
||||
const { url, referrer } = filters;
|
||||
let urlFilter = '';
|
||||
let refFilter = '';
|
||||
|
||||
|
|
@ -344,9 +344,9 @@ export function getWebsiteStats(website_id, start_at, end_at, filters = {}) {
|
|||
params.push(decodeURIComponent(url));
|
||||
}
|
||||
|
||||
if (ref) {
|
||||
if (referrer) {
|
||||
refFilter = `and referrer like $${params.length + 1}`;
|
||||
params.push(`%${decodeURIComponent(ref)}%`);
|
||||
params.push(`%${decodeURIComponent(referrer)}%`);
|
||||
}
|
||||
|
||||
return rawQuery(
|
||||
|
|
@ -382,7 +382,7 @@ export function getPageviewStats(
|
|||
filters = {},
|
||||
) {
|
||||
const params = [website_id, start_at, end_at];
|
||||
const { url, ref } = filters;
|
||||
const { url, referrer } = filters;
|
||||
|
||||
let urlFilter = '';
|
||||
let refFilter = '';
|
||||
|
|
@ -392,9 +392,9 @@ export function getPageviewStats(
|
|||
params.push(decodeURIComponent(url));
|
||||
}
|
||||
|
||||
if (ref) {
|
||||
if (referrer) {
|
||||
refFilter = `and referrer like $${params.length + 1}`;
|
||||
params.push(`%${decodeURIComponent(ref)}%`);
|
||||
params.push(`%${decodeURIComponent(referrer)}%`);
|
||||
}
|
||||
|
||||
return rawQuery(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue