Skip to content

Commit 0c1b4e3

Browse files
authored
chore: add isWsl in telemetry (#2172)
1 parent 02f458d commit 0c1b4e3

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

packages/schema/src/telemetry.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import * as os from 'os';
88
import { CliError } from './cli/cli-error';
99
import { TELEMETRY_TRACKING_TOKEN } from './constants';
1010
import isDocker from './utils/is-docker';
11+
import { isWsl } from './utils/is-wsl';
1112
import { getMachineId } from './utils/machine-id-utils';
1213
import { getVersion } from './utils/version-utils';
1314

@@ -42,6 +43,7 @@ export class Telemetry {
4243
private readonly version = getVersion();
4344
private readonly prismaVersion = getPrismaVersion();
4445
private readonly isDocker = isDocker();
46+
private readonly isWsl = isWsl();
4547
private exitWait = 200;
4648

4749
constructor() {
@@ -105,6 +107,7 @@ export class Telemetry {
105107
version: this.version,
106108
prismaVersion: this.prismaVersion,
107109
isDocker: this.isDocker,
110+
isWsl: this.isWsl,
108111
...properties,
109112
};
110113
this.mixpanel.track(event, payload);

packages/schema/src/utils/is-wsl.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import process from 'node:process';
2+
import os from 'node:os';
3+
import fs from 'node:fs';
4+
export const isWsl = () => {
5+
if (process.platform !== 'linux') {
6+
return false;
7+
}
8+
9+
if (os.release().toLowerCase().includes('microsoft')) {
10+
return true;
11+
}
12+
13+
try {
14+
return fs.readFileSync('/proc/version', 'utf8').toLowerCase().includes('microsoft');
15+
} catch {
16+
return false;
17+
}
18+
};

0 commit comments

Comments
 (0)