Monitor Cursor IDE usage, detect spending anomalies, and alert your team. Self-hosted, open-source.
by ofershapTypeScript
Last 12 weeks · 3 commits
4 of 6 standards met
Summary Running fails to persist spending data because Cursor's API response shape has changed. Two related issues: 1. The endpoint no longer returns , causing a SQLite constraint violation. 2. The endpoint now returns for users under their plan limit and exposes the actual cycle total in a new field, . As a result, even after working around the constraint error, all stored spend values would be . Reproduction Output: is reported, while every other collector (daily usage, groups, usage events, analytics) succeeds. Root cause A live response from (page 1, pageSize 3) currently looks like: Differences from what the codebase expects (see in and in ): — no longer present. The collector binds , which better-sqlite3 sends as , hitting . — semantics appear to have changed. It now seems to represent the overage above the plan-included amount, and is for everyone within plan. — new field. Represents the cycle-to-date total (what the dashboard previously showed as ). New fields seen on members: , . Suggested fix In , normalize the response so the rest of the pipeline keeps working: (total cycle spend) (or if not derivable) Defensive / in bindings as a belt-and-suspenders fix against future schema changes. Update and to document the new fields and the new semantics of . The API reference in should also be refreshed — it currently lists only for this endpoint. Environment Branch: @ Node / SQLite: better-sqlite3 Team size in repro: 50 members, 17 spend pages
Enhanced the /teams/spend endpoint response structure to include new fields: overallSpendCents, totalMembers, limitedUsersCount, and maxUserSpendCents. Updated the normalizeMemberSpend function to accommodate the new API shape, ensuring backward compatibility with pre-2026 data. Added defensive defaults in the SQLite upsert function to prevent crashes due to missing fields. Implemented tests to verify the normalization of both pre-2026 and post-2026 API shapes. Addresses issue #19.
Repository: ofershap/cursor-usage-tracker. Description: Monitor Cursor IDE usage, detect spending anomalies, and alert your team. Self-hosted, open-source. Stars: 30, Forks: 10. Primary language: TypeScript. Languages: TypeScript (99.3%), JavaScript (0.3%), CSS (0.2%), Dockerfile (0.1%). License: MIT. Topics: ai, ai-costs, anomaly-detection, cursor, cursor-ide, enterprise, nextjs, open-source, slack-alerts, sqlite, typescript, usage-monitoring. Latest release: v1.24.0 (3mo ago). Open PRs: 1, open issues: 1. Last activity: 1mo ago. Community health: 85%. Top contributors: ofershap, dependabot[bot].