@mintlify/cli 4.0.1067 → 4.0.1068
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/__test__/telemetry.test.ts +313 -0
- package/__test__/utils.ts +11 -6
- package/bin/cli.js +19 -1
- package/bin/config.js +42 -0
- package/bin/constants.js +4 -0
- package/bin/helpers.js +2 -0
- package/bin/start.js +32 -1
- package/bin/telemetry/client.js +39 -0
- package/bin/telemetry/distinctId.js +62 -0
- package/bin/telemetry/middleware.js +39 -0
- package/bin/telemetry/track.js +65 -0
- package/bin/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/src/cli.tsx +19 -1
- package/src/config.ts +34 -0
- package/src/constants.ts +5 -0
- package/src/helpers.tsx +2 -0
- package/src/start.ts +22 -1
- package/src/telemetry/client.ts +31 -0
- package/src/telemetry/distinctId.ts +62 -0
- package/src/telemetry/middleware.ts +29 -0
- package/src/telemetry/track.ts +60 -0
- package/vitest.config.ts +1 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import os from 'os';
|
|
11
|
+
import { isTelemetryEnabled } from '../config.js';
|
|
12
|
+
import { TELEMETRY_ASYNC_TIMEOUT_MS } from '../constants.js';
|
|
13
|
+
import { getVersions } from '../helpers.js';
|
|
14
|
+
import { getPostHogClient } from './client.js';
|
|
15
|
+
import { getDistinctId } from './distinctId.js';
|
|
16
|
+
function captureWithTimeout(event, properties) {
|
|
17
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
18
|
+
yield Promise.race([
|
|
19
|
+
getPostHogClient()
|
|
20
|
+
.captureImmediate({
|
|
21
|
+
distinctId: getDistinctId(),
|
|
22
|
+
event,
|
|
23
|
+
properties,
|
|
24
|
+
})
|
|
25
|
+
.catch(() => { }),
|
|
26
|
+
new Promise((resolve) => {
|
|
27
|
+
const t = setTimeout(resolve, TELEMETRY_ASYNC_TIMEOUT_MS);
|
|
28
|
+
t.unref();
|
|
29
|
+
}),
|
|
30
|
+
]);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
export function trackCommand(_a) {
|
|
34
|
+
return __awaiter(this, arguments, void 0, function* ({ command, cliVersion }) {
|
|
35
|
+
if (!isTelemetryEnabled())
|
|
36
|
+
return;
|
|
37
|
+
try {
|
|
38
|
+
yield captureWithTimeout('cli.command.executed', {
|
|
39
|
+
command,
|
|
40
|
+
cli_version: cliVersion,
|
|
41
|
+
os: os.platform(),
|
|
42
|
+
arch: os.arch(),
|
|
43
|
+
node_version: process.version,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
catch (_b) { }
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
export function trackTelemetryPreferenceChange(options) {
|
|
50
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
51
|
+
if (process.env.CLI_TEST_MODE === 'true')
|
|
52
|
+
return;
|
|
53
|
+
try {
|
|
54
|
+
const { cli: cliVersion } = getVersions();
|
|
55
|
+
yield captureWithTimeout('cli.telemetry.preference_changed', {
|
|
56
|
+
enabled: options.enabled,
|
|
57
|
+
cli_version: cliVersion,
|
|
58
|
+
os: os.platform(),
|
|
59
|
+
arch: os.arch(),
|
|
60
|
+
node_version: process.version,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
catch (_a) { }
|
|
64
|
+
});
|
|
65
|
+
}
|