diff --git a/packages/schema/src/telemetry.ts b/packages/schema/src/telemetry.ts index f0a0afe5f..e00557347 100644 --- a/packages/schema/src/telemetry.ts +++ b/packages/schema/src/telemetry.ts @@ -8,6 +8,7 @@ import * as os from 'os'; import { CliError } from './cli/cli-error'; import { TELEMETRY_TRACKING_TOKEN } from './constants'; import isDocker from './utils/is-docker'; +import { isWsl } from './utils/is-wsl'; import { getMachineId } from './utils/machine-id-utils'; import { getVersion } from './utils/version-utils'; @@ -42,6 +43,7 @@ export class Telemetry { private readonly version = getVersion(); private readonly prismaVersion = getPrismaVersion(); private readonly isDocker = isDocker(); + private readonly isWsl = isWsl(); private exitWait = 200; constructor() { @@ -105,6 +107,7 @@ export class Telemetry { version: this.version, prismaVersion: this.prismaVersion, isDocker: this.isDocker, + isWsl: this.isWsl, ...properties, }; this.mixpanel.track(event, payload); diff --git a/packages/schema/src/utils/is-wsl.ts b/packages/schema/src/utils/is-wsl.ts new file mode 100644 index 000000000..564c68076 --- /dev/null +++ b/packages/schema/src/utils/is-wsl.ts @@ -0,0 +1,18 @@ +import process from 'node:process'; +import os from 'node:os'; +import fs from 'node:fs'; +export const isWsl = () => { + if (process.platform !== 'linux') { + return false; + } + + if (os.release().toLowerCase().includes('microsoft')) { + return true; + } + + try { + return fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft'); + } catch { + return false; + } +}; \ No newline at end of file