Added action to telemetry payload.

This commit is contained in:
Mike Cao 2022-03-18 22:39:39 -07:00
parent 7cf0927741
commit 5b1eb8bec2
3 changed files with 30 additions and 31 deletions

View File

@ -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');
} }
} }

View File

@ -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');
} }
} }

View File

@ -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,13 +19,13 @@ 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: isDocker } = await import('is-docker');
const { default: fetch } = await import('node-fetch'); const { default: fetch } = await import('node-fetch');
await fs.writeJSON(dest, { version: pkg.version });
const payload = { const payload = {
action,
version: pkg.version, version: pkg.version,
node: process.version, node: process.version,
platform: os.platform(), platform: os.platform(),
@ -50,7 +50,6 @@ async function sendTelemetry() {
{ minTimeout: 500, retries: 1, factor: 1 }, { minTimeout: 500, retries: 1, factor: 1 },
).catch(() => {}); ).catch(() => {});
} }
}
module.exports = { module.exports = {
sendTelemetry, sendTelemetry,