diff options
| author | Fuwn <[email protected]> | 2026-01-24 13:09:50 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2026-01-24 13:09:50 +0000 |
| commit | 396acf3bbbe00a192cb0ea0a9ccf91b1d8d2850b (patch) | |
| tree | b9df4ca6a70db45cfffbae6fdd7252e20fb8e93c /scripts/telemetry.js | |
| download | umami-396acf3bbbe00a192cb0ea0a9ccf91b1d8d2850b.tar.xz umami-396acf3bbbe00a192cb0ea0a9ccf91b1d8d2850b.zip | |
Created from https://vercel.com/new
Diffstat (limited to 'scripts/telemetry.js')
| -rw-r--r-- | scripts/telemetry.js | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/scripts/telemetry.js b/scripts/telemetry.js new file mode 100644 index 0000000..78bf54f --- /dev/null +++ b/scripts/telemetry.js @@ -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 + } +} |