From 0b4e4d77f0d2639877aa66c26ea8ef6494d60f68 Mon Sep 17 00:00:00 2001 From: Josh-Walker-GM <56300765+Josh-Walker-GM@users.noreply.github.com> Date: Wed, 19 Apr 2023 21:18:46 +0100 Subject: [PATCH] Enable telemetry mock server and check only that packets are received --- .github/actions/telemetry_check/check.mjs | 47 ++------------------ packages/create-redwood-app/src/telemetry.js | 4 +- 2 files changed, 6 insertions(+), 45 deletions(-) diff --git a/.github/actions/telemetry_check/check.mjs b/.github/actions/telemetry_check/check.mjs index 52837b76f7f5..31327059c0ac 100644 --- a/.github/actions/telemetry_check/check.mjs +++ b/.github/actions/telemetry_check/check.mjs @@ -8,28 +8,6 @@ console.log( `Telemetry is being redirected to ${process.env.REDWOOD_REDIRECT_TELEMETRY}` ) -// All the fields we expect inside a telemetry packet -const expectedPacketFields = [ - 'type', - 'command', - 'duration', - 'uid', - 'ci', - 'redwoodCi', - 'NODE_ENV', - 'os', - 'osVersion', - // "shell", // Not expected on windows - 'nodeVersion', - 'yarnVersion', - 'npmVersion', - 'redwoodVersion', - 'system', - 'complexity', - 'sides', - 'webBundler', -] - // Setup fake telemetry server const server = http.createServer((req, res) => { let data = '' @@ -39,27 +17,8 @@ const server = http.createServer((req, res) => { req.on('end', () => { res.writeHead(200) res.end() - - const packet = JSON.parse(data) - - let hasAllFields = true - for (const field of expectedPacketFields) { - if (packet[field] === undefined) { - hasAllFields = false - console.error(`Telemetry packet is missing field "${field}"`) - } - } - - const isCI = packet.ci ?? false - - if (hasAllFields && isCI) { - console.log('Valid telemetry received') - process.exit(0) - } else { - console.error('Invalid telemetry received') - console.error(packet) - process.exit(1) - } + console.log('Telemetry packet received') + process.exit(0) }) }) @@ -77,7 +36,7 @@ try { switch (mode) { case 'crwa': exitCode = await exec( - `yarn node ./packages/create-redwood-app/dist/create-redwood-app.js ../project-for-telemetry --typescript false --git false --yarn-install true` + `yarn node ./packages/create-redwood-app/dist/create-redwood-app.js ../project-for-telemetry --typescript true --git false --yarn-install true` ) if (exitCode) { process.exit(1) diff --git a/packages/create-redwood-app/src/telemetry.js b/packages/create-redwood-app/src/telemetry.js index 3bff4368b547..b7f59880bcac 100644 --- a/packages/create-redwood-app/src/telemetry.js +++ b/packages/create-redwood-app/src/telemetry.js @@ -80,7 +80,9 @@ export async function startTelemetry() { }) traceExporter = new OTLPTraceExporter({ // TODO: Point this to somewhere permanent - url: 'https://master-axolotl.telemetry-analytics-jgmw.c66.me/v1/traces', + url: + process.env.REDWOOD_REDIRECT_TELEMETRY || + 'https://master-axolotl.telemetry-analytics-jgmw.c66.me/v1/traces', }) traceProcessor = new BatchSpanProcessor(traceExporter) traceProvider.addSpanProcessor(traceProcessor)