Skip to content

fix: remove warning in vercel environment #954

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
Jan 22, 2024
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
4 changes: 2 additions & 2 deletions packages/schema/src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ import { getPrismaVersion } from '@zenstackhq/sdk';
import exitHook from 'async-exit-hook';
import { CommanderError } from 'commander';
import { init, Mixpanel } from 'mixpanel';
import { machineIdSync } from 'node-machine-id';
import * as os from 'os';
import sleep from 'sleep-promise';
import { CliError } from './cli/cli-error';
import { TELEMETRY_TRACKING_TOKEN } from './constants';
import isDocker from './utils/is-docker';
import { getVersion } from './utils/version-utils';
import { getMachineId } from './utils/machine-id-utils';

/**
* Telemetry events
Expand All @@ -32,7 +32,7 @@ export type TelemetryEvents =
*/
export class Telemetry {
private readonly mixpanel: Mixpanel | undefined;
private readonly hostId = machineIdSync();
private readonly hostId = getMachineId();
private readonly sessionid = createId();
private readonly _os_type = os.type();
private readonly _os_release = os.release();
Expand Down
11 changes: 11 additions & 0 deletions packages/schema/src/utils/machine-id-utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { machineIdSync } from "node-machine-id";
import { v4 as uuid } from 'uuid';

export function getMachineId() {
// machineIdSync() is not compatible with non-shell hosts such as Vercel
try {
return machineIdSync();
} catch {
return uuid();
}
}
21 changes: 11 additions & 10 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.