From ae3126bd9a905f34487aebf428b84c371a3514bc Mon Sep 17 00:00:00 2001
From: "mathias.chouet" <mathias.chouet@irstea.fr>
Date: Thu, 6 Feb 2020 11:05:28 +0100
Subject: [PATCH] Restore matomo tracking in docs

---
 docs/matomo-tracking.js       | 12 ++++++++++++
 scripts/mkdocs-postprocess.js | 19 +++++++++++--------
 2 files changed, 23 insertions(+), 8 deletions(-)
 create mode 100644 docs/matomo-tracking.js

diff --git a/docs/matomo-tracking.js b/docs/matomo-tracking.js
new file mode 100644
index 000000000..0610b88f4
--- /dev/null
+++ b/docs/matomo-tracking.js
@@ -0,0 +1,12 @@
+var _paq = window._paq || [];
+/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
+_paq.push(['disableCookies']); // évite de mettre en place un bandeau RGPD
+_paq.push(['trackPageView']);
+_paq.push(['enableLinkTracking']);
+(function() {
+var u="//stasi.g-eau.fr/";
+_paq.push(['setTrackerUrl', u+'matomo.php']);
+_paq.push(['setSiteId', '1']);
+var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
+g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
+})();
\ No newline at end of file
diff --git a/scripts/mkdocs-postprocess.js b/scripts/mkdocs-postprocess.js
index 7d5a9cd33..fcb2b04eb 100644
--- a/scripts/mkdocs-postprocess.js
+++ b/scripts/mkdocs-postprocess.js
@@ -1,22 +1,25 @@
 'use strict';
 
 /**
- * copies Mathjax to src/assets/docs/javascripts after doc was built by MkDocs
+ * copies extra javascripts (MathJax, matomo-tracking) to src/assets/docs/javascripts after doc was built by MkDocs
  */
 
 const fs = require('fs-extra');
 
-const destPath = "src/assets/docs/javascripts/mathjax";
+const destPath = "src/assets/docs/javascripts";
+const destPathMJ = destPath + "/mathjax";
 
 // empty destination folder
 fs.emptyDirSync(destPath);
 
 // create destination subfolders
-fs.ensureDirSync(destPath + "/fonts/HTML-CSS/TeX/", { recursive: true });
+fs.ensureDirSync(destPathMJ + "/fonts/HTML-CSS/TeX/", { recursive: true });
 
 // copy required files only
-fs.copySync("node_modules/mathjax/MathJax.js", destPath + "/MathJax.js");
-fs.copySync("node_modules/mathjax/config", destPath + "/config");
-fs.copySync("node_modules/mathjax/jax", destPath + "/jax");
-fs.copySync("node_modules/mathjax/fonts/HTML-CSS/TeX/woff", destPath + "/fonts/HTML-CSS/TeX/woff");
-fs.copySync("node_modules/mathjax/fonts/HTML-CSS/TeX/otf", destPath + "/fonts/HTML-CSS/TeX/otf");
+fs.copySync("node_modules/mathjax/MathJax.js", destPathMJ + "/MathJax.js");
+fs.copySync("node_modules/mathjax/config", destPathMJ + "/config");
+fs.copySync("node_modules/mathjax/jax", destPathMJ + "/jax");
+fs.copySync("node_modules/mathjax/fonts/HTML-CSS/TeX/woff", destPathMJ + "/fonts/HTML-CSS/TeX/woff");
+fs.copySync("node_modules/mathjax/fonts/HTML-CSS/TeX/otf", destPathMJ + "/fonts/HTML-CSS/TeX/otf");
+
+fs.copySync("docs/matomo-tracking.js", destPath + "/matomo-tracking.js");
-- 
GitLab