Skip to content

feat: comprehensive analytics api #8

Closed
samarth30 wants to merge 16 commits intomainfrom
staging
Closed

feat: comprehensive analytics api #8
samarth30 wants to merge 16 commits intomainfrom
staging

Conversation

@samarth30
Copy link
Member

This pull request introduces a comprehensive analytics API for the application, adding new endpoints, configuration options, and data export capabilities. The changes provide flexible breakdowns, predictive analytics, and enhanced export utilities, along with robust authentication and configuration management. Below are the most important changes grouped by theme:

Analytics API Endpoints

  • Added new analytics endpoints for overview, breakdown, projections, export, and configuration, enabling advanced analytics features and flexible data retrieval in the app/api/analytics directory. [1] [2] [3]

Export & Data Utilities

  • Implemented enhanced data export functionality supporting CSV and JSON formats, with user, provider, model, and timeseries breakdowns, including metadata and formatting helpers in app/api/analytics/export/route.ts.

Configuration Management

  • Added support for retrieving and updating analytics configuration (markup percentage, refresh interval, time range, export formats) with validation and role-based access in app/api/analytics/config/route.ts.

Documentation & Developer Experience

  • Added ANALYTICS_QUICK_REFERENCE.md providing a summary of endpoints, usage examples, file structure, common use cases, configuration options, troubleshooting, and integration tips for the analytics API.
  • Updated .env.example and CLAUDE.md to include local development environment variables and commands for automated database setup and management. [1] [2]

samarth30 and others added 16 commits October 6, 2025 22:21
…e operations to nonblocking to decrease loading states duration
…or database user migration + test files for db connection test
Brings all missing optimizations from feat/stripe branch:

- Non-blocking chat API with fire-and-forget pattern (fixes 6-10s delay)
- AI Gateway integration for proper model routing
- Atomic message sequencing with addMessageWithSequence
- Credit deduction race condition fixes with row-level locking
- Local Docker PostgreSQL setup for development
- Database driver switching (pg for local, neon-serverless for production)
- Improved chat interface with error handling and timeout safety
- Logout functionality and session management
- Seed scripts for local development
- .env.example template

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vercel
Copy link

vercel bot commented Oct 7, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
eliza-cloud-v2 Error Error Oct 7, 2025 4:06pm

@coderabbitai
Copy link

coderabbitai bot commented Oct 7, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.


Note

Free review on us!

CodeRabbit is offering free reviews until Wed Oct 08 2025 to showcase some of the refinements we've made.

Comment @coderabbitai help to get the list of available commands and usage tips.

@claude claude bot mentioned this pull request Jan 2, 2026
0xSolace added a commit that referenced this pull request Mar 9, 2026
Critical bugs fixed:
- #1: resolveContainer() now hydrates from DB after restart instead of
  falling back to first node. Added findBySandboxId() and listByNodeId()
  repository methods for DB-backed container resolution.
- #2: create() now uses DockerNodeManager.getAvailableNode() for
  least-loaded placement instead of random env-var selection. Increments
  allocated_count on create, decrements on stop. Falls back to env var
  only when DB has no nodes registered.
- #3: Port allocation now queries DB for ports already assigned on the
  target node. allocatePort() takes an exclusion set and retries until
  it finds a free port.

Security fixes:
- #4: runCommand() now shell-escapes cmd and each arg individually via
  shellQuote() before passing to SSH exec. Container names also quoted
  in docker exec/stop/rm commands.
- #5: Added validateAgentId() check (UUID-safe chars only, max 128)
  called before any shell interpolation of agentId. getVolumePath()
  validates before constructing path.

Functional fixes:
- #6: checkHealth() now polls with retry loop (3s interval, 60s total
  timeout) matching Vercel provider behavior, instead of single-shot
  8s request.
- #7: getContainerName() now uses full agentId instead of truncated
  first-8-chars to eliminate collision risk.

Code quality fixes:
- #8: Exported DockerSandboxMetadata interface for strongly-typed
  metadata. milaidy-sandbox.ts imports and narrows with it instead
  of Record<string, unknown> + as casts.
- #9: Fixed step numbering in create() comments (was 8→10, now 8→9→10).
- #10: SSH pool key changed from hostname-only to hostname:port to
  prevent collisions when nodes share hostname with different ports.
- #11: parseDockerNodes() result now cached at module level, only
  re-parsed when MILAIDY_DOCKER_NODES env var changes.
- #12: Moved DOCKER_HEADSCALE_PLAN.md and DOCKER_PROVISIONING_SUMMARY.md
  from repo root to docs/ directory.

No new type errors (tsc --noEmit passes with only 2 pre-existing errors).
0xSolace added a commit that referenced this pull request Mar 9, 2026
Fixes all 11 findings from the automated review:

Critical:
- (#1) Fix migration number references: 0034 → 0046 in schema comments and docs
- (#2) Port race TOCTOU: add partial UNIQUE index on (node_id, bridge_port)
  for active sandboxes. allocatePort() already retries; DB constraint is the
  safety net for concurrent provisioning
- (#3) SSH pool serverless compat: add idle timeout (5min) eviction on
  getClient(), track lastActivityMs on exec()

Security:
- (#4) Remove `as any` cast on statusFilter — validate against known status
  set, return 400 for invalid values, cast to MiladySandboxStatus type
- (#5) Add SENSITIVE_KEYS set to redact TS_AUTHKEY, DATABASE_URL, etc. from
  any logged docker run commands
- (#6) Document MILADY_DOCKER_NODES fallback as seed-only path with no load
  balancing — production should use Admin API node registration

Code quality:
- (#7) Remove ssh! non-null assertions in health check route — use definite
  assignment after early-return guard
- (#8) Migration already uses IF NOT EXISTS on all statements ✓
- (#9) Unit tests noted as follow-up work (not blocking)

Nits:
- (#10) Add logger.warn fallback when Vercel sandbox has neither shutdown()
  nor close() method
- (#11) PR draft status — will mark ready after fixes are confirmed
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.

1 participant