@medusajs/telemetry 2.22.1 → 2.22.2-preview-20261029135257
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/AGENTS.md +1 -2
- package/dist/store.d.ts +1 -2
- package/dist/store.d.ts.map +1 -1
- package/dist/store.js +4 -2
- package/dist/telemeter.d.ts +1 -0
- package/dist/telemeter.d.ts.map +1 -1
- package/dist/telemeter.js +13 -5
- package/dist/util/in-memory-config.js +2 -2
- package/dist/util/show-notification.d.ts +1 -1
- package/dist/util/show-notification.d.ts.map +1 -1
- package/dist/util/show-notification.js +10 -6
- package/package.json +13 -12
package/AGENTS.md
CHANGED
|
@@ -24,7 +24,6 @@ Anonymous usage telemetry for the Medusa CLI and server. Used internally by `@me
|
|
|
24
24
|
## Development
|
|
25
25
|
|
|
26
26
|
- `yarn build`, `yarn watch`, `yarn test` (`jest --passWithNoTests src`; there are currently no tests).
|
|
27
|
-
- The `start` script (nodemon on `plugins/`) is stale; don't rely on it.
|
|
28
27
|
- To debug locally, point `MEDUSA_TELEMETRY_HOST` at a local server and set `MEDUSA_TELEMETRY_VERBOSE=true`.
|
|
29
28
|
|
|
30
29
|
## Gotchas
|
|
@@ -32,5 +31,5 @@ Anonymous usage telemetry for the Medusa CLI and server. Used internally by `@me
|
|
|
32
31
|
- Importing the package has side effects: it constructs a `Telemeter`, reads/writes config, may print the opt-out notice (outside CI) on first run, and registers `process.on("exit", flush)`.
|
|
33
32
|
- `postinstall` runs `node dist/postinstall.js || true` to show the opt-out notice on install; it must never throw.
|
|
34
33
|
- `MEDUSA_DISABLE_TELEMETRY` only stops events from being written (`Store.addEvent`); the on/off decision for flushing comes from the stored `telemetry.enabled` config, which defaults to `true` when unset.
|
|
35
|
-
- If `configstore` can't write (read-only home dir), `Store` falls back to `InMemoryConfigStore` with a throwaway `not-a-machine-id-*` id and the OS temp dir as base path.
|
|
34
|
+
- If `configstore` can't load (it's ESM-only, so under Jest) or can't write (read-only home dir), `Store` falls back to `InMemoryConfigStore` with a throwaway `not-a-machine-id-*` id and the OS temp dir as base path.
|
|
36
35
|
- The sender is a separate process: a failed POST writes the batch back to `events.json`, but events can be lost if that process dies mid-send (see comment in `outbox-store.js`).
|
package/dist/store.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export default Store;
|
|
2
2
|
declare class Store {
|
|
3
|
-
config_: InMemoryConfigStore |
|
|
3
|
+
config_: InMemoryConfigStore | import("configstore", { with: { "resolution-mode": "import" } }).default;
|
|
4
4
|
outbox_: OutboxStore;
|
|
5
5
|
disabled_: boolean;
|
|
6
6
|
getQueueSize(): number;
|
|
@@ -11,6 +11,5 @@ declare class Store {
|
|
|
11
11
|
setConfig(path: any, val: any): void;
|
|
12
12
|
}
|
|
13
13
|
import { InMemoryConfigStore } from "./util/in-memory-config";
|
|
14
|
-
import Configstore from "configstore";
|
|
15
14
|
import OutboxStore from "./util/outbox-store";
|
|
16
15
|
//# sourceMappingURL=store.d.ts.map
|
package/dist/store.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.js"],"names":[],"mappings":";AAMA;IAMM,wGAAwE;IAM1E,qBAAuC;IAEvC,mBAA+D;IAGjE,uBAEC;IAED,wBAEC;IAED,2BAOC;IAED,4CASC;IAED,0BAEC;IAED,qCAEC;CACF;oCAxDmC,yBAAyB;wBAErC,qBAAqB"}
|
package/dist/store.js
CHANGED
|
@@ -3,7 +3,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const configstore_1 = __importDefault(require("configstore"));
|
|
7
6
|
const path_1 = __importDefault(require("path"));
|
|
8
7
|
const in_memory_config_1 = require("./util/in-memory-config");
|
|
9
8
|
const is_truthy_1 = __importDefault(require("./util/is-truthy"));
|
|
@@ -11,7 +10,10 @@ const outbox_store_1 = __importDefault(require("./util/outbox-store"));
|
|
|
11
10
|
class Store {
|
|
12
11
|
constructor() {
|
|
13
12
|
try {
|
|
14
|
-
|
|
13
|
+
// configstore is ESM-only; requiring it here lets Jest (which can't load
|
|
14
|
+
// ESM from node_modules) fall back to the in-memory store below.
|
|
15
|
+
const { default: Configstore } = require("configstore");
|
|
16
|
+
this.config_ = new Configstore(`medusa`, {}, { globalConfigPath: true });
|
|
15
17
|
}
|
|
16
18
|
catch (e) {
|
|
17
19
|
this.config_ = new in_memory_config_1.InMemoryConfigStore();
|
package/dist/telemeter.d.ts
CHANGED
package/dist/telemeter.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"telemeter.d.ts","sourceRoot":"","sources":["../src/telemeter.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"telemeter.d.ts","sourceRoot":"","sources":["../src/telemeter.js"],"names":[],"mappings":";AAcA;IACE,0BAcC;IAbC,cAAyB;IAEzB,gBAAiD;IACjD,kBAAsD;IACtD,mBAAuD;IACvD,iBAAoB;IAEpB,mBAA4C;IAC5C,oBAA8C;IAE9C,wBAA8B;IAC9B,mBAAyB;IACzB,gBAAkB;IAGpB,oBAWC;IAFC,eAA0B;IAI5B,yBAeC;IAFC,qBAA8B;IAIhC;;;;;;;;;;MAkBC;IAFC;;;;;;;;;;kBAAoB;IAItB,oBAOC;IAED,wBAWC;IAED,qBAeC;IAED,wCAGC;IAED,mCAEC;IAED,qCAkCC;IAHK,kCAAkD;IAKxD,kCAIC;IAED,+BAIC;IAED,+BAIC;CACF;kBAjLiB,SAAS"}
|
package/dist/telemeter.js
CHANGED
|
@@ -3,11 +3,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const crypto_1 = require("crypto");
|
|
6
7
|
const fs_1 = __importDefault(require("fs"));
|
|
7
|
-
const is_docker_1 = __importDefault(require("is-docker"));
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
9
|
const path_1 = require("path");
|
|
10
|
-
const uuid_1 = require("uuid");
|
|
11
10
|
const store_1 = __importDefault(require("./store"));
|
|
12
11
|
const create_flush_1 = __importDefault(require("./util/create-flush"));
|
|
13
12
|
const get_term_program_1 = __importDefault(require("./util/get-term-program"));
|
|
@@ -34,7 +33,7 @@ class Telemeter {
|
|
|
34
33
|
}
|
|
35
34
|
let machineId = this.store_.getConfig(`telemetry.machine_id`);
|
|
36
35
|
if (typeof machineId !== `string`) {
|
|
37
|
-
machineId = (0,
|
|
36
|
+
machineId = (0, crypto_1.randomUUID)();
|
|
38
37
|
this.store_.setConfig(`telemetry.machine_id`, machineId);
|
|
39
38
|
}
|
|
40
39
|
this.machineId = machineId;
|
|
@@ -69,12 +68,21 @@ class Telemeter {
|
|
|
69
68
|
is_ci: (0, is_ci_1.isCI)(),
|
|
70
69
|
ci_name: (0, is_ci_1.getCIName)(),
|
|
71
70
|
arch: os_1.default.arch(),
|
|
72
|
-
docker:
|
|
71
|
+
docker: this.isDocker(),
|
|
73
72
|
term_program: (0, get_term_program_1.default)(),
|
|
74
73
|
};
|
|
75
74
|
this.osInfo = osInfo;
|
|
76
75
|
return osInfo;
|
|
77
76
|
}
|
|
77
|
+
isDocker() {
|
|
78
|
+
// is-docker is ESM-only, so Jest (which can't load it) reports false.
|
|
79
|
+
try {
|
|
80
|
+
return require("is-docker").default();
|
|
81
|
+
}
|
|
82
|
+
catch {
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
78
86
|
getMedusaVersion() {
|
|
79
87
|
try {
|
|
80
88
|
const packageJson = require.resolve(`@medusajs/medusa/package.json`);
|
|
@@ -110,7 +118,7 @@ class Telemeter {
|
|
|
110
118
|
}
|
|
111
119
|
enqueue_(type, data) {
|
|
112
120
|
const event = {
|
|
113
|
-
id: `te_${(0,
|
|
121
|
+
id: `te_${(0, crypto_1.randomUUID)()}`,
|
|
114
122
|
type,
|
|
115
123
|
properties: data,
|
|
116
124
|
timestamp: new Date(),
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.InMemoryConfigStore = void 0;
|
|
7
|
-
const
|
|
7
|
+
const crypto_1 = require("crypto");
|
|
8
8
|
const os_1 = __importDefault(require("os"));
|
|
9
9
|
const path_1 = require("path");
|
|
10
10
|
class InMemoryConfigStore {
|
|
@@ -16,7 +16,7 @@ class InMemoryConfigStore {
|
|
|
16
16
|
createBaseConfig() {
|
|
17
17
|
return {
|
|
18
18
|
"telemetry.enabled": true,
|
|
19
|
-
"telemetry.machine_id": `not-a-machine-id-${(0,
|
|
19
|
+
"telemetry.machine_id": `not-a-machine-id-${(0, crypto_1.randomUUID)()}`,
|
|
20
20
|
};
|
|
21
21
|
}
|
|
22
22
|
get(key) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"show-notification.d.ts","sourceRoot":"","sources":["../../src/util/show-notification.js"],"names":[],"mappings":";
|
|
1
|
+
{"version":3,"file":"show-notification.d.ts","sourceRoot":"","sources":["../../src/util/show-notification.js"],"names":[],"mappings":";AAYA;;GAEG;AACH;;;;oCAYC"}
|
|
@@ -1,9 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const boxen_1 = __importDefault(require("boxen"));
|
|
7
3
|
const defaultConfig = {
|
|
8
4
|
padding: 1,
|
|
9
5
|
borderColor: `blue`,
|
|
@@ -16,7 +12,15 @@ const defaultMessage = `Medusa collects anonymous usage analytics\n` +
|
|
|
16
12
|
/**
|
|
17
13
|
* Analytics notice for the end-user
|
|
18
14
|
*/
|
|
19
|
-
function showAnalyticsNotification(config = defaultConfig, message = defaultMessage) {
|
|
20
|
-
|
|
15
|
+
async function showAnalyticsNotification(config = defaultConfig, message = defaultMessage) {
|
|
16
|
+
// boxen is ESM-only; loading it lazily keeps this package requirable from
|
|
17
|
+
// Jest (which can't load ESM from node_modules), where we print it unboxed.
|
|
18
|
+
try {
|
|
19
|
+
const { default: boxen } = await import("boxen");
|
|
20
|
+
console.log(boxen(message, config));
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
console.log(message);
|
|
24
|
+
}
|
|
21
25
|
}
|
|
22
26
|
exports.default = showAnalyticsNotification;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@medusajs/telemetry",
|
|
3
|
-
"version": "2.22.
|
|
3
|
+
"version": "2.22.2-preview-20261029135257",
|
|
4
4
|
"description": "Telemetry for Medusa",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"repository": {
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"url": "https://github.com/medusajs/medusa/issues"
|
|
13
13
|
},
|
|
14
14
|
"engines": {
|
|
15
|
-
"node": ">=
|
|
15
|
+
"node": ">=22.22.0"
|
|
16
16
|
},
|
|
17
17
|
"publishConfig": {
|
|
18
18
|
"access": "public"
|
|
@@ -27,7 +27,6 @@
|
|
|
27
27
|
"author": "Sebastian Rindom",
|
|
28
28
|
"license": "MIT",
|
|
29
29
|
"scripts": {
|
|
30
|
-
"start": "nodemon --watch plugins/ --watch src/ --exec node src/index.js",
|
|
31
30
|
"prepare": "cross-env NODE_ENV=production yarn run build",
|
|
32
31
|
"watch": "yarn run -T tsc --build --watch",
|
|
33
32
|
"build": "yarn run -T rimraf dist && yarn run -T tsc --build",
|
|
@@ -36,15 +35,17 @@
|
|
|
36
35
|
"test": "../../node_modules/.bin/jest --passWithNoTests src"
|
|
37
36
|
},
|
|
38
37
|
"dependencies": {
|
|
39
|
-
"@babel/runtime": "^7.
|
|
40
|
-
"axios": "^1.
|
|
41
|
-
"axios-retry": "^
|
|
42
|
-
"boxen": "^
|
|
43
|
-
"ci-info": "^
|
|
44
|
-
"configstore": "^
|
|
45
|
-
"is-docker": "^
|
|
46
|
-
"remove-trailing-slash": "^0.1.1"
|
|
47
|
-
|
|
38
|
+
"@babel/runtime": "^7.29.10",
|
|
39
|
+
"axios": "^1.20.0",
|
|
40
|
+
"axios-retry": "^4.5.0",
|
|
41
|
+
"boxen": "^9.0.0",
|
|
42
|
+
"ci-info": "^4.4.0",
|
|
43
|
+
"configstore": "^8.0.0",
|
|
44
|
+
"is-docker": "^4.0.0",
|
|
45
|
+
"remove-trailing-slash": "^0.1.1"
|
|
46
|
+
},
|
|
47
|
+
"devDependencies": {
|
|
48
|
+
"cross-env": "^10.1.0"
|
|
48
49
|
},
|
|
49
50
|
"gitHead": "41a5425405aea5045a26def95c0dc00cf4a5a44d"
|
|
50
51
|
}
|