diff --git a/src/app/api/chat/route.ts b/src/app/api/chat/route.ts index 72b0764..99476f9 100644 --- a/src/app/api/chat/route.ts +++ b/src/app/api/chat/route.ts @@ -28,7 +28,7 @@ export async function POST(request: Request) { if (!messages || !Array.isArray(messages)) { Sentry.logger.warn('Chat request received with invalid messages payload') - Sentry.metrics.increment('chat.requests', 1, { tags: { status: 'invalid' } }) + Sentry.metrics.count('chat.requests', 1, { attributes: { status: 'invalid' } }) return new Response( JSON.stringify({ error: 'Messages array is required' }), { status: 400, headers: { 'Content-Type': 'application/json' } } @@ -39,7 +39,7 @@ export async function POST(request: Request) { const lastUserMessage = messages.filter(m => m.role === 'user').pop() if (!lastUserMessage) { Sentry.logger.warn('Chat request received with no user message') - Sentry.metrics.increment('chat.requests', 1, { tags: { status: 'invalid' } }) + Sentry.metrics.count('chat.requests', 1, { attributes: { status: 'invalid' } }) return new Response( JSON.stringify({ error: 'No user message found' }), { status: 400, headers: { 'Content-Type': 'application/json' } } @@ -47,7 +47,7 @@ export async function POST(request: Request) { } Sentry.logger.info('Chat request received with %d messages', [messages.length]) - Sentry.metrics.increment('chat.requests', 1, { tags: { status: 'started' } }) + Sentry.metrics.count('chat.requests', 1, { attributes: { status: 'started' } }) Sentry.metrics.distribution('chat.messages_per_request', messages.length) // Build conversation context @@ -99,7 +99,7 @@ export async function POST(request: Request) { for (const block of content) { if (block.type === 'tool_use') { Sentry.logger.info('Agent tool invoked: %s', [block.name]) - Sentry.metrics.increment('chat.tool_invocations', 1, { tags: { tool: block.name } }) + Sentry.metrics.count('chat.tool_invocations', 1, { attributes: { tool: block.name } }) controller.enqueue(encoder.encode( `data: ${JSON.stringify({ type: 'tool_start', tool: block.name })}\n\n` )) @@ -118,7 +118,7 @@ export async function POST(request: Request) { // Signal completion if (message.type === 'result' && message.subtype === 'success') { Sentry.logger.info('Chat stream completed successfully') - Sentry.metrics.increment('chat.requests', 1, { tags: { status: 'success' } }) + Sentry.metrics.count('chat.requests', 1, { attributes: { status: 'success' } }) controller.enqueue(encoder.encode( `data: ${JSON.stringify({ type: 'done' })}\n\n` )) @@ -127,7 +127,7 @@ export async function POST(request: Request) { // Handle errors if (message.type === 'result' && message.subtype !== 'success') { Sentry.logger.error('Chat query did not complete successfully, subtype: %s', [message.subtype]) - Sentry.metrics.increment('chat.requests', 1, { tags: { status: 'query_failure' } }) + Sentry.metrics.count('chat.requests', 1, { attributes: { status: 'query_failure' } }) controller.enqueue(encoder.encode( `data: ${JSON.stringify({ type: 'error', message: 'Query did not complete successfully' })}\n\n` )) @@ -138,7 +138,7 @@ export async function POST(request: Request) { controller.close() } catch (error) { Sentry.logger.error('Chat stream error: %s', [error instanceof Error ? error.message : String(error)]) - Sentry.metrics.increment('chat.errors', 1, { tags: { phase: 'stream' } }) + Sentry.metrics.count('chat.errors', 1, { attributes: { phase: 'stream' } }) Sentry.captureException(error) controller.enqueue(encoder.encode( `data: ${JSON.stringify({ type: 'error', message: 'Stream error occurred' })}\n\n` @@ -157,7 +157,7 @@ export async function POST(request: Request) { }) } catch (error) { Sentry.logger.error('Chat API error: %s', [error instanceof Error ? error.message : String(error)]) - Sentry.metrics.increment('chat.errors', 1, { tags: { phase: 'request' } }) + Sentry.metrics.count('chat.errors', 1, { attributes: { phase: 'request' } }) Sentry.captureException(error) return new Response( diff --git a/src/components/desktop/Desktop.tsx b/src/components/desktop/Desktop.tsx index 3abda94..cdd8db7 100644 --- a/src/components/desktop/Desktop.tsx +++ b/src/components/desktop/Desktop.tsx @@ -61,7 +61,7 @@ function DesktopContent() { const openInstallGuide = () => { Sentry.logger.info('App launched: %s', ['Install Guide']) - Sentry.metrics.increment('app.launched', 1, { tags: { app: 'install-guide' } }) + Sentry.metrics.count('app.launched', 1, { attributes: { app: 'install-guide' } }) openWindow({ id: 'install-guide', title: 'Install Guide.md', @@ -80,7 +80,7 @@ function DesktopContent() { const openChatWindow = () => { Sentry.logger.info('App launched: %s', ['Chat']) - Sentry.metrics.increment('app.launched', 1, { tags: { app: 'chat' } }) + Sentry.metrics.count('app.launched', 1, { attributes: { app: 'chat' } }) openWindow({ id: 'chat', title: 'SentryOS Chat', @@ -99,7 +99,7 @@ function DesktopContent() { const openAgentsFolder = () => { Sentry.logger.info('App launched: %s', ['Agents Folder']) - Sentry.metrics.increment('app.launched', 1, { tags: { app: 'agents-folder' } }) + Sentry.metrics.count('app.launched', 1, { attributes: { app: 'agents-folder' } }) const agentsFolderItems: FolderItem[] = [] openWindow({ diff --git a/src/components/desktop/WindowManager.tsx b/src/components/desktop/WindowManager.tsx index eb1910c..ba8bf0b 100644 --- a/src/components/desktop/WindowManager.tsx +++ b/src/components/desktop/WindowManager.tsx @@ -33,7 +33,7 @@ export function WindowManagerProvider({ children }: { children: ReactNode }) { const openWindow = useCallback((window: Omit) => { Sentry.logger.info('Window opened: %s', [window.title]) - Sentry.metrics.increment('window.opened', 1, { tags: { window_id: window.id } }) + Sentry.metrics.count('window.opened', 1, { attributes: { window_id: window.id } }) setTopZIndex(currentZ => { const newZ = currentZ + 1 setWindows(prev => { @@ -63,13 +63,13 @@ export function WindowManagerProvider({ children }: { children: ReactNode }) { const closeWindow = useCallback((id: string) => { Sentry.logger.info('Window closed: %s', [id]) - Sentry.metrics.increment('window.closed', 1, { tags: { window_id: id } }) + Sentry.metrics.count('window.closed', 1, { attributes: { window_id: id } }) setWindows(prev => prev.filter(w => w.id !== id)) }, []) const minimizeWindow = useCallback((id: string) => { Sentry.logger.info('Window minimized: %s', [id]) - Sentry.metrics.increment('window.minimized', 1, { tags: { window_id: id } }) + Sentry.metrics.count('window.minimized', 1, { attributes: { window_id: id } }) setWindows(prev => prev.map(w => w.id === id ? { ...w, isMinimized: true, isFocused: false } : w )) @@ -80,7 +80,7 @@ export function WindowManagerProvider({ children }: { children: ReactNode }) { const win = prev.find(w => w.id === id) const action = win?.isMaximized ? 'restored' : 'maximized' Sentry.logger.info('Window %s: %s', [action, id]) - Sentry.metrics.increment(`window.${action}`, 1, { tags: { window_id: id } }) + Sentry.metrics.count(`window.${action}`, 1, { attributes: { window_id: id } }) return prev.map(w => w.id === id ? { ...w, isMaximized: !w.isMaximized } : w ) diff --git a/src/components/desktop/apps/Chat.tsx b/src/components/desktop/apps/Chat.tsx index 30361b3..592ef80 100644 --- a/src/components/desktop/apps/Chat.tsx +++ b/src/components/desktop/apps/Chat.tsx @@ -85,7 +85,7 @@ export function Chat() { setCurrentTool(null) Sentry.logger.info('User sent chat message, conversation length: %d', [messages.length + 1]) - Sentry.metrics.increment('chat.client.message_sent', 1) + Sentry.metrics.count('chat.client.message_sent', 1) try { const response = await fetch('/api/chat', { @@ -150,7 +150,7 @@ export function Chat() { )) } else if (parsed.type === 'tool_start') { Sentry.logger.info('Tool execution started: %s', [parsed.tool]) - Sentry.metrics.increment('chat.client.tool_execution', 1, { tags: { tool: parsed.tool } }) + Sentry.metrics.count('chat.client.tool_execution', 1, { attributes: { tool: parsed.tool } }) setCurrentTool({ name: parsed.tool, status: 'running' @@ -162,7 +162,7 @@ export function Chat() { } : null) } else if (parsed.type === 'done') { Sentry.logger.info('Chat response stream completed') - Sentry.metrics.increment('chat.client.response_received', 1) + Sentry.metrics.count('chat.client.response_received', 1) setCurrentTool(null) } else if (parsed.type === 'error') { Sentry.logger.error('Chat stream returned error: %s', [parsed.message]) @@ -187,7 +187,7 @@ export function Chat() { } } catch (error) { Sentry.logger.error('Chat fetch error: %s', [error instanceof Error ? error.message : String(error)]) - Sentry.metrics.increment('chat.client.errors', 1) + Sentry.metrics.count('chat.client.errors', 1) Sentry.captureException(error) const errorMessage: Message = { id: crypto.randomUUID(),