@cedarjs/telemetry 5.0.6-rc.4 → 5.0.7-next.186
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 +1 -22
- package/dist/scripts/invoke.js +2 -3
- package/dist/sendTelemetry.d.ts.map +1 -1
- package/dist/sendTelemetry.js +41 -72
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +12 -45
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1,22 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var index_exports = {};
|
|
17
|
-
module.exports = __toCommonJS(index_exports);
|
|
18
|
-
__reExport(index_exports, require("./telemetry.js"), module.exports);
|
|
19
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
-
0 && (module.exports = {
|
|
21
|
-
...require("./telemetry.js")
|
|
22
|
-
});
|
|
1
|
+
export * from "./telemetry.js";
|
package/dist/scripts/invoke.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendTelemetry.d.ts","sourceRoot":"","sources":["../src/sendTelemetry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sendTelemetry.d.ts","sourceRoot":"","sources":["../src/sendTelemetry.ts"],"names":[],"mappings":"AAcA,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"}
|
package/dist/sendTelemetry.js
CHANGED
|
@@ -1,47 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var sendTelemetry_exports = {};
|
|
30
|
-
__export(sendTelemetry_exports, {
|
|
31
|
-
sanitizeArgv: () => sanitizeArgv,
|
|
32
|
-
sendTelemetry: () => sendTelemetry
|
|
33
|
-
});
|
|
34
|
-
module.exports = __toCommonJS(sendTelemetry_exports);
|
|
35
|
-
var import_node_fs = __toESM(require("node:fs"));
|
|
36
|
-
var import_os = __toESM(require("os"));
|
|
37
|
-
var import_path = __toESM(require("path"));
|
|
38
|
-
var import_fetch = require("@whatwg-node/fetch");
|
|
39
|
-
var import_ci_info = __toESM(require("ci-info"));
|
|
40
|
-
var import_envinfo = __toESM(require("envinfo"));
|
|
41
|
-
var import_systeminformation = __toESM(require("systeminformation"));
|
|
42
|
-
var import_uuid = require("uuid");
|
|
43
|
-
var import_project_config = require("@cedarjs/project-config");
|
|
44
|
-
var import_RWProject = require("@cedarjs/structure/dist/model/RWProject");
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "os";
|
|
3
|
+
import path from "path";
|
|
4
|
+
import { fetch } from "@whatwg-node/fetch";
|
|
5
|
+
import ci from "ci-info";
|
|
6
|
+
import envinfo from "envinfo";
|
|
7
|
+
import system from "systeminformation";
|
|
8
|
+
import { v4 as uuidv4 } from "uuid";
|
|
9
|
+
import yargsParser from "yargs/yargs";
|
|
10
|
+
import { getRawConfig, getPaths } from "@cedarjs/project-config";
|
|
11
|
+
import { RWProject } from "@cedarjs/structure/dist/model/RWProject";
|
|
45
12
|
const SENSITIVE_ARG_POSITIONS = {
|
|
46
13
|
exec: {
|
|
47
14
|
positions: [1],
|
|
@@ -67,7 +34,7 @@ const SENSITIVE_ARG_POSITIONS = {
|
|
|
67
34
|
};
|
|
68
35
|
const getInfo = async (presets = {}) => {
|
|
69
36
|
const info = JSON.parse(
|
|
70
|
-
await
|
|
37
|
+
await envinfo.run(
|
|
71
38
|
{
|
|
72
39
|
System: ["OS", "Shell"],
|
|
73
40
|
Binaries: ["Node", "Yarn", "npm"],
|
|
@@ -83,9 +50,9 @@ const getInfo = async (presets = {}) => {
|
|
|
83
50
|
} else if (shell?.path.match("\\")) {
|
|
84
51
|
info.System.Shell.name = info.System.Shell.path.split("\\").pop();
|
|
85
52
|
}
|
|
86
|
-
const cpu = await
|
|
87
|
-
const mem = await
|
|
88
|
-
const experiments = Object.keys(
|
|
53
|
+
const cpu = await system.cpu();
|
|
54
|
+
const mem = await system.mem();
|
|
55
|
+
const experiments = Object.keys(getRawConfig()["experimental"] || {});
|
|
89
56
|
return {
|
|
90
57
|
os: info.System?.OS?.split(" ")[0],
|
|
91
58
|
osVersion: info.System?.OS?.split(" ")[1],
|
|
@@ -96,8 +63,6 @@ const getInfo = async (presets = {}) => {
|
|
|
96
63
|
vsCodeVersion: info.IDEs?.VSCode?.version,
|
|
97
64
|
cedarVersion: presets.cedarVersion || info.npmPackages?.["@cedarjs/core"]?.installed,
|
|
98
65
|
system: `${cpu.physicalCores}.${Math.round(mem.total / 1073741824)}`,
|
|
99
|
-
webBundler: "vite",
|
|
100
|
-
// Hardcoded as this is now the only supported bundler
|
|
101
66
|
experiments
|
|
102
67
|
};
|
|
103
68
|
};
|
|
@@ -134,7 +99,7 @@ const sanitizeArgv = (argv) => {
|
|
|
134
99
|
const buildPayload = async () => {
|
|
135
100
|
let payload = {};
|
|
136
101
|
const processArgv = [...process.argv];
|
|
137
|
-
if (
|
|
102
|
+
if (os.type() === "Windows_NT") {
|
|
138
103
|
const argvIndex = processArgv.findIndex((arg) => arg === "--argv") + 1;
|
|
139
104
|
let argvFormatted = argvIndex !== 0 ? processArgv[argvIndex] : null;
|
|
140
105
|
if (argvFormatted) {
|
|
@@ -144,23 +109,28 @@ const buildPayload = async () => {
|
|
|
144
109
|
processArgv[argvIndex] = argvFormatted;
|
|
145
110
|
}
|
|
146
111
|
}
|
|
147
|
-
const
|
|
148
|
-
const
|
|
112
|
+
const rawArgv = yargsParser(processArgv.slice(2)).parseSync();
|
|
113
|
+
const argvFlag = typeof rawArgv.argv === "string" ? rawArgv.argv : void 0;
|
|
114
|
+
const typeFlag = typeof rawArgv.type === "string" ? rawArgv.type : void 0;
|
|
115
|
+
const durationFlag = typeof rawArgv.duration === "string" ? rawArgv.duration : void 0;
|
|
116
|
+
const rwVersionFlag = typeof rawArgv.rwVersion === "string" ? rawArgv.rwVersion : void 0;
|
|
117
|
+
const errorFlag = typeof rawArgv.error === "string" ? rawArgv.error : void 0;
|
|
118
|
+
const command = argvFlag ? sanitizeArgv(JSON.parse(argvFlag)) : "";
|
|
149
119
|
payload = {
|
|
150
|
-
type:
|
|
120
|
+
type: typeFlag || "command",
|
|
151
121
|
command,
|
|
152
|
-
duration:
|
|
122
|
+
duration: durationFlag ? parseInt(durationFlag) : null,
|
|
153
123
|
uid: uniqueId(),
|
|
154
|
-
ci:
|
|
124
|
+
ci: ci.isCI,
|
|
155
125
|
cedarCi: !!process.env.CEDAR_CI,
|
|
156
126
|
NODE_ENV: process.env.NODE_ENV || null,
|
|
157
|
-
...await getInfo({ cedarVersion:
|
|
127
|
+
...await getInfo({ cedarVersion: rwVersionFlag, command })
|
|
158
128
|
};
|
|
159
|
-
if (
|
|
129
|
+
if (errorFlag) {
|
|
160
130
|
payload.type = "error";
|
|
161
|
-
payload.error =
|
|
131
|
+
payload.error = errorFlag.split("\n")[0].replace(/(\/[@\-\.\w]+)/g, "[path]");
|
|
162
132
|
}
|
|
163
|
-
const project = new
|
|
133
|
+
const project = new RWProject();
|
|
164
134
|
const routes = project.getRouter().routes;
|
|
165
135
|
const prerenderedRoutes = routes.filter((route) => route.hasPrerender);
|
|
166
136
|
payload = {
|
|
@@ -171,25 +141,25 @@ const buildPayload = async () => {
|
|
|
171
141
|
return payload;
|
|
172
142
|
};
|
|
173
143
|
function uniqueId() {
|
|
174
|
-
const telemetryCachePath =
|
|
175
|
-
|
|
144
|
+
const telemetryCachePath = path.join(
|
|
145
|
+
getPaths().generated.base,
|
|
176
146
|
"telemetry.txt"
|
|
177
147
|
);
|
|
178
148
|
const now = Date.now();
|
|
179
149
|
const expires = now - 24 * 60 * 60 * 1e3;
|
|
180
150
|
let uuid;
|
|
181
|
-
if (!
|
|
182
|
-
uuid = (
|
|
151
|
+
if (!fs.existsSync(telemetryCachePath) || fs.statSync(telemetryCachePath).mtimeMs < expires) {
|
|
152
|
+
uuid = uuidv4();
|
|
183
153
|
try {
|
|
184
|
-
if (!
|
|
185
|
-
|
|
154
|
+
if (!fs.existsSync(path.dirname(telemetryCachePath))) {
|
|
155
|
+
fs.mkdirSync(path.dirname(telemetryCachePath), { recursive: true });
|
|
186
156
|
}
|
|
187
|
-
|
|
157
|
+
fs.writeFileSync(telemetryCachePath, uuid);
|
|
188
158
|
} catch {
|
|
189
159
|
console.error("\nCould not create telemetry.txt file\n");
|
|
190
160
|
}
|
|
191
161
|
} else {
|
|
192
|
-
uuid =
|
|
162
|
+
uuid = fs.readFileSync(telemetryCachePath).toString();
|
|
193
163
|
}
|
|
194
164
|
return uuid;
|
|
195
165
|
}
|
|
@@ -201,7 +171,7 @@ const sendTelemetry = async () => {
|
|
|
201
171
|
if (verboseTelemetry) {
|
|
202
172
|
console.info("Cedar Telemetry Payload", payload);
|
|
203
173
|
}
|
|
204
|
-
const response = await
|
|
174
|
+
const response = await fetch(telemetryUrl, {
|
|
205
175
|
method: "post",
|
|
206
176
|
body: JSON.stringify(payload),
|
|
207
177
|
headers: { "Content-Type": "application/json" }
|
|
@@ -218,8 +188,7 @@ const sendTelemetry = async () => {
|
|
|
218
188
|
}
|
|
219
189
|
}
|
|
220
190
|
};
|
|
221
|
-
|
|
222
|
-
0 && (module.exports = {
|
|
191
|
+
export {
|
|
223
192
|
sanitizeArgv,
|
|
224
193
|
sendTelemetry
|
|
225
|
-
}
|
|
194
|
+
};
|
package/dist/telemetry.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"telemetry.d.ts","sourceRoot":"","sources":["../src/telemetry.ts"],"names":[],"mappings":"AAsDA,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"}
|
package/dist/telemetry.js
CHANGED
|
@@ -1,43 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
|
-
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
-
for (let key of __getOwnPropNames(from))
|
|
15
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
-
}
|
|
18
|
-
return to;
|
|
19
|
-
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
-
var telemetry_exports = {};
|
|
30
|
-
__export(telemetry_exports, {
|
|
31
|
-
errorTelemetry: () => errorTelemetry,
|
|
32
|
-
telemetryMiddleware: () => telemetryMiddleware,
|
|
33
|
-
timedTelemetry: () => timedTelemetry
|
|
34
|
-
});
|
|
35
|
-
module.exports = __toCommonJS(telemetry_exports);
|
|
36
|
-
var import_child_process = require("child_process");
|
|
37
|
-
var import_os = __toESM(require("os"));
|
|
38
|
-
var import_path = __toESM(require("path"));
|
|
1
|
+
import { spawn } from "child_process";
|
|
2
|
+
import os from "os";
|
|
3
|
+
import path from "path";
|
|
39
4
|
const spawnProcess = (...args) => {
|
|
40
|
-
const isWindows =
|
|
5
|
+
const isWindows = os.type() === "Windows_NT";
|
|
41
6
|
const execPath = isWindows ? `"${process.execPath}"` : process.execPath;
|
|
42
7
|
const spawnOptions = isWindows ? {
|
|
43
8
|
stdio: process.env.CEDAR_VERBOSE_TELEMETRY || process.env.REDWOOD_VERBOSE_TELEMETRY ? ["ignore", "inherit", "inherit"] : "ignore",
|
|
@@ -51,11 +16,14 @@ const spawnProcess = (...args) => {
|
|
|
51
16
|
detached: process.env.CEDAR_VERBOSE_TELEMETRY || process.env.REDWOOD_VERBOSE_TELEMETRY ? false : true,
|
|
52
17
|
windowsHide: true
|
|
53
18
|
};
|
|
54
|
-
const scriptArgs = [
|
|
19
|
+
const scriptArgs = [
|
|
20
|
+
path.join(import.meta.dirname, "scripts", "invoke.js"),
|
|
21
|
+
...args
|
|
22
|
+
];
|
|
55
23
|
if (isWindows) {
|
|
56
|
-
|
|
24
|
+
spawn([execPath, ...scriptArgs].join(" "), [], spawnOptions).unref();
|
|
57
25
|
} else {
|
|
58
|
-
|
|
26
|
+
spawn(process.execPath, scriptArgs, spawnOptions).unref();
|
|
59
27
|
}
|
|
60
28
|
};
|
|
61
29
|
const timedTelemetry = async (argv, options, func) => {
|
|
@@ -87,9 +55,8 @@ const telemetryMiddleware = async () => {
|
|
|
87
55
|
}
|
|
88
56
|
spawnProcess("--argv", JSON.stringify(process.argv));
|
|
89
57
|
};
|
|
90
|
-
|
|
91
|
-
0 && (module.exports = {
|
|
58
|
+
export {
|
|
92
59
|
errorTelemetry,
|
|
93
60
|
telemetryMiddleware,
|
|
94
61
|
timedTelemetry
|
|
95
|
-
}
|
|
62
|
+
};
|
package/package.json
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cedarjs/telemetry",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.7-next.186",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/cedarjs/cedar.git",
|
|
7
7
|
"directory": "packages/telemetry"
|
|
8
8
|
},
|
|
9
9
|
"license": "MIT",
|
|
10
|
-
"type": "
|
|
10
|
+
"type": "module",
|
|
11
11
|
"main": "./dist/index.js",
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"files": [
|
|
14
14
|
"dist"
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
|
-
"build": "node build.mts
|
|
17
|
+
"build": "node build.mts",
|
|
18
18
|
"build:pack": "yarn pack -o cedarjs-telemetry.tgz",
|
|
19
|
-
"build:types": "tsc --build --verbose",
|
|
19
|
+
"build:types": "tsc --build --verbose ./tsconfig.build.json",
|
|
20
20
|
"prepublishOnly": "NODE_ENV=production yarn build",
|
|
21
21
|
"test": "vitest run",
|
|
22
22
|
"test:watch": "vitest watch"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@cedarjs/project-config": "5.0.
|
|
26
|
-
"@cedarjs/structure": "5.0.
|
|
25
|
+
"@cedarjs/project-config": "5.0.7-next.186",
|
|
26
|
+
"@cedarjs/structure": "5.0.7-next.186",
|
|
27
27
|
"@whatwg-node/fetch": "0.10.13",
|
|
28
28
|
"ci-info": "4.4.0",
|
|
29
29
|
"envinfo": "7.21.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@types/envinfo": "7.8.4",
|
|
36
36
|
"@types/yargs": "17.0.35",
|
|
37
37
|
"typescript": "5.9.3",
|
|
38
|
-
"vitest": "
|
|
38
|
+
"vitest": "4.1.10"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=24"
|