Updated start scripts.

This commit is contained in:
Mike Cao 2022-04-04 14:36:42 -07:00
parent bf5068d32a
commit 76211dc5a2
4 changed files with 19 additions and 35 deletions

View file

@ -1,7 +1,6 @@
const fs = require('fs-extra');
const path = require('path');
const os = require('os');
const retry = require('async-retry');
const isCI = require('is-ci');
const pkg = require('../package.json');
@ -9,8 +8,6 @@ const dest = path.resolve(__dirname, '../.next/cache/umami.json');
const url = 'https://telemetry.umami.is/api/collect';
async function sendTelemetry(action) {
await fs.ensureFile(dest);
let json = {};
try {
@ -19,7 +16,11 @@ async function sendTelemetry(action) {
// Ignore
}
await fs.writeJSON(dest, { version: pkg.version });
try {
await fs.writeJSON(dest, { version: pkg.version });
} catch {
// Ignore
}
const { default: isDocker } = await import('is-docker');
const { default: fetch } = await import('node-fetch');
@ -38,19 +39,14 @@ async function sendTelemetry(action) {
upgrade,
};
await retry(
async () => {
await fetch(url, {
method: 'post',
cache: 'no-cache',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(payload),
});
await fetch(url, {
method: 'post',
cache: 'no-cache',
headers: {
'Content-Type': 'application/json',
},
{ minTimeout: 500, retries: 1, factor: 1 },
).catch(() => {});
body: JSON.stringify(payload),
});
}
module.exports = {