Repository: incubator-senssoft-useralejs
Updated Branches:
  refs/heads/master 3c1e0c1df -> 505ca3b41


Fixed issue with array reassignment for closure values. Switched to using 
setInterval.


Project: 
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/repo
Commit: 
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/commit/89af0bbe
Tree: 
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/tree/89af0bbe
Diff: 
http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/diff/89af0bbe

Branch: refs/heads/master
Commit: 89af0bbe14c212a59791f4b9e966cf5d180979e2
Parents: 5c84a39
Author: Rob Foley <rob.foley...@gmail.com>
Authored: Wed Sep 21 14:56:24 2016 -0400
Committer: Rob Foley <rob.foley...@gmail.com>
Committed: Wed Sep 21 14:56:24 2016 -0400

----------------------------------------------------------------------
 src/sendLogs.js | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-senssoft-useralejs/blob/89af0bbe/src/sendLogs.js
----------------------------------------------------------------------
diff --git a/src/sendLogs.js b/src/sendLogs.js
index 41c5798..c20ce67 100644
--- a/src/sendLogs.js
+++ b/src/sendLogs.js
@@ -18,11 +18,11 @@ export function initSender(logs, config) {
 }
 
 export function sendOnInterval(logs, config) {
-  setTimeout(function() {
-    if (logs.length >= config.logCountThreshold) {
-      var data = logs;
-      logs = [];
-      sendLogs(data, config.url, 5);
+  setInterval(function() {
+    var logCount = logs.length;
+    if (logCount >= config.logCountThreshold) {
+      sendLogs(logs.slice(0), config.url, 0); // Send a copy
+      logs.splice(0, logCount); // Clear array reference (no reassignment)
     }
   }, config.transmitInterval);
 }

Reply via email to