MCPcopy Create free account
hub / github.com/SethGammon/Citadel / readTotalCost

Function readTotalCost

scripts/telemetry-stats.js:194–212  ·  view source on GitHub ↗

* Get total spend across all campaigns. * Uses real cost when available, falls back to estimated. * @returns {{ total: number, by_campaign: Object, session_count: number, has_real_data: boolean }}

()

Source from the content-addressed store, hash-verified

192 * @returns {{ total: number, by_campaign: Object, session_count: number, has_real_data: boolean }}
193 */
194function readTotalCost() {
195 const byCampaign = readCostByCampaign();
196 let total = 0;
197 let sessionCount = 0;
198 let hasRealData = false;
199
200 for (const slug of Object.keys(byCampaign)) {
201 total += byCampaign[slug].total_cost;
202 sessionCount += byCampaign[slug].sessions;
203 if (byCampaign[slug].has_real_data) hasRealData = true;
204 }
205
206 return {
207 total: Math.round(total * 100) / 100,
208 by_campaign: byCampaign,
209 session_count: sessionCount,
210 has_real_data: hasRealData,
211 };
212}
213
214/**
215 * Compute estimated cost for a single session based on agent activity.

Callers 1

readCostDashboardFunction · 0.85

Calls 1

readCostByCampaignFunction · 0.85

Tested by

no test coverage detected