summaryrefslogtreecommitdiffstats
path: root/client/lib/utils.js
diff options
context:
space:
mode:
authorLauri Ojansivu <x@xet7.org>2018-07-30 17:42:57 +0300
committerLauri Ojansivu <x@xet7.org>2018-07-30 17:42:57 +0300
commit92bb646977793bd0e6c1e0557404172ffe4ad95d (patch)
tree196392e56a21ad2956df26f87555cfb45ac706b4 /client/lib/utils.js
parent2bb80956dd54aa6af0a56b863bc5d047305f8a8a (diff)
parent43c38f87a53ed25456f45e5666b6a3a06dd1dbc3 (diff)
downloadwekan-92bb646977793bd0e6c1e0557404172ffe4ad95d.tar.gz
wekan-92bb646977793bd0e6c1e0557404172ffe4ad95d.tar.bz2
wekan-92bb646977793bd0e6c1e0557404172ffe4ad95d.zip
Merge branch 'devel'
Diffstat (limited to 'client/lib/utils.js')
-rw-r--r--client/lib/utils.js45
1 files changed, 45 insertions, 0 deletions
diff --git a/client/lib/utils.js b/client/lib/utils.js
index 6b8e3524..5349e500 100644
--- a/client/lib/utils.js
+++ b/client/lib/utils.js
@@ -144,6 +144,51 @@ Utils = {
}
});
},
+
+ setMatomo(data){
+ window._paq = window._paq || [];
+ window._paq.push(['setDoNotTrack', data.doNotTrack]);
+ if (data.withUserName){
+ window._paq.push(['setUserId', Meteor.user().username]);
+ }
+ window._paq.push(['trackPageView']);
+ window._paq.push(['enableLinkTracking']);
+
+ (function() {
+ window._paq.push(['setTrackerUrl', `${data.address}piwik.php`]);
+ window._paq.push(['setSiteId', data.siteId]);
+
+ const script = document.createElement('script');
+ Object.assign(script, {
+ id: 'scriptMatomo',
+ type: 'text/javascript',
+ async: 'true',
+ defer: 'true',
+ src: `${data.address}piwik.js`,
+ });
+
+ const s = document.getElementsByTagName('script')[0];
+ s.parentNode.insertBefore(script, s);
+ })();
+
+ Session.set('matomo', true);
+ },
+
+ manageMatomo() {
+ const matomo = Session.get('matomo');
+ if (matomo === undefined){
+ Meteor.call('getMatomoConf', (err, data) => {
+ if (err && err.error[0] === 'var-not-exist'){
+ Session.set('matomo', false); // siteId || address server not defined
+ }
+ if (!err){
+ Utils.setMatomo(data);
+ }
+ });
+ } else if (matomo) {
+ window._paq.push(['trackPageView']);
+ }
+ },
};
// A simple tracker dependency that we invalidate every time the window is