mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-07-24 21:30:17 +08:00
feat: add session log usage tracking without proxy
Parse Claude Code JSONL session files (~/.claude/projects/) and Codex SQLite database (~/.codex/state_5.sqlite) to track API usage without requiring proxy interception. This enables usage statistics for users who don't use the proxy feature. Key changes: - Add session_usage.rs: incremental JSONL parser with message.id dedup - Add session_usage_codex.rs: import thread-level token data from Codex - Add data_source column to proxy_request_logs (proxy/session_log/codex_db) - Add session_log_sync table for tracking parse offsets - Background sync every 60s + manual sync via DataSourceBar UI - Schema migration v7→v8 - i18n support for zh/en/ja
This commit is contained in:
@@ -9,6 +9,8 @@ import type {
|
||||
ModelPricing,
|
||||
ProviderLimitStatus,
|
||||
PaginatedLogs,
|
||||
SessionSyncResult,
|
||||
DataSourceSummary,
|
||||
} from "@/types/usage";
|
||||
import type { UsageResult } from "@/types";
|
||||
import type { AppId } from "./types";
|
||||
@@ -115,4 +117,13 @@ export const usageApi = {
|
||||
): Promise<ProviderLimitStatus> => {
|
||||
return invoke("check_provider_limits", { providerId, appType });
|
||||
},
|
||||
|
||||
// Session usage sync
|
||||
syncSessionUsage: async (): Promise<SessionSyncResult> => {
|
||||
return invoke("sync_session_usage");
|
||||
},
|
||||
|
||||
getDataSourceBreakdown: async (): Promise<DataSourceSummary[]> => {
|
||||
return invoke("get_usage_data_sources");
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user