Merge branch 'dev' of https://github.com/umami-software/umami into analytics

This commit is contained in:
Francis Cao 2025-07-23 09:38:59 -07:00
commit e8ff32b063
19 changed files with 244 additions and 33 deletions

View file

@ -44,7 +44,7 @@ async function relationalQuery(
startDate,
endDate,
},
).then(result => parseParameters(result as any[]));
);
}
async function clickhouseQuery(
@ -73,30 +73,5 @@ async function clickhouseQuery(
startDate,
endDate,
},
).then(result => parseParameters(result as any[]));
}
function parseParameters(data: any[]) {
return data.reduce((obj, { url_query, num }) => {
try {
const searchParams = new URLSearchParams(url_query);
for (const [key, value] of searchParams) {
if (key.match(/^utm_(\w+)$/)) {
const name = value;
if (!obj[key]) {
obj[key] = { [name]: Number(num) };
} else if (!obj[key][name]) {
obj[key][name] = Number(num);
} else {
obj[key][name] += Number(num);
}
}
}
} catch {
// Ignore
}
return obj;
}, {});
);
}