Skip to content

Commit 0aa69d9

Browse files
authored
fix: remove warning in vercel environment (#954)
1 parent f90ef77 commit 0aa69d9

File tree

3 files changed

+24
-12
lines changed

3 files changed

+24
-12
lines changed

packages/schema/src/telemetry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import { getPrismaVersion } from '@zenstackhq/sdk';
33
import exitHook from 'async-exit-hook';
44
import { CommanderError } from 'commander';
55
import { init, Mixpanel } from 'mixpanel';
6-
import { machineIdSync } from 'node-machine-id';
76
import * as os from 'os';
87
import sleep from 'sleep-promise';
98
import { CliError } from './cli/cli-error';
109
import { TELEMETRY_TRACKING_TOKEN } from './constants';
1110
import isDocker from './utils/is-docker';
1211
import { getVersion } from './utils/version-utils';
12+
import { getMachineId } from './utils/machine-id-utils';
1313

1414
/**
1515
* Telemetry events
@@ -32,7 +32,7 @@ export type TelemetryEvents =
3232
*/
3333
export class Telemetry {
3434
private readonly mixpanel: Mixpanel | undefined;
35-
private readonly hostId = machineIdSync();
35+
private readonly hostId = getMachineId();
3636
private readonly sessionid = createId();
3737
private readonly _os_type = os.type();
3838
private readonly _os_release = os.release();
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { machineIdSync } from "node-machine-id";
2+
import { v4 as uuid } from 'uuid';
3+
4+
export function getMachineId() {
5+
// machineIdSync() is not compatible with non-shell hosts such as Vercel
6+
try {
7+
return machineIdSync();
8+
} catch {
9+
return uuid();
10+
}
11+
}

pnpm-lock.yaml

Lines changed: 11 additions & 10 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)