summaryrefslogtreecommitdiffstats
path: root/client/lib
diff options
context:
space:
mode:
authorguillaume <guillaume.cassou@supinfo.com>2018-07-27 18:08:09 +0200
committerguillaume <guillaume.cassou@supinfo.com>2018-07-27 18:08:09 +0200
commitec59af3777f5ac88ee6ad44a502c0de5d35213e2 (patch)
tree78c15ddc925d3e54cbca2a7b346b4c07484ff94d /client/lib
parentaa080a75062405d1f7734422f8dc3f2c08c96140 (diff)
downloadwekan-ec59af3777f5ac88ee6ad44a502c0de5d35213e2.tar.gz
wekan-ec59af3777f5ac88ee6ad44a502c0de5d35213e2.tar.bz2
wekan-ec59af3777f5ac88ee6ad44a502c0de5d35213e2.zip
Integration of matomo with env vars
Diffstat (limited to 'client/lib')
-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