@insforge/cli 0.1.34 → 0.1.35

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
@@ -1870,6 +1870,31 @@ async function readEnvFile(cwd) {
1870
1870
  return [];
1871
1871
  }
1872
1872
 
1873
+ // src/lib/analytics.ts
1874
+ import { PostHog } from "posthog-node";
1875
+ var POSTHOG_API_KEY = "";
1876
+ var POSTHOG_HOST = process.env.POSTHOG_HOST || "https://us.i.posthog.com";
1877
+ var client = null;
1878
+ function getClient() {
1879
+ if (!POSTHOG_API_KEY) return null;
1880
+ if (!client) {
1881
+ client = new PostHog(POSTHOG_API_KEY, { host: POSTHOG_HOST });
1882
+ }
1883
+ return client;
1884
+ }
1885
+ function captureEvent(distinctId, event, properties) {
1886
+ try {
1887
+ getClient()?.capture({ distinctId, event, properties });
1888
+ } catch {
1889
+ }
1890
+ }
1891
+ async function shutdownAnalytics() {
1892
+ try {
1893
+ if (client) await client.shutdown();
1894
+ } catch {
1895
+ }
1896
+ }
1897
+
1873
1898
  // src/commands/deployments/deploy.ts
1874
1899
  import * as path2 from "path";
1875
1900
  import * as fs2 from "fs/promises";
@@ -2204,6 +2229,9 @@ function registerCreateCommand(program2) {
2204
2229
  ]
2205
2230
  });
2206
2231
  if (clack10.isCancel(approach)) process.exit(0);
2232
+ captureEvent(orgId, "create_approach_selected", {
2233
+ approach
2234
+ });
2207
2235
  if (approach === "blank") {
2208
2236
  template = "empty";
2209
2237
  } else {
@@ -2222,6 +2250,10 @@ function registerCreateCommand(program2) {
2222
2250
  }
2223
2251
  }
2224
2252
  }
2253
+ captureEvent(orgId, "template_selected", {
2254
+ template,
2255
+ approach: template === "empty" ? "blank" : "template"
2256
+ });
2225
2257
  const s = !json ? clack10.spinner() : null;
2226
2258
  s?.start("Creating project...");
2227
2259
  const project = await createProject(orgId, projectName, opts.region, apiUrl);
@@ -2342,6 +2374,8 @@ function registerCreateCommand(program2) {
2342
2374
  }
2343
2375
  } catch (err) {
2344
2376
  handleError(err, json);
2377
+ } finally {
2378
+ await shutdownAnalytics();
2345
2379
  }
2346
2380
  });
2347
2381
  }