Merge branch 'master' of https://github.com/umami-software/umami into francis/uc-24-kafka-test

This commit is contained in:
Francis Cao 2022-08-18 16:54:57 -07:00
commit 295ce2487d
20 changed files with 206 additions and 175 deletions

View file

@ -1,18 +1,18 @@
import { TELEMETRY_PIXEL } from 'lib/constants';
import { CURRENT_VERSION, TELEMETRY_PIXEL } from 'lib/constants';
export default function handler(req, res) {
const { v } = req.query;
res.setHeader('content-type', 'text/javascript');
if (process.env.DISABLE_TELEMETRY) {
return res.send('/* telemetry disabled */');
}
const script = `
(()=>{const i=document.createElement('img');
i.setAttribute('src','${TELEMETRY_PIXEL}?v=${v}');
i.setAttribute('src','${TELEMETRY_PIXEL}?v=${CURRENT_VERSION}');
i.setAttribute('style','width:0;height:0;position:absolute;pointer-events:none;');
document.body.appendChild(i);})();
`;
res.setHeader('content-type', 'text/javascript');
if (process.env.DISABLE_TELEMETRY) {
res.send('/* telemetry disabled */');
} else {
res.send(script.replace(/\s\s+/g, ''));
}
return res.send(script.replace(/\s\s+/g, ''));
}