diff --git a/packages/telemetry/src/telemetry.ts b/packages/telemetry/src/telemetry.ts index b06ff6d33ff0..cd863cd7a218 100644 --- a/packages/telemetry/src/telemetry.ts +++ b/packages/telemetry/src/telemetry.ts @@ -1,4 +1,5 @@ import { spawn } from 'child_process' +import os from 'node:os' import path from 'path' import { getPaths } from '@redwoodjs/internal' @@ -43,8 +44,14 @@ export const timedTelemetry = async ( return result } +// Returns 'Windows_NT' on Windows. +// See https://nodejs.org/docs/latest-v12.x/api/os.html#os_os_type. +const isWindows = os.type() === 'Windows_NT' + export const errorTelemetry = async (argv: Array, error: any) => { - if (process.env.REDWOOD_DISABLE_TELEMETRY) { + // FIXME: on Windows, cmd opens and closes a few times. + // See https://github.com/redwoodjs/redwood/issues/5728. + if (isWindows || process.env.REDWOOD_DISABLE_TELEMETRY) { return } @@ -53,7 +60,9 @@ export const errorTelemetry = async (argv: Array, error: any) => { // used as yargs middleware when any command is invoked export const telemetryMiddleware = async () => { - if (process.env.REDWOOD_DISABLE_TELEMETRY) { + // FIXME: on Windows, cmd opens and closes a few times. + // See https://github.com/redwoodjs/redwood/issues/5728. + if (isWindows || process.env.REDWOOD_DISABLE_TELEMETRY) { return }