Something went wrong. Try again.
source dump of claude code forked from oppi.li/claude-code
Something went wrong. Try again.
claude-code costHook.ts
617 B · 22 lines
TypeScript
at main
1234567891011121314151617181920212223import { useEffect } from 'react'import { formatTotalCost, saveCurrentSessionCosts } from './cost-tracker.js'import { hasConsoleBillingAccess } from './utils/billing.js'import type { FpsMetrics } from './utils/fpsTracker.js'
export function useCostSummary( getFpsMetrics?: () => FpsMetrics | undefined,): void { useEffect(() => { const f = () => { if (hasConsoleBillingAccess()) { process.stdout.write('\n' + formatTotalCost() + '\n') }
saveCurrentSessionCosts(getFpsMetrics?.()) } process.on('exit', f) return () => { process.off('exit', f) } }, [])}