cursor-usage-analyzer 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,13 @@
1
+ {
2
+ "permissions": {
3
+ "allow": [
4
+ "Bash(npm install)",
5
+ "Bash(sqlite3:*)",
6
+ "Bash(python3:*)",
7
+ "Bash(node -e:*)",
8
+ "Bash(for file in cursor-logs-export/chats/2025-12-17*.txt)",
9
+ "Bash(grep:*)",
10
+ "Bash(node analyze.js:*)"
11
+ ]
12
+ }
13
+ }
package/.idea/vcs.xml CHANGED
@@ -1,5 +1,10 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <project version="4">
3
+ <component name="GitSharedSettings">
4
+ <option name="FORCE_PUSH_PROHIBITED_PATTERNS">
5
+ <list />
6
+ </option>
7
+ </component>
3
8
  <component name="VcsDirectoryMappings">
4
9
  <mapping directory="" vcs="Git" />
5
10
  </component>
package/README.md CHANGED
@@ -5,11 +5,13 @@ A powerful Node.js tool to analyze and visualize your Cursor AI editor usage. Ex
5
5
  ## Features
6
6
 
7
7
  - 📊 **Comprehensive Analytics**: Track conversations, messages, tokens, code changes, and more
8
+ - 💰 **API Token Tracking**: Import CSV from Cursor dashboard to track actual API usage, costs, and billing
8
9
  - 📈 **Interactive Charts**: Visualize usage patterns with Chart.js-powered graphs
9
10
  - 🔍 **Smart Filtering**: Filter and sort conversations by project, model, date, and name
10
11
  - 📁 **Full Export**: Export complete conversation histories as readable text files
11
12
  - 🎯 **Project Detection**: Automatically resolves workspace names from Cursor's database
12
13
  - 📅 **Flexible Date Ranges**: Analyze single days, months, or custom periods
14
+ - 🖥️ **Cross-Platform**: Works on Windows, macOS, and Linux
13
15
 
14
16
  ## Installation
15
17
 
@@ -86,8 +88,35 @@ npx cursor-usage-analyzer --last-month
86
88
 
87
89
  # This month
88
90
  npx cursor-usage-analyzer --this-month
91
+
92
+ # Include API token usage from CSV export
93
+ npx cursor-usage-analyzer --csv path/to/team-usage-events.csv
89
94
  ```
90
95
 
96
+ ### API Token Tracking (CSV Import)
97
+
98
+ For detailed API usage tracking including actual tokens sent to Claude's API and costs, you can import CSV data from the Cursor dashboard:
99
+
100
+ 1. **Export CSV from Cursor**:
101
+ - Go to [Cursor Dashboard](https://cursor.com/dashboard)
102
+ - Navigate to Usage tab
103
+ - Click "Export" to download your usage CSV
104
+
105
+ 2. **Run analyzer with CSV**:
106
+ ```bash
107
+ npx cursor-usage-analyzer --csv ~/Downloads/team-usage-events-XXXXX-2025-12-18.csv
108
+ ```
109
+
110
+ 3. **What you get**:
111
+ - **Input Tokens** (with/without cache write)
112
+ - **Cache Read tokens**
113
+ - **Output tokens**
114
+ - **Total API tokens** (actual usage sent to Claude API)
115
+ - **Cost per conversation** (in USD)
116
+ - **API call count** per conversation
117
+
118
+ The tool automatically matches API calls to conversations based on timestamp and model, giving you complete visibility into your actual usage and costs.
119
+
91
120
  ### NPM Scripts (Local Installation Only)
92
121
 
93
122
  If you cloned the repo locally, you can use these convenient shortcuts:
@@ -111,11 +140,22 @@ Name: Feature implementation
111
140
  Workspace: my-project
112
141
  Time: 12/8/2025, 2:30:45 PM
113
142
  Model: claude-4.5-sonnet-thinking
114
- Tokens: 15,234 / 200,000 (7.6%)
143
+ Context Tokens: 15,234 / 200,000 (7.6%)
115
144
  Changes: +245 -12 lines in 8 files
116
145
  Messages: 23
146
+
147
+ API TOKEN USAGE (from dashboard export):
148
+ API Calls: 3
149
+ Input (w/ Cache Write): 12,456
150
+ Input (w/o Cache Write): 1,234
151
+ Cache Read: 45,678
152
+ Output Tokens: 2,345
153
+ Total API Tokens: 61,713
154
+ Cost: $0.23
117
155
  ```
118
156
 
157
+ **Note**: API token data only appears when using `--csv` flag
158
+
119
159
  ### 2. HTML Report (`report.html`)
120
160
 
121
161
  Interactive dashboard featuring:
@@ -137,25 +177,69 @@ Interactive dashboard featuring:
137
177
  - Filter by project, model, name, or date range
138
178
  - View complete conversation metadata
139
179
 
140
- ## Data Source
180
+ ### Opening the Report
181
+
182
+ After generation, open the HTML report with:
183
+
184
+ **macOS:**
185
+ ```bash
186
+ open cursor-logs-export/report.html
187
+ ```
188
+
189
+ **Windows:**
190
+ ```cmd
191
+ start cursor-logs-export/report.html
192
+ ```
193
+
194
+ **Linux:**
195
+ ```bash
196
+ xdg-open cursor-logs-export/report.html
197
+ ```
198
+
199
+ Or simply double-click `report.html` in your file explorer.
141
200
 
142
- The analyzer reads from Cursor's local SQLite database:
201
+ ## Data Sources
202
+
203
+ ### 1. Local SQLite Database (Required)
204
+
205
+ The analyzer reads from Cursor's local SQLite database at platform-specific locations:
206
+
207
+ **macOS:**
143
208
  ```
144
209
  ~/Library/Application Support/Cursor/User/globalStorage/state.vscdb
145
210
  ```
146
211
 
147
- It extracts:
212
+ **Windows:**
213
+ ```
214
+ %APPDATA%\Cursor\User\globalStorage\state.vscdb
215
+ ```
216
+
217
+ **Linux:**
218
+ ```
219
+ ~/.config/Cursor/User/globalStorage/state.vscdb
220
+ ```
221
+
222
+ From the database, it extracts:
148
223
  - **Conversation metadata**: Names, timestamps, models
149
224
  - **Message content**: Full chat history (user prompts & AI responses)
150
225
  - **Code changes**: Lines added/removed, files modified
151
- - **Token usage**: Context tokens used and limits
226
+ - **Context token usage**: Tokens in conversation context window
152
227
  - **Project information**: Workspace paths and names
153
228
 
229
+ ### 2. CSV Export (Optional, for API Token Tracking)
230
+
231
+ When you provide a CSV export from Cursor's dashboard using `--csv`:
232
+ - **API token usage**: Actual tokens sent to Claude API (input with/without cache, cache reads, output)
233
+ - **Cost tracking**: Exact costs in USD per conversation
234
+ - **API call details**: Number of API calls, model used, timestamps
235
+
236
+ The tool automatically matches CSV data to conversations based on timestamps and models, giving you a complete picture of both context usage and actual API consumption.
237
+
154
238
  ## Requirements
155
239
 
156
240
  - **Node.js**: v14 or higher
157
241
  - **Cursor Editor**: Must have conversations stored locally
158
- - **OS**: macOS (paths are macOS-specific)
242
+ - **OS**: Windows, macOS, or Linux
159
243
 
160
244
  ## Project Structure
161
245
 
@@ -200,11 +284,24 @@ npx cursor-usage-analyzer --date 2025-11-15
200
284
  ## Troubleshooting
201
285
 
202
286
  ### "Database not found"
203
- Ensure Cursor has been used and conversations exist. Database path:
287
+ Ensure Cursor has been used and conversations exist. Check the database path for your platform:
288
+
289
+ **macOS:**
204
290
  ```
205
291
  ~/Library/Application Support/Cursor/User/globalStorage/state.vscdb
206
292
  ```
207
293
 
294
+ **Windows:**
295
+ ```
296
+ %APPDATA%\Cursor\User\globalStorage\state.vscdb
297
+ ```
298
+ (Usually: `C:\Users\YourUsername\AppData\Roaming\Cursor\User\globalStorage\state.vscdb`)
299
+
300
+ **Linux:**
301
+ ```
302
+ ~/.config/Cursor/User/globalStorage/state.vscdb
303
+ ```
304
+
208
305
  ### "No conversations found"
209
306
  - Check the date range is correct
210
307
  - Verify you have conversations in Cursor from that period