From 0f8aceefeaee0755615ade7e22b44556149eff81 Mon Sep 17 00:00:00 2001 From: Mario Basic Date: Wed, 3 Jun 2015 01:42:04 +0200 Subject: [PATCH] Started creating a payload. --- assets/js/WakaTime.js | 13 ++++++++++++- assets/js/helpers/currentTimestamp.js | 3 +++ public/js/events.js | 28 +++++++++++++++++++++++++-- 3 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 assets/js/helpers/currentTimestamp.js diff --git a/assets/js/WakaTime.js b/assets/js/WakaTime.js index 5ef15a4..e281dff 100644 --- a/assets/js/WakaTime.js +++ b/assets/js/WakaTime.js @@ -1,5 +1,7 @@ var UrlHelper = require('./UrlHelper'); +var currentTimestamp = require('./helpers/currentTimestamp'); + class WakaTime { detectionIntervalInSeconds = 60; //default @@ -44,7 +46,7 @@ class WakaTime { var data = { entity: domain, type: 'domain', - time: Math.round((new Date()).getTime() / 1000), + time: currentTimestamp(), is_debugging: false }; @@ -56,6 +58,15 @@ class WakaTime { console.log('sending entity with type url'); // Send entity in heartbeat + + var data = { + entity: entity, + type: 'url', + time: currentTimestamp(), + is_debugging: false + }; + + console.log(data); } }); diff --git a/assets/js/helpers/currentTimestamp.js b/assets/js/helpers/currentTimestamp.js new file mode 100644 index 0000000..c0a7b2c --- /dev/null +++ b/assets/js/helpers/currentTimestamp.js @@ -0,0 +1,3 @@ +export default function(){ + return Math.round((new Date()).getTime() / 1000); +} diff --git a/public/js/events.js b/public/js/events.js index 2e848f1..f429bc2 100644 --- a/public/js/events.js +++ b/public/js/events.js @@ -83,6 +83,8 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons var UrlHelper = require('./UrlHelper'); +var currentTimestamp = require('./helpers/currentTimestamp'); + var WakaTime = (function () { function WakaTime() { _classCallCheck(this, WakaTime); @@ -133,7 +135,7 @@ var WakaTime = (function () { var data = { entity: domain, type: 'domain', - time: Math.round(new Date().getTime() / 1000), + time: currentTimestamp(), is_debugging: false }; @@ -142,6 +144,15 @@ var WakaTime = (function () { console.log('sending entity with type url'); // Send entity in heartbeat + + var data = { + entity: entity, + type: 'url', + time: currentTimestamp(), + is_debugging: false + }; + + console.log(data); } }); } @@ -154,4 +165,17 @@ exports['default'] = WakaTime; module.exports = exports['default']; //default -},{"./UrlHelper":2}]},{},[1]); +},{"./UrlHelper":2,"./helpers/currentTimestamp":4}],4:[function(require,module,exports){ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); + +exports["default"] = function () { + return Math.round(new Date().getTime() / 1000); +}; + +module.exports = exports["default"]; + +},{}]},{},[1]);