1
0
mirror of https://github.com/BoostIo/Boostnote synced 2025-12-13 17:56:25 +00:00
Files
Boostnote/browser/lib/wakatime-plugin.js
2019-03-12 20:40:27 -05:00

27 lines
882 B
JavaScript

const exec = require('child_process').exec
const path = require('path')
let lastHeartbeat = 0
function sendWakatimeHeartBeat (storagePath, noteKey, storageName, isWrite, hasFileChanges, isFileChange) {
if (new Date().getTime() - lastHeartbeat > 120000 || isFileChange) {
const notePath = path.join(storagePath, 'notes', noteKey + '.cson')
if (!isWrite && !hasFileChanges && !isFileChange) {
return
}
lastHeartbeat = new Date()
// TODO: add --key sdasdsa-sdsad-asdasd-asdsa-asdasdadas from configuration UI or use ~/.wakatime.conf
exec(`wakatime --file ${notePath} --project ${storageName} --plugin Boostnote-wakatime`, (error, stdOut, stdErr) => {
if (error) {
console.log(error)
} else {
console.log('wakatime', 'isWrite', isWrite, 'hasChanges', hasFileChanges)
}
})
}
}
export { sendWakatimeHeartBeat }