mirror of
https://github.com/umami-software/umami.git
synced 2025-12-08 05:12:36 +01:00
Switched to type: module.
This commit is contained in:
parent
615a6d444f
commit
4e37e10b6d
20 changed files with 25 additions and 50 deletions
40
scripts/telemetry.js
Normal file
40
scripts/telemetry.js
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import os from 'node:os';
|
||||
import path from 'node:path';
|
||||
import isCI from 'is-ci';
|
||||
import { createRequire } from 'module';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const pkg = require(path.resolve(process.cwd(), 'package.json'));
|
||||
|
||||
const url = 'https://api.umami.is/v1/telemetry';
|
||||
|
||||
export 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()}`,
|
||||
is_docker: isDocker(),
|
||||
is_ci: isCI,
|
||||
},
|
||||
};
|
||||
|
||||
try {
|
||||
await fetch(url, {
|
||||
method: 'post',
|
||||
cache: 'no-cache',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
} catch {
|
||||
// Ignore
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue