@velum-labs/routekit-daemon 0.16.7 → 0.16.9
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 +2 -2
- package/dist/telemetry.d.ts +2 -0
- package/dist/telemetry.js +5 -2
- package/dist/test/daemon.test.js +2 -1
- package/dist/test/telemetry.test.js +20 -5
- package/package.json +9 -9
package/dist/index.js
CHANGED
|
@@ -21,7 +21,7 @@ import { cleanupAccountTransaction, markAccountTransactionCommitted, prepareAcco
|
|
|
21
21
|
import { CallAttributionStore, callInspection } from "./call-attribution-store.js";
|
|
22
22
|
import { createCliproxySidecar } from "./cliproxy-sidecar.js";
|
|
23
23
|
import { aggregateInspections, buildLeaderboardResult, defaultLeaderboardWindow, LeaderboardRollupStore } from "./leaderboard.js";
|
|
24
|
-
import { DaemonTelemetry, DEFAULT_TELEMETRY_HOST, GatewayTelemetryAggregator } from "./telemetry.js";
|
|
24
|
+
import { DaemonTelemetry, DEFAULT_TELEMETRY_HOST, GatewayTelemetryAggregator, resolveTelemetryProjectKey } from "./telemetry.js";
|
|
25
25
|
export const ROUTEKIT_DAEMON_KIND = "daemon";
|
|
26
26
|
export const ROUTEKIT_PRODUCT = "routekit";
|
|
27
27
|
function dataTokenPath(home) {
|
|
@@ -494,7 +494,7 @@ export async function startRouteKitDaemon(options) {
|
|
|
494
494
|
const telemetryStatus = () => telemetryStatusMetadata(telemetry.resolve(env), {
|
|
495
495
|
provider: "posthog",
|
|
496
496
|
host: env.ROUTEKIT_POSTHOG_HOST?.trim() || DEFAULT_TELEMETRY_HOST,
|
|
497
|
-
configured: (env
|
|
497
|
+
configured: resolveTelemetryProjectKey(env).length > 0
|
|
498
498
|
});
|
|
499
499
|
handlers = {
|
|
500
500
|
"daemon.status": async () => ({
|
package/dist/telemetry.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import type { ModelCallRecord } from "@velum-labs/routekit-gateway";
|
|
2
2
|
import { type ConsentDecision, type TelemetryCategory, type TelemetryEventName, type TelemetryEventProperties } from "@velum-labs/routekit-telemetry-core";
|
|
3
3
|
export declare const DEFAULT_TELEMETRY_HOST = "https://us.i.posthog.com";
|
|
4
|
+
export declare const DEFAULT_TELEMETRY_PROJECT_KEY = "phc_nDTdKsasUFwVC5a7mkUxGBUnJtrNsTMPeWcwSHEmT7zb";
|
|
4
5
|
export declare const DEFAULT_TELEMETRY_FLUSH_INTERVAL_MS: number;
|
|
5
6
|
export declare const DEFAULT_TELEMETRY_GROUP_LIMIT = 256;
|
|
6
7
|
export declare const DEFAULT_TELEMETRY_SHUTDOWN_TIMEOUT_MS = 2000;
|
|
8
|
+
export declare function resolveTelemetryProjectKey(env: NodeJS.ProcessEnv): string;
|
|
7
9
|
export type TelemetryTransportPayload = {
|
|
8
10
|
distinctId: string;
|
|
9
11
|
event: string;
|
package/dist/telemetry.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
import { boundedShutdown, buildTelemetryEvent } from "@velum-labs/routekit-telemetry-core";
|
|
2
2
|
import { PostHog } from "posthog-node";
|
|
3
3
|
export const DEFAULT_TELEMETRY_HOST = "https://us.i.posthog.com";
|
|
4
|
+
export const DEFAULT_TELEMETRY_PROJECT_KEY = "phc_nDTdKsasUFwVC5a7mkUxGBUnJtrNsTMPeWcwSHEmT7zb";
|
|
4
5
|
export const DEFAULT_TELEMETRY_FLUSH_INTERVAL_MS = 60 * 60 * 1_000;
|
|
5
6
|
export const DEFAULT_TELEMETRY_GROUP_LIMIT = 256;
|
|
6
7
|
export const DEFAULT_TELEMETRY_SHUTDOWN_TIMEOUT_MS = 2_000;
|
|
8
|
+
export function resolveTelemetryProjectKey(env) {
|
|
9
|
+
return env.ROUTEKIT_POSTHOG_KEY?.trim() || DEFAULT_TELEMETRY_PROJECT_KEY;
|
|
10
|
+
}
|
|
7
11
|
const postHogFactory = (key, options) => {
|
|
8
12
|
const client = new PostHog(key, {
|
|
9
13
|
host: options.host,
|
|
@@ -96,8 +100,7 @@ export class DaemonTelemetry {
|
|
|
96
100
|
await this.#retireTransport(false);
|
|
97
101
|
}
|
|
98
102
|
#key() {
|
|
99
|
-
|
|
100
|
-
return key === undefined || key.length === 0 ? undefined : key;
|
|
103
|
+
return resolveTelemetryProjectKey(this.#env);
|
|
101
104
|
}
|
|
102
105
|
#retireTransport(flush = true) {
|
|
103
106
|
const client = this.#client;
|
package/dist/test/daemon.test.js
CHANGED
|
@@ -1370,7 +1370,7 @@ test("daemon telemetry emits lifecycle and committed operations exactly once wit
|
|
|
1370
1370
|
ROUTEKIT_HOME: stateHome,
|
|
1371
1371
|
OPENAI_API_KEY: "unique-api-key-canary",
|
|
1372
1372
|
OPENAI_BASE_URL: upstream.url,
|
|
1373
|
-
ROUTEKIT_POSTHOG_KEY: "
|
|
1373
|
+
ROUTEKIT_POSTHOG_KEY: "",
|
|
1374
1374
|
ROUTEKIT_PORTLESS: "0"
|
|
1375
1375
|
},
|
|
1376
1376
|
telemetryTransportFactory: () => ({
|
|
@@ -1384,6 +1384,7 @@ test("daemon telemetry emits lifecycle and committed operations exactly once wit
|
|
|
1384
1384
|
url: daemon.record.url,
|
|
1385
1385
|
token: daemon.record.controlToken
|
|
1386
1386
|
});
|
|
1387
|
+
assert.equal((await client.call("telemetry.get", {})).destination.configured, true);
|
|
1387
1388
|
const snapshot = await client.call("config.get", {});
|
|
1388
1389
|
const params = {
|
|
1389
1390
|
expectedRevision: snapshot.revision,
|
|
@@ -2,7 +2,7 @@ import assert from "node:assert/strict";
|
|
|
2
2
|
import { createServer } from "node:http";
|
|
3
3
|
import test from "node:test";
|
|
4
4
|
import { gunzipSync, inflateSync } from "node:zlib";
|
|
5
|
-
import { DaemonTelemetry, GatewayTelemetryAggregator } from "../telemetry.js";
|
|
5
|
+
import { DaemonTelemetry, DEFAULT_TELEMETRY_PROJECT_KEY, GatewayTelemetryAggregator, resolveTelemetryProjectKey } from "../telemetry.js";
|
|
6
6
|
function consent(enabled = true, categories = {}) {
|
|
7
7
|
return {
|
|
8
8
|
enabled,
|
|
@@ -47,6 +47,7 @@ function fixture(decision = consent(), env = { ROUTEKIT_POSTHOG_KEY: "key" }) {
|
|
|
47
47
|
let created = 0;
|
|
48
48
|
let flushed = 0;
|
|
49
49
|
let shutdown = 0;
|
|
50
|
+
const keys = [];
|
|
50
51
|
const client = {
|
|
51
52
|
capture: (payload) => {
|
|
52
53
|
payloads.push(payload);
|
|
@@ -61,8 +62,9 @@ function fixture(decision = consent(), env = { ROUTEKIT_POSTHOG_KEY: "key" }) {
|
|
|
61
62
|
const telemetry = new DaemonTelemetry({
|
|
62
63
|
env,
|
|
63
64
|
resolveConsent: () => decision,
|
|
64
|
-
factory: () => {
|
|
65
|
+
factory: (key) => {
|
|
65
66
|
created += 1;
|
|
67
|
+
keys.push(key);
|
|
66
68
|
return client;
|
|
67
69
|
},
|
|
68
70
|
shutdownTimeoutMs: 20
|
|
@@ -70,16 +72,16 @@ function fixture(decision = consent(), env = { ROUTEKIT_POSTHOG_KEY: "key" }) {
|
|
|
70
72
|
return {
|
|
71
73
|
telemetry,
|
|
72
74
|
payloads,
|
|
75
|
+
keys,
|
|
73
76
|
created: () => created,
|
|
74
77
|
flushed: () => flushed,
|
|
75
78
|
shutdown: () => shutdown
|
|
76
79
|
};
|
|
77
80
|
}
|
|
78
|
-
test("transport stays absent while disabled, DNT-equivalent, category-disabled
|
|
81
|
+
test("transport stays absent while disabled, DNT-equivalent, or category-disabled", () => {
|
|
79
82
|
for (const [decision, env] of [
|
|
80
83
|
[consent(false), { ROUTEKIT_POSTHOG_KEY: "key" }],
|
|
81
|
-
[consent(true, { reliability: false }), { ROUTEKIT_POSTHOG_KEY: "key" }]
|
|
82
|
-
[consent(), {}]
|
|
84
|
+
[consent(true, { reliability: false }), { ROUTEKIT_POSTHOG_KEY: "key" }]
|
|
83
85
|
]) {
|
|
84
86
|
const item = fixture(decision, env);
|
|
85
87
|
assert.equal(item.telemetry.capture("routekit.daemon_lifecycle", {
|
|
@@ -91,6 +93,19 @@ test("transport stays absent while disabled, DNT-equivalent, category-disabled,
|
|
|
91
93
|
assert.equal(item.created(), 0);
|
|
92
94
|
}
|
|
93
95
|
});
|
|
96
|
+
test("bundled project token is the default and a non-empty environment value overrides it", () => {
|
|
97
|
+
assert.equal(resolveTelemetryProjectKey({}), DEFAULT_TELEMETRY_PROJECT_KEY);
|
|
98
|
+
assert.equal(resolveTelemetryProjectKey({ ROUTEKIT_POSTHOG_KEY: " " }), DEFAULT_TELEMETRY_PROJECT_KEY);
|
|
99
|
+
assert.equal(resolveTelemetryProjectKey({ ROUTEKIT_POSTHOG_KEY: " override " }), "override");
|
|
100
|
+
const item = fixture(consent(), {});
|
|
101
|
+
assert.equal(item.telemetry.capture("routekit.daemon_lifecycle", {
|
|
102
|
+
action: "started",
|
|
103
|
+
outcome: "success",
|
|
104
|
+
supervisor: "unknown",
|
|
105
|
+
version: "test"
|
|
106
|
+
}), true);
|
|
107
|
+
assert.deepEqual(item.keys, [DEFAULT_TELEMETRY_PROJECT_KEY]);
|
|
108
|
+
});
|
|
94
109
|
test("transport payload has stable identity and mandatory privacy flags", () => {
|
|
95
110
|
const item = fixture();
|
|
96
111
|
assert.equal(item.telemetry.capture("routekit.daemon_lifecycle", {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@velum-labs/routekit-daemon",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.16.
|
|
4
|
+
"version": "0.16.9",
|
|
5
5
|
"description": "Singleton RouteKit control daemon and stable model gateway.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -35,14 +35,14 @@
|
|
|
35
35
|
"dependencies": {
|
|
36
36
|
"posthog-node": "5.46.1",
|
|
37
37
|
"yaml": "2.9.0",
|
|
38
|
-
"@velum-labs/routekit-accounts": "0.16.
|
|
39
|
-
"@velum-labs/routekit-config": "0.16.
|
|
40
|
-
"@velum-labs/routekit-control": "0.16.
|
|
41
|
-
"@velum-labs/routekit-gateway": "0.16.
|
|
42
|
-
"@velum-labs/routekit-registry": "0.16.
|
|
43
|
-
"@velum-labs/routekit-router": "0.16.
|
|
44
|
-
"@velum-labs/routekit-runtime": "0.16.
|
|
45
|
-
"@velum-labs/routekit-telemetry-core": "0.16.
|
|
38
|
+
"@velum-labs/routekit-accounts": "0.16.9",
|
|
39
|
+
"@velum-labs/routekit-config": "0.16.9",
|
|
40
|
+
"@velum-labs/routekit-control": "0.16.9",
|
|
41
|
+
"@velum-labs/routekit-gateway": "0.16.9",
|
|
42
|
+
"@velum-labs/routekit-registry": "0.16.9",
|
|
43
|
+
"@velum-labs/routekit-router": "0.16.9",
|
|
44
|
+
"@velum-labs/routekit-runtime": "0.16.9",
|
|
45
|
+
"@velum-labs/routekit-telemetry-core": "0.16.9"
|
|
46
46
|
},
|
|
47
47
|
"scripts": {
|
|
48
48
|
"build": "tsc -b",
|