mirror of
https://github.com/umami-software/umami.git
synced 2025-12-06 01:18:00 +01:00
Updates to insights, event data, telemetry.
This commit is contained in:
parent
39562d4a64
commit
e4bd314bd6
44 changed files with 413 additions and 278 deletions
|
|
@ -1,40 +1,24 @@
|
|||
const fs = require('fs-extra');
|
||||
const path = require('path');
|
||||
const os = require('os');
|
||||
const isCI = require('is-ci');
|
||||
const pkg = require('../package.json');
|
||||
|
||||
const dest = path.resolve(__dirname, '../.next/cache/umami.json');
|
||||
const url = 'https://api.umami.is/v1/telemetry';
|
||||
|
||||
async function sendTelemetry(action) {
|
||||
let json = {};
|
||||
|
||||
try {
|
||||
json = await fs.readJSON(dest);
|
||||
} catch {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
try {
|
||||
await fs.writeJSON(dest, { version: pkg.version });
|
||||
} catch {
|
||||
// Ignore
|
||||
}
|
||||
|
||||
async function sendTelemetry(type) {
|
||||
const { default: isDocker } = await import('is-docker');
|
||||
const { default: fetch } = await import('node-fetch');
|
||||
|
||||
const payload = {
|
||||
action,
|
||||
version: pkg.version,
|
||||
node: process.version,
|
||||
platform: os.platform(),
|
||||
arch: os.arch(),
|
||||
os: `${os.type()} (${os.version()})`,
|
||||
isDocker: isDocker(),
|
||||
isCi: isCI,
|
||||
prevVersion: json.version,
|
||||
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 {
|
||||
|
|
@ -44,7 +28,7 @@ async function sendTelemetry(action) {
|
|||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: JSON.stringify(payload),
|
||||
body: JSON.stringify(data),
|
||||
});
|
||||
} catch {
|
||||
// Ignore
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue