Monitor Cursor IDE usage, detect spending anomalies, and alert your team. Self-hosted, open-source.
by ofershapTypeScript
Last 12 weeks · 0 commits
4 of 6 standards met
Enhanced the /teams/spend endpoint response structure to include new fields: , , , and . Updated the 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 GH issue https://github.com/ofershap/cursor-usage-tracker/issues/19. Introduced PostgreSQL as an alternative database option, allowing users to set for enhanced data handling. Created for a full stack setup including the tracker app and PostgreSQL. Added for standalone PostgreSQL service management. Updated and to include PostgreSQL dependencies ( and ). Enhanced error handling in the application to accommodate PostgreSQL integration. Updated README with instructions for using PostgreSQL and Docker setup. Bumped several dependencies including @tailwindcss/postcss to 4.2.1, resend to 6.9.3, and tailwindcss to 4.2.1. Updated @elevenlabs/elevenlabs-js to 2.37.0, @types/node to 25.3.3, eslint to 10.0.2, lint-staged to 16.3.1, and typescript-eslint to 8.56.1. These updates include minor and patch version changes to improve stability and performance. Introduced a new script command "detect" in package.json to facilitate detection functionality via the CLI. This addition enhances the usability of the CLI tools provided in the project. Introduced new CLI commands and in package.json to clear collected data from the database, allowing for a fresh start or post-testing cleanup. Updated README with instructions on using the reset command, including options for wiping specific tables or all tables. Enhanced project documentation to reflect the addition of the reset functionality and its usage. Modified to include PostgreSQL configuration options for user, password, database, host, and port. Updated files to utilize environment variables for PostgreSQL settings, enhancing flexibility and security. Adjusted npm scripts in to remove hardcoded PostgreSQL URLs, allowing for dynamic configuration through the file. Enhanced error handling in PostgreSQL-related scripts to ensure proper execution and user guidance.
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: 33, Forks: 11. 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 (5mo ago). Open PRs: 2, open issues: 1. Last activity: 3mo ago. Community health: 85%. Top contributors: ofershap, dependabot[bot].