@cedarjs/telemetry 8.0.0-canary.3592 → 8.0.0-canary.3597

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.
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Describes the running CLI command for telemetry, e.g.
3
+ * `generate page [name] [path] --force` for
4
+ * `cedar g page Payroll /payroll --force`.
5
+ *
6
+ * The description is built from the command's yargs definition, so it only
7
+ * contains Cedar's own command names, positional argument names and option
8
+ * names. Every value the user typed is replaced by a placeholder named after
9
+ * its argument or option. Everything after `--` is left out.
10
+ *
11
+ * Options that a command doesn't declare are forwarded to the tool it wraps,
12
+ * like Prisma or Vitest, and their names are kept. `exec` forwards them to
13
+ * the user's own script, where the names can identify the user's project, so
14
+ * for `exec` only declared options are kept.
15
+ *
16
+ * Returns `undefined` if `yargs` doesn't expose the running command.
17
+ *
18
+ * @param argv The arguments yargs parsed
19
+ * @param yargs The yargs instance, as passed to middleware
20
+ * @param rawArgs The arguments the user typed, without the node and script
21
+ * paths
22
+ */
23
+ export declare function commandForTelemetry(argv: Record<string, unknown>, yargs: unknown, rawArgs: string[]): string | undefined;
24
+ //# sourceMappingURL=commandForTelemetry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commandForTelemetry.d.ts","sourceRoot":"","sources":["../src/commandForTelemetry.ts"],"names":[],"mappings":"AAiEA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,KAAK,EAAE,OAAO,EACd,OAAO,EAAE,MAAM,EAAE,GAChB,MAAM,GAAG,SAAS,CA8FpB"}
@@ -0,0 +1,90 @@
1
+ const OPTION = /^(--?)([a-zA-Z][\w-]*)/;
2
+ function getYargsInternals(yargs) {
3
+ if (typeof yargs !== "object" || yargs === null || !("getInternalMethods" in yargs) || typeof yargs.getInternalMethods !== "function" || !("getOptions" in yargs) || typeof yargs.getOptions !== "function") {
4
+ return void 0;
5
+ }
6
+ const context = yargs.getInternalMethods().getContext?.();
7
+ const options = yargs.getOptions();
8
+ if (typeof context !== "object" || context === null || !("fullCommands" in context) || !Array.isArray(context.fullCommands) || typeof options !== "object" || options === null || !("key" in options) || typeof options.key !== "object" || options.key === null || !("boolean" in options) || !Array.isArray(options.boolean) || !("alias" in options) || typeof options.alias !== "object" || options.alias === null) {
9
+ return void 0;
10
+ }
11
+ return {
12
+ fullCommands: context.fullCommands.filter(
13
+ (command) => typeof command === "string"
14
+ ),
15
+ // `key` and `alias` are plain objects that yargs builds from the option
16
+ // definitions
17
+ declared: options.key,
18
+ booleans: options.boolean.filter(
19
+ (name) => typeof name === "string"
20
+ ),
21
+ aliases: options.alias
22
+ };
23
+ }
24
+ function hasValue(value) {
25
+ return value !== void 0 && !(Array.isArray(value) && value.length === 0);
26
+ }
27
+ function commandForTelemetry(argv, yargs, rawArgs) {
28
+ const internals = getYargsInternals(yargs);
29
+ if (!internals) {
30
+ return void 0;
31
+ }
32
+ const { fullCommands, declared, booleans, aliases } = internals;
33
+ const parts = [];
34
+ for (const fullCommand of fullCommands) {
35
+ const [name, ...positionals] = fullCommand.split(/\s+/);
36
+ if (name && !name.startsWith("$")) {
37
+ parts.push(name);
38
+ }
39
+ for (const positional of positionals) {
40
+ if (!/^[<[]/.test(positional)) {
41
+ continue;
42
+ }
43
+ const key = positional.replace(/[<>[\].]/g, "");
44
+ if (hasValue(argv[key])) {
45
+ parts.push(`[${key}]`);
46
+ }
47
+ }
48
+ }
49
+ const forwardsToUserCode = parts[0] === "exec";
50
+ const passthroughIndex = rawArgs.indexOf("--");
51
+ const ownArgs = passthroughIndex === -1 ? rawArgs : rawArgs.slice(0, passthroughIndex);
52
+ const isFlag = (key) => booleans.includes(key) || typeof argv[key] === "boolean";
53
+ const placeholderFor = (key) => `[${Object.keys(aliases).find((alias) => aliases[alias]?.includes(key)) ?? key}]`;
54
+ for (const arg of ownArgs) {
55
+ const match = arg.match(OPTION);
56
+ if (!match) {
57
+ continue;
58
+ }
59
+ const [, dashes, matchedName] = match;
60
+ if (dashes === "-") {
61
+ for (const letter of matchedName) {
62
+ if (!/[a-zA-Z]/.test(letter)) {
63
+ break;
64
+ }
65
+ const flag = isFlag(letter);
66
+ const known = letter in declared;
67
+ if (!forwardsToUserCode || known) {
68
+ parts.push(
69
+ flag ? `-${letter}` : `-${letter} ${placeholderFor(letter)}`
70
+ );
71
+ }
72
+ if (!flag || !known) {
73
+ break;
74
+ }
75
+ }
76
+ continue;
77
+ }
78
+ const key = matchedName.startsWith("no-") && !(matchedName in declared) ? matchedName.slice(3) : matchedName;
79
+ if (forwardsToUserCode && !(key in declared)) {
80
+ continue;
81
+ }
82
+ parts.push(
83
+ isFlag(key) ? `--${matchedName}` : `--${matchedName} ${placeholderFor(key)}`
84
+ );
85
+ }
86
+ return parts.join(" ");
87
+ }
88
+ export {
89
+ commandForTelemetry
90
+ };
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Turns an error (or any thrown value) into a message that is safe to send
3
+ * with telemetry.
4
+ *
5
+ * Only the first line is kept, because some errors include the full stack
6
+ * trace in the message. Then every word that could identify a user, their
7
+ * project or their infrastructure is replaced: anything containing `/`, `\`,
8
+ * `@` or `:`, and IPv4 addresses. Replacements are labelled `[url]`, `[host]`,
9
+ * `[path]` or `[redacted]`. Quoted paths are replaced as a whole, since they
10
+ * can contain spaces, and so are hostnames in DNS errors.
11
+ *
12
+ * Words that describe the failure without identifying anyone are kept:
13
+ * scoped package names (`@cedarjs/vite`), known specifiers (`node:fs`),
14
+ * version numbers, clock times and words that only end in a colon (`Error:`).
15
+ * What is left is the shape of the error, e.g.
16
+ * `ENOENT: no such file or directory, open '[path]'`.
17
+ *
18
+ * The same function is exported from `@cedarjs/cli-helpers/telemetry`.
19
+ * `@cedarjs/cli-helpers` depends on this package, so this package keeps its
20
+ * own copy instead of importing it from there.
21
+ */
22
+ export declare function redactErrorMessage(error: unknown): string;
23
+ //# sourceMappingURL=redact.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"redact.d.ts","sourceRoot":"","sources":["../src/redact.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAwBzD"}
package/dist/redact.js ADDED
@@ -0,0 +1,69 @@
1
+ function redactErrorMessage(error) {
2
+ const message = error instanceof Error ? error.message : typeof error === "string" ? error : String(error);
3
+ return (message.split("\n")[0] || "Unknown error").replace(
4
+ /(['"`])([^'"`\\/\n]*[\\/][^'"`\n]*)\1/g,
5
+ (_match, quote, inner) => `${quote}${isSafeWord(inner) ? inner : placeholderFor(inner)}${quote}`
6
+ ).replace(/\b(ENOTFOUND|EAI_AGAIN)\s+[^\s'"`]+/g, "$1 [host]").replace(/\S+/g, redactWord);
7
+ }
8
+ const SCOPED_PACKAGE = /^@[a-z0-9~-][\w.~-]*\/[a-z0-9~-][\w.~-]*(?:\/[\w.-]+)*(?:@[\w.^~*<>=-]+)?$/i;
9
+ const KNOWN_SPECIFIER = /^(?:node|npm|workspace|catalog):[\w.^~*<>=-]*$/;
10
+ const CLOCK_TIME = /^\d{1,2}:\d{2}(?::\d{2})?$/;
11
+ const IPV4 = /(?:^|[^\d.])\d{1,3}(?:\.\d{1,3}){3}(?![.\d])/;
12
+ const IPV6 = /^\[?[\da-f]*:[\da-f]*:[\da-f:]*\]?(?::\d+)?$/i;
13
+ const HOST_AND_PORT = /^[\w.-]+:\d+$/;
14
+ const LEADING_PUNCTUATION = /* @__PURE__ */ new Set(["(", "'", '"', "`", "<", "[", "{"]);
15
+ const TRAILING_PUNCTUATION = /* @__PURE__ */ new Set([
16
+ ")",
17
+ "'",
18
+ '"',
19
+ "`",
20
+ ">",
21
+ "]",
22
+ "}",
23
+ ",",
24
+ ";",
25
+ ".",
26
+ "!",
27
+ "?"
28
+ ]);
29
+ function isSafeWord(word) {
30
+ if (!/[/\\@:]/.test(word) && !IPV4.test(word)) {
31
+ return true;
32
+ }
33
+ return SCOPED_PACKAGE.test(word) || KNOWN_SPECIFIER.test(word) || word.startsWith("npm:") && SCOPED_PACKAGE.test(word.slice(4)) || CLOCK_TIME.test(word);
34
+ }
35
+ function placeholderFor(word) {
36
+ if (word.includes("://")) {
37
+ return "[url]";
38
+ }
39
+ if (IPV4.test(word) || IPV6.test(word) || HOST_AND_PORT.test(word)) {
40
+ return "[host]";
41
+ }
42
+ if (/[/\\]/.test(word)) {
43
+ return "[path]";
44
+ }
45
+ return "[redacted]";
46
+ }
47
+ function redactWord(word) {
48
+ let start = 0;
49
+ let end = word.length;
50
+ while (end > start && TRAILING_PUNCTUATION.has(word[end - 1])) {
51
+ end--;
52
+ }
53
+ const withoutTrailing = word.slice(0, end);
54
+ if (!CLOCK_TIME.test(withoutTrailing) && IPV6.test(withoutTrailing)) {
55
+ return "[host]" + word.slice(end);
56
+ }
57
+ while (start < end && LEADING_PUNCTUATION.has(word[start])) {
58
+ start++;
59
+ }
60
+ const core = word.slice(start, end);
61
+ const checked = core.endsWith(":") ? core.slice(0, -1) : core;
62
+ if (checked === "" || isSafeWord(checked)) {
63
+ return word;
64
+ }
65
+ return word.slice(0, start) + placeholderFor(core) + word.slice(end);
66
+ }
67
+ export {
68
+ redactErrorMessage
69
+ };
@@ -1,36 +1,19 @@
1
- interface SensitiveArgPositions {
2
- exec: {
3
- positions: number[];
4
- options?: never;
5
- redactWith: string[];
6
- allowOnly: string[];
7
- };
8
- g: {
9
- positions: number[];
10
- options?: never;
11
- redactWith: string[];
12
- allowOnly?: string[];
13
- };
14
- generate: {
15
- positions: number[];
16
- options?: never;
17
- redactWith: string[];
18
- allowOnly?: string[];
19
- };
20
- prisma: {
21
- positions?: never;
22
- options: string[];
23
- redactWith: string[];
24
- allowOnly?: string[];
25
- };
26
- lint: {
27
- positions?: number[];
28
- options?: never;
29
- redactWith: string[];
30
- allowOnly: string[];
31
- };
32
- }
33
- export declare const sanitizeArgv: (argv: [string, string, keyof SensitiveArgPositions, ...string[]]) => string;
1
+ /**
2
+ * Turns `process.argv` into the `command` string sent with telemetry, for
3
+ * events sent before the CLI has described the running command (see
4
+ * `commandForTelemetry`).
5
+ *
6
+ * Only the command and the names of the options are kept, e.g.
7
+ * `generate --force --typescript`. Option values, positional arguments and
8
+ * everything after `--` can contain names, paths, hosts and other values
9
+ * that identify a user or their project, so they are left out.
10
+ *
11
+ * The command is the first argument after the script path. It is only kept
12
+ * if it looks like a command name, like `build` or `data-migrate`.
13
+ *
14
+ * `exec` passes its options on to the user's script, so for `exec` only the
15
+ * command is kept.
16
+ */
17
+ export declare const sanitizeArgv: (argv: string[]) => string;
34
18
  export declare const sendTelemetry: () => Promise<void>;
35
- export {};
36
19
  //# sourceMappingURL=sendTelemetry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sendTelemetry.d.ts","sourceRoot":"","sources":["../src/sendTelemetry.ts"],"names":[],"mappings":"AAaA,UAAU,qBAAqB;IAC7B,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM,EAAE,CAAA;QACnB,OAAO,CAAC,EAAE,KAAK,CAAA;QACf,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,SAAS,EAAE,MAAM,EAAE,CAAA;KACpB,CAAA;IACD,CAAC,EAAE;QACD,SAAS,EAAE,MAAM,EAAE,CAAA;QACnB,OAAO,CAAC,EAAE,KAAK,CAAA;QACf,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;KACrB,CAAA;IACD,QAAQ,EAAE;QACR,SAAS,EAAE,MAAM,EAAE,CAAA;QACnB,OAAO,CAAC,EAAE,KAAK,CAAA;QACf,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;KACrB,CAAA;IACD,MAAM,EAAE;QACN,SAAS,CAAC,EAAE,KAAK,CAAA;QACjB,OAAO,EAAE,MAAM,EAAE,CAAA;QACjB,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;KACrB,CAAA;IACD,IAAI,EAAE;QACJ,SAAS,CAAC,EAAE,MAAM,EAAE,CAAA;QACpB,OAAO,CAAC,EAAE,KAAK,CAAA;QACf,UAAU,EAAE,MAAM,EAAE,CAAA;QACpB,SAAS,EAAE,MAAM,EAAE,CAAA;KACpB,CAAA;CACF;AA8ED,eAAO,MAAM,YAAY,GACvB,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,qBAAqB,EAAE,GAAG,MAAM,EAAE,CAAC,WAyCjE,CAAA;AA2GD,eAAO,MAAM,aAAa,qBAsCzB,CAAA"}
1
+ {"version":3,"file":"sendTelemetry.d.ts","sourceRoot":"","sources":["../src/sendTelemetry.ts"],"names":[],"mappings":"AAsEA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,YAAY,GAAI,MAAM,MAAM,EAAE,WAsB1C,CAAA;AAgHD,eAAO,MAAM,aAAa,qBAsCzB,CAAA"}
@@ -8,29 +8,7 @@ import { v4 as uuidv4 } from "uuid";
8
8
  import yargsParser from "yargs/yargs";
9
9
  import { getRawConfig, getPaths } from "@cedarjs/project-config";
10
10
  import { RWProject } from "@cedarjs/structure/dist/model/RWProject";
11
- const SENSITIVE_ARG_POSITIONS = {
12
- exec: {
13
- positions: [1],
14
- redactWith: ["[script]"],
15
- allowOnly: ["exec"]
16
- },
17
- g: {
18
- positions: [2, 3],
19
- redactWith: ["[name]", "[path]"]
20
- },
21
- generate: {
22
- positions: [2, 3],
23
- redactWith: ["[name]", "[path]"]
24
- },
25
- prisma: {
26
- options: ["--name"],
27
- redactWith: ["[name]"]
28
- },
29
- lint: {
30
- allowOnly: ["lint", "--fix"],
31
- redactWith: ["[path]"]
32
- }
33
- };
11
+ import { redactErrorMessage } from "./redact.js";
34
12
  const getInfo = async (presets = {}) => {
35
13
  const info = JSON.parse(
36
14
  await envinfo.run(
@@ -65,35 +43,23 @@ const getInfo = async (presets = {}) => {
65
43
  experiments
66
44
  };
67
45
  };
46
+ const LONG_OPTION_NAME = /^--[a-zA-Z][\w-]*/;
47
+ const SHORT_OPTION_NAME = /^-[a-zA-Z]/;
48
+ const COMMAND_NAME = /^[a-z][\w:-]*$/i;
68
49
  const sanitizeArgv = (argv) => {
69
- const name = argv[2];
70
- const sensitiveCommand = SENSITIVE_ARG_POSITIONS[name];
71
50
  const args = argv.slice(2);
72
- if (sensitiveCommand) {
73
- if (sensitiveCommand.positions) {
74
- sensitiveCommand.positions.forEach((pos, index) => {
75
- if (args[pos] && !args[pos].includes("--")) {
76
- args[pos] = sensitiveCommand.redactWith[index];
77
- }
78
- });
79
- }
80
- if (sensitiveCommand.options) {
81
- sensitiveCommand.options.forEach((option, index) => {
82
- const argIndex = args.indexOf(option);
83
- if (argIndex !== -1) {
84
- args[argIndex + 1] = sensitiveCommand.redactWith[index];
85
- }
86
- });
87
- }
88
- if (sensitiveCommand.allowOnly) {
89
- args.forEach((arg, index) => {
90
- if (!sensitiveCommand.allowOnly?.includes(arg) && !sensitiveCommand.redactWith.includes(arg)) {
91
- args[index] = sensitiveCommand.redactWith[0];
92
- }
93
- });
94
- }
51
+ const passthroughIndex = args.indexOf("--");
52
+ const ownArgs = passthroughIndex === -1 ? args : args.slice(0, passthroughIndex);
53
+ if (ownArgs[0] === "exec") {
54
+ return "exec";
95
55
  }
96
- return args.join(" ");
56
+ return ownArgs.flatMap((arg, index) => {
57
+ const optionName = arg.match(LONG_OPTION_NAME)?.[0] ?? arg.match(SHORT_OPTION_NAME)?.[0];
58
+ if (optionName) {
59
+ return [optionName];
60
+ }
61
+ return index === 0 && COMMAND_NAME.test(arg) ? [arg] : [];
62
+ }).join(" ");
97
63
  };
98
64
  const buildPayload = async () => {
99
65
  let payload = {};
@@ -114,7 +80,8 @@ const buildPayload = async () => {
114
80
  const durationFlag = typeof rawArgv.duration === "string" ? rawArgv.duration : void 0;
115
81
  const rwVersionFlag = typeof rawArgv.rwVersion === "string" ? rawArgv.rwVersion : void 0;
116
82
  const errorFlag = typeof rawArgv.error === "string" ? rawArgv.error : void 0;
117
- const command = argvFlag ? sanitizeArgv(JSON.parse(argvFlag)) : "";
83
+ const commandFlag = typeof rawArgv.command === "string" ? rawArgv.command : void 0;
84
+ const command = commandFlag ? String(JSON.parse(commandFlag)) : argvFlag ? sanitizeArgv(JSON.parse(argvFlag)) : "";
118
85
  payload = {
119
86
  type: typeFlag || "command",
120
87
  command,
@@ -127,7 +94,7 @@ const buildPayload = async () => {
127
94
  };
128
95
  if (errorFlag) {
129
96
  payload.type = "error";
130
- payload.error = errorFlag.split("\n")[0].replace(/(\/[@\-\.\w]+)/g, "[path]");
97
+ payload.error = redactErrorMessage(errorFlag);
131
98
  }
132
99
  const project = new RWProject();
133
100
  const routes = project.getRouter().routes;
@@ -13,6 +13,15 @@
13
13
  */
14
14
  export declare function quoteForWindowsShell(arg: string): string;
15
15
  export declare const timedTelemetry: (argv: string[], options: Record<string, unknown>, func: (...args: any[]) => any) => Promise<any>;
16
- export declare const errorTelemetry: (argv: string[], error: any) => Promise<void>;
17
- export declare const telemetryMiddleware: () => Promise<void>;
16
+ /**
17
+ * Sends an error telemetry event. Only a redacted version of the error message
18
+ * is sent, see `redactErrorMessage`.
19
+ */
20
+ export declare const errorTelemetry: (argv: string[], error: unknown) => Promise<void>;
21
+ /**
22
+ * Used as yargs middleware when any command is invoked. Sends a telemetry
23
+ * event for the command, described from its yargs definition so that no
24
+ * values the user typed are sent.
25
+ */
26
+ export declare const telemetryMiddleware: (argv: Record<string, unknown>, yargs: unknown) => Promise<void>;
18
27
  //# sourceMappingURL=telemetry.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,UAuB/C;AAsDD,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,EAAE,EACd,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,iBAuB9B,CAAA;AAED,eAAO,MAAM,cAAc,GAAU,MAAM,MAAM,EAAE,EAAE,OAAO,GAAG,kBAS9D,CAAA;AAGD,eAAO,MAAM,mBAAmB,qBAS/B,CAAA"}
1
+ {"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;GAYG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,UAuB/C;AAsED,eAAO,MAAM,cAAc,GACzB,MAAM,MAAM,EAAE,EACd,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,MAAM,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,iBAsB9B,CAAA;AAED;;;GAGG;AACH,eAAO,MAAM,cAAc,GAAU,MAAM,MAAM,EAAE,EAAE,OAAO,OAAO,kBAalE,CAAA;AAED;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,GAC9B,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,OAAO,OAAO,kBAYf,CAAA"}
package/dist/telemetry.js CHANGED
@@ -1,6 +1,9 @@
1
1
  import { spawn } from "child_process";
2
2
  import os from "os";
3
3
  import path from "path";
4
+ import { hideBin } from "yargs/helpers";
5
+ import { commandForTelemetry } from "./commandForTelemetry.js";
6
+ import { redactErrorMessage } from "./redact.js";
4
7
  function quoteForWindowsShell(arg) {
5
8
  let quoted = '"';
6
9
  let backslashes = 0;
@@ -43,6 +46,8 @@ const spawnProcess = (...args) => {
43
46
  spawn(process.execPath, scriptArgs, spawnOptions).unref();
44
47
  }
45
48
  };
49
+ let currentCommand;
50
+ const commandArgs = (argv) => currentCommand === void 0 ? ["--argv", JSON.stringify(argv)] : ["--command", JSON.stringify(currentCommand)];
46
51
  const timedTelemetry = async (argv, options, func) => {
47
52
  if (process.env.CEDAR_DISABLE_TELEMETRY || process.env.REDWOOD_DISABLE_TELEMETRY) {
48
53
  return func.call(void 0);
@@ -51,8 +56,7 @@ const timedTelemetry = async (argv, options, func) => {
51
56
  const result = await func.call(void 0);
52
57
  const duration = (/* @__PURE__ */ new Date()).getTime() - start.getTime();
53
58
  spawnProcess(
54
- "--argv",
55
- JSON.stringify(argv),
59
+ ...commandArgs(argv),
56
60
  "--duration",
57
61
  duration.toString(),
58
62
  "--type",
@@ -64,13 +68,18 @@ const errorTelemetry = async (argv, error) => {
64
68
  if (process.env.CEDAR_DISABLE_TELEMETRY || process.env.REDWOOD_DISABLE_TELEMETRY) {
65
69
  return;
66
70
  }
67
- spawnProcess("--argv", JSON.stringify(argv), "--error", JSON.stringify(error));
71
+ spawnProcess(
72
+ ...commandArgs(argv),
73
+ "--error",
74
+ JSON.stringify(redactErrorMessage(error))
75
+ );
68
76
  };
69
- const telemetryMiddleware = async () => {
77
+ const telemetryMiddleware = async (argv, yargs) => {
70
78
  if (process.env.CEDAR_DISABLE_TELEMETRY || process.env.REDWOOD_DISABLE_TELEMETRY) {
71
79
  return;
72
80
  }
73
- spawnProcess("--argv", JSON.stringify(process.argv));
81
+ currentCommand = commandForTelemetry(argv, yargs, hideBin(process.argv));
82
+ spawnProcess(...commandArgs(process.argv));
74
83
  };
75
84
  export {
76
85
  errorTelemetry,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cedarjs/telemetry",
3
- "version": "8.0.0-canary.3592",
3
+ "version": "8.0.0-canary.3597",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/cedarjs/cedar.git",
@@ -22,8 +22,8 @@
22
22
  "test:watch": "vitest watch"
23
23
  },
24
24
  "dependencies": {
25
- "@cedarjs/project-config": "8.0.0-canary.3592",
26
- "@cedarjs/structure": "8.0.0-canary.3592",
25
+ "@cedarjs/project-config": "8.0.0-canary.3597",
26
+ "@cedarjs/structure": "8.0.0-canary.3597",
27
27
  "@whatwg-node/fetch": "0.12.1",
28
28
  "ci-info": "4.4.0",
29
29
  "envinfo": "7.21.0",