@meltstudio/meltctl 4.33.0 → 4.33.2

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/dist/index.js CHANGED
@@ -48,7 +48,7 @@ ${chalk.dim(' /melt-help Answer questions about the development pla
48
48
  .hook('preAction', async () => {
49
49
  await checkAndEnforceUpdate();
50
50
  })
51
- .hook('postAction', (_thisCommand, actionCommand) => {
51
+ .hook('postAction', async (_thisCommand, actionCommand) => {
52
52
  try {
53
53
  const parts = [];
54
54
  let cmd = actionCommand;
@@ -56,7 +56,7 @@ ${chalk.dim(' /melt-help Answer questions about the development pla
56
56
  parts.unshift(cmd.name());
57
57
  cmd = cmd.parent;
58
58
  }
59
- trackCommand(parts.join(' '), true);
59
+ await trackCommand(parts.join(' '), true);
60
60
  }
61
61
  catch {
62
62
  // Analytics must never break the CLI
@@ -3,6 +3,7 @@ import { join, dirname } from 'path';
3
3
  import { fileURLToPath } from 'url';
4
4
  import { getStoredAuth, API_BASE } from './auth.js';
5
5
  import { getGitRepository, getGitBranch, getProjectName } from './git.js';
6
+ import { debugLog } from './debug.js';
6
7
  const __filename = fileURLToPath(import.meta.url);
7
8
  const __dirname = dirname(__filename);
8
9
  function getVersion() {
@@ -16,12 +17,19 @@ function getVersion() {
16
17
  }
17
18
  export async function trackCommand(command, success, errorMessage) {
18
19
  try {
20
+ if (process.env['MELTCTL_NO_ANALYTICS']) {
21
+ debugLog('Analytics disabled via MELTCTL_NO_ANALYTICS');
22
+ return;
23
+ }
19
24
  const auth = await getStoredAuth();
20
25
  if (!auth || new Date(auth.expiresAt) <= new Date()) {
26
+ debugLog('Analytics skipped: not authenticated or token expired');
21
27
  return;
22
28
  }
23
29
  const repo = getGitRepository();
24
- fetch(`${API_BASE}/events`, {
30
+ const controller = new AbortController();
31
+ const timeout = setTimeout(() => controller.abort(), 3000);
32
+ const res = await fetch(`${API_BASE}/events`, {
25
33
  method: 'POST',
26
34
  headers: {
27
35
  Authorization: `Bearer ${auth.token}`,
@@ -36,9 +44,21 @@ export async function trackCommand(command, success, errorMessage) {
36
44
  success,
37
45
  errorMessage: errorMessage?.slice(0, 500) ?? null,
38
46
  }),
39
- }).catch(() => { });
47
+ signal: controller.signal,
48
+ }).catch(e => {
49
+ debugLog(`Analytics fetch failed: ${e instanceof Error ? e.message : e}`);
50
+ return null;
51
+ });
52
+ clearTimeout(timeout);
53
+ if (res && !res.ok) {
54
+ const body = await res.text().catch(() => '');
55
+ debugLog(`Analytics API error ${res.status}: ${body}`);
56
+ }
57
+ else if (res) {
58
+ debugLog(`Analytics event sent for "${command}"`);
59
+ }
40
60
  }
41
- catch {
42
- // Analytics must never break the CLI
61
+ catch (e) {
62
+ debugLog(`Analytics error: ${e instanceof Error ? e.message : e}`);
43
63
  }
44
64
  }
@@ -0,0 +1 @@
1
+ export declare function debugLog(message: string): void;
@@ -0,0 +1,6 @@
1
+ import chalk from 'chalk';
2
+ export function debugLog(message) {
3
+ if (process.env['MELTCTL_DEBUG']) {
4
+ console.error(chalk.dim(`[debug] ${message}`));
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meltstudio/meltctl",
3
- "version": "4.33.0",
3
+ "version": "4.33.2",
4
4
  "description": "AI-first development tools for teams - set up AGENTS.md, Claude Code, Cursor, and OpenCode standards",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",