Skip to content

Add analytics API endpoints and frontend integration#2

Merged
jhd3197 merged 1 commit into
mainfrom
dev
Feb 1, 2026
Merged

Add analytics API endpoints and frontend integration#2
jhd3197 merged 1 commit into
mainfrom
dev

Conversation

@jhd3197

@jhd3197 jhd3197 commented Feb 1, 2026

Copy link
Copy Markdown
Owner

Introduces new backend endpoints for agent run stats, including daily aggregates and time filtering. Updates frontend analytics components to fetch and display live data, replaces mock data, and adds hooks for analytics state management. Refactors settings modal to support tabs and routes for API keys and general settings. Improves builder and layout components for code view, version selection, and navigation.

Introduces new backend endpoints for agent run stats, including daily aggregates and time filtering. Updates frontend analytics components to fetch and display live data, replaces mock data, and adds hooks for analytics state management. Refactors settings modal to support tabs and routes for API keys and general settings. Improves builder and layout components for code view, version selection, and navigation.
Copilot AI review requested due to automatic review settings February 1, 2026 18:34
@jhd3197 jhd3197 merged commit 6596b98 into main Feb 1, 2026
6 checks passed

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR introduces backend analytics endpoints for agent runs and wires them into a new, live analytics dashboard and settings experience on the frontend, while also refactoring versioning and settings workflows. It replaces mock analytics data with real API-driven metrics and upgrades the page builder header to support version selection, code view, and export.

Changes:

  • Add new backend repository methods and FastAPI routes for agent run stats, daily aggregates, and time-filtered run listings, plus corresponding frontend analytics hooks and visualizations (metrics, charts, and activity table).
  • Refactor the settings UX from a modal to routed pages for general settings and API keys, update provider state management, and add dedicated API keys management UI.
  • Enhance the page builder layout with a code view (per-version file listing and viewer), version selector integration in the header, and an export button, while adjusting CI workflows to use a static version in pyproject.toml and sed-based version bumps.

Reviewed changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
pyproject.toml Switches from setuptools_scm dynamic versioning to a static version field, simplifying packaging metadata.
frontend/src/pages/SettingsPage.jsx Adds a routed “General Settings” page to manage default model and display data directory and default port information.
frontend/src/pages/PageBuilderPage.jsx Integrates CodeView, tracks viewMode, and passes versions, agents, and view state into the header while simplifying generation-related comments.
frontend/src/pages/ApiKeysPage.jsx Introduces a full-page API keys settings UI with provider cards, masked input, visibility toggles, and save/remove actions wired to the providers hook.
frontend/src/pages/AnalyticsPage.jsx Replaces static analytics mock UI with data-driven metrics using useAnalytics, wiring in stats, daily aggregates, and runs into cards, charts, and the activity table.
frontend/src/main.jsx Registers new routes for /settings and /settings/api-keys, wiring SettingsPage and ApiKeysPage into the main router.
frontend/src/hooks/useProviders.js Adjusts provider state initialization to accept either { providers: [...] } or a bare array from the /api/providers endpoint.
frontend/src/hooks/useAnalytics.js Adds a hook that translates time filters into query params and fetches aggregated stats, daily stats, and recent runs in parallel for the analytics UI.
frontend/src/context/AppContext.jsx Removes settingsOpen modal state from the global app context now that settings are page-routed.
frontend/src/components/shared/SettingsModal.jsx Refactors the modal into tabbed “General” and “API Keys” sections, mirroring the new settings functionality while remaining modal-based.
frontend/src/components/layout/TopHeader.jsx Simplifies top header by removing the settings modal trigger and retaining search and conditional “New Project” button behavior.
frontend/src/components/layout/PageBuilderHeader.jsx Extends the page builder header with version selection, pipeline progress, preview/code view toggle, and an export button linking to the project export URL.
frontend/src/components/layout/AppSidebar.jsx Replaces modal-based settings buttons with NavLinks to /settings and /settings/api-keys, adding a structured Settings section in the sidebar.
frontend/src/components/builder/PreviewFrame.jsx Tightens iframe sandboxing by removing allow-same-origin, leaving allow-scripts for safer previews.
frontend/src/components/builder/CodeView.jsx Adds a code viewer that lists version files, lazy-loads their contents via API, and supports copying the active file to the clipboard.
frontend/src/components/analytics/TokenChart.jsx Converts the token chart from static mock data to a prop-driven bar chart that visualizes daily input/output tokens with formatted labels.
frontend/src/components/analytics/CostByAgentChart.jsx Replaces fixed sample agents with a dynamic per-agent cost breakdown using backend stats, including colors, labels, and percentage widths.
frontend/src/components/analytics/ActivityTable.jsx Swaps out mock activity rows for real agent runs, with filtering, token/cost formatting, statuses, and loading/empty states.
frontend/src/api/agents.js Extends agent API helpers with optional since filtering, stats querying, and a new getAgentDailyStats endpoint wrapper.
agentsite/storage/repository.py Enhances AgentRunRepository with since-aware run listing and stats plus a new get_daily_stats query for daily token aggregates.
agentsite/api/routes/agents.py Extends the agents API with time-filtered runs, optionally filtered stats, and a daily stats endpoint backing the analytics frontend.
.gitignore Ignores a .marketing directory alongside existing frontend build artifacts.
.github/workflows/publish.yml Removes setuptools_scm from the publish workflow and injects the computed tag version into pyproject.toml prior to building.
.github/workflows/dev.yml Mirrors the main publish workflow by setting the dev package version via sed in pyproject.toml before building a dev release.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pyproject.toml
Comment on lines 5 to 8
[project]
name = "agentsite"
dynamic = ["version"]
version = "0.1.0"
description = "AI-Powered Website Builder using Prompture agent orchestration"

Copilot AI Feb 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that the project version is hard-coded here and the release workflows mutate pyproject.toml with sed, the library has two independent version sources: this field and agentsite.__version__ in agentsite/__init__.py. Because the workflows only update pyproject.toml, these values will drift over time; consider either updating __version__ in the same workflow step or deriving the runtime version from package metadata instead of duplicating it.

Copilot uses AI. Check for mistakes.
Comment on lines 11 to 13
const data = await providersApi.getProviders();
setProviders(data);
setProviders(data.providers || data);
} catch {

Copilot AI Feb 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing the providers state here to data.providers || data means that when /api/providers returns { providers: [...] } (as implemented in agentsite/api/routes/providers.py), the hook will now store the bare array instead of the response object. All existing consumers (e.g. ApiKeysPage and SettingsModal) still expect providers.providers, so after this change providers.providers becomes undefined and calls like providers.providers.filter(...) will throw at runtime; either keep the state as the full response object or update all consumers to work with the flattened array shape.

Copilot uses AI. Check for mistakes.

const PROVIDER_INFO = {
openai: { label: "OpenAI", env: "OPENAI_API_KEY", placeholder: "sk-...", description: "Powers GPT-4o and other OpenAI models." },
anthropic: { label: "Anthropic", env: "CLAUDE_API_KEY", placeholder: "sk-ant-...", description: "Powers Claude models." },

Copilot AI Feb 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PROVIDER_INFO key anthropic does not match any provider names returned by the /api/providers backend (which exposes "claude" for the Claude API key), so providers.providers.find((p) => p.name === key) will never find this provider and providers.update("anthropic", ...)/providers.remove("anthropic") will 404. To make the Anthropic/Claude card functional, align this key with the backend name (e.g. use claude) or introduce a mapping between display labels and backend provider IDs.

Suggested change
anthropic: { label: "Anthropic", env: "CLAUDE_API_KEY", placeholder: "sk-ant-...", description: "Powers Claude models." },
claude: { label: "Anthropic", env: "CLAUDE_API_KEY", placeholder: "sk-ant-...", description: "Powers Claude models." },

Copilot uses AI. Check for mistakes.
Comment on lines +15 to +22
const TABS = [
{ id: "general", label: "General", icon: Gear },
{ id: "api-keys", label: "API Keys", icon: Key },
];

export default function SettingsModal({ initialTab = "general", onClose }) {
const { providers, models } = useApp();
const [tab, setTab] = useState(initialTab);

Copilot AI Feb 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SettingsModal appears to be no longer used now that settings are exposed via routed pages (/settings and /settings/api-keys), and the last in-repo references to this component have been removed. Keeping this dead component around risks the modal and the new pages drifting out of sync; consider either wiring it back up explicitly or removing it to reduce duplication.

Copilot uses AI. Check for mistakes.
}

function formatTokens(n) {
if (n == null) return "0";

Copilot AI Feb 1, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This guard always evaluates to false.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants