mirror of
https://github.com/kremalicious/umami.git
synced 2024-11-22 09:57:00 +01:00
41 lines
820 B
JavaScript
41 lines
820 B
JavaScript
const os = require('os');
|
|
const isCI = require('is-ci');
|
|
const pkg = require('../package.json');
|
|
|
|
const url = 'https://api.umami.is/v1/telemetry';
|
|
|
|
async function sendTelemetry(type) {
|
|
const { default: isDocker } = await import('is-docker');
|
|
const { default: fetch } = await import('node-fetch');
|
|
|
|
const data = {
|
|
type,
|
|
payload: {
|
|
version: pkg.version,
|
|
node: process.version,
|
|
platform: os.platform(),
|
|
arch: os.arch(),
|
|
os: `${os.type()} (${os.version()})`,
|
|
isDocker: isDocker(),
|
|
isCi: isCI,
|
|
},
|
|
};
|
|
|
|
try {
|
|
await fetch(url, {
|
|
method: 'post',
|
|
cache: 'no-cache',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify(data),
|
|
});
|
|
} catch {
|
|
// Ignore
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
sendTelemetry,
|
|
};
|