🐛 don't record unless we're actually working.
This commit is contained in:
27
scripts/fix-ghost-sessions.mjs
Normal file
27
scripts/fix-ghost-sessions.mjs
Normal 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}).`)
|
||||
Reference in New Issue
Block a user