Skip to content

chore: add isWsl in telemetry #2172

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions packages/schema/src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 18 additions & 0 deletions packages/schema/src/utils/is-wsl.ts
Original file line number Diff line number Diff line change
@@ -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;
}
};
Loading