diff --git a/src/client.js b/src/client.js index 3a1fd6d..a692f8c 100644 --- a/src/client.js +++ b/src/client.js @@ -91,38 +91,46 @@ var client = { if (this.testing === null) return; - var payload = { - "data": data, - "duration": 0.0, - "timestamp": timestamp.toISOString(), - }; - - var attempt = () => { - return this.awc.heartbeat(this.getBucketId(), pulsetime, payload); - }; - - retry(attempt, { retries: 3 }).then( - (res) => { - if (!client.lastSyncSuccess) { - emitNotification( - "Now connected again", - "Connection to ActivityWatch server established again" - ); - } - client.lastSyncSuccess = true; - client.updateSyncStatus(); - }, (err) => { - if(client.lastSyncSuccess) { - emitNotification( - "Unable to send event to server", - "Please ensure that ActivityWatch is running" - ); - } - client.lastSyncSuccess = false; - client.updateSyncStatus(); - logHttpError(err); + // First get tags if they exist + chrome.storage.local.get(['tags'], (result) => { + var payload = { + "data": data, + "duration": 0.0, + "timestamp": timestamp.toISOString(), + }; + + // Only add tags if they exist + if (result.tags) { + payload.data.tags = result.tags; } - ); + + var attempt = () => { + return client.awc.heartbeat(client.getBucketId(), pulsetime, payload); + }; + + retry(attempt, { retries: 3 }).then( + (res) => { + if (!client.lastSyncSuccess) { + emitNotification( + "Now connected again", + "Connection to ActivityWatch server established again" + ); + } + client.lastSyncSuccess = true; + client.updateSyncStatus(); + }, (err) => { + if(client.lastSyncSuccess) { + emitNotification( + "Unable to send event to server", + "Please ensure that ActivityWatch is running" + ); + } + client.lastSyncSuccess = false; + client.updateSyncStatus(); + logHttpError(err); + } + ); + }); } }; diff --git a/static/popup.html b/static/popup.html index be17372..4ff659d 100644 --- a/static/popup.html +++ b/static/popup.html @@ -57,6 +57,13 @@ + +