refactor: change tracker path

This commit is contained in:
moonrailgun 2023-10-29 01:26:02 +08:00
parent b9d9391342
commit e53de57720
2 changed files with 7 additions and 5 deletions

View File

@ -43,7 +43,7 @@ websiteRouter.post(
.matches(/event|identify/i)
),
async (req, res) => {
// https://github1s.com/umami-software/umami/blob/master/src/pages/api/send.ts
// Reference: https://github1s.com/umami-software/umami/blob/master/src/pages/api/send.ts
const { type, payload } = req.body;
const {

View File

@ -47,10 +47,11 @@
};
const getPath = (url) => {
if (url.substring(0, 4) === 'http') {
return '/' + url.split('/').splice(3).join('/');
try {
return new URL(url).pathname;
} catch (e) {
return url;
}
return url;
};
const getPayload = () => ({
@ -199,7 +200,8 @@
headers,
})
.then((res) => res.text())
.then((text) => (cache = text));
.then((text) => (cache = text))
.catch(() => {});
};
const track = (obj, data) => {