getaimeter 0.1.3 → 0.1.4

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/watcher.js +10 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "getaimeter",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Track your Claude AI usage across CLI, VS Code, and Desktop App. One command to start.",
5
5
  "bin": {
6
6
  "aimeter": "cli.js"
package/watcher.js CHANGED
@@ -138,6 +138,7 @@ async function reportEvents(events) {
138
138
  // ---------------------------------------------------------------------------
139
139
 
140
140
  const _debounceTimers = new Map();
141
+ const _processing = new Set();
141
142
 
142
143
  function handleFileChange(filePath) {
143
144
  // Only care about .jsonl files
@@ -146,12 +147,17 @@ function handleFileChange(filePath) {
146
147
  // Normalize path for consistent debounce key (Windows fires with mixed separators/casing)
147
148
  const normalizedKey = path.resolve(filePath).toLowerCase();
148
149
 
149
- // Debounce: wait 1000ms after last change before processing
150
+ // Skip if already being processed
151
+ if (_processing.has(normalizedKey)) return;
152
+
153
+ // Debounce: wait 2000ms after last change before processing
150
154
  const existing = _debounceTimers.get(normalizedKey);
151
155
  if (existing) clearTimeout(existing);
152
156
 
153
157
  _debounceTimers.set(normalizedKey, setTimeout(async () => {
154
158
  _debounceTimers.delete(normalizedKey);
159
+ if (_processing.has(normalizedKey)) return;
160
+ _processing.add(normalizedKey);
155
161
  try {
156
162
  const events = extractNewUsage(filePath);
157
163
  if (events.length > 0) {
@@ -160,8 +166,10 @@ function handleFileChange(filePath) {
160
166
  }
161
167
  } catch (err) {
162
168
  logError(`Processing ${filePath}:`, err.message);
169
+ } finally {
170
+ _processing.delete(normalizedKey);
163
171
  }
164
- }, 500));
172
+ }, 2000));
165
173
  }
166
174
 
167
175
  /**