MCPcopy Create free account
hub / github.com/MemTensor/MemOS / loadTelemetryCredentials

Function loadTelemetryCredentials

packages/memos-core/src/telemetry.ts:22–41  ·  view source on GitHub ↗
(pluginDir?: string)

Source from the content-addressed store, hash-verified

20}
21
22function loadTelemetryCredentials(pluginDir?: string): { endpoint: string; pid: string; env: string } {
23 if (process.env.MEMOS_ARMS_ENDPOINT) {
24 return {
25 endpoint: process.env.MEMOS_ARMS_ENDPOINT,
26 pid: process.env.MEMOS_ARMS_PID ?? "",
27 env: process.env.MEMOS_ARMS_ENV ?? "prod",
28 };
29 }
30 const bases = pluginDir ? [pluginDir, path.join(pluginDir, "src")] : [];
31 if (typeof __dirname === "string") bases.push(path.resolve(__dirname, ".."), __dirname);
32 const candidates = bases.map(b => path.join(b, "telemetry.credentials.json"));
33 for (const credPath of candidates) {
34 try {
35 const raw = fs.readFileSync(credPath, "utf-8");
36 const creds = JSON.parse(raw);
37 if (creds.endpoint) return { endpoint: creds.endpoint, pid: creds.pid ?? "", env: creds.env ?? "prod" };
38 } catch {}
39 }
40 return { endpoint: "", pid: "", env: "prod" };
41}
42
43const FLUSH_AT = 10;
44const FLUSH_INTERVAL_MS = 30_000;

Callers 1

constructorMethod · 0.70

Calls 4

resolveMethod · 0.80
mapMethod · 0.80
joinMethod · 0.45
parseMethod · 0.45

Tested by

no test coverage detected