@mintlify/cli 4.0.1617 → 4.0.1618
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mintlify/cli",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.1618",
|
|
4
4
|
"description": "The Mintlify CLI",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=18.0.0"
|
|
@@ -105,5 +105,5 @@
|
|
|
105
105
|
"vitest": "2.1.9",
|
|
106
106
|
"vitest-mock-process": "1.0.4"
|
|
107
107
|
},
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "4beaa4d9a8f9f1841a3990ea46bd28961a1e5597"
|
|
109
109
|
}
|
|
@@ -32,6 +32,13 @@ function tryPersistId(id: string): void {
|
|
|
32
32
|
fs.writeFileSync(ID_FILE, id, { flag: 'wx' });
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
+
let createdThisRun = false;
|
|
36
|
+
|
|
37
|
+
export function isFirstRun(): boolean {
|
|
38
|
+
getDistinctId();
|
|
39
|
+
return createdThisRun;
|
|
40
|
+
}
|
|
41
|
+
|
|
35
42
|
export function getDistinctId(): string {
|
|
36
43
|
const existing = readValidIdFromFile();
|
|
37
44
|
if (existing) return existing;
|
|
@@ -40,6 +47,7 @@ export function getDistinctId(): string {
|
|
|
40
47
|
|
|
41
48
|
try {
|
|
42
49
|
tryPersistId(randomId);
|
|
50
|
+
createdThisRun = true;
|
|
43
51
|
return readValidIdFromFile() ?? randomId;
|
|
44
52
|
} catch (err) {
|
|
45
53
|
const code = (err as NodeJS.ErrnoException).code;
|
package/src/telemetry/track.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { getVersions } from '../helpers.js';
|
|
|
7
7
|
import { getAccessToken, getUserEmail, storeUserEmail } from '../keyring.js';
|
|
8
8
|
import { fetchCliStatus } from '../status.js';
|
|
9
9
|
import { deferShutdownUntil, getPostHogClient } from './client.js';
|
|
10
|
-
import { getDistinctId } from './distinctId.js';
|
|
10
|
+
import { getDistinctId, isFirstRun } from './distinctId.js';
|
|
11
11
|
|
|
12
12
|
export interface TrackCommandOptions {
|
|
13
13
|
command: string;
|
|
@@ -25,6 +25,7 @@ function getEnvironmentProperties(): Record<string, unknown> {
|
|
|
25
25
|
ai_agent: agent,
|
|
26
26
|
is_ci: isCI(),
|
|
27
27
|
is_tty: Boolean(process.stdin.isTTY),
|
|
28
|
+
is_first_run: isFirstRun(),
|
|
28
29
|
};
|
|
29
30
|
}
|
|
30
31
|
|
|
@@ -47,20 +48,23 @@ async function captureWithTimeout(
|
|
|
47
48
|
]);
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
async function
|
|
51
|
+
async function getIdentity(): Promise<{ loggedIn: boolean; email: string | null }> {
|
|
51
52
|
try {
|
|
52
|
-
const [accessToken, storedEmail] = await Promise.all([
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
const [accessToken, storedEmail] = await Promise.all([
|
|
54
|
+
getAccessToken(),
|
|
55
|
+
getUserEmail().catch(() => null),
|
|
56
|
+
]);
|
|
57
|
+
if (!accessToken) return { loggedIn: false, email: null };
|
|
58
|
+
if (storedEmail) return { loggedIn: true, email: storedEmail };
|
|
55
59
|
|
|
56
60
|
const status = await fetchCliStatus(AbortSignal.timeout(TELEMETRY_IDENTITY_TIMEOUT_MS));
|
|
57
|
-
if (!status.ok) return null;
|
|
61
|
+
if (!status.ok) return { loggedIn: true, email: null };
|
|
58
62
|
|
|
59
63
|
const email = status.status.user.email;
|
|
60
64
|
await storeUserEmail(email).catch(() => {});
|
|
61
|
-
return email;
|
|
65
|
+
return { loggedIn: true, email };
|
|
62
66
|
} catch {
|
|
63
|
-
return null;
|
|
67
|
+
return { loggedIn: false, email: null };
|
|
64
68
|
}
|
|
65
69
|
}
|
|
66
70
|
|
|
@@ -73,11 +77,12 @@ export async function trackCommand({
|
|
|
73
77
|
|
|
74
78
|
const work = (async () => {
|
|
75
79
|
try {
|
|
76
|
-
const email = await
|
|
80
|
+
const { loggedIn, email } = await getIdentity();
|
|
77
81
|
await captureWithTimeout('cli.command.executed', {
|
|
78
82
|
command,
|
|
79
83
|
cli_version: cliVersion,
|
|
80
84
|
...getEnvironmentProperties(),
|
|
85
|
+
is_logged_in: loggedIn,
|
|
81
86
|
subdomain,
|
|
82
87
|
...(email ? { email, $set: { email } } : {}),
|
|
83
88
|
});
|