@@ -180,34 +180,37 @@ export const injectAuditData: Script = {
180180 const activityChance = isWeekend ? user . weekendActivity : user . weekdayActivity ;
181181 if ( Math . random ( ) >= activityChance ) continue ;
182182
183- // --- Web UI activity (no source metadata ) ---
183+ // --- Web UI activity (source='sourcebot-web-client' or 'sourcebot-ui-codenav' ) ---
184184 if ( user . webWeight > 0 ) {
185+ const webMeta : Prisma . InputJsonValue = { source : 'sourcebot-web-client' } ;
186+ const codenavMeta : Prisma . InputJsonValue = { source : 'sourcebot-ui-codenav' } ;
187+
185188 // Code searches (2-5 base)
186189 await createAudits ( user . id , 'user.performed_code_search' ,
187- scaledCount ( 2 , 5 , user . webWeight , isWeekend ) , currentDate , isWeekend , 'search' ) ;
190+ scaledCount ( 2 , 5 , user . webWeight , isWeekend ) , currentDate , isWeekend , 'search' , webMeta ) ;
188191
189192 // Navigations: find references + goto definition (5-10 base)
190193 const navCount = scaledCount ( 5 , 10 , user . webWeight , isWeekend ) ;
191194 for ( let i = 0 ; i < navCount ; i ++ ) {
192195 const action = Math . random ( ) < 0.6 ? 'user.performed_find_references' : 'user.performed_goto_definition' ;
193- await createAudits ( user . id , action , 1 , currentDate , isWeekend , 'symbol' ) ;
196+ await createAudits ( user . id , action , 1 , currentDate , isWeekend , 'symbol' , codenavMeta ) ;
194197 }
195198
196199 // Ask chats (0-2 base) - web only
197200 await createAudits ( user . id , 'user.created_ask_chat' ,
198- scaledCount ( 0 , 2 , user . webWeight , isWeekend ) , currentDate , isWeekend , 'org' ) ;
201+ scaledCount ( 0 , 2 , user . webWeight , isWeekend ) , currentDate , isWeekend , 'org' , webMeta ) ;
199202
200203 // File source views (3-8 base)
201204 await createAudits ( user . id , 'user.fetched_file_source' ,
202- scaledCount ( 3 , 8 , user . webWeight , isWeekend ) , currentDate , isWeekend , 'file' ) ;
205+ scaledCount ( 3 , 8 , user . webWeight , isWeekend ) , currentDate , isWeekend , 'file' , webMeta ) ;
203206
204207 // File tree browsing (2-5 base)
205208 await createAudits ( user . id , 'user.fetched_file_tree' ,
206- scaledCount ( 2 , 5 , user . webWeight , isWeekend ) , currentDate , isWeekend , 'repo' ) ;
209+ scaledCount ( 2 , 5 , user . webWeight , isWeekend ) , currentDate , isWeekend , 'repo' , webMeta ) ;
207210
208211 // List repos (1-3 base)
209212 await createAudits ( user . id , 'user.listed_repos' ,
210- scaledCount ( 1 , 3 , user . webWeight , isWeekend ) , currentDate , isWeekend , 'org' ) ;
213+ scaledCount ( 1 , 3 , user . webWeight , isWeekend ) , currentDate , isWeekend , 'org' , webMeta ) ;
211214 }
212215
213216 // --- MCP activity (source='mcp') ---
@@ -279,17 +282,18 @@ export const injectAuditData: Script = {
279282 let webCount = 0 , mcpCount = 0 , apiCount = 0 ;
280283 for ( const audit of allAudits ) {
281284 const meta = audit . metadata as Record < string , unknown > | null ;
282- if ( ! meta || ! meta . source ) {
285+ const source = meta ?. source as string | undefined ;
286+ if ( source && typeof source === 'string' && source . startsWith ( 'sourcebot-' ) ) {
283287 webCount ++ ;
284- } else if ( meta . source === 'mcp' ) {
288+ } else if ( source === 'mcp' ) {
285289 mcpCount ++ ;
286290 } else {
287291 apiCount ++ ;
288292 }
289293 }
290294 console . log ( '\nSource breakdown:' ) ;
291- console . log ( ` Web UI (no source): ${ webCount } ` ) ;
295+ console . log ( ` Web UI (source=sourcebot-* ): ${ webCount } ` ) ;
292296 console . log ( ` MCP (source=mcp): ${ mcpCount } ` ) ;
293- console . log ( ` API (source=other): ${ apiCount } ` ) ;
297+ console . log ( ` API (source=other/null ): ${ apiCount } ` ) ;
294298 } ,
295299} ;
0 commit comments