mirror of
https://github.com/kremalicious/umami.git
synced 2025-02-14 21:10:34 +01:00
Cleaned up script.
This commit is contained in:
parent
9969c9b6b1
commit
1662b66fbb
@ -2,17 +2,17 @@ import { TELEMETRY_PIXEL } from 'lib/constants';
|
|||||||
|
|
||||||
export default function handler(req, res) {
|
export default function handler(req, res) {
|
||||||
const { v } = req.query;
|
const { v } = req.query;
|
||||||
|
const script = `
|
||||||
|
(()=>{const i=document.createElement('img');
|
||||||
|
i.setAttribute('src','${TELEMETRY_PIXEL}?v=${v}');
|
||||||
|
i.setAttribute('style','width:0;height:0;position:absolute;pointer-events:none;');
|
||||||
|
document.body.appendChild(i);})();
|
||||||
|
`;
|
||||||
|
|
||||||
res.setHeader('content-type', 'text/javascript');
|
res.setHeader('content-type', 'text/javascript');
|
||||||
if (process.env.DISABLE_TELEMETRY) {
|
if (process.env.DISABLE_TELEMETRY) {
|
||||||
res.send('/* telemetry disabled */');
|
res.send('/* telemetry disabled */');
|
||||||
} else {
|
} else {
|
||||||
res.send(
|
res.send(script.replace(/\s\s+/g, ''));
|
||||||
`(() => {
|
|
||||||
const i = document.createElement('img');
|
|
||||||
i.setAttribute('src','${TELEMETRY_PIXEL}?v=${v}');
|
|
||||||
i.setAttribute('style','width:0;height:0;position:absolute;pointer-events:none;');
|
|
||||||
document.body.appendChild(i);
|
|
||||||
})();`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user