@revenium/claude-code-metering 0.1.0 → 0.1.2
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/CHANGELOG.md +22 -28
- package/README.md +323 -139
- package/dist/cli/commands/backfill.d.ts +106 -1
- package/dist/cli/commands/backfill.d.ts.map +1 -1
- package/dist/cli/commands/backfill.js +359 -146
- package/dist/cli/commands/backfill.js.map +1 -1
- package/dist/cli/commands/setup.d.ts +2 -0
- package/dist/cli/commands/setup.d.ts.map +1 -1
- package/dist/cli/commands/setup.js +55 -49
- package/dist/cli/commands/setup.js.map +1 -1
- package/dist/cli/commands/status.d.ts.map +1 -1
- package/dist/cli/commands/status.js +23 -30
- package/dist/cli/commands/status.js.map +1 -1
- package/dist/cli/commands/test.d.ts.map +1 -1
- package/dist/cli/commands/test.js +4 -3
- package/dist/cli/commands/test.js.map +1 -1
- package/dist/cli/index.d.ts +2 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +44 -30
- package/dist/cli/index.js.map +1 -1
- package/dist/core/api/client.d.ts +17 -8
- package/dist/core/api/client.d.ts.map +1 -1
- package/dist/core/api/client.js +58 -49
- package/dist/core/api/client.js.map +1 -1
- package/dist/core/config/loader.d.ts +5 -13
- package/dist/core/config/loader.d.ts.map +1 -1
- package/dist/core/config/loader.js +70 -46
- package/dist/core/config/loader.js.map +1 -1
- package/dist/core/config/validator.d.ts +5 -1
- package/dist/core/config/validator.d.ts.map +1 -1
- package/dist/core/config/validator.js +37 -22
- package/dist/core/config/validator.js.map +1 -1
- package/dist/core/config/writer.d.ts +1 -1
- package/dist/core/config/writer.d.ts.map +1 -1
- package/dist/core/config/writer.js +82 -74
- package/dist/core/config/writer.js.map +1 -1
- package/dist/core/shell/detector.d.ts +8 -1
- package/dist/core/shell/detector.d.ts.map +1 -1
- package/dist/core/shell/detector.js +38 -24
- package/dist/core/shell/detector.js.map +1 -1
- package/dist/core/shell/profile-updater.d.ts +1 -1
- package/dist/core/shell/profile-updater.d.ts.map +1 -1
- package/dist/core/shell/profile-updater.js +40 -27
- package/dist/core/shell/profile-updater.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/index.d.ts +30 -25
- package/dist/types/index.d.ts.map +1 -1
- package/dist/utils/constants.d.ts +2 -2
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +2 -2
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/hashing.d.ts +18 -0
- package/dist/utils/hashing.d.ts.map +1 -0
- package/dist/utils/hashing.js +27 -0
- package/dist/utils/hashing.js.map +1 -0
- package/package.json +6 -3
package/dist/cli/index.js
CHANGED
|
@@ -1,65 +1,79 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
"use strict";
|
|
3
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.program = void 0;
|
|
4
5
|
const commander_1 = require("commander");
|
|
5
6
|
const setup_js_1 = require("./commands/setup.js");
|
|
6
7
|
const status_js_1 = require("./commands/status.js");
|
|
7
8
|
const test_js_1 = require("./commands/test.js");
|
|
8
9
|
const backfill_js_1 = require("./commands/backfill.js");
|
|
9
|
-
|
|
10
|
-
program
|
|
11
|
-
.name(
|
|
12
|
-
.description(
|
|
13
|
-
.version(
|
|
14
|
-
program
|
|
15
|
-
.command(
|
|
16
|
-
.description(
|
|
17
|
-
.option(
|
|
18
|
-
.option(
|
|
19
|
-
.option(
|
|
20
|
-
.option(
|
|
21
|
-
.option(
|
|
10
|
+
exports.program = new commander_1.Command();
|
|
11
|
+
exports.program
|
|
12
|
+
.name("revenium-metering")
|
|
13
|
+
.description("Configure Claude Code telemetry export to Revenium")
|
|
14
|
+
.version("0.1.1");
|
|
15
|
+
exports.program
|
|
16
|
+
.command("setup")
|
|
17
|
+
.description("Interactive setup wizard to configure Claude Code metering")
|
|
18
|
+
.option("-k, --api-key <key>", "Revenium API key (hak_...)")
|
|
19
|
+
.option("-e, --email <email>", "Email for usage attribution")
|
|
20
|
+
.option("-t, --tier <tier>", "Subscription tier (professional, max, team, enterprise, api)")
|
|
21
|
+
.option("--endpoint <url>", "Revenium API endpoint URL")
|
|
22
|
+
.option("-o, --organization <name>", "Organization name for cost attribution")
|
|
23
|
+
.option("-p, --product <name>", "Product name for cost attribution")
|
|
24
|
+
.option("--skip-shell-update", "Skip automatic shell profile update")
|
|
22
25
|
.action(async (options) => {
|
|
23
26
|
await (0, setup_js_1.setupCommand)({
|
|
24
27
|
apiKey: options.apiKey,
|
|
25
28
|
email: options.email,
|
|
26
29
|
tier: options.tier,
|
|
27
30
|
endpoint: options.endpoint,
|
|
31
|
+
organizationId: options.organization,
|
|
32
|
+
productId: options.product,
|
|
28
33
|
skipShellUpdate: options.skipShellUpdate,
|
|
29
34
|
});
|
|
30
35
|
});
|
|
31
|
-
program
|
|
32
|
-
.command(
|
|
33
|
-
.description(
|
|
36
|
+
exports.program
|
|
37
|
+
.command("status")
|
|
38
|
+
.description("Check current configuration and endpoint connectivity")
|
|
34
39
|
.action(async () => {
|
|
35
40
|
await (0, status_js_1.statusCommand)();
|
|
36
41
|
});
|
|
37
|
-
program
|
|
38
|
-
.command(
|
|
39
|
-
.description(
|
|
40
|
-
.option(
|
|
42
|
+
exports.program
|
|
43
|
+
.command("test")
|
|
44
|
+
.description("Send a test metric to verify the integration")
|
|
45
|
+
.option("-v, --verbose", "Show detailed payload information")
|
|
41
46
|
.action(async (options) => {
|
|
42
47
|
await (0, test_js_1.testCommand)({ verbose: options.verbose });
|
|
43
48
|
});
|
|
44
|
-
program
|
|
45
|
-
.command(
|
|
46
|
-
.description(
|
|
47
|
-
.option(
|
|
48
|
-
.option(
|
|
49
|
-
.option(
|
|
50
|
-
.option(
|
|
49
|
+
exports.program
|
|
50
|
+
.command("backfill")
|
|
51
|
+
.description("Import historical Claude Code usage data from local JSONL files")
|
|
52
|
+
.option("--since <date>", 'Only backfill after this date (ISO format or relative like "7d", "1m")')
|
|
53
|
+
.option("--dry-run", "Show what would be sent without sending")
|
|
54
|
+
.option("--batch-size <n>", "Messages per API batch (default: 100)", "100")
|
|
55
|
+
.option("--delay <ms>", "Delay between batches in milliseconds (default: 100)", "100")
|
|
56
|
+
.option("-v, --verbose", "Show detailed progress")
|
|
51
57
|
.action(async (options) => {
|
|
52
58
|
const batchSize = parseInt(options.batchSize, 10);
|
|
53
|
-
if (!Number.isFinite(batchSize) || batchSize < 1) {
|
|
54
|
-
console.error(
|
|
59
|
+
if (!Number.isFinite(batchSize) || batchSize < 1 || batchSize > 10000) {
|
|
60
|
+
console.error("Error: --batch-size must be between 1 and 10000");
|
|
61
|
+
process.exit(1);
|
|
62
|
+
}
|
|
63
|
+
const delay = parseInt(options.delay, 10);
|
|
64
|
+
if (!Number.isFinite(delay) || delay < 0 || delay > 60000) {
|
|
65
|
+
console.error("Error: --delay must be between 0 and 60000 milliseconds");
|
|
55
66
|
process.exit(1);
|
|
56
67
|
}
|
|
57
68
|
await (0, backfill_js_1.backfillCommand)({
|
|
58
69
|
since: options.since,
|
|
59
70
|
dryRun: options.dryRun,
|
|
60
71
|
batchSize,
|
|
72
|
+
delay,
|
|
61
73
|
verbose: options.verbose,
|
|
62
74
|
});
|
|
63
75
|
});
|
|
64
|
-
|
|
76
|
+
if (process.env.NODE_ENV !== "test") {
|
|
77
|
+
exports.program.parse();
|
|
78
|
+
}
|
|
65
79
|
//# sourceMappingURL=index.js.map
|
package/dist/cli/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":";;;;AAEA,yCAAoC;AACpC,kDAAmD;AACnD,oDAAqD;AACrD,gDAAiD;AACjD,wDAAyD;AAE5C,QAAA,OAAO,GAAG,IA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;QACT,KAAK;QACL,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEL,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,EAAE,CAAC;IACpC,eAAO,CAAC,KAAK,EAAE,CAAC;AAClB,CAAC"}
|
|
@@ -1,22 +1,31 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { OTLPLogsPayload, OTLPResponse, HealthCheckResult } from "../../types/index.js";
|
|
2
2
|
/**
|
|
3
|
-
* Sends an OTLP
|
|
4
|
-
* Posts to /meter/v2/otel/v1/metrics with OTEL Metrics format.
|
|
3
|
+
* Sends an OTLP logs payload to the Revenium endpoint.
|
|
5
4
|
*/
|
|
6
|
-
export declare function
|
|
5
|
+
export declare function sendOtlpLogs(baseEndpoint: string, apiKey: string, payload: OTLPLogsPayload): Promise<OTLPResponse>;
|
|
7
6
|
/**
|
|
8
7
|
* Options for creating a test payload.
|
|
9
8
|
*/
|
|
10
9
|
export interface TestPayloadOptions {
|
|
11
|
-
/** Optional
|
|
10
|
+
/** Optional subscriber email for attribution */
|
|
11
|
+
email?: string;
|
|
12
|
+
/** Optional organization name to attribute costs to */
|
|
13
|
+
organizationName?: string;
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Use organizationName instead. This field will be removed in a future version.
|
|
16
|
+
*/
|
|
12
17
|
organizationId?: string;
|
|
13
|
-
/** Optional product
|
|
18
|
+
/** Optional product name to attribute costs to */
|
|
19
|
+
productName?: string;
|
|
20
|
+
/**
|
|
21
|
+
* @deprecated Use productName instead. This field will be removed in a future version.
|
|
22
|
+
*/
|
|
14
23
|
productId?: string;
|
|
15
24
|
}
|
|
16
25
|
/**
|
|
17
|
-
* Creates a minimal test
|
|
26
|
+
* Creates a minimal test OTLP logs payload.
|
|
18
27
|
*/
|
|
19
|
-
export declare function createTestPayload(sessionId: string, options?: TestPayloadOptions):
|
|
28
|
+
export declare function createTestPayload(sessionId: string, options?: TestPayloadOptions): OTLPLogsPayload;
|
|
20
29
|
/**
|
|
21
30
|
* Generates a unique session ID for test payloads.
|
|
22
31
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/core/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/core/api/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,YAAY,EACZ,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAG9B;;GAEG;AACH,wBAAsB,YAAY,CAChC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,YAAY,CAAC,CAuBvB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,gDAAgD;IAChD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,uDAAuD;IACvD,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kDAAkD;IAClD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,SAAS,EAAE,MAAM,EACjB,OAAO,CAAC,EAAE,kBAAkB,GAC3B,eAAe,CA2EjB;AAED;;GAEG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAI9C;AAED;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,kBAAkB,GAC3B,OAAO,CAAC,iBAAiB,CAAC,CA+B5B"}
|
package/dist/core/api/client.js
CHANGED
|
@@ -1,82 +1,91 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.sendOtlpLogs = sendOtlpLogs;
|
|
4
4
|
exports.createTestPayload = createTestPayload;
|
|
5
5
|
exports.generateTestSessionId = generateTestSessionId;
|
|
6
6
|
exports.checkEndpointHealth = checkEndpointHealth;
|
|
7
7
|
const loader_js_1 = require("../config/loader.js");
|
|
8
8
|
/**
|
|
9
|
-
* Sends an OTLP
|
|
10
|
-
* Posts to /meter/v2/otel/v1/metrics with OTEL Metrics format.
|
|
9
|
+
* Sends an OTLP logs payload to the Revenium endpoint.
|
|
11
10
|
*/
|
|
12
|
-
async function
|
|
11
|
+
async function sendOtlpLogs(baseEndpoint, apiKey, payload) {
|
|
13
12
|
const fullEndpoint = (0, loader_js_1.getFullOtlpEndpoint)(baseEndpoint);
|
|
14
|
-
const url = `${fullEndpoint}/v1/
|
|
13
|
+
const url = `${fullEndpoint}/v1/logs`;
|
|
15
14
|
const response = await fetch(url, {
|
|
16
|
-
method:
|
|
15
|
+
method: "POST",
|
|
17
16
|
headers: {
|
|
18
|
-
|
|
19
|
-
|
|
17
|
+
"Content-Type": "application/json",
|
|
18
|
+
"x-api-key": apiKey,
|
|
20
19
|
},
|
|
21
20
|
body: JSON.stringify(payload),
|
|
22
21
|
});
|
|
23
22
|
if (!response.ok) {
|
|
24
23
|
const errorText = await response.text();
|
|
25
|
-
|
|
24
|
+
const safeErrorText = errorText.length > 200 ? errorText.substring(0, 200) + "..." : errorText;
|
|
25
|
+
throw new Error(`OTLP request failed: ${response.status} ${response.statusText} - ${safeErrorText}`);
|
|
26
26
|
}
|
|
27
27
|
return response.json();
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
|
-
* Creates a minimal test
|
|
30
|
+
* Creates a minimal test OTLP logs payload.
|
|
31
31
|
*/
|
|
32
32
|
function createTestPayload(sessionId, options) {
|
|
33
33
|
const now = Date.now() * 1_000_000; // Convert to nanoseconds
|
|
34
|
-
//
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
{ key:
|
|
38
|
-
{ key:
|
|
34
|
+
// Build log record attributes
|
|
35
|
+
// Note: organization.name and product.name go here because ClaudeCodeMapper reads from log record attrs
|
|
36
|
+
const logAttributes = [
|
|
37
|
+
{ key: "session.id", value: { stringValue: sessionId } },
|
|
38
|
+
{ key: "model", value: { stringValue: "cli-connectivity-test" } },
|
|
39
|
+
{ key: "input_tokens", value: { stringValue: "0" } },
|
|
40
|
+
{ key: "output_tokens", value: { stringValue: "0" } },
|
|
41
|
+
{ key: "cache_read_tokens", value: { stringValue: "0" } },
|
|
42
|
+
{ key: "cache_creation_tokens", value: { stringValue: "0" } },
|
|
43
|
+
{ key: "cost_usd", value: { stringValue: "0.0" } },
|
|
44
|
+
{ key: "duration_ms", value: { stringValue: "0" } },
|
|
39
45
|
];
|
|
40
|
-
// Add optional
|
|
41
|
-
|
|
42
|
-
|
|
46
|
+
// Add optional subscriber/attribution attributes at log record level
|
|
47
|
+
// (backend ClaudeCodeMapper reads these from log record attrs, not resource attrs)
|
|
48
|
+
if (options?.email) {
|
|
49
|
+
logAttributes.push({
|
|
50
|
+
key: "user.email",
|
|
51
|
+
value: { stringValue: options.email },
|
|
52
|
+
});
|
|
43
53
|
}
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
54
|
+
// Support both new (organizationName) and old (organizationId) field names with fallback
|
|
55
|
+
const organizationValue = options?.organizationName || options?.organizationId;
|
|
56
|
+
if (organizationValue) {
|
|
57
|
+
logAttributes.push({
|
|
58
|
+
key: "organization.name",
|
|
59
|
+
value: { stringValue: organizationValue },
|
|
60
|
+
});
|
|
47
61
|
}
|
|
48
|
-
//
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
62
|
+
// Support both new (productName) and old (productId) field names with fallback
|
|
63
|
+
const productValue = options?.productName || options?.productId;
|
|
64
|
+
if (productValue) {
|
|
65
|
+
logAttributes.push({
|
|
66
|
+
key: "product.name",
|
|
67
|
+
value: { stringValue: productValue },
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
// Build resource attributes (only service.name needed here)
|
|
71
|
+
const resourceAttributes = [{ key: "service.name", value: { stringValue: "claude-code" } }];
|
|
52
72
|
return {
|
|
53
|
-
|
|
73
|
+
resourceLogs: [
|
|
54
74
|
{
|
|
55
75
|
resource: {
|
|
56
76
|
attributes: resourceAttributes,
|
|
57
77
|
},
|
|
58
|
-
|
|
78
|
+
scopeLogs: [
|
|
59
79
|
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
attributes: commonAttributes,
|
|
66
|
-
timeUnixNano: now.toString(),
|
|
67
|
-
asInt: 0,
|
|
68
|
-
}],
|
|
69
|
-
},
|
|
70
|
-
},
|
|
80
|
+
scope: {
|
|
81
|
+
name: "claude_code",
|
|
82
|
+
version: "0.1.0",
|
|
83
|
+
},
|
|
84
|
+
logRecords: [
|
|
71
85
|
{
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
attributes: commonAttributes,
|
|
76
|
-
timeUnixNano: now.toString(),
|
|
77
|
-
asInt: 0,
|
|
78
|
-
}],
|
|
79
|
-
},
|
|
86
|
+
timeUnixNano: now.toString(),
|
|
87
|
+
body: { stringValue: "claude_code.api_request" },
|
|
88
|
+
attributes: logAttributes,
|
|
80
89
|
},
|
|
81
90
|
],
|
|
82
91
|
},
|
|
@@ -101,18 +110,18 @@ async function checkEndpointHealth(baseEndpoint, apiKey, options) {
|
|
|
101
110
|
try {
|
|
102
111
|
const sessionId = generateTestSessionId();
|
|
103
112
|
const payload = createTestPayload(sessionId, options);
|
|
104
|
-
const response = await
|
|
113
|
+
const response = await sendOtlpLogs(baseEndpoint, apiKey, payload);
|
|
105
114
|
const latencyMs = Date.now() - startTime;
|
|
106
115
|
return {
|
|
107
116
|
healthy: true,
|
|
108
117
|
statusCode: 200,
|
|
109
|
-
message: `Endpoint healthy. Processed ${response.
|
|
118
|
+
message: `Endpoint healthy. Processed ${response.processedEvents} event(s).`,
|
|
110
119
|
latencyMs,
|
|
111
120
|
};
|
|
112
121
|
}
|
|
113
122
|
catch (error) {
|
|
114
123
|
const latencyMs = Date.now() - startTime;
|
|
115
|
-
const message = error instanceof Error ? error.message :
|
|
124
|
+
const message = error instanceof Error ? error.message : "Unknown error";
|
|
116
125
|
// Try to extract status code from error message
|
|
117
126
|
const statusMatch = message.match(/(\d{3})/);
|
|
118
127
|
const statusCode = statusMatch ? parseInt(statusMatch[1], 10) : undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/core/api/client.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../../src/core/api/client.ts"],"names":[],"mappings":";;AAUA,oCA2BC;AAyBD,8CA8EC;AAKD,sDAIC;AAKD,kDAmCC;AAxLD,mDAA0D;AAE1D;;GAEG;AACI,KAAK,UAAU,YAAY,CAChC,YAAoB,EACpB,MAAc,EACd,OAAwB;IAExB,MAAM,YAAY,GAAG,IAAA,+BAAmB,EAAC,YAAY,CAAC,CAAC;IACvD,MAAM,GAAG,GAAG,GAAG,YAAY,UAAU,CAAC;IAEtC,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE;QAChC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,WAAW,EAAE,MAAM;SACpB;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC;KAC9B,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,aAAa,GACjB,SAAS,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC,SAA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ACV,CAAC;IACJ,CAAC;AACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReveniumConfig } from
|
|
1
|
+
import type { ReveniumConfig } from "../../types/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* Gets the path to the Revenium configuration file.
|
|
4
4
|
*/
|
|
@@ -7,6 +7,10 @@ export declare function getConfigPath(): string;
|
|
|
7
7
|
* Checks if the configuration file exists.
|
|
8
8
|
*/
|
|
9
9
|
export declare function configExists(): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Parses an .env file content into key-value pairs.
|
|
12
|
+
*/
|
|
13
|
+
export declare function parseEnvContent(content: string): Record<string, string>;
|
|
10
14
|
/**
|
|
11
15
|
* Loads the Revenium configuration from the .env file.
|
|
12
16
|
* Returns null if the file doesn't exist.
|
|
@@ -16,18 +20,6 @@ export declare function loadConfig(): Promise<ReveniumConfig | null>;
|
|
|
16
20
|
* Checks if the environment variables are currently loaded in the shell.
|
|
17
21
|
*/
|
|
18
22
|
export declare function isEnvLoaded(): boolean;
|
|
19
|
-
/**
|
|
20
|
-
* Migration status for config file updates.
|
|
21
|
-
*/
|
|
22
|
-
export interface MigrationStatus {
|
|
23
|
-
needsMigration: boolean;
|
|
24
|
-
issues: string[];
|
|
25
|
-
}
|
|
26
|
-
/**
|
|
27
|
-
* Checks if the config file needs migration from old format.
|
|
28
|
-
* Detects: OTEL_LOGS_EXPORTER (should be OTEL_METRICS_EXPORTER)
|
|
29
|
-
*/
|
|
30
|
-
export declare function checkMigrationStatus(): Promise<MigrationStatus>;
|
|
31
23
|
/**
|
|
32
24
|
* Gets the full OTLP endpoint URL from a base URL.
|
|
33
25
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/core/config/loader.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAEtC;
|
|
1
|
+
{"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../../src/core/config/loader.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAEtC;AAED;;GAEG;AACH,wBAAgB,YAAY,IAAI,OAAO,CAEtC;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CA2CvE;AA4DD;;;GAGG;AACH,wBAAsB,UAAU,IAAI,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CA4DjE;AAED;;GAEG;AACH,wBAAgB,WAAW,IAAI,OAAO,CAKrC;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAI3D"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getConfigPath = getConfigPath;
|
|
4
4
|
exports.configExists = configExists;
|
|
5
|
+
exports.parseEnvContent = parseEnvContent;
|
|
5
6
|
exports.loadConfig = loadConfig;
|
|
6
7
|
exports.isEnvLoaded = isEnvLoaded;
|
|
7
|
-
exports.checkMigrationStatus = checkMigrationStatus;
|
|
8
8
|
exports.getFullOtlpEndpoint = getFullOtlpEndpoint;
|
|
9
9
|
const node_os_1 = require("node:os");
|
|
10
10
|
const node_path_1 = require("node:path");
|
|
@@ -28,26 +28,33 @@ function configExists() {
|
|
|
28
28
|
*/
|
|
29
29
|
function parseEnvContent(content) {
|
|
30
30
|
const result = {};
|
|
31
|
-
for (const line of content.split(
|
|
31
|
+
for (const line of content.split("\n")) {
|
|
32
32
|
let trimmed = line.trim();
|
|
33
33
|
// Skip empty lines and comments
|
|
34
|
-
if (!trimmed || trimmed.startsWith(
|
|
34
|
+
if (!trimmed || trimmed.startsWith("#")) {
|
|
35
35
|
continue;
|
|
36
36
|
}
|
|
37
37
|
// Handle 'export' prefix
|
|
38
|
-
if (trimmed.startsWith(
|
|
38
|
+
if (trimmed.startsWith("export ")) {
|
|
39
39
|
trimmed = trimmed.substring(7).trim();
|
|
40
40
|
}
|
|
41
|
-
const equalsIndex = trimmed.indexOf(
|
|
41
|
+
const equalsIndex = trimmed.indexOf("=");
|
|
42
42
|
if (equalsIndex === -1) {
|
|
43
43
|
continue;
|
|
44
44
|
}
|
|
45
45
|
const key = trimmed.substring(0, equalsIndex).trim();
|
|
46
46
|
let value = trimmed.substring(equalsIndex + 1).trim();
|
|
47
|
-
// Remove surrounding quotes if present
|
|
47
|
+
// Remove surrounding quotes if present and unescape
|
|
48
48
|
if ((value.startsWith('"') && value.endsWith('"')) ||
|
|
49
49
|
(value.startsWith("'") && value.endsWith("'"))) {
|
|
50
50
|
value = value.substring(1, value.length - 1);
|
|
51
|
+
// Unescape common shell escape sequences
|
|
52
|
+
value = value
|
|
53
|
+
.replace(/\\"/g, '"')
|
|
54
|
+
.replace(/\\'/g, "'")
|
|
55
|
+
.replace(/\\\$/g, "$")
|
|
56
|
+
.replace(/\\`/g, "`")
|
|
57
|
+
.replace(/\\\\/g, "\\");
|
|
51
58
|
}
|
|
52
59
|
result[key] = value;
|
|
53
60
|
}
|
|
@@ -71,8 +78,8 @@ function extractBaseEndpoint(fullEndpoint) {
|
|
|
71
78
|
// Remove the OTLP path suffix to get the base URL
|
|
72
79
|
// Handle both old path (/meter/v2/ai/otlp) and new path (/meter/v2/otlp)
|
|
73
80
|
const path = url.pathname;
|
|
74
|
-
if (path.includes(
|
|
75
|
-
url.pathname =
|
|
81
|
+
if (path.includes("/meter/v2/otlp") || path.includes("/meter/v2/ai/otlp")) {
|
|
82
|
+
url.pathname = "";
|
|
76
83
|
}
|
|
77
84
|
return url.origin;
|
|
78
85
|
}
|
|
@@ -80,6 +87,35 @@ function extractBaseEndpoint(fullEndpoint) {
|
|
|
80
87
|
return fullEndpoint;
|
|
81
88
|
}
|
|
82
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* Parses OTEL_RESOURCE_ATTRIBUTES value into key-value pairs.
|
|
92
|
+
* Format: "key1=value1,key2=value2"
|
|
93
|
+
*/
|
|
94
|
+
function parseOtelResourceAttributes(value) {
|
|
95
|
+
const result = {};
|
|
96
|
+
if (!value || typeof value !== "string")
|
|
97
|
+
return result;
|
|
98
|
+
const pairs = value.split(",");
|
|
99
|
+
for (const pair of pairs) {
|
|
100
|
+
const trimmed = pair.trim();
|
|
101
|
+
if (!trimmed)
|
|
102
|
+
continue;
|
|
103
|
+
const equalsIndex = trimmed.indexOf("=");
|
|
104
|
+
if (equalsIndex === -1)
|
|
105
|
+
continue;
|
|
106
|
+
const key = trimmed.substring(0, equalsIndex).trim();
|
|
107
|
+
let attrValue = trimmed.substring(equalsIndex + 1).trim();
|
|
108
|
+
try {
|
|
109
|
+
attrValue = decodeURIComponent(attrValue);
|
|
110
|
+
}
|
|
111
|
+
catch {
|
|
112
|
+
// If decoding fails, use raw value
|
|
113
|
+
}
|
|
114
|
+
if (key)
|
|
115
|
+
result[key] = attrValue;
|
|
116
|
+
}
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
83
119
|
/**
|
|
84
120
|
* Loads the Revenium configuration from the .env file.
|
|
85
121
|
* Returns null if the file doesn't exist.
|
|
@@ -90,25 +126,42 @@ async function loadConfig() {
|
|
|
90
126
|
return null;
|
|
91
127
|
}
|
|
92
128
|
try {
|
|
93
|
-
const content = await (0, promises_1.readFile)(configPath,
|
|
129
|
+
const content = await (0, promises_1.readFile)(configPath, "utf-8");
|
|
94
130
|
const env = parseEnvContent(content);
|
|
95
|
-
const fullEndpoint = env[constants_js_1.ENV_VARS.OTLP_ENDPOINT] ||
|
|
96
|
-
const headers = env[constants_js_1.ENV_VARS.OTLP_HEADERS] ||
|
|
131
|
+
const fullEndpoint = env[constants_js_1.ENV_VARS.OTLP_ENDPOINT] || "";
|
|
132
|
+
const headers = env[constants_js_1.ENV_VARS.OTLP_HEADERS] || "";
|
|
97
133
|
const apiKey = extractApiKeyFromHeaders(headers);
|
|
98
134
|
if (!apiKey) {
|
|
99
135
|
return null;
|
|
100
136
|
}
|
|
101
137
|
// Parse cost multiplier override if present
|
|
102
138
|
const costMultiplierStr = env[constants_js_1.ENV_VARS.COST_MULTIPLIER];
|
|
103
|
-
const costMultiplierOverride = costMultiplierStr
|
|
139
|
+
const costMultiplierOverride = costMultiplierStr
|
|
140
|
+
? parseFloat(costMultiplierStr)
|
|
141
|
+
: undefined;
|
|
142
|
+
// Parse OTEL_RESOURCE_ATTRIBUTES for org/product (primary source)
|
|
143
|
+
const resourceAttrsStr = env["OTEL_RESOURCE_ATTRIBUTES"] || "";
|
|
144
|
+
const resourceAttrs = parseOtelResourceAttributes(resourceAttrsStr);
|
|
145
|
+
// Support both .name (preferred) and .id (legacy), with fallback to standalone vars
|
|
146
|
+
// Priority: organizationName > organizationId > organization.name > organization.id > env var
|
|
147
|
+
const organizationName = resourceAttrs["organization.name"] ||
|
|
148
|
+
resourceAttrs["organization.id"] ||
|
|
149
|
+
env[constants_js_1.ENV_VARS.ORGANIZATION_ID];
|
|
150
|
+
const productName = resourceAttrs["product.name"] ||
|
|
151
|
+
resourceAttrs["product.id"] ||
|
|
152
|
+
env[constants_js_1.ENV_VARS.PRODUCT_ID];
|
|
104
153
|
return {
|
|
105
154
|
apiKey,
|
|
106
155
|
endpoint: extractBaseEndpoint(fullEndpoint),
|
|
107
156
|
email: env[constants_js_1.ENV_VARS.SUBSCRIBER_EMAIL],
|
|
108
157
|
subscriptionTier: env[constants_js_1.ENV_VARS.SUBSCRIPTION],
|
|
109
|
-
costMultiplierOverride: costMultiplierOverride && !isNaN(costMultiplierOverride)
|
|
110
|
-
|
|
111
|
-
|
|
158
|
+
costMultiplierOverride: costMultiplierOverride !== undefined && !isNaN(costMultiplierOverride)
|
|
159
|
+
? costMultiplierOverride
|
|
160
|
+
: undefined,
|
|
161
|
+
organizationName,
|
|
162
|
+
organizationId: organizationName, // Keep for backward compatibility
|
|
163
|
+
productName,
|
|
164
|
+
productId: productName, // Keep for backward compatibility
|
|
112
165
|
};
|
|
113
166
|
}
|
|
114
167
|
catch {
|
|
@@ -119,44 +172,15 @@ async function loadConfig() {
|
|
|
119
172
|
* Checks if the environment variables are currently loaded in the shell.
|
|
120
173
|
*/
|
|
121
174
|
function isEnvLoaded() {
|
|
122
|
-
return (process.env[constants_js_1.ENV_VARS.TELEMETRY_ENABLED] ===
|
|
175
|
+
return (process.env[constants_js_1.ENV_VARS.TELEMETRY_ENABLED] === "1" &&
|
|
123
176
|
!!process.env[constants_js_1.ENV_VARS.OTLP_ENDPOINT]);
|
|
124
177
|
}
|
|
125
|
-
/**
|
|
126
|
-
* Checks if the config file needs migration from old format.
|
|
127
|
-
* Detects: OTEL_LOGS_EXPORTER (should be OTEL_METRICS_EXPORTER)
|
|
128
|
-
*/
|
|
129
|
-
async function checkMigrationStatus() {
|
|
130
|
-
const configPath = getConfigPath();
|
|
131
|
-
const issues = [];
|
|
132
|
-
if (!(0, node_fs_1.existsSync)(configPath)) {
|
|
133
|
-
return { needsMigration: false, issues: [] };
|
|
134
|
-
}
|
|
135
|
-
try {
|
|
136
|
-
const content = await (0, promises_1.readFile)(configPath, 'utf-8');
|
|
137
|
-
// Check for old OTEL_LOGS_EXPORTER (should be OTEL_METRICS_EXPORTER)
|
|
138
|
-
if (content.includes('OTEL_LOGS_EXPORTER')) {
|
|
139
|
-
issues.push('Config uses OTEL_LOGS_EXPORTER (should be OTEL_METRICS_EXPORTER)');
|
|
140
|
-
}
|
|
141
|
-
// Check for old endpoint path
|
|
142
|
-
if (content.includes('/meter/v2/ai/otlp')) {
|
|
143
|
-
issues.push('Config uses old endpoint path /meter/v2/ai/otlp (should be /meter/v2/otel)');
|
|
144
|
-
}
|
|
145
|
-
return {
|
|
146
|
-
needsMigration: issues.length > 0,
|
|
147
|
-
issues,
|
|
148
|
-
};
|
|
149
|
-
}
|
|
150
|
-
catch {
|
|
151
|
-
return { needsMigration: false, issues: [] };
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
178
|
/**
|
|
155
179
|
* Gets the full OTLP endpoint URL from a base URL.
|
|
156
180
|
*/
|
|
157
181
|
function getFullOtlpEndpoint(baseUrl) {
|
|
158
182
|
// Remove trailing slash if present
|
|
159
|
-
const cleanUrl = baseUrl.replace(/\/$/,
|
|
183
|
+
const cleanUrl = baseUrl.replace(/\/$/, "");
|
|
160
184
|
return `${cleanUrl}${constants_js_1.OTLP_PATH}`;
|
|
161
185
|
}
|
|
162
186
|
//# sourceMappingURL=loader.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../src/core/config/loader.ts"],"names":[],"mappings":";;AAgBA,sCAEC;AAKD,oCAEC;
|
|
1
|
+
{"version":3,"file":"loader.js","sourceRoot":"","sources":["../../../src/core/config/loader.ts"],"names":[],"mappings":";;AAgBA,sCAEC;AAKD,oCAEC;AAKD,0CA2CC;AAgED,gCA4DC;AAKD,kCAKC;AAKD,kDAIC;AAxND,qCAAkC;AAClC,yCAAiC;AACjC,+CAA4C;AAC5C,qCAAqC;AACrC,2DAKkC;AAIlC;;GAEG;AACH,SAAgB,aAAa;IAC3B,OAAO,IAAA,gBAAI,EAAC,IAAA,iBAAO,GAAE,EAAE,gCAAiB,EAAE,gCAAiB,CAAC,CAAC;AAC/D,CAAC;AAED;;GAEG;AACH,SAAgB,YAAY;IAC1B,OAAO,IAAA,oBAAU,EAAC,aAAa,EAAE,CAAC,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,OAAe;IAC7C,MAAM,MAAM,GAA2B,EAAE,CAAC;IAE1C,KAAK,MAAM,IAAI,IAAI,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;QACvC,IAA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