You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
617 B
22 lines
617 B
import { 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)
|
|
}
|
|
}, [])
|
|
}
|
|
|