mirror of https://github.com/node-red/node-red.git
Import the got module only once + fix console statement
parent
30215b02ac
commit
bb49fc6c16
|
@ -6,6 +6,9 @@ const cronosjs = require('cronosjs')
|
||||||
const METRICS_DIR = path.join(__dirname, 'metrics')
|
const METRICS_DIR = path.join(__dirname, 'metrics')
|
||||||
const INITIAL_PING_DELAY = 1000 * 60 * 30 // 30 minutes from startup
|
const INITIAL_PING_DELAY = 1000 * 60 * 30 // 30 minutes from startup
|
||||||
|
|
||||||
|
/** @type {import("got").Got | undefined} */
|
||||||
|
let got
|
||||||
|
|
||||||
let runtime
|
let runtime
|
||||||
|
|
||||||
let scheduleTask
|
let scheduleTask
|
||||||
|
@ -48,11 +51,14 @@ async function report () {
|
||||||
}
|
}
|
||||||
// If enabled, gather metrics
|
// If enabled, gather metrics
|
||||||
const metrics = await gather()
|
const metrics = await gather()
|
||||||
console.log(JSON.stringify(metrics, null, 2))
|
runtime.log.debug(`Telemetry metrics: ${JSON.stringify(metrics, null, 2)}`)
|
||||||
|
|
||||||
// Post metrics to endpoint - handle any error silently
|
// Post metrics to endpoint - handle any error silently
|
||||||
|
|
||||||
const { got } = await import('got')
|
if (!got) {
|
||||||
|
got = (await import('got')).got
|
||||||
|
}
|
||||||
|
|
||||||
runtime.log.debug('Sending telemetry')
|
runtime.log.debug('Sending telemetry')
|
||||||
const response = await got.post('https://telemetry.nodered.org/ping', {
|
const response = await got.post('https://telemetry.nodered.org/ping', {
|
||||||
json: metrics,
|
json: metrics,
|
||||||
|
|
Loading…
Reference in New Issue