@mintlify/cli 4.0.1790 → 4.0.1792

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.1790",
3
+ "version": "4.0.1792",
4
4
  "description": "The Mintlify CLI",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -45,12 +45,12 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@inquirer/prompts": "7.9.0",
48
- "@mintlify/common": "1.0.1336",
49
- "@mintlify/link-rot": "3.0.1576",
48
+ "@mintlify/common": "1.0.1337",
49
+ "@mintlify/link-rot": "3.0.1577",
50
50
  "@mintlify/models": "0.0.385",
51
- "@mintlify/og": "0.0.135",
52
- "@mintlify/prebuild": "1.0.1509",
53
- "@mintlify/previewing": "4.0.1594",
51
+ "@mintlify/og": "0.0.136",
52
+ "@mintlify/prebuild": "1.0.1510",
53
+ "@mintlify/previewing": "4.0.1595",
54
54
  "@mintlify/validation": "0.1.957",
55
55
  "adm-zip": "0.6.0",
56
56
  "chalk": "5.2.0",
@@ -87,7 +87,7 @@
87
87
  "keytar": "7.9.0"
88
88
  },
89
89
  "devDependencies": {
90
- "@mintlify/editor": "0.0.613",
90
+ "@mintlify/editor": "0.0.614",
91
91
  "@mintlify/ts-config": "2.0.2",
92
92
  "@tsconfig/recommended": "1.0.2",
93
93
  "@types/detect-port": "1.3.2",
@@ -106,5 +106,5 @@
106
106
  "vitest": "2.1.9",
107
107
  "vitest-mock-process": "1.0.4"
108
108
  },
109
- "gitHead": "29b4f8341ee54922fec07d0850b2606c96d55de0"
109
+ "gitHead": "7a2db4b1b95b33d9aee9631696c6635427f7e440"
110
110
  }
package/src/cli.tsx CHANGED
@@ -55,7 +55,7 @@ import { buildOverlayRegistryForCheck, checkOpenApiFile } from './openApiCheck.j
55
55
  import { scoreHandler } from './score/index.js';
56
56
  import { signup } from './signup.js';
57
57
  import { status, getCliSubdomains } from './status.js';
58
- import { trackTelemetryPreferenceChange } from './telemetry/track.js';
58
+ import { trackEvent, trackTelemetryPreferenceChange } from './telemetry/track.js';
59
59
  import { update } from './update.js';
60
60
  import { splitList, validateHandler } from './validate/command.js';
61
61
  import { RULES } from './validate/rules/index.js';
@@ -999,6 +999,11 @@ export const cli = ({ packageName = 'mint' }: { packageName?: string }) => {
999
999
  }),
1000
1000
  async (argv) => {
1001
1001
  const agent = argv.agent ?? (argv.claude ? 'claude' : undefined);
1002
+ void trackEvent('cli.migrate.executed', {
1003
+ from: argv.from,
1004
+ topic: argv.topic,
1005
+ agent,
1006
+ });
1002
1007
  if (agent) {
1003
1008
  try {
1004
1009
  return await terminate(await migrateWithAgent(agent, argv.from));
package/src/deploy.ts CHANGED
@@ -87,6 +87,12 @@ export async function prepareAgentDeployment(
87
87
  saved = null;
88
88
  continue;
89
89
  }
90
+ void trackEvent('cli.deploy.provisioned', {
91
+ registration_id: credentials.registrationId,
92
+ deployment_id: site.deploymentId,
93
+ subdomain: site.subdomain,
94
+ created: site.created,
95
+ });
90
96
  await setAgentSiteMetadata(metadataKey, {
91
97
  registrationId: credentials.registrationId,
92
98
  subdomain: site.subdomain,
@@ -0,0 +1,40 @@
1
+ import crypto from 'crypto';
2
+ import fs from 'fs';
3
+ import path from 'path';
4
+
5
+ import { CONFIG_DIR } from '../constants.js';
6
+
7
+ const SESSION_FILE = path.join(CONFIG_DIR, 'telemetry-session.json');
8
+ const SESSION_IDLE_MS = 30 * 60 * 1000;
9
+
10
+ let current: string | undefined;
11
+
12
+ function uuidv7(now: number): string {
13
+ const bytes = crypto.randomBytes(16);
14
+ bytes.writeUIntBE(now, 0, 6);
15
+ bytes[6] = (bytes[6]! & 0x0f) | 0x70;
16
+ bytes[8] = (bytes[8]! & 0x3f) | 0x80;
17
+ const hex = bytes.toString('hex');
18
+ return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
19
+ }
20
+
21
+ function readSession(): { id: string; lastSeenAt: number } | null {
22
+ try {
23
+ const { id, lastSeenAt } = JSON.parse(fs.readFileSync(SESSION_FILE, 'utf-8'));
24
+ return typeof id === 'string' && typeof lastSeenAt === 'number' ? { id, lastSeenAt } : null;
25
+ } catch {
26
+ return null;
27
+ }
28
+ }
29
+
30
+ export function getSessionId(now = Date.now()): string {
31
+ if (!current) {
32
+ const saved = readSession();
33
+ current = saved && now - saved.lastSeenAt < SESSION_IDLE_MS ? saved.id : uuidv7(now);
34
+ }
35
+ try {
36
+ fs.mkdirSync(CONFIG_DIR, { recursive: true });
37
+ fs.writeFileSync(SESSION_FILE, JSON.stringify({ id: current, lastSeenAt: now }));
38
+ } catch {}
39
+ return current;
40
+ }
@@ -8,6 +8,7 @@ import { getAccessToken, getUserEmail, storeUserEmail } from '../keyring.js';
8
8
  import { fetchCliStatus } from '../status.js';
9
9
  import { deferShutdownUntil, getPostHogClient } from './client.js';
10
10
  import { getDistinctId, isFirstRun } from './distinctId.js';
11
+ import { getSessionId } from './sessionId.js';
11
12
 
12
13
  export interface TrackCommandOptions {
13
14
  command: string;
@@ -26,6 +27,7 @@ function getEnvironmentProperties(): Record<string, unknown> {
26
27
  is_ci: isCI(),
27
28
  is_tty: Boolean(process.stdin.isTTY),
28
29
  is_first_run: isFirstRun(),
30
+ $session_id: getSessionId(),
29
31
  };
30
32
  }
31
33
 
@@ -68,6 +70,11 @@ async function getIdentity(): Promise<{ loggedIn: boolean; email: string | null
68
70
  }
69
71
  }
70
72
 
73
+ async function getIdentityProperties(): Promise<Record<string, unknown>> {
74
+ const { loggedIn, email } = await getIdentity();
75
+ return { is_logged_in: loggedIn, ...(email ? { email, $set: { email } } : {}) };
76
+ }
77
+
71
78
  export async function trackCommand({
72
79
  command,
73
80
  cliVersion,
@@ -77,14 +84,12 @@ export async function trackCommand({
77
84
 
78
85
  const work = (async () => {
79
86
  try {
80
- const { loggedIn, email } = await getIdentity();
81
87
  await captureWithTimeout('cli.command.executed', {
82
88
  command,
83
89
  cli_version: cliVersion,
84
90
  ...getEnvironmentProperties(),
85
- is_logged_in: loggedIn,
91
+ ...(await getIdentityProperties()),
86
92
  subdomain,
87
- ...(email ? { email, $set: { email } } : {}),
88
93
  });
89
94
  } catch {}
90
95
  })();
@@ -95,14 +100,20 @@ export async function trackCommand({
95
100
 
96
101
  async function trackLoginEvent(event: string, extra?: Record<string, unknown>): Promise<void> {
97
102
  if (!isTelemetryEnabled()) return;
98
- try {
99
- const { cli: cliVersion } = getVersions();
100
- await captureWithTimeout(event, {
101
- ...extra,
102
- cli_version: cliVersion,
103
- ...getEnvironmentProperties(),
104
- });
105
- } catch {}
103
+
104
+ const work = (async () => {
105
+ try {
106
+ const { cli: cliVersion } = getVersions();
107
+ await captureWithTimeout(event, {
108
+ ...extra,
109
+ cli_version: cliVersion,
110
+ ...getEnvironmentProperties(),
111
+ ...(await getIdentityProperties()),
112
+ });
113
+ } catch {}
114
+ })();
115
+ deferShutdownUntil(work);
116
+ await work;
106
117
  }
107
118
 
108
119
  export async function trackLoginAttempt(): Promise<void> {
@@ -130,6 +141,7 @@ export async function trackEvent(
130
141
  ...properties,
131
142
  cli_version: cliVersion,
132
143
  ...getEnvironmentProperties(),
144
+ ...(await getIdentityProperties()),
133
145
  });
134
146
  } catch {}
135
147
  })();