Skip to content

Commit

Permalink
add doPing method to JS api (matomo-org#14127)
Browse files Browse the repository at this point in the history
* add ping method to JS api

Fixes matomo-org#14100

* update minified version

* mention new ping method

* fix test which doesn't like a newline at the end

* fix test which doesn't like a newline at the end
  • Loading branch information
pimlottc-gov authored and tsteur committed Apr 17, 2019
1 parent 6a1442f commit abeafe6
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 36 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ This is the Developer Changelog for Matomo platform developers. All changes in o

The Product Changelog at **[matomo.org/changelog](https://matomo.org/changelog)** lets you see more details about any Matomo release, such as the list of new guides and FAQs, security fixes, and links to all closed issues.

## Matomo 3.10.0

### New APIs
* A new tracker method `ping` has been added to send a ping request manually instead of using the heart beat timer.

## Matomo 3.9.0

### Breaking Changes
Expand Down
16 changes: 13 additions & 3 deletions js/piwik.js
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ if (typeof JSON_PIWIK !== 'object' && typeof window.JSON === 'object' && window.
enableCrossDomainLinking, disableCrossDomainLinking, isCrossDomainLinkingEnabled, setCrossDomainLinkingTimeout, getCrossDomainLinkingUrlParameter,
addListener, enableLinkTracking, enableJSErrorTracking, setLinkTrackingTimer, getLinkTrackingTimer,
enableHeartBeatTimer, disableHeartBeatTimer, killFrame, redirectFile, setCountPreRendered,
trackGoal, trackLink, trackPageView, getNumTrackedPageViews, trackRequest, queueRequest, trackSiteSearch, trackEvent,
trackGoal, trackLink, trackPageView, getNumTrackedPageViews, trackRequest, ping, queueRequest, trackSiteSearch, trackEvent,
requests, timeout, enabled, sendRequests, queueRequest, disableQueueRequest,getRequestQueue, unsetPageIsUnloading,
setEcommerceView, getEcommerceItems, addEcommerceItem, removeEcommerceItem, clearEcommerceCart, trackEcommerceOrder, trackEcommerceCartUpdate,
deleteCookie, deleteCookies, offsetTop, offsetLeft, offsetHeight, offsetWidth, nodeType, defaultView,
Expand Down Expand Up @@ -4526,8 +4526,7 @@ if (typeof window.Piwik !== 'object') {
heartBeatPingIfActivityAlias = function heartBeatPingIfActivity() {
var now = new Date();
if (lastTrackerRequestTime + configHeartBeatDelay <= now.getTime()) {
var requestPing = getRequest('ping=1', null, 'ping');
sendRequest(requestPing, configTrackerPause);
trackerInstance.ping();

return true;
}
Expand Down Expand Up @@ -7360,6 +7359,17 @@ if (typeof window.Piwik !== 'object') {
});
};

/**
* Sends a ping request.
*
* Ping requests do not track new actions. If they are sent within the standard visit length, they will
* extend the existing visit and the current last action for the visit. If after the standard visit
* length, ping requests will create a new visit using the last action in the last known visit.
*/
this.ping = function () {
this.trackRequest('ping=1', null, null, 'ping')
}

/**
* Disables sending requests queued
*/
Expand Down
Loading

0 comments on commit abeafe6

Please sign in to comment.