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:
authorAndreas Schnederle-Wagner <schnederle@futureweb.at>2022-07-21 16:24:42 +0300
committerGitHub <noreply@github.com>2022-07-21 16:24:42 +0300
commit06b431bdecb630f89b507eb8eebfd8e35ea7e099 (patch)
tree0f38e02b343d96ed704a9b008486a913200ef625 /js
parente459f3cc12758fdab09fe9182f28584276a1f9fe (diff)
Implement cookie expire time - forgetConsentGiven (#19532)
* Implement cookie expire time - forgetConsentGiven Implement Feature Request #19530 * Implement cookie expire time - forgetConsentGiven * Implement cookie expire time - forgetConsentGiven * Implement cookie expire time - forgetConsentGiven * forgetConsentGiven cookie expire Param description
Diffstat (limited to 'js')
-rw-r--r--js/piwik.js25
-rw-r--r--js/piwik.min.js6
2 files changed, 20 insertions, 11 deletions
diff --git a/js/piwik.js b/js/piwik.js
index 5af350389b..274d4ea4ac 100644
--- a/js/piwik.js
+++ b/js/piwik.js
@@ -7218,16 +7218,25 @@ if (typeof window.Matomo !== 'object') {
};
/**
- * Calling this method will remove any previously given consent and during this page view no request
- * will be sent anymore ({@link requireConsent()}) will be called automatically to ensure the removed
- * consent will be enforced. You may call this method if the user removes consent manually, or if you
- * want to re-ask for consent after a specific time period.
- */
- this.forgetConsentGiven = function () {
- var thirtyYears = 30 * 365 * 24 * 60 * 60 * 1000;
+ * Calling this method will remove any previously given consent and during this page view no request
+ * will be sent anymore ({@link requireConsent()}) will be called automatically to ensure the removed
+ * consent will be enforced. You may call this method if the user removes consent manually, or if you
+ * want to re-ask for consent after a specific time period. You can optionally define the lifetime of
+ * the CONSENT_REMOVED_COOKIE_NAME cookie in hours using a parameter.
+ *
+ * @param int hoursToExpire After how many hours the CONSENT_REMOVED_COOKIE_NAME cookie should expire.
+ * By default the consent is valid for 30 years unless cookies are deleted by the user or the browser
+ * prior to this
+ */
+ this.forgetConsentGiven = function (hoursToExpire) {
+ if (hoursToExpire) {
+ hoursToExpire = hoursToExpire * 60 * 60 * 1000;
+ } else {
+ hoursToExpire = 30 * 365 * 24 * 60 * 60 * 1000;
+ }
deleteCookie(CONSENT_COOKIE_NAME, configCookiePath, configCookieDomain);
- setCookie(CONSENT_REMOVED_COOKIE_NAME, new Date().getTime(), thirtyYears, configCookiePath, configCookieDomain, configCookieIsSecure, configCookieSameSite);
+ setCookie(CONSENT_REMOVED_COOKIE_NAME, new Date().getTime(), hoursToExpire, configCookiePath, configCookieDomain, configCookieIsSecure, configCookieSameSite);
this.forgetCookieConsentGiven();
this.requireConsent();
};
diff --git a/js/piwik.min.js b/js/piwik.min.js
index 001583932d..4f9904d400 100644
--- a/js/piwik.min.js
+++ b/js/piwik.min.js
@@ -64,8 +64,8 @@ var dC=W.onerror;W.onerror=function(dH,dF,dE,dG,dD){cr(function(){var dI="JavaSc
})};this.getNumTrackedPageViews=function(){return cE};this.trackPageView=function(dC,dE,dD){ck=[];c1=[];cG=[];if(R(cf)){cr(function(){ad(aI,bQ,cf)})}else{cr(function(){cE++;b9(dC,dE,dD)})}};this.disableBrowserFeatureDetection=function(){de=false};this.enableBrowserFeatureDetection=function(){de=true};this.trackAllContentImpressions=function(){if(R(cf)){return}cr(function(){q(function(){var dC=w.findContentNodes();var dD=cP(dC);bM.pushMultiple(dD)})})};this.trackVisibleContentImpressions=function(dC,dD){if(R(cf)){return}if(!M(dC)){dC=true}if(!M(dD)){dD=750}aX(dC,dD,this);cr(function(){n(function(){var dE=w.findContentNodes();var dF=bg(dE);bM.pushMultiple(dF)})})};this.trackContentImpression=function(dE,dC,dD){if(R(cf)){return}dE=a(dE);dC=a(dC);dD=a(dD);if(!dE){return}dC=dC||"Unknown";cr(function(){var dF=aK(dE,dC,dD);bM.push(dF)})};this.trackContentImpressionsWithinNode=function(dC){if(R(cf)||!dC){return}cr(function(){if(cp){n(function(){var dD=w.findContentNodesWithinNode(dC);var dE=bg(dD);
bM.pushMultiple(dE)})}else{q(function(){var dD=w.findContentNodesWithinNode(dC);var dE=cP(dD);bM.pushMultiple(dE)})}})};this.trackContentInteraction=function(dE,dF,dC,dD){if(R(cf)){return}dE=a(dE);dF=a(dF);dC=a(dC);dD=a(dD);if(!dE||!dF){return}dC=dC||"Unknown";cr(function(){var dG=aU(dE,dF,dC,dD);if(dG){bM.push(dG)}})};this.trackContentInteractionNode=function(dE,dD){if(R(cf)||!dE){return}var dC=null;cr(function(){dC=du(dE,dD);if(dC){bM.push(dC)}});return dC};this.logAllContentBlocksOnPage=function(){var dE=w.findContentNodes();var dC=w.collectContent(dE);var dD=typeof console;if(dD!=="undefined"&&console&&console.log){console.log(dC)}};this.trackEvent=function(dD,dF,dC,dE,dH,dG){cr(function(){ax(dD,dF,dC,dE,dH,dG)})};this.trackSiteSearch=function(dC,dE,dD,dF){ck=[];cr(function(){ch(dC,dE,dD,dF)})};this.setEcommerceView=function(dG,dC,dE,dD){cH={};if(ac(dE)){dE=String(dE)}if(!M(dE)||dE===null||dE===false||!dE.length){dE=""}else{if(dE instanceof Array){dE=W.JSON.stringify(dE)}}var dF="_pkc";
cH[dF]=dE;if(M(dD)&&dD!==null&&dD!==false&&String(dD).length){dF="_pkp";cH[dF]=dD}if(!ac(dG)&&!ac(dC)){return}if(ac(dG)){dF="_pks";cH[dF]=dG}if(!ac(dC)){dC=""}dF="_pkn";cH[dF]=dC};this.getEcommerceItems=function(){return JSON.parse(JSON.stringify(di))};this.addEcommerceItem=function(dG,dC,dE,dD,dF){if(ac(dG)){di[dG]=[String(dG),dC,dE,dD,dF]}};this.removeEcommerceItem=function(dC){if(ac(dC)){dC=String(dC);delete di[dC]}};this.clearEcommerceCart=function(){di={}};this.trackEcommerceOrder=function(dC,dG,dF,dE,dD,dH){b7(dC,dG,dF,dE,dD,dH)};this.trackEcommerceCartUpdate=function(dC){bB(dC)};this.trackRequest=function(dD,dF,dE,dC){cr(function(){var dG=cF(dD,dF,dC);bO(dG,bS,dE)})};this.ping=function(){this.trackRequest("ping=1",null,null,"ping")};this.disableQueueRequest=function(){bM.enabled=false};this.setRequestQueueInterval=function(dC){if(dC<1000){throw new Error("Request queue interval needs to be at least 1000ms")}bM.interval=dC};this.queueRequest=function(dC){cr(function(){var dD=cF(dC);
-bM.push(dD)})};this.isConsentRequired=function(){return cQ};this.getRememberedConsent=function(){var dC=aH(bk);if(aH(c2)){if(dC){b8(bk,by,df)}return null}if(!dC||dC===0){return null}return dC};this.hasRememberedConsent=function(){return !!this.getRememberedConsent()};this.requireConsent=function(){cQ=true;bL=this.hasRememberedConsent();if(!bL){bt=true}y++;b["CoreConsent"+y]={unload:function(){if(!bL){aJ()}}}};this.setConsentGiven=function(dD){bL=true;de=true;b8(c2,by,df);var dE,dC;for(dE=0;dE<c1.length;dE++){dC=typeof c1[dE];if(dC==="string"){bO(c1[dE],bS)}else{if(dC==="object"){dy(c1[dE],bS)}}}c1=[];if(!M(dD)||dD){this.setCookieConsentGiven()}};this.rememberConsentGiven=function(dE){if(dE){dE=dE*60*60*1000}else{dE=30*365*24*60*60*1000}var dC=true;this.setConsentGiven(dC);var dD=new Date().getTime();dx(bk,dD,dE,by,df,b1,aN)};this.forgetConsentGiven=function(){var dC=30*365*24*60*60*1000;b8(bk,by,df);dx(c2,new Date().getTime(),dC,by,df,b1,aN);this.forgetCookieConsentGiven();this.requireConsent()
-};this.isUserOptedOut=function(){return !bL};this.optUserOut=this.forgetConsentGiven;this.forgetUserOptOut=function(){this.setConsentGiven(false)};n(function(){setTimeout(function(){bN=true},0)});u.trigger("TrackerSetup",[this]);u.addPlugin("TrackerVisitorIdCookie"+aB,{unload:function(){if(!aA){aR();ds()}}})}function K(){return{push:aj}}function c(ay,ax){var az={};var av,aw;for(av=0;av<ax.length;av++){var at=ax[av];az[at]=1;for(aw=0;aw<ay.length;aw++){if(ay[aw]&&ay[aw][0]){var au=ay[aw][0];if(at===au){aj(ay[aw]);delete ay[aw];if(az[au]>1&&au!=="addTracker"&&au!=="enableLinkTracking"){ao("The method "+au+' is registered more than once in "_paq" variable. Only the last call has an effect. Please have a look at the multiple Matomo trackers documentation: https://developer.matomo.org/guides/tracking-javascript-guide#multiple-piwik-trackers')}az[au]++}}}}return ay}var E=["addTracker","forgetCookieConsentGiven","requireCookieConsent","disableBrowserFeatureDetection","disableCookies","setTrackerUrl","setAPIUrl","enableCrossDomainLinking","setCrossDomainLinkingTimeout","setSessionCookieTimeout","setVisitorCookieTimeout","setCookieNamePrefix","setCookieSameSite","setSecureCookie","setCookiePath","setCookieDomain","setDomains","setUserId","setVisitorId","setSiteId","alwaysUseSendBeacon","disableAlwaysUseSendBeacon","enableLinkTracking","setCookieConsentGiven","requireConsent","setConsentGiven","disablePerformanceTracking","setPagePerformanceTiming","setExcludedQueryParams","setExcludedReferrers"];
+bM.push(dD)})};this.isConsentRequired=function(){return cQ};this.getRememberedConsent=function(){var dC=aH(bk);if(aH(c2)){if(dC){b8(bk,by,df)}return null}if(!dC||dC===0){return null}return dC};this.hasRememberedConsent=function(){return !!this.getRememberedConsent()};this.requireConsent=function(){cQ=true;bL=this.hasRememberedConsent();if(!bL){bt=true}y++;b["CoreConsent"+y]={unload:function(){if(!bL){aJ()}}}};this.setConsentGiven=function(dD){bL=true;de=true;b8(c2,by,df);var dE,dC;for(dE=0;dE<c1.length;dE++){dC=typeof c1[dE];if(dC==="string"){bO(c1[dE],bS)}else{if(dC==="object"){dy(c1[dE],bS)}}}c1=[];if(!M(dD)||dD){this.setCookieConsentGiven()}};this.rememberConsentGiven=function(dE){if(dE){dE=dE*60*60*1000}else{dE=30*365*24*60*60*1000}var dC=true;this.setConsentGiven(dC);var dD=new Date().getTime();dx(bk,dD,dE,by,df,b1,aN)};this.forgetConsentGiven=function(dC){if(dC){dC=dC*60*60*1000}else{dC=30*365*24*60*60*1000}b8(bk,by,df);dx(c2,new Date().getTime(),dC,by,df,b1,aN);this.forgetCookieConsentGiven();
+this.requireConsent()};this.isUserOptedOut=function(){return !bL};this.optUserOut=this.forgetConsentGiven;this.forgetUserOptOut=function(){this.setConsentGiven(false)};n(function(){setTimeout(function(){bN=true},0)});u.trigger("TrackerSetup",[this]);u.addPlugin("TrackerVisitorIdCookie"+aB,{unload:function(){if(!aA){aR();ds()}}})}function K(){return{push:aj}}function c(ay,ax){var az={};var av,aw;for(av=0;av<ax.length;av++){var at=ax[av];az[at]=1;for(aw=0;aw<ay.length;aw++){if(ay[aw]&&ay[aw][0]){var au=ay[aw][0];if(at===au){aj(ay[aw]);delete ay[aw];if(az[au]>1&&au!=="addTracker"&&au!=="enableLinkTracking"){ao("The method "+au+' is registered more than once in "_paq" variable. Only the last call has an effect. Please have a look at the multiple Matomo trackers documentation: https://developer.matomo.org/guides/tracking-javascript-guide#multiple-piwik-trackers')}az[au]++}}}}return ay}var E=["addTracker","forgetCookieConsentGiven","requireCookieConsent","disableBrowserFeatureDetection","disableCookies","setTrackerUrl","setAPIUrl","enableCrossDomainLinking","setCrossDomainLinkingTimeout","setSessionCookieTimeout","setVisitorCookieTimeout","setCookieNamePrefix","setCookieSameSite","setSecureCookie","setCookiePath","setCookieDomain","setDomains","setUserId","setVisitorId","setSiteId","alwaysUseSendBeacon","disableAlwaysUseSendBeacon","enableLinkTracking","setCookieConsentGiven","requireConsent","setConsentGiven","disablePerformanceTracking","setPagePerformanceTiming","setExcludedQueryParams","setExcludedReferrers"];
function ah(av,au){var at=new T(av,au);L.push(at);_paq=c(_paq,E);for(H=0;H<_paq.length;H++){if(_paq[H]){aj(_paq[H])}}_paq=new K();u.trigger("TrackerAdded",[at]);return at}ar(W,"beforeunload",am,false);ar(W,"visibilitychange",function(){if(m){return}if(J.visibilityState==="hidden"){ag("unload")}},false);ar(W,"online",function(){if(M(g.serviceWorker)){g.serviceWorker.ready.then(function(at){if(at&&at.sync){return at.sync.register("matomoSync")}},function(){})}},false);ar(W,"message",function(ay){if(!ay||!ay.origin){return}var aA,aw,au;var aB=d(ay.origin);var ax=u.getAsyncTrackers();for(aw=0;aw<ax.length;aw++){au=d(ax[aw].getMatomoUrl());if(au===aB){aA=ax[aw];break}}if(!aA){return}var av=null;try{av=JSON.parse(ay.data)}catch(az){return}if(!av){return}function at(aE){var aG=J.getElementsByTagName("iframe");for(aw=0;aw<aG.length;aw++){var aF=aG[aw];var aC=d(aF.src);if(aF.contentWindow&&M(aF.contentWindow.postMessage)&&aC===aB){var aD=JSON.stringify(aE);aF.contentWindow.postMessage(aD,"*")}}}if(M(av.maq_initial_value)){at({maq_opted_in:av.maq_initial_value&&aA.hasConsent(),maq_url:aA.getMatomoUrl(),maq_optout_by_default:aA.isConsentRequired()})
}else{if(M(av.maq_opted_in)){ax=u.getAsyncTrackers();for(aw=0;aw<ax.length;aw++){aA=ax[aw];if(av.maq_opted_in){aA.rememberConsentGiven()}else{aA.forgetConsentGiven()}}at({maq_confirm_opted_in:aA.hasConsent(),maq_url:aA.getMatomoUrl(),maq_optout_by_default:aA.isConsentRequired()})}}},false);Date.prototype.getTimeAlias=Date.prototype.getTime;u={initialized:false,JSON:W.JSON,DOM:{addEventListener:function(aw,av,au,at){var ax=typeof at;if(ax==="undefined"){at=false}ar(aw,av,au,at)},onLoad:n,onReady:q,isNodeVisible:i,isOrWasNodeVisible:w.isNodeVisible},on:function(au,at){if(!z[au]){z[au]=[]}z[au].push(at)},off:function(av,au){if(!z[av]){return}var at=0;for(at;at<z[av].length;at++){if(z[av][at]===au){z[av].splice(at,1)}}},trigger:function(av,aw,au){if(!z[av]){return}var at=0;for(at;at<z[av].length;at++){z[av][at].apply(au||W,aw)}},addPlugin:function(at,au){b[at]=au},getTracker:function(au,at){if(!M(at)){at=this.getAsyncTracker().getSiteId()}if(!M(au)){au=this.getAsyncTracker().getTrackerUrl()
}return new T(au,at)},getAsyncTrackers:function(){return L},addTracker:function(av,au){var at;if(!L.length){at=ah(av,au)}else{at=L[0].addTracker(av,au)}return at},getAsyncTracker:function(ax,aw){var av;if(L&&L.length&&L[0]){av=L[0]}else{return ah(ax,aw)}if(!aw&&!ax){return av}if((!M(aw)||null===aw)&&av){aw=av.getSiteId()}if((!M(ax)||null===ax)&&av){ax=av.getTrackerUrl()}var au,at=0;for(at;at<L.length;at++){au=L[at];if(au&&String(au.getSiteId())===String(aw)&&au.getTrackerUrl()===ax){return au}}},retryMissedPluginCalls:function(){var au=al;al=[];var at=0;for(at;at<au.length;at++){aj(au[at])}}};if(typeof define==="function"&&define.amd){define("piwik",[],function(){return u});define("matomo",[],function(){return u})}return u}())}
@@ -73,4 +73,4 @@ function ah(av,au){var at=new T(av,au);L.push(at);_paq=c(_paq,E);for(H=0;H<_paq.
(function(){function b(){if("object"!==typeof _paq){return false}var c=typeof _paq.length;if("undefined"===c){return false}return !!_paq.length}if(window&&"object"===typeof window.matomoPluginAsyncInit&&window.matomoPluginAsyncInit.length){var a=0;
for(a;a<window.matomoPluginAsyncInit.length;a++){if(typeof window.matomoPluginAsyncInit[a]==="function"){window.matomoPluginAsyncInit[a]()}}}if(window&&window.piwikAsyncInit){window.piwikAsyncInit()}if(window&&window.matomoAsyncInit){window.matomoAsyncInit()}if(!window.Matomo.getAsyncTrackers().length){if(b()){window.Matomo.addTracker()}else{_paq={push:function(c){var d=typeof console;if(d!=="undefined"&&console&&console.error){console.error("_paq.push() was used but Matomo tracker was not initialized before the matomo.js file was loaded. Make sure to configure the tracker via _paq.push before loading matomo.js. Alternatively, you can create a tracker via Matomo.addTracker() manually and then use _paq.push but it may not fully work as tracker methods may not be executed in the correct order.",c)}}}}}window.Matomo.trigger("MatomoInitialized",[]);window.Matomo.initialized=true}());(function(){var a=(typeof window.AnalyticsTracker);if(a==="undefined"){window.AnalyticsTracker=window.Matomo}}());
if(typeof window.piwik_log!=="function"){window.piwik_log=function(c,e,g,f){function b(h){try{if(window["piwik_"+h]){return window["piwik_"+h]}}catch(i){}return}var d,a=window.Matomo.getTracker(g,e);a.setDocumentTitle(c);a.setCustomData(f);d=b("tracker_pause");if(d){a.setLinkTrackingTimer(d)}d=b("download_extensions");if(d){a.setDownloadExtensions(d)}d=b("hosts_alias");if(d){a.setDomains(d)}d=b("ignore_classes");if(d){a.setIgnoreClasses(d)}a.trackPageView();if(b("install_tracker")){piwik_track=function(i,j,k,h){a.setSiteId(j);a.setTrackerUrl(k);a.trackLink(i,h)};a.enableLinkTracking()}}}
-/*!! @license-end */; \ No newline at end of file
+/*!! @license-end */;