@decantr/cli 2.1.1 → 2.3.0

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.
@@ -134,6 +134,30 @@ async function sendProjectHealthReportTelemetry(input) {
134
134
  });
135
135
  }
136
136
  }
137
+ async function sendAnalyzeCompletedTelemetry(input) {
138
+ const projectRoot = input.projectRoot ?? process.cwd();
139
+ const metadata = readProjectTelemetryMetadata(projectRoot);
140
+ const properties = {
141
+ command: "analyze",
142
+ success: input.success,
143
+ durationMs: input.durationMs,
144
+ adoptionMode: metadata.adoptionMode ?? "contract-only",
145
+ componentCount: input.componentCount,
146
+ dependencyCategoryCount: input.dependencyCategoryCount,
147
+ errorCode: input.success ? void 0 : "analyze_failed",
148
+ pageCount: input.pageCount,
149
+ projectScope: metadata.projectScope ?? inferProjectScope(projectRoot),
150
+ routeCount: input.routeCount,
151
+ targetFramework: input.targetFramework,
152
+ workflowMode: metadata.workflowMode ?? "brownfield-attach"
153
+ };
154
+ await captureCliTelemetryEvent({
155
+ args: ["analyze"],
156
+ name: "decantr.analyze.completed",
157
+ projectRoot,
158
+ properties
159
+ });
160
+ }
137
161
  async function sendNewProjectCompletedTelemetry(input) {
138
162
  const projectRoot = input.projectRoot ?? process.cwd();
139
163
  const args = input.args ?? ["new"];
@@ -303,6 +327,19 @@ function collectMetrics(essence, issues) {
303
327
  theme: theme.id ?? "unknown"
304
328
  };
305
329
  }
330
+ function getCliTelemetryIdentityStatus(projectRoot, options = {}) {
331
+ const projectJsonPath = join(projectRoot, ".decantr", "project.json");
332
+ const hasProjectConfig = existsSync(projectJsonPath);
333
+ const identities = options.create ? ensureTelemetryIdentities(projectRoot) : null;
334
+ const projectData = readProjectJson(projectRoot);
335
+ return {
336
+ enabled: projectData?.telemetry === true,
337
+ hasProjectConfig,
338
+ installId: identities?.installId ?? readExistingInstallId(),
339
+ projectId: identities?.projectId ?? readStringProperty(projectData, "telemetryProjectId"),
340
+ projectRoot
341
+ };
342
+ }
306
343
  function ensureTelemetryIdentities(projectRoot) {
307
344
  const installId = getOrCreateInstallId();
308
345
  const projectJsonPath = join(projectRoot, ".decantr", "project.json");
@@ -348,6 +385,16 @@ function getOrCreateInstallId() {
348
385
  return `install_${randomUUID()}`;
349
386
  }
350
387
  }
388
+ function readExistingInstallId() {
389
+ const configPath = join(getConfigDir(), "config.json");
390
+ if (!existsSync(configPath)) return void 0;
391
+ try {
392
+ const data = JSON.parse(readFileSync(configPath, "utf-8"));
393
+ return readStringProperty(data, "telemetryInstallId");
394
+ } catch {
395
+ return void 0;
396
+ }
397
+ }
351
398
  function getConfigDir() {
352
399
  return process.env.DECANTR_CONFIG_DIR || join(homedir(), ".config", "decantr");
353
400
  }
@@ -386,6 +433,10 @@ function readProjectJson(projectRoot) {
386
433
  return null;
387
434
  }
388
435
  }
436
+ function readStringProperty(value, key) {
437
+ const property = value?.[key];
438
+ return typeof property === "string" && property.trim() ? property : void 0;
439
+ }
389
440
  function isRecord(value) {
390
441
  return typeof value === "object" && value !== null && !Array.isArray(value);
391
442
  }
@@ -1650,12 +1701,14 @@ export {
1650
1701
  optIn,
1651
1702
  sendCliCommandTelemetry,
1652
1703
  sendProjectHealthReportTelemetry,
1704
+ sendAnalyzeCompletedTelemetry,
1653
1705
  sendNewProjectCompletedTelemetry,
1654
1706
  sendProjectHealthPromptTelemetry,
1655
1707
  sendProjectHealthCiFailedTelemetry,
1656
1708
  sendStudioStartedTelemetry,
1657
1709
  sendStudioHealthRefreshedTelemetry,
1658
1710
  collectMetrics,
1711
+ getCliTelemetryIdentityStatus,
1659
1712
  buildGuardRegistryContext,
1660
1713
  scanProjectInteractions
1661
1714
  };
@@ -10,7 +10,7 @@ import {
10
10
  scanRoutes,
11
11
  scanStyling,
12
12
  sendGuardMetrics
13
- } from "./chunk-JYEEXSUX.js";
13
+ } from "./chunk-IEW2QFYI.js";
14
14
 
15
15
  // src/commands/heal.ts
16
16
  import { existsSync as existsSync2, readFileSync as readFileSync2 } from "fs";
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  cmdHeal,
3
3
  collectCheckIssues
4
- } from "./chunk-LLQCXOHK.js";
5
- import "./chunk-JYEEXSUX.js";
4
+ } from "./chunk-NBJCO4G5.js";
5
+ import "./chunk-IEW2QFYI.js";
6
6
  export {
7
7
  cmdHeal,
8
8
  collectCheckIssues
@@ -8,9 +8,9 @@ import {
8
8
  renderProjectHealthCiWorkflow,
9
9
  shouldFailHealth,
10
10
  writeProjectHealthCiWorkflow
11
- } from "./chunk-DPFORHLL.js";
12
- import "./chunk-LLQCXOHK.js";
13
- import "./chunk-JYEEXSUX.js";
11
+ } from "./chunk-3H3HWDJA.js";
12
+ import "./chunk-NBJCO4G5.js";
13
+ import "./chunk-IEW2QFYI.js";
14
14
  export {
15
15
  cmdHealth,
16
16
  createProjectHealthReport,
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import "./chunk-GOX5EJ56.js";
1
+ import "./chunk-FSZ6OIAC.js";
2
2
  import "./chunk-WDA4SHIQ.js";
3
- import "./chunk-JYEEXSUX.js";
3
+ import "./chunk-IEW2QFYI.js";