Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

Cleaned up script.

Mike Cao1662b66fbbdf
diff --git a/pages/api/scripts/telemetry.js b/pages/api/scripts/telemetry.js
index 4b9ebde12..f264a1fee 100644
--- a/pages/api/scripts/telemetry.js
+++ b/pages/api/scripts/telemetry.js
@@ -2,17 +2,17 @@ import { TELEMETRY_PIXEL } from 'lib/constants';
export default function handler(req, res) {
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');
if (process.env.DISABLE_TELEMETRY) {
res.send('/* telemetry disabled */');
} else {
- res.send(
- `(() => {
- 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.send(script.replace(/\s\s+/g, ''));
}
}