@mintlify/cli 4.0.1093 → 4.0.1095

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.1093",
3
+ "version": "4.0.1095",
4
4
  "description": "The Mintlify CLI",
5
5
  "engines": {
6
6
  "node": ">=18.0.0"
@@ -45,11 +45,11 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@inquirer/prompts": "7.9.0",
48
- "@mintlify/common": "1.0.838",
49
- "@mintlify/link-rot": "3.0.1013",
50
- "@mintlify/prebuild": "1.0.980",
51
- "@mintlify/previewing": "4.0.1041",
52
- "@mintlify/validation": "0.1.654",
48
+ "@mintlify/common": "1.0.839",
49
+ "@mintlify/link-rot": "3.0.1014",
50
+ "@mintlify/prebuild": "1.0.981",
51
+ "@mintlify/previewing": "4.0.1042",
52
+ "@mintlify/validation": "0.1.655",
53
53
  "adm-zip": "0.5.16",
54
54
  "chalk": "5.2.0",
55
55
  "color": "4.2.3",
@@ -93,5 +93,5 @@
93
93
  "vitest": "2.1.9",
94
94
  "vitest-mock-process": "1.0.4"
95
95
  },
96
- "gitHead": "d41d0aa4d76a098f980161b0616d5c79273c3d15"
96
+ "gitHead": "a73f32187c10dfdaa3da77758f323b43d2de4a33"
97
97
  }
package/src/login.tsx CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  import { startCallbackServer } from './callbackServer.js';
14
14
  import { DASHBOARD_URL, STYTCH_CLIENT_ID, TOKEN_ENDPOINT } from './constants.js';
15
15
  import { storeCredentials } from './keyring.js';
16
+ import { trackLoginAttempt, trackLoginFailed, trackLoginSuccess } from './telemetry/track.js';
16
17
 
17
18
  interface TokenResponse {
18
19
  access_token: string;
@@ -37,6 +38,8 @@ export async function login(): Promise<void> {
37
38
  authorizeUrl.searchParams.set('code_challenge', codeChallenge);
38
39
  const url = authorizeUrl.toString();
39
40
 
41
+ void trackLoginAttempt();
42
+
40
43
  const { codePromise, close: closeServer } = await startCallbackServer();
41
44
 
42
45
  addLog(
@@ -101,15 +104,14 @@ export async function login(): Promise<void> {
101
104
  const body = await res.json().catch(() => ({}));
102
105
 
103
106
  if (!res.ok) {
104
- addLog(
105
- <Text color="red">
106
- Login failed: {body.error_message ?? body.error ?? 'unknown error'}
107
- </Text>
108
- );
107
+ const reason = body.error_message ?? body.error ?? 'unknown error';
108
+ void trackLoginFailed(reason);
109
+ addLog(<Text color="red">✖ Login failed: {reason}</Text>);
109
110
  return;
110
111
  }
111
112
 
112
113
  const token = body as TokenResponse;
113
114
  await storeCredentials(token.access_token, token.refresh_token);
115
+ void trackLoginSuccess();
114
116
  addLog(<Text color="green">✔ Logged in successfully.</Text>);
115
117
  }
@@ -44,6 +44,32 @@ export async function trackCommand({ command, cliVersion }: TrackCommandOptions)
44
44
  } catch {}
45
45
  }
46
46
 
47
+ async function trackLoginEvent(event: string, extra?: Record<string, unknown>): Promise<void> {
48
+ if (!isTelemetryEnabled()) return;
49
+ try {
50
+ const { cli: cliVersion } = getVersions();
51
+ await captureWithTimeout(event, {
52
+ ...extra,
53
+ cli_version: cliVersion,
54
+ os: os.platform(),
55
+ arch: os.arch(),
56
+ node_version: process.version,
57
+ });
58
+ } catch {}
59
+ }
60
+
61
+ export async function trackLoginAttempt(): Promise<void> {
62
+ return trackLoginEvent('cli.login.attempted');
63
+ }
64
+
65
+ export async function trackLoginSuccess(): Promise<void> {
66
+ return trackLoginEvent('cli.login.succeeded');
67
+ }
68
+
69
+ export async function trackLoginFailed(reason: string): Promise<void> {
70
+ return trackLoginEvent('cli.login.failed', { reason });
71
+ }
72
+
47
73
  export async function trackTelemetryPreferenceChange(options: { enabled: boolean }): Promise<void> {
48
74
  if (process.env.CLI_TEST_MODE === 'true') return;
49
75