Forgot the actual check.

pull/1387/head
Mike Cao 2022-08-02 00:32:28 -07:00
parent a4a6888248
commit 9969c9b6b1
1 changed files with 7 additions and 3 deletions

View File

@ -3,12 +3,16 @@ 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;
res.setHeader('content-type', 'text/javascript'); res.setHeader('content-type', 'text/javascript');
res.send( if (process.env.DISABLE_TELEMETRY) {
`(() => { res.send('/* telemetry disabled */');
} else {
res.send(
`(() => {
const i = document.createElement('img'); const i = document.createElement('img');
i.setAttribute('src','${TELEMETRY_PIXEL}?v=${v}'); i.setAttribute('src','${TELEMETRY_PIXEL}?v=${v}');
i.setAttribute('style','width:0;height:0;position:absolute;pointer-events:none;'); i.setAttribute('style','width:0;height:0;position:absolute;pointer-events:none;');
document.body.appendChild(i); document.body.appendChild(i);
})();`, })();`,
); );
}
} }