blob: b19e99f1f9c0fca24f5fe7bde074f81c8fd20a40 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
import { CURRENT_VERSION, TELEMETRY_PIXEL } from '@/lib/constants';
export async function GET() {
if (
process.env.NODE_ENV !== 'production' ||
process.env.DISABLE_TELEMETRY ||
process.env.PRIVATE_MODE
) {
return new Response('/* telemetry disabled */', {
headers: {
'content-type': 'text/javascript',
},
});
}
const script = `
(()=>{const i=document.createElement('img');
i.setAttribute('src','${TELEMETRY_PIXEL}?v=${CURRENT_VERSION}');
i.setAttribute('style','width:0;height:0;position:absolute;pointer-events:none;');
document.body.appendChild(i);})();
`;
return new Response(script.replace(/\s\s+/g, ''), {
headers: {
'content-type': 'text/javascript',
},
});
}
|