claude-usage-dashboard 1.5.2 → 1.5.4
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/README.md +122 -122
- package/bin/cli.cjs +20 -20
- package/bin/cli.js +16 -16
- package/bin/cli.sh +11 -11
- package/package.json +43 -43
- package/public/css/style.css +287 -287
- package/public/index.html +123 -123
- package/public/js/api.js +17 -17
- package/public/js/app.js +333 -326
- package/public/js/charts/cache-efficiency.js +29 -29
- package/public/js/charts/cost-comparison.js +39 -39
- package/public/js/charts/model-distribution.js +56 -56
- package/public/js/charts/project-distribution.js +103 -103
- package/public/js/charts/quota-cycles.js +209 -209
- package/public/js/charts/session-stats.js +117 -117
- package/public/js/charts/token-trend.js +357 -357
- package/public/js/components/date-picker.js +35 -35
- package/public/js/components/plan-selector.js +57 -57
- package/server/aggregator.js +151 -151
- package/server/credentials.js +112 -112
- package/server/index.js +53 -53
- package/server/parser.js +151 -129
- package/server/pricing.js +52 -52
- package/server/quota-cycles.js +325 -274
- package/server/routes/api.js +175 -175
- package/server/sync.js +104 -69
package/server/pricing.js
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
export const MODEL_PRICING = {
|
|
2
|
-
'claude-opus-4-6': {
|
|
3
|
-
input_price_per_mtok: 5,
|
|
4
|
-
output_price_per_mtok: 25,
|
|
5
|
-
cache_read_price_per_mtok: 0.50,
|
|
6
|
-
cache_creation_price_per_mtok: 6.25,
|
|
7
|
-
},
|
|
8
|
-
'claude-sonnet-4-6': {
|
|
9
|
-
input_price_per_mtok: 3,
|
|
10
|
-
output_price_per_mtok: 15,
|
|
11
|
-
cache_read_price_per_mtok: 0.30,
|
|
12
|
-
cache_creation_price_per_mtok: 3.75,
|
|
13
|
-
},
|
|
14
|
-
'claude-haiku-4-5': {
|
|
15
|
-
input_price_per_mtok: 1,
|
|
16
|
-
output_price_per_mtok: 5,
|
|
17
|
-
cache_read_price_per_mtok: 0.10,
|
|
18
|
-
cache_creation_price_per_mtok: 1.25,
|
|
19
|
-
},
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export const PLAN_DEFAULTS = {
|
|
23
|
-
pro: 20,
|
|
24
|
-
max5x: 100,
|
|
25
|
-
max20x: 200,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export function getModelPricing(modelId) {
|
|
29
|
-
return MODEL_PRICING[modelId] || null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Calculate the API cost for a single usage record.
|
|
34
|
-
* Returns 0 for unknown models.
|
|
35
|
-
*
|
|
36
|
-
* In Claude Code logs, input_tokens is the non-cached input.
|
|
37
|
-
* cache_read_tokens and cache_creation_tokens are separate, additive fields.
|
|
38
|
-
* cost = input * input_rate + cache_read * read_rate + cache_creation * write_rate + output * output_rate
|
|
39
|
-
*/
|
|
40
|
-
export function calculateRecordCost(record) {
|
|
41
|
-
const pricing = MODEL_PRICING[record.model];
|
|
42
|
-
if (!pricing) return 0;
|
|
43
|
-
|
|
44
|
-
const M = 1_000_000;
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
(record.input_tokens / M) * pricing.input_price_per_mtok +
|
|
48
|
-
(record.cache_read_tokens / M) * pricing.cache_read_price_per_mtok +
|
|
49
|
-
(record.cache_creation_tokens / M) * pricing.cache_creation_price_per_mtok +
|
|
50
|
-
(record.output_tokens / M) * pricing.output_price_per_mtok
|
|
51
|
-
);
|
|
52
|
-
}
|
|
1
|
+
export const MODEL_PRICING = {
|
|
2
|
+
'claude-opus-4-6': {
|
|
3
|
+
input_price_per_mtok: 5,
|
|
4
|
+
output_price_per_mtok: 25,
|
|
5
|
+
cache_read_price_per_mtok: 0.50,
|
|
6
|
+
cache_creation_price_per_mtok: 6.25,
|
|
7
|
+
},
|
|
8
|
+
'claude-sonnet-4-6': {
|
|
9
|
+
input_price_per_mtok: 3,
|
|
10
|
+
output_price_per_mtok: 15,
|
|
11
|
+
cache_read_price_per_mtok: 0.30,
|
|
12
|
+
cache_creation_price_per_mtok: 3.75,
|
|
13
|
+
},
|
|
14
|
+
'claude-haiku-4-5': {
|
|
15
|
+
input_price_per_mtok: 1,
|
|
16
|
+
output_price_per_mtok: 5,
|
|
17
|
+
cache_read_price_per_mtok: 0.10,
|
|
18
|
+
cache_creation_price_per_mtok: 1.25,
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
export const PLAN_DEFAULTS = {
|
|
23
|
+
pro: 20,
|
|
24
|
+
max5x: 100,
|
|
25
|
+
max20x: 200,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export function getModelPricing(modelId) {
|
|
29
|
+
return MODEL_PRICING[modelId] || null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Calculate the API cost for a single usage record.
|
|
34
|
+
* Returns 0 for unknown models.
|
|
35
|
+
*
|
|
36
|
+
* In Claude Code logs, input_tokens is the non-cached input.
|
|
37
|
+
* cache_read_tokens and cache_creation_tokens are separate, additive fields.
|
|
38
|
+
* cost = input * input_rate + cache_read * read_rate + cache_creation * write_rate + output * output_rate
|
|
39
|
+
*/
|
|
40
|
+
export function calculateRecordCost(record) {
|
|
41
|
+
const pricing = MODEL_PRICING[record.model];
|
|
42
|
+
if (!pricing) return 0;
|
|
43
|
+
|
|
44
|
+
const M = 1_000_000;
|
|
45
|
+
|
|
46
|
+
return (
|
|
47
|
+
(record.input_tokens / M) * pricing.input_price_per_mtok +
|
|
48
|
+
(record.cache_read_tokens / M) * pricing.cache_read_price_per_mtok +
|
|
49
|
+
(record.cache_creation_tokens / M) * pricing.cache_creation_price_per_mtok +
|
|
50
|
+
(record.output_tokens / M) * pricing.output_price_per_mtok
|
|
51
|
+
);
|
|
52
|
+
}
|