@disposabl/cli 2.0.1 → 2.1.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.
package/README.md CHANGED
@@ -39,4 +39,6 @@ The command exits unsuccessfully while manual cleanup is pending. Rerun the same
39
39
 
40
40
  When configured for a published release, Disposabl collects the command category, outcome, package version, operating system and package-manager category. A random ID stored in `~/.config/disposabl/telemetry.json` connects anonymous usage to the Disposabl user ID after login. Logout and account changes reset that ID. Prompts, arguments, paths, error messages, credentials and email addresses are not collected. Set `DO_NOT_TRACK=1` or `DISPOSABL_TELEMETRY_DISABLED=1` to opt out. Local source, development, CI and E2E runs do not send events. This is separate from a generated app's analytics.
41
41
 
42
+ Failed commands also send a fixed, coarse error-tracking event with no exception message or stack trace.
43
+
42
44
  Release builds must supply the central public PostHog project token in `DISPOSABL_CLI_POSTHOG_PROJECT_TOKEN` and its ingestion host in `DISPOSABL_CLI_POSTHOG_HOST` (US or EU PostHog ingestion origin) at build time. The build embeds these public values and rejects a release without them. Set `DISPOSABL_CLI_TELEMETRY_REQUIRED=1` to enforce the same check on a development-version qualification build. Development builds without this configuration remain inert. Do not use a personal API key or an app owner's project token. Configure the central PostHog project to disable IP data capture.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // auth.ts
4
4
  import { lock } from "proper-lockfile";
5
5
  // package.json
6
- var version = "2.0.1";
6
+ var version = "2.1.0";
7
7
  var package_default = {
8
8
  name: "@disposabl/cli",
9
9
  version,
@@ -322,10 +322,13 @@ Sign in to Expo if needed and choose Delete project. Then rerun this command to
322
322
  openUrl(url.href);
323
323
  }
324
324
 
325
+ // commands.ts
326
+ import { CommanderError } from "commander";
327
+
325
328
  // telemetry.ts
326
329
  import { createHash as createHash2, randomUUID } from "node:crypto";
327
330
  import { realpathSync } from "node:fs";
328
- import { mkdir as mkdir2, readFile as readFile2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
331
+ import { mkdir as mkdir2, open, readFile as readFile2, rm as rm2, writeFile as writeFile2 } from "node:fs/promises";
329
332
  import { homedir as homedir2 } from "node:os";
330
333
  import { dirname, join as join2 } from "node:path";
331
334
  import { lock as lock2 } from "proper-lockfile";
@@ -391,6 +394,18 @@ async function send(config, event, distinctId, properties) {
391
394
  });
392
395
  return response.ok;
393
396
  }
397
+ async function firstExecution(path, product, version) {
398
+ try {
399
+ const directory = join2(dirname(path), "activations");
400
+ await mkdir2(directory, { recursive: true, mode: 448 });
401
+ const name = createHash2("sha256").update(`${product}:${version}`).digest("hex");
402
+ const file = await open(join2(directory, name), "wx", 384);
403
+ await file.close();
404
+ return true;
405
+ } catch {
406
+ return false;
407
+ }
408
+ }
394
409
  async function capture(version, product, command, outcome, path) {
395
410
  const config = telemetryConfig(version);
396
411
  if (!config)
@@ -412,15 +427,29 @@ async function capture(version, product, command, outcome, path) {
412
427
  "other",
413
428
  "create"
414
429
  ];
415
- await send(config, "cli_command", current.userId ?? current.anonymousId, {
430
+ const distinctId = current.userId ?? current.anonymousId;
431
+ const activation = outcome === "started" && await firstExecution(path, product, version);
432
+ const properties = {
416
433
  product,
417
434
  command: allowed.includes(command) ? command : "other",
418
435
  outcome,
419
436
  version,
437
+ ...activation ? { first_execution: true } : {},
420
438
  invocation: process.env.npm_command === "exec" ? "npx" : /^(npm|pnpm|yarn|bun)\//.exec(process.env.npm_config_user_agent ?? "")?.[1] ?? "direct",
421
439
  platform: ["darwin", "linux", "win32"].includes(process.platform) ? process.platform : "other",
422
440
  ...!current.userId ? { $process_person_profile: false } : {}
423
- });
441
+ };
442
+ const pending = [send(config, "cli_command", distinctId, properties)];
443
+ if (outcome === "failure") {
444
+ pending.push(send(config, "$exception", distinctId, {
445
+ ...properties,
446
+ $exception_list: [
447
+ { type: "CommandFailure", value: "Command failed" }
448
+ ],
449
+ $exception_fingerprint: `disposabl-${product}-${properties.command}`
450
+ }));
451
+ }
452
+ await Promise.allSettled(pending);
424
453
  } catch {}
425
454
  }
426
455
  async function prepareLogin(path) {
@@ -900,6 +929,7 @@ function formatPreview(preview) {
900
929
  // commands.ts
901
930
  async function runCli(argv = process.argv, serviceOrigin = process.env.DISPOSABL_API_ORIGIN || SERVICE_ORIGIN) {
902
931
  const program = createProgram(serviceOrigin, true);
932
+ program.exitOverride();
903
933
  const origin = () => apiUrl(serviceOrigin);
904
934
  async function main() {
905
935
  if (needsContract(program, argv, serviceOrigin)) {
@@ -1014,18 +1044,21 @@ Waiting for connections. Press Ctrl+C to keep your files and finish later.`);
1014
1044
  }
1015
1045
  await program.parseAsync(argv);
1016
1046
  }
1017
- const command = argv[2] ?? "help";
1047
+ const command = ["--version", "-V"].includes(argv[2] ?? "") ? "version" : ["--help", "-h"].includes(argv[2] ?? "") ? "help" : argv[2] ?? "help";
1018
1048
  const central = serviceOrigin === SERVICE_ORIGIN;
1019
- if (central)
1020
- await capture(version, "cli", command, "started", telemetryStatePath());
1049
+ const started = central ? capture(version, "cli", command, "started", telemetryStatePath()) : undefined;
1021
1050
  try {
1022
1051
  await main();
1052
+ await started;
1023
1053
  if (central)
1024
1054
  await capture(version, "cli", command, "success", telemetryStatePath());
1025
1055
  } catch (error) {
1056
+ await started;
1057
+ const success = error instanceof CommanderError && error.exitCode === 0;
1026
1058
  if (central)
1027
- await capture(version, "cli", command, "failure", telemetryStatePath());
1028
- throw error;
1059
+ await capture(version, "cli", command, success ? "success" : "failure", telemetryStatePath());
1060
+ if (!success)
1061
+ throw error;
1029
1062
  }
1030
1063
  }
1031
1064
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@disposabl/cli",
3
- "version": "2.0.1",
3
+ "version": "2.1.0",
4
4
  "type": "module",
5
5
  "description": "Command-line access to your Disposabl app",
6
6
  "license": "MIT",