Skip to content

Add analytics for QA agent#54

Merged
amrit110 merged 4 commits intomainfrom
add_analytics_doc
Mar 15, 2026
Merged

Add analytics for QA agent#54
amrit110 merged 4 commits intomainfrom
add_analytics_doc

Conversation

@amrit110
Copy link
Copy Markdown
Member

This pull request adds comprehensive analytics and activity logging to the Bookstack Agent, including backend support for logging query activity and new frontend components for visualizing usage metrics, query velocity, and recent queries. The changes enable tracking and display of detailed agent usage statistics, tool calls, and query outcomes, improving observability and user insight into the agent’s performance.

Backend: Analytics Logging Integration

  • Added an activity_logger (BookstackActivityLogger) to the FastAPI app state, initialized at startup, for capturing analytics about each query. Logging is performed asynchronously in the background to avoid blocking the main event stream. Query details such as session ID, question, tool calls, answer, duration, and status are logged for each query processed. [1] [2] [3] [4] [5]

Frontend: Analytics Dashboard Components

  • Introduced a QueryMetrics component that displays key metrics (total queries, unique sessions, success rate, average duration, tool calls, etc.) in a visually appealing card layout, including a success/error bar for answer rates.
  • Added a QueryVelocityChart component using recharts to visualize daily query volume and error rates over the last 90 days, with responsive design and gradient area charts for success and error counts.
  • Implemented a RecentQueriesTable component with search, status filtering, pagination, and per-query trace inspection (modal view), showing recent queries, tool usage, durations, and statuses. Tool calls and answer previews are available for each query.

@amrit110 amrit110 self-assigned this Mar 15, 2026
@amrit110 amrit110 added the enhancement New feature or request label Mar 15, 2026
Comment thread bookstack_agent/ui/app/api/bookstack-trace/route.ts Fixed
Comment thread bookstack_agent/ui/app/api/bookstack-trace/route.ts Fixed
amrit110 and others added 2 commits March 14, 2026 21:02
Replace the custom sanitizeTracePath helper with a strict regex that
captures only the date and filename segments, then reconstruct the GCS
URL from those encodeURIComponent-encoded groups. This ensures no
raw user input is ever interpolated into the fetch URL, satisfying
CodeQL's taint-flow analysis.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@amrit110 amrit110 merged commit 4075965 into main Mar 15, 2026
9 checks passed
@amrit110 amrit110 deleted the add_analytics_doc branch March 15, 2026 01:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants