🐛 don't record unless we're actually working.

This commit is contained in:
2026-06-15 22:43:15 +10:00
parent cf32c4f82a
commit 3644885b39
2 changed files with 29 additions and 2 deletions

View File

@@ -0,0 +1,27 @@
#!/usr/bin/env node
// One-time migration: remove ghost sessions created by clicking into a document
// without typing. These have activeMs === 0 (no keystrokes recorded).
import { readFileSync, writeFileSync, copyFileSync } from 'fs'
const TELEMETRY = `${process.env.HOME}/Library/Application Support/Borges/.borges/telemetry.json`
const BACKUP = TELEMETRY + '.ghost-bak'
const sessions = JSON.parse(readFileSync(TELEMETRY, 'utf-8'))
const ghosts = sessions.filter(s => s.activeMs === 0)
const cleaned = sessions.filter(s => s.activeMs > 0)
if (ghosts.length === 0) {
console.log('No ghost sessions found.')
process.exit(0)
}
for (const s of ghosts) {
console.log(`Removing ghost session ${s.id} (${s.storyId}) date=${s.date} words ${s.wordsStart}${s.wordsEnd}`)
}
copyFileSync(TELEMETRY, BACKUP)
console.log(`\nBacked up to ${BACKUP}`)
writeFileSync(TELEMETRY, JSON.stringify(cleaned, null, 2), 'utf-8')
console.log(`Done. Removed ${ghosts.length} ghost session(s) → ${cleaned.length} total (was ${sessions.length}).`)