@@ -304,41 +304,58 @@ function sanitizeStats(raw: any): UsageAnalysisStats | null {
304304 symbol : coerceNumber ( refs ?. symbol ) ,
305305 codebase : coerceNumber ( refs ?. codebase ) ,
306306 workspace : coerceNumber ( refs ?. workspace ) ,
307+ terminal : coerceNumber ( refs ?. terminal ) ,
308+ vscode : coerceNumber ( refs ?. vscode ) ,
309+ terminalLastCommand : coerceNumber ( refs ?. terminalLastCommand ) ,
310+ terminalSelection : coerceNumber ( refs ?. terminalSelection ) ,
311+ clipboard : coerceNumber ( refs ?. clipboard ) ,
312+ changes : coerceNumber ( refs ?. changes ) ,
313+ outputPanel : coerceNumber ( refs ?. outputPanel ) ,
314+ problemsPanel : coerceNumber ( refs ?. problemsPanel ) ,
315+ byKind : refs ?. byKind ?? { } ,
316+ copilotInstructions : coerceNumber ( refs ?. copilotInstructions ) ,
317+ agentsMd : coerceNumber ( refs ?. agentsMd ) ,
318+ byPath : refs ?. byPath ?? { } ,
307319 } ) ;
308320
309- try {
310- const today = raw . today ?? { } ;
311- const last30Days = raw . last30Days ?? { } ;
321+ const sanitizePeriod = ( period : any ) : UsageAnalysisPeriod => ( {
322+ sessions : coerceNumber ( period ?. sessions ) ,
323+ modeUsage : sanitizeModeUsage ( period ?. modeUsage ?? { } ) ,
324+ contextReferences : sanitizeContextRefs ( period ?. contextReferences ?? { } ) ,
325+ toolCalls : {
326+ total : coerceNumber ( period ?. toolCalls ?. total ) ,
327+ byTool : period ?. toolCalls ?. byTool ?? { } ,
328+ } ,
329+ mcpTools : {
330+ total : coerceNumber ( period ?. mcpTools ?. total ) ,
331+ byServer : period ?. mcpTools ?. byServer ?? { } ,
332+ byTool : period ?. mcpTools ?. byTool ?? { } ,
333+ } ,
334+ modelSwitching : period ?. modelSwitching ?? {
335+ modelsPerSession : [ ] ,
336+ totalSessions : 0 ,
337+ averageModelsPerSession : 0 ,
338+ maxModelsPerSession : 0 ,
339+ minModelsPerSession : 0 ,
340+ switchingFrequency : 0 ,
341+ standardModels : [ ] ,
342+ premiumModels : [ ] ,
343+ unknownModels : [ ] ,
344+ mixedTierSessions : 0 ,
345+ standardRequests : 0 ,
346+ premiumRequests : 0 ,
347+ unknownRequests : 0 ,
348+ totalRequests : 0 ,
349+ } ,
350+ } ) ;
312351
352+ try {
313353 const sanitized : UsageAnalysisStats = {
314- today : {
315- modeUsage : sanitizeModeUsage ( today . modeUsage ?? { } ) ,
316- contextReferences : sanitizeContextRefs ( today . contextReferences ?? { } ) ,
317- toolUsage : {
318- total : coerceNumber ( today . toolUsage ?. total ) ,
319- byTool : today . toolUsage ?. byTool ?? { } ,
320- } ,
321- mcpToolUsage : {
322- total : coerceNumber ( today . mcpToolUsage ?. total ) ,
323- byServer : today . mcpToolUsage ?. byServer ?? { } ,
324- byTool : today . mcpToolUsage ?. byTool ?? { } ,
325- } ,
326- } ,
327- last30Days : {
328- modeUsage : sanitizeModeUsage ( last30Days . modeUsage ?? { } ) ,
329- contextReferences : sanitizeContextRefs ( last30Days . contextReferences ?? { } ) ,
330- toolUsage : {
331- total : coerceNumber ( last30Days . toolUsage ?. total ) ,
332- byTool : last30Days . toolUsage ?. byTool ?? { } ,
333- } ,
334- mcpToolUsage : {
335- total : coerceNumber ( last30Days . mcpToolUsage ?. total ) ,
336- byServer : last30Days . mcpToolUsage ?. byServer ?? { } ,
337- byTool : last30Days . mcpToolUsage ?. byTool ?? { } ,
338- } ,
339- } ,
354+ today : sanitizePeriod ( raw . today ) ,
355+ last30Days : sanitizePeriod ( raw . last30Days ) ,
356+ month : sanitizePeriod ( raw . month ) ,
357+ lastUpdated : typeof raw . lastUpdated === 'string' ? raw . lastUpdated : '' ,
340358 backendConfigured : ! ! raw . backendConfigured ,
341- repoAnalysis : raw . repoAnalysis ,
342359 } ;
343360
344361 return sanitized ;
0 commit comments