MCPcopy Index your code
hub / github.com/zenstackhq/zenstack / Telemetry

Class Telemetry

packages/cli/src/telemetry.ts:29–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27 * Utility class for sending telemetry
28 */
29export class Telemetry {
30 private readonly mixpanel: Mixpanel | undefined;
31 private readonly hostId = getMachineId();
32 private readonly sessionid = randomUUID();
33 private readonly _os_type = os.type();
34 private readonly _os_release = os.release();
35 private readonly _os_arch = os.arch();
36 private readonly _os_version = os.version();
37 private readonly _os_platform = os.platform();
38 private readonly version = getVersion();
39 private readonly prismaVersion = this.getPrismaVersion();
40 private readonly isDocker = isDocker();
41 private readonly isWsl = isWsl();
42 private readonly isContainer = isInContainer();
43 private readonly isCi = isInCi;
44
45 constructor() {
46 // if (process.env['DO_NOT_TRACK'] !== '1' && TELEMETRY_TRACKING_TOKEN) {
47 // this.mixpanel = init(TELEMETRY_TRACKING_TOKEN, {
48 // geolocate: true,
49 // });
50 // }
51
52 // Telemetry is currently muted
53 return;
54 }
55
56 get isTracking() {
57 return !!this.mixpanel;
58 }
59
60 track(event: TelemetryEvents, properties: Record<string, unknown> = {}) {
61 if (this.mixpanel) {
62 const payload = {
63 distinct_id: this.hostId,
64 session: this.sessionid,
65 time: new Date(),
66 $os: this._os_type,
67 osType: this._os_type,
68 osRelease: this._os_release,
69 osPlatform: this._os_platform,
70 osArch: this._os_arch,
71 osVersion: this._os_version,
72 nodeVersion: process.version,
73 version: this.version,
74 prismaVersion: this.prismaVersion,
75 isDocker: this.isDocker,
76 isWsl: this.isWsl,
77 isContainer: this.isContainer,
78 isCi: this.isCi,
79 ...properties,
80 };
81 this.mixpanel.track(event, payload);
82 }
83 }
84
85 trackError(err: Error) {
86 this.track('cli:error', {

Callers

nothing calls this directly

Calls 6

getPrismaVersionMethod · 0.95
getMachineIdFunction · 0.90
getVersionFunction · 0.90
isWslFunction · 0.90
isInContainerFunction · 0.90
isDockerFunction · 0.85

Tested by

no test coverage detected