Skip to content

Commit

Permalink
added disableHeartBeatTimer feature
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteur committed Nov 7, 2016
1 parent a0dff4b commit 0bf5c46
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ Read more about migrating a plugin from Piwik 2.X to Piwik 3 on our [Migration g
* `Updater.componentUninstalled` triggered after a component was uninstalled
* New HTTP Tracking API parameter `pv_id` which accepts a six character unique ID that identifies which actions were performed on a specific page view. Read more about it in the [HTTP Tracking API](https://developer.piwik.org/api-reference/tracking-api);
* New event `Segment.addSegments` that lets you add segments.
* New Piwik JavaScript Tracker method `disableHeartBeatTimer()` to disable the heartbeat timer if it was previously enabled.

### New features
* New "Sparklines" visualization that lets you create a widget showing multiple sparklines.
Expand Down
19 changes: 13 additions & 6 deletions js/piwik.js
Original file line number Diff line number Diff line change
Expand Up @@ -6093,18 +6093,25 @@ if (typeof window.Piwik !== 'object') {
}
};

/*<DEBUG>*/
/**
* Clear heartbeat.
* Disable heartbeat if it was previously activated.
*/
this.disableHeartBeatTimer = function () {
heartBeatDown();
configHeartBeatDelay = null;

if (configHeartBeatDelay || heartBeatSetUp) {
if (windowAlias.removeEventListener) {
windowAlias.removeEventListener('focus', heartBeatOnFocus, true);
windowAlias.removeEventListener('blur', heartBeatOnBlur, true);
} else if (windowAlias.detachEvent) {
windowAlias.detachEvent('onfocus', heartBeatOnFocus);
windowAlias.detachEvent('onblur', heartBeatOnBlur);
}
}

window.removeEventListener('focus', heartBeatOnFocus);
window.removeEventListener('blur', heartBeatOnBlur);
configHeartBeatDelay = null;
heartBeatSetUp = false;
};
/*</DEBUG>*/

/**
* Frame buster
Expand Down
3 changes: 2 additions & 1 deletion tests/javascript/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2096,7 +2096,7 @@ function assertTrackingRequest(actual, expectedStartsWith, message)
});

test("API methods", function() {
expect(71);
expect(72);

equal( typeof Piwik.addPlugin, 'function', 'addPlugin' );
equal( typeof Piwik.addPlugin, 'function', 'addTracker' );
Expand Down Expand Up @@ -2158,6 +2158,7 @@ function assertTrackingRequest(actual, expectedStartsWith, message)
equal( typeof tracker.addListener, 'function', 'addListener' );
equal( typeof tracker.enableLinkTracking, 'function', 'enableLinkTracking' );
equal( typeof tracker.enableHeartBeatTimer, 'function', 'enableHeartBeatTimer' );
equal( typeof tracker.disableHeartBeatTimer, 'function', 'disableHeartBeatTimer' );
equal( typeof tracker.killFrame, 'function', 'killFrame' );
equal( typeof tracker.redirectFile, 'function', 'redirectFile' );
equal( typeof tracker.setCountPreRendered, 'function', 'setCountPreRendered' );
Expand Down

0 comments on commit 0bf5c46

Please sign in to comment.