refactor: change tracker path
This commit is contained in:
parent
b9d9391342
commit
e53de57720
@ -43,7 +43,7 @@ websiteRouter.post(
|
|||||||
.matches(/event|identify/i)
|
.matches(/event|identify/i)
|
||||||
),
|
),
|
||||||
async (req, res) => {
|
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 { type, payload } = req.body;
|
||||||
const {
|
const {
|
||||||
|
@ -47,10 +47,11 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
const getPath = (url) => {
|
const getPath = (url) => {
|
||||||
if (url.substring(0, 4) === 'http') {
|
try {
|
||||||
return '/' + url.split('/').splice(3).join('/');
|
return new URL(url).pathname;
|
||||||
|
} catch (e) {
|
||||||
|
return url;
|
||||||
}
|
}
|
||||||
return url;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getPayload = () => ({
|
const getPayload = () => ({
|
||||||
@ -199,7 +200,8 @@
|
|||||||
headers,
|
headers,
|
||||||
})
|
})
|
||||||
.then((res) => res.text())
|
.then((res) => res.text())
|
||||||
.then((text) => (cache = text));
|
.then((text) => (cache = text))
|
||||||
|
.catch(() => {});
|
||||||
};
|
};
|
||||||
|
|
||||||
const track = (obj, data) => {
|
const track = (obj, data) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user