@mintlify/cli 4.0.1617 → 4.0.1619
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.
|
@@ -29,6 +29,11 @@ function tryPersistId(id) {
|
|
|
29
29
|
fs.mkdirSync(path.dirname(ID_FILE), { recursive: true });
|
|
30
30
|
fs.writeFileSync(ID_FILE, id, { flag: 'wx' });
|
|
31
31
|
}
|
|
32
|
+
let createdThisRun = false;
|
|
33
|
+
export function isFirstRun() {
|
|
34
|
+
getDistinctId();
|
|
35
|
+
return createdThisRun;
|
|
36
|
+
}
|
|
32
37
|
export function getDistinctId() {
|
|
33
38
|
var _a, _b, _c;
|
|
34
39
|
const existing = readValidIdFromFile();
|
|
@@ -37,6 +42,7 @@ export function getDistinctId() {
|
|
|
37
42
|
const randomId = crypto.randomUUID();
|
|
38
43
|
try {
|
|
39
44
|
tryPersistId(randomId);
|
|
45
|
+
createdThisRun = true;
|
|
40
46
|
return (_a = readValidIdFromFile()) !== null && _a !== void 0 ? _a : randomId;
|
|
41
47
|
}
|
|
42
48
|
catch (err) {
|
package/bin/telemetry/track.js
CHANGED
|
@@ -15,7 +15,7 @@ import { getVersions } from '../helpers.js';
|
|
|
15
15
|
import { getAccessToken, getUserEmail, storeUserEmail } from '../keyring.js';
|
|
16
16
|
import { fetchCliStatus } from '../status.js';
|
|
17
17
|
import { deferShutdownUntil, getPostHogClient } from './client.js';
|
|
18
|
-
import { getDistinctId } from './distinctId.js';
|
|
18
|
+
import { getDistinctId, isFirstRun } from './distinctId.js';
|
|
19
19
|
function getEnvironmentProperties() {
|
|
20
20
|
const agent = detectAgent();
|
|
21
21
|
return {
|
|
@@ -26,6 +26,7 @@ function getEnvironmentProperties() {
|
|
|
26
26
|
ai_agent: agent,
|
|
27
27
|
is_ci: isCI(),
|
|
28
28
|
is_tty: Boolean(process.stdin.isTTY),
|
|
29
|
+
is_first_run: isFirstRun(),
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
32
|
function captureWithTimeout(event, properties) {
|
|
@@ -45,23 +46,26 @@ function captureWithTimeout(event, properties) {
|
|
|
45
46
|
]);
|
|
46
47
|
});
|
|
47
48
|
}
|
|
48
|
-
function
|
|
49
|
+
function getIdentity() {
|
|
49
50
|
return __awaiter(this, void 0, void 0, function* () {
|
|
50
51
|
try {
|
|
51
|
-
const [accessToken, storedEmail] = yield Promise.all([
|
|
52
|
+
const [accessToken, storedEmail] = yield Promise.all([
|
|
53
|
+
getAccessToken(),
|
|
54
|
+
getUserEmail().catch(() => null),
|
|
55
|
+
]);
|
|
52
56
|
if (!accessToken)
|
|
53
|
-
return null;
|
|
57
|
+
return { loggedIn: false, email: null };
|
|
54
58
|
if (storedEmail)
|
|
55
|
-
return storedEmail;
|
|
59
|
+
return { loggedIn: true, email: storedEmail };
|
|
56
60
|
const status = yield fetchCliStatus(AbortSignal.timeout(TELEMETRY_IDENTITY_TIMEOUT_MS));
|
|
57
61
|
if (!status.ok)
|
|
58
|
-
return null;
|
|
62
|
+
return { loggedIn: true, email: null };
|
|
59
63
|
const email = status.status.user.email;
|
|
60
64
|
yield storeUserEmail(email).catch(() => { });
|
|
61
|
-
return email;
|
|
65
|
+
return { loggedIn: true, email };
|
|
62
66
|
}
|
|
63
67
|
catch (_a) {
|
|
64
|
-
return null;
|
|
68
|
+
return { loggedIn: false, email: null };
|
|
65
69
|
}
|
|
66
70
|
});
|
|
67
71
|
}
|
|
@@ -71,8 +75,8 @@ export function trackCommand(_a) {
|
|
|
71
75
|
return;
|
|
72
76
|
const work = (() => __awaiter(this, void 0, void 0, function* () {
|
|
73
77
|
try {
|
|
74
|
-
const email = yield
|
|
75
|
-
yield captureWithTimeout('cli.command.executed', Object.assign(Object.assign(Object.assign({ command, cli_version: cliVersion }, getEnvironmentProperties()), { subdomain }), (email ? { email, $set: { email } } : {})));
|
|
78
|
+
const { loggedIn, email } = yield getIdentity();
|
|
79
|
+
yield captureWithTimeout('cli.command.executed', Object.assign(Object.assign(Object.assign({ command, cli_version: cliVersion }, getEnvironmentProperties()), { is_logged_in: loggedIn, subdomain }), (email ? { email, $set: { email } } : {})));
|
|
76
80
|
}
|
|
77
81
|
catch (_a) { }
|
|
78
82
|
}))();
|