@cedarjs/telemetry 6.0.0-canary.2742 → 6.0.0-canary.2745
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 -70
- package/dist/telemetry.d.ts.map +1 -1
- package/dist/telemetry.js +12 -45
- package/package.json +6 -6
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;AA+ED,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],
|
|
@@ -134,7 +101,7 @@ const sanitizeArgv = (argv) => {
|
|
|
134
101
|
const buildPayload = async () => {
|
|
135
102
|
let payload = {};
|
|
136
103
|
const processArgv = [...process.argv];
|
|
137
|
-
if (
|
|
104
|
+
if (os.type() === "Windows_NT") {
|
|
138
105
|
const argvIndex = processArgv.findIndex((arg) => arg === "--argv") + 1;
|
|
139
106
|
let argvFormatted = argvIndex !== 0 ? processArgv[argvIndex] : null;
|
|
140
107
|
if (argvFormatted) {
|
|
@@ -144,23 +111,28 @@ const buildPayload = async () => {
|
|
|
144
111
|
processArgv[argvIndex] = argvFormatted;
|
|
145
112
|
}
|
|
146
113
|
}
|
|
147
|
-
const
|
|
148
|
-
const
|
|
114
|
+
const rawArgv = yargsParser(processArgv.slice(2)).parseSync();
|
|
115
|
+
const argvFlag = typeof rawArgv.argv === "string" ? rawArgv.argv : void 0;
|
|
116
|
+
const typeFlag = typeof rawArgv.type === "string" ? rawArgv.type : void 0;
|
|
117
|
+
const durationFlag = typeof rawArgv.duration === "string" ? rawArgv.duration : void 0;
|
|
118
|
+
const rwVersionFlag = typeof rawArgv.rwVersion === "string" ? rawArgv.rwVersion : void 0;
|
|
119
|
+
const errorFlag = typeof rawArgv.error === "string" ? rawArgv.error : void 0;
|
|
120
|
+
const command = argvFlag ? sanitizeArgv(JSON.parse(argvFlag)) : "";
|
|
149
121
|
payload = {
|
|
150
|
-
type:
|
|
122
|
+
type: typeFlag || "command",
|
|
151
123
|
command,
|
|
152
|
-
duration:
|
|
124
|
+
duration: durationFlag ? parseInt(durationFlag) : null,
|
|
153
125
|
uid: uniqueId(),
|
|
154
|
-
ci:
|
|
126
|
+
ci: ci.isCI,
|
|
155
127
|
cedarCi: !!process.env.CEDAR_CI,
|
|
156
128
|
NODE_ENV: process.env.NODE_ENV || null,
|
|
157
|
-
...await getInfo({ cedarVersion:
|
|
129
|
+
...await getInfo({ cedarVersion: rwVersionFlag, command })
|
|
158
130
|
};
|
|
159
|
-
if (
|
|
131
|
+
if (errorFlag) {
|
|
160
132
|
payload.type = "error";
|
|
161
|
-
payload.error =
|
|
133
|
+
payload.error = errorFlag.split("\n")[0].replace(/(\/[@\-\.\w]+)/g, "[path]");
|
|
162
134
|
}
|
|
163
|
-
const project = new
|
|
135
|
+
const project = new RWProject();
|
|
164
136
|
const routes = project.getRouter().routes;
|
|
165
137
|
const prerenderedRoutes = routes.filter((route) => route.hasPrerender);
|
|
166
138
|
payload = {
|
|
@@ -171,25 +143,25 @@ const buildPayload = async () => {
|
|
|
171
143
|
return payload;
|
|
172
144
|
};
|
|
173
145
|
function uniqueId() {
|
|
174
|
-
const telemetryCachePath =
|
|
175
|
-
|
|
146
|
+
const telemetryCachePath = path.join(
|
|
147
|
+
getPaths().generated.base,
|
|
176
148
|
"telemetry.txt"
|
|
177
149
|
);
|
|
178
150
|
const now = Date.now();
|
|
179
151
|
const expires = now - 24 * 60 * 60 * 1e3;
|
|
180
152
|
let uuid;
|
|
181
|
-
if (!
|
|
182
|
-
uuid = (
|
|
153
|
+
if (!fs.existsSync(telemetryCachePath) || fs.statSync(telemetryCachePath).mtimeMs < expires) {
|
|
154
|
+
uuid = uuidv4();
|
|
183
155
|
try {
|
|
184
|
-
if (!
|
|
185
|
-
|
|
156
|
+
if (!fs.existsSync(path.dirname(telemetryCachePath))) {
|
|
157
|
+
fs.mkdirSync(path.dirname(telemetryCachePath), { recursive: true });
|
|
186
158
|
}
|
|
187
|
-
|
|
159
|
+
fs.writeFileSync(telemetryCachePath, uuid);
|
|
188
160
|
} catch {
|
|
189
161
|
console.error("\nCould not create telemetry.txt file\n");
|
|
190
162
|
}
|
|
191
163
|
} else {
|
|
192
|
-
uuid =
|
|
164
|
+
uuid = fs.readFileSync(telemetryCachePath).toString();
|
|
193
165
|
}
|
|
194
166
|
return uuid;
|
|
195
167
|
}
|
|
@@ -201,7 +173,7 @@ const sendTelemetry = async () => {
|
|
|
201
173
|
if (verboseTelemetry) {
|
|
202
174
|
console.info("Cedar Telemetry Payload", payload);
|
|
203
175
|
}
|
|
204
|
-
const response = await
|
|
176
|
+
const response = await fetch(telemetryUrl, {
|
|
205
177
|
method: "post",
|
|
206
178
|
body: JSON.stringify(payload),
|
|
207
179
|
headers: { "Content-Type": "application/json" }
|
|
@@ -218,8 +190,7 @@ const sendTelemetry = async () => {
|
|
|
218
190
|
}
|
|
219
191
|
}
|
|
220
192
|
};
|
|
221
|
-
|
|
222
|
-
0 && (module.exports = {
|
|
193
|
+
export {
|
|
223
194
|
sanitizeArgv,
|
|
224
195
|
sendTelemetry
|
|
225
|
-
}
|
|
196
|
+
};
|
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": "6.0.0-canary.
|
|
3
|
+
"version": "6.0.0-canary.2745",
|
|
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": "6.0.0-canary.
|
|
26
|
-
"@cedarjs/structure": "6.0.0-canary.
|
|
25
|
+
"@cedarjs/project-config": "6.0.0-canary.2745",
|
|
26
|
+
"@cedarjs/structure": "6.0.0-canary.2745",
|
|
27
27
|
"@whatwg-node/fetch": "0.10.13",
|
|
28
28
|
"ci-info": "4.4.0",
|
|
29
29
|
"envinfo": "7.21.0",
|