Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-10-14 07:31:21 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-10-14 07:31:21 +0400
commit1eb64a40a0c5220bfe40273de33c0a130980ad99 (patch)
tree2223d57167ec4a0c069cae781b3f7675b06c46de /js
parent863b35ff38636e1ee1e8871e1b02ec36c9cc5786 (diff)
refs #6341 always calculate the remaining visitor cookie lifetime.
Otherwise the behavior whether lifetime will be extended or whether remaining will be calculated would depend on the time at which setVisitorCookieTimeout is called which is very confusing. Also makes sure in case the page is open for an hour and there is a tracking request the lifetime will not be extended by an hour.
Diffstat (limited to 'js')
-rw-r--r--js/piwik.js61
1 files changed, 27 insertions, 34 deletions
diff --git a/js/piwik.js b/js/piwik.js
index c6a70cb7c0..e374649c64 100644
--- a/js/piwik.js
+++ b/js/piwik.js
@@ -455,7 +455,7 @@ if (typeof JSON2 !== 'object') {
trackVisibleContentImpressions, isTrackOnlyVisibleContentEnabled, port, isUrlToCurrentDomain,
isNodeAuthorizedToTriggerInteraction, replaceHrefIfInternalLink, getConfigDownloadExtensions, disableLinkTracking,
substr, setAnyAttribute, wasContentTargetAttrReplaced, max, abs, childNodes, compareDocumentPosition, body,
- getConfigVisitorCookieTimeout
+ getConfigVisitorCookieTimeout, getRemainingVisitorCookieTimeout
*/
/*global _paq:true */
/*members push */
@@ -2622,14 +2622,6 @@ if (typeof Piwik !== 'object') {
}
/*
- * Sets the Visitor ID cookie: either the first time loadVisitorIdCookie is called
- * or when there is a new visit or a new page view
- */
- function setVisitorIdCookie(uuid, createTs, visitCount, nowTs, lastVisitTs, lastEcommerceOrderTs) {
- setCookie(getCookieName('id'), uuid + '.' + createTs + '.' + visitCount + '.' + nowTs + '.' + lastVisitTs + '.' + lastEcommerceOrderTs, configVisitorCookieTimeout, configCookiePath, configCookieDomain);
- }
-
- /*
* Load visitor ID cookie
*/
function loadVisitorIdCookie() {
@@ -2650,10 +2642,10 @@ if (typeof Piwik !== 'object') {
if (!visitorUUID) {
visitorUUID = hash(
(navigatorAlias.userAgent || '') +
- (navigatorAlias.platform || '') +
- JSON2.stringify(browserFeatures) +
- now.getTime() +
- Math.random()
+ (navigatorAlias.platform || '') +
+ JSON2.stringify(browserFeatures) +
+ now.getTime() +
+ Math.random()
).slice(0, 16); // 16 hexits = 64 bits
}
@@ -2684,6 +2676,26 @@ if (typeof Piwik !== 'object') {
return tmpContainer;
}
+ function getRemainingVisitorCookieTimeout() {
+ var now = new Date(),
+ nowTs = now.getTime(),
+ visitorInfo = loadVisitorIdCookie();
+
+ var createTs = parseInt(visitorInfo[2], 10);
+ var originalTimeout = (createTs * 1000) + configVisitorCookieTimeout - nowTs;
+ return originalTimeout;
+ }
+
+ /*
+ * Sets the Visitor ID cookie: either the first time loadVisitorIdCookie is called
+ * or when there is a new visit or a new page view
+ */
+ function setVisitorIdCookie(uuid, createTs, visitCount, nowTs, lastVisitTs, lastEcommerceOrderTs) {
+ var timeout = getRemainingVisitorCookieTimeout();
+
+ setCookie(getCookieName('id'), uuid + '.' + createTs + '.' + visitCount + '.' + nowTs + '.' + lastVisitTs + '.' + lastEcommerceOrderTs, timeout, configCookiePath, configCookieDomain);
+ }
+
/*
* Loads the referrer attribution information
*
@@ -3958,21 +3970,6 @@ if (typeof Piwik !== 'object') {
browserFeatures.res = screenAlias.width * devicePixelRatio + 'x' + screenAlias.height * devicePixelRatio;
}
- function getRemainingVisitorCookieTimeout() {
- var now = new Date(),
- nowTs = now.getTime(),
- visitorInfo = loadVisitorIdCookie();
-
- var createTs = parseInt(visitorInfo[2], 10);
- var originalTimeout = (createTs * 1000) + configVisitorCookieTimeout - nowTs;
- return originalTimeout;
- }
-
- function updateRemainingVisitorCookieTimeout()
- {
- configVisitorCookieTimeout = getRemainingVisitorCookieTimeout();
- }
-
/*<DEBUG>*/
/*
* Register a test hook. Using eval() permits access to otherwise
@@ -4006,7 +4003,6 @@ if (typeof Piwik !== 'object') {
*/
detectBrowserFeatures();
updateDomainHash();
- updateRemainingVisitorCookieTimeout();
/*<DEBUG>*/
/*
@@ -4076,6 +4072,7 @@ if (typeof Piwik !== 'object') {
getConfigVisitorCookieTimeout: function () {
return configVisitorCookieTimeout;
},
+ getRemainingVisitorCookieTimeout: getRemainingVisitorCookieTimeout,
/*</DEBUG>*/
/**
@@ -4164,7 +4161,6 @@ if (typeof Piwik !== 'object') {
*/
setSiteId: function (siteId) {
configTrackerSiteId = siteId;
- updateRemainingVisitorCookieTimeout();
},
/**
@@ -4520,7 +4516,6 @@ if (typeof Piwik !== 'object') {
configCookieNamePrefix = cookieNamePrefix;
// Re-init the Custom Variables cookie
customVariables = getCustomVariablesFromCookie();
- updateRemainingVisitorCookieTimeout();
},
/**
@@ -4531,7 +4526,6 @@ if (typeof Piwik !== 'object') {
setCookieDomain: function (domain) {
configCookieDomain = domainFixup(domain);
updateDomainHash();
- updateRemainingVisitorCookieTimeout();
},
/**
@@ -4542,12 +4536,11 @@ if (typeof Piwik !== 'object') {
setCookiePath: function (path) {
configCookiePath = path;
updateDomainHash();
- updateRemainingVisitorCookieTimeout();
},
/**
* Set visitor cookie timeout (in seconds)
- * Defaults to 2 years (timeout=63072000000)
+ * Defaults to 13 months (timeout=33955200)
*
* @param int timeout
*/