@insforge/cli 0.1.40 → 0.1.41

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
@@ -1914,6 +1914,16 @@ function captureEvent(distinctId, event, properties) {
1914
1914
  } catch {
1915
1915
  }
1916
1916
  }
1917
+ function trackDiagnose(subcommand, config) {
1918
+ captureEvent(config.project_id, "cli_diagnose_invoked", {
1919
+ subcommand,
1920
+ project_id: config.project_id,
1921
+ project_name: config.project_name,
1922
+ org_id: config.org_id,
1923
+ region: config.region,
1924
+ oss_mode: config.project_id === "oss-project"
1925
+ });
1926
+ }
1917
1927
  async function shutdownAnalytics() {
1918
1928
  try {
1919
1929
  if (client) await client.shutdown();
@@ -3465,6 +3475,7 @@ function registerDiagnoseMetricsCommand(diagnoseCmd2) {
3465
3475
  "Metrics requires InsForge Platform login. Not available when linked via --api-key."
3466
3476
  );
3467
3477
  }
3478
+ trackDiagnose("metrics", config);
3468
3479
  const params = new URLSearchParams({ range: opts.range });
3469
3480
  if (opts.metrics) params.set("metrics", opts.metrics);
3470
3481
  const res = await platformFetch(
@@ -3505,6 +3516,8 @@ function registerDiagnoseMetricsCommand(diagnoseCmd2) {
3505
3516
  } catch (err) {
3506
3517
  await reportCliUsage("cli.diagnose.metrics", false);
3507
3518
  handleError(err, json);
3519
+ } finally {
3520
+ await shutdownAnalytics();
3508
3521
  }
3509
3522
  });
3510
3523
  }
@@ -3526,6 +3539,7 @@ function registerDiagnoseAdvisorCommand(diagnoseCmd2) {
3526
3539
  "Advisor requires InsForge Platform login. Not available when linked via --api-key."
3527
3540
  );
3528
3541
  }
3542
+ trackDiagnose("advisor", config);
3529
3543
  const projectId = config.project_id;
3530
3544
  const scanRes = await platformFetch(
3531
3545
  `/projects/v1/${projectId}/advisor/latest`,
@@ -3569,6 +3583,8 @@ function registerDiagnoseAdvisorCommand(diagnoseCmd2) {
3569
3583
  } catch (err) {
3570
3584
  await reportCliUsage("cli.diagnose.advisor", false);
3571
3585
  handleError(err, json);
3586
+ } finally {
3587
+ await shutdownAnalytics();
3572
3588
  }
3573
3589
  });
3574
3590
  }
@@ -3719,7 +3735,9 @@ function registerDiagnoseDbCommand(diagnoseCmd2) {
3719
3735
  const { json } = getRootOpts(cmd);
3720
3736
  try {
3721
3737
  await requireAuth();
3722
- if (!getProjectConfig()) throw new ProjectNotLinkedError();
3738
+ const config = getProjectConfig();
3739
+ if (!config) throw new ProjectNotLinkedError();
3740
+ trackDiagnose("db", config);
3723
3741
  const checkNames = opts.check === "all" ? ALL_CHECKS : opts.check.split(",").map((s) => s.trim());
3724
3742
  const results = {};
3725
3743
  for (const name of checkNames) {
@@ -3754,6 +3772,8 @@ function registerDiagnoseDbCommand(diagnoseCmd2) {
3754
3772
  } catch (err) {
3755
3773
  await reportCliUsage("cli.diagnose.db", false);
3756
3774
  handleError(err, json);
3775
+ } finally {
3776
+ await shutdownAnalytics();
3757
3777
  }
3758
3778
  });
3759
3779
  }
@@ -3807,7 +3827,9 @@ function registerDiagnoseLogsCommand(diagnoseCmd2) {
3807
3827
  const { json } = getRootOpts(cmd);
3808
3828
  try {
3809
3829
  await requireAuth();
3810
- if (!getProjectConfig()) throw new ProjectNotLinkedError();
3830
+ const config = getProjectConfig();
3831
+ if (!config) throw new ProjectNotLinkedError();
3832
+ trackDiagnose("logs", config);
3811
3833
  const limit = parseInt(opts.limit, 10) || 100;
3812
3834
  const sources = opts.source ? [opts.source] : [...LOG_SOURCES];
3813
3835
  const summaries = [];
@@ -3840,6 +3862,8 @@ function registerDiagnoseLogsCommand(diagnoseCmd2) {
3840
3862
  } catch (err) {
3841
3863
  await reportCliUsage("cli.diagnose.logs", false);
3842
3864
  handleError(err, json);
3865
+ } finally {
3866
+ await shutdownAnalytics();
3843
3867
  }
3844
3868
  });
3845
3869
  }
@@ -3858,6 +3882,7 @@ function registerDiagnoseCommands(diagnoseCmd2) {
3858
3882
  const projectId = config.project_id;
3859
3883
  const projectName = config.project_name;
3860
3884
  const ossMode = config.project_id === "oss-project";
3885
+ trackDiagnose("report", config);
3861
3886
  const metricsPromise = ossMode ? Promise.reject(new Error("Platform login required (linked via --api-key)")) : fetchMetricsSummary(projectId, apiUrl);
3862
3887
  const advisorPromise = ossMode ? Promise.reject(new Error("Platform login required (linked via --api-key)")) : fetchAdvisorSummary(projectId, apiUrl);
3863
3888
  const [metricsResult, advisorResult, dbResult, logsResult] = await Promise.allSettled([
@@ -3977,6 +4002,8 @@ function registerDiagnoseCommands(diagnoseCmd2) {
3977
4002
  } catch (err) {
3978
4003
  await reportCliUsage("cli.diagnose", false);
3979
4004
  handleError(err, json);
4005
+ } finally {
4006
+ await shutdownAnalytics();
3980
4007
  }
3981
4008
  });
3982
4009
  registerDiagnoseMetricsCommand(diagnoseCmd2);