mirror of
https://github.com/kremalicious/umami.git
synced 2024-12-24 18:26:20 +01:00
Added action to telemetry payload.
This commit is contained in:
parent
7cf0927741
commit
5b1eb8bec2
@ -3,7 +3,7 @@ const { sendTelemetry } = require('./telemetry');
|
|||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
if (!process.env.DISABLE_TELEMETRY) {
|
if (!process.env.DISABLE_TELEMETRY) {
|
||||||
await sendTelemetry();
|
await sendTelemetry('build');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ const { sendTelemetry } = require('./telemetry');
|
|||||||
|
|
||||||
async function run() {
|
async function run() {
|
||||||
if (!process.env.DISABLE_TELEMETRY) {
|
if (!process.env.DISABLE_TELEMETRY) {
|
||||||
await sendTelemetry();
|
await sendTelemetry('start');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ const pkg = require('../package.json');
|
|||||||
const dest = path.resolve(__dirname, '../.next/cache/umami.json');
|
const dest = path.resolve(__dirname, '../.next/cache/umami.json');
|
||||||
const url = 'https://telemetry.umami.is/api/collect';
|
const url = 'https://telemetry.umami.is/api/collect';
|
||||||
|
|
||||||
async function sendTelemetry() {
|
async function sendTelemetry(action) {
|
||||||
await fs.ensureFile(dest);
|
await fs.ensureFile(dest);
|
||||||
|
|
||||||
let json = {};
|
let json = {};
|
||||||
@ -19,37 +19,36 @@ async function sendTelemetry() {
|
|||||||
// Ignore
|
// Ignore
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json.version !== pkg.version) {
|
await fs.writeJSON(dest, { version: pkg.version });
|
||||||
const { default: isDocker } = await import('is-docker');
|
|
||||||
const { default: fetch } = await import('node-fetch');
|
|
||||||
|
|
||||||
await fs.writeJSON(dest, { version: pkg.version });
|
const { default: isDocker } = await import('is-docker');
|
||||||
|
const { default: fetch } = await import('node-fetch');
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
version: pkg.version,
|
action,
|
||||||
node: process.version,
|
version: pkg.version,
|
||||||
platform: os.platform(),
|
node: process.version,
|
||||||
arch: os.arch(),
|
platform: os.platform(),
|
||||||
os: `${os.type()} (${os.version()})`,
|
arch: os.arch(),
|
||||||
docker: isDocker(),
|
os: `${os.type()} (${os.version()})`,
|
||||||
ci: isCI,
|
docker: isDocker(),
|
||||||
upgrade: json.version || false,
|
ci: isCI,
|
||||||
};
|
upgrade: json.version || false,
|
||||||
|
};
|
||||||
|
|
||||||
await retry(
|
await retry(
|
||||||
async () => {
|
async () => {
|
||||||
await fetch(url, {
|
await fetch(url, {
|
||||||
method: 'post',
|
method: 'post',
|
||||||
cache: 'no-cache',
|
cache: 'no-cache',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify(payload),
|
body: JSON.stringify(payload),
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
{ minTimeout: 500, retries: 1, factor: 1 },
|
{ minTimeout: 500, retries: 1, factor: 1 },
|
||||||
).catch(() => {});
|
).catch(() => {});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
Loading…
Reference in New Issue
Block a user