diff options
author | diosmosis <benaka@piwik.pro> | 2015-06-25 14:20:41 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-06-25 14:20:41 +0300 |
commit | ced91af7d11d7aeab86953ead34d82a49080caaf (patch) | |
tree | f686bd44376d45ecdcb600af0a6d78db6947b13f /js | |
parent | 0bbf109040038bdb4ec4f4200ca3f85546178d28 (diff) |
Remoe heart beat events in disableHeartBeatTimer in JS tracker.
Diffstat (limited to 'js')
-rw-r--r-- | js/piwik.js | 31 |
1 files changed, 19 insertions, 12 deletions
diff --git a/js/piwik.js b/js/piwik.js index ceaa1453ec..8bbdffa2a5 100644 --- a/js/piwik.js +++ b/js/piwik.js @@ -2526,6 +2526,20 @@ if (typeof Piwik !== 'object') { heartBeatTimeout = null; } + function heartBeatOnFocus() { + // since it's possible for a user to come back to a tab after several hours or more, we try to send + // a ping if the page is active. (after the ping is sent, the heart beat timeout will be set) + if (heartBeatPingIfActivityAlias()) { + return; + } + + heartBeatUp(); + } + + function heartBeatOnBlur() { + heartBeatDown(); + } + /* * Setup event handlers and timeout for initial heart beat. */ @@ -2538,18 +2552,8 @@ if (typeof Piwik !== 'object') { heartBeatSetUp = true; - addEventListener(windowAlias, 'focus', function heartBeatOnFocus() { - // since it's possible for a user to come back to a tab after several hours or more, we try to send - // a ping if the page is active. (after the ping is sent, the heart beat timeout will be set) - if (heartBeatPingIfActivityAlias()) { - return; - } - - heartBeatUp(); - }); - addEventListener(windowAlias, 'blur', function heartBeatOnBlur() { - heartBeatDown(); - }); + addEventListener(windowAlias, 'focus', heartBeatOnFocus); + addEventListener(windowAlias, 'blur', heartBeatOnBlur); heartBeatUp(); } @@ -5021,6 +5025,9 @@ if (typeof Piwik !== 'object') { disableHeartBeatTimer: function () { heartBeatDown(); configHeartBeatDelay = null; + + window.removeEventListener('focus', heartBeatOnFocus); + window.removeEventListener('blur', heartBeatOnBlur); }, /*</DEBUG>*/ |