]> git.openstreetmap.org Git - rails.git/commitdiff
Rename piwik to matomo and merge configuration into settings
authorTom Hughes <tom@compton.nu>
Mon, 1 Aug 2022 19:40:25 +0000 (20:40 +0100)
committerTom Hughes <tom@compton.nu>
Mon, 1 Aug 2022 21:42:04 +0000 (22:42 +0100)
13 files changed:
.gitignore
app/assets/javascripts/application.js
app/assets/javascripts/index.js
app/assets/javascripts/matomo.js [new file with mode: 0644]
app/assets/javascripts/osm.js.erb
app/assets/javascripts/piwik.js [deleted file]
app/controllers/users_controller.rb
app/views/layouts/_meta.html.erb
app/views/layouts/site.html.erb
config/eslint.json
config/initializers/piwik.rb [deleted file]
config/initializers/secure_headers.rb
config/settings.yml

index 73316769e63ae7989ff9507682a1011cdf9db21a..75e9eb59e73fe2fb5dfe474e590dfed8fd748c67 100644 (file)
@@ -6,7 +6,6 @@
 .vagrant
 app/assets/javascripts/i18n
 config/environments/*.local.yml
-config/piwik.yml
 config/settings.local.yml
 config/settings/*.local.yml
 coverage
index d5b16bbfb293c3019bee839066dfe803b4e87941..aea9e01a468df7646fd52ca3589175067c144d08 100644 (file)
@@ -13,7 +13,7 @@
 //= require leaflet.locationfilter
 //= require i18n
 //= require oauth
-//= require piwik
+//= require matomo
 //= require richtext
 //= require qs/dist/qs
 //= require bs-custom-file-input
index f0b96f59fa95d28aa273d8f0362ae290bdfa565d..6d379ca8c32caa8b038af3fa7c7cb4fa096cca13 100644 (file)
@@ -212,13 +212,13 @@ $(document).ready(function () {
     }
   });
 
-  if (OSM.PIWIK) {
+  if (OSM.MATOMO) {
     map.on("layeradd", function (e) {
       if (e.layer.options) {
-        var goal = OSM.PIWIK.goals[e.layer.options.keyid];
+        var goal = OSM.MATOMO.goals[e.layer.options.keyid];
 
         if (goal) {
-          $("body").trigger("piwikgoal", goal);
+          $("body").trigger("matomogoal", goal);
         }
       }
     });
diff --git a/app/assets/javascripts/matomo.js b/app/assets/javascripts/matomo.js
new file mode 100644 (file)
index 0000000..34af54c
--- /dev/null
@@ -0,0 +1,32 @@
+if (OSM.MATOMO) {
+  $(document).ready(function () {
+    var base = document.location.protocol + "//" + OSM.MATOMO.location + "/";
+    var matomoTracker;
+
+    var matomoLoader = $.ajax({
+      url: base + "matomo.js",
+      dataType: "script",
+      cache: true,
+      success: function () {
+        matomoTracker = Matomo.getTracker(base + "matomo.php", OSM.MATOMO.site);
+
+        if (OSM.user) {
+          matomoTracker.setUserId(OSM.user.toString());
+        }
+
+        matomoTracker.trackPageView();
+        matomoTracker.enableLinkTracking();
+
+        $("meta[name=matomo-goal]").each(function () {
+          matomoTracker.trackGoal($(this).attr("content"));
+        });
+      }
+    });
+
+    $("body").on("matomogoal", function (e, goal) {
+      matomoLoader.done(function () {
+        matomoTracker.trackGoal(goal);
+      });
+    });
+  });
+}
index 3e2e7c866e6998403613a361abcda082f7387093..f82516632f2247cb86655b658d72a0e1f305635a 100644 (file)
@@ -3,8 +3,8 @@
 //= require qs/dist/qs
 
 OSM = {
-<% if defined?(PIWIK) %>
-  PIWIK:                   <%= PIWIK.to_json %>,
+<% if defined?(Settings.matomo) %>
+  MATOMO:                  <%= Settings.matomo.to_json %>,
 <% end %>
 
   MAX_REQUEST_AREA:        <%= Settings.max_request_area.to_json %>,
diff --git a/app/assets/javascripts/piwik.js b/app/assets/javascripts/piwik.js
deleted file mode 100644 (file)
index 5353a99..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-if (OSM.PIWIK) {
-  $(document).ready(function () {
-    var base = document.location.protocol + "//" + OSM.PIWIK.location + "/";
-    var piwikTracker;
-
-    var piwikLoader = $.ajax({
-      url: base + "piwik.js",
-      dataType: "script",
-      cache: true,
-      success: function () {
-        piwikTracker = Piwik.getTracker(base + "piwik.php", OSM.PIWIK.site);
-
-        if (OSM.user) {
-          piwikTracker.setUserId(OSM.user.toString());
-        }
-
-        piwikTracker.trackPageView();
-        piwikTracker.enableLinkTracking();
-
-        $("meta[name=piwik-goal]").each(function () {
-          piwikTracker.trackGoal($(this).attr("content"));
-        });
-      }
-    });
-
-    $("body").on("piwikgoal", function (e, goal) {
-      piwikLoader.done(function () {
-        piwikTracker.trackGoal(goal);
-      });
-    });
-  });
-}
index 6215403c9795895d4059e5e483412065084afb16..933cec53de9f2a78344363bf40b3f98870d1e30d 100644 (file)
@@ -83,7 +83,7 @@ class UsersController < ApplicationController
         end
 
         if current_user.save
-          flash[:piwik_goal] = PIWIK["goals"]["signup"] if defined?(PIWIK)
+          flash[:matomo_goal] = Settings.matomo["goals"]["signup"] if defined?(Settings.matomo)
 
           referer = welcome_path
 
index 2052b1d64135f802f873ca3a2595a666e81837c6..3517673ac6ba085624da2f3ce0a26b01d98a3b87 100644 (file)
@@ -20,6 +20,6 @@
 <%= tag.link :rel => "search", :type => "application/opensearchdescription+xml", :title => "OpenStreetMap Search", :href => asset_path("osm.xml") %>
 <%= tag.meta :name => "description", :content => "OpenStreetMap is the free wiki world map." %>
 <%= opengraph_tags(@title) %>
-<% if flash[:piwik_goal] -%>
-<%= tag.meta :name => "piwik-goal", :content => flash[:piwik_goal] %>
+<% if flash[:matomo_goal] -%>
+<%= tag.meta :name => "matomo-goal", :content => flash[:matomo_goal] %>
 <% end -%>
index ca59f5763ee4bca50ce7eeb049d899c255e0d3b4..7c921658d46102d54b720eb5deb57a7107f07d9b 100644 (file)
@@ -4,8 +4,8 @@
   <body class="<%= body_class %>">
     <%= render :partial => "layouts/header" %>
     <%= render :partial => "layouts/content" %>
-    <% if defined?(PIWIK) -%>
-    <noscript><p><img src="<%= request.protocol %><%= PIWIK["location"] %>/piwik.php?idsite=<%= PIWIK["site"] %>" class="piwik" alt="" /></p></noscript>
+    <% if defined?(Settings.matomo) -%>
+    <noscript><p><img src="<%= request.protocol %><%= Settings.matomo["location"] %>/matomo.php?idsite=<%= Settings.matomo["site"] %>" class="matomo" alt="" /></p></noscript>
     <% end -%>
   </body>
 </html>
index 22ecdd3db9950f618ae1399fe80c2485e777edef..3b878d48a8cb813955fb399243ed01af1e892fef 100644 (file)
@@ -11,7 +11,7 @@
     "I18n": "readonly",
     "L": "readonly",
     "OSM": "writable",
-    "Piwik": "readonly",
+    "Matomo": "readonly",
     "Qs": "readonly",
     "updateLinks": "readonly"
   },
diff --git a/config/initializers/piwik.rb b/config/initializers/piwik.rb
deleted file mode 100644 (file)
index 1b9fa73..0000000
+++ /dev/null
@@ -1,5 +0,0 @@
-require "yaml"
-
-if File.exist?(piwik_file = File.expand_path("../piwik.yml", __dir__))
-  PIWIK = YAML.load_file(piwik_file)
-end
index 97952f7cbc08c80f8f97f294018f5a9fc016554c..53ab768088a5b18db05ba9bde6dd690f289d3e57 100644 (file)
@@ -18,9 +18,9 @@ csp_policy = {
   :report_uri => []
 }
 
-csp_policy[:connect_src] << PIWIK["location"] if defined?(PIWIK)
-csp_policy[:img_src] << PIWIK["location"] if defined?(PIWIK)
-csp_policy[:script_src] << PIWIK["location"] if defined?(PIWIK)
+csp_policy[:connect_src] << Settings.matomo["location"] if defined?(Settings.matomo)
+csp_policy[:img_src] << Settings.matomo["location"] if defined?(Settings.matomo)
+csp_policy[:script_src] << Settings.matomo["location"] if defined?(Settings.matomo)
 
 csp_policy[:img_src] << Settings.avatar_storage_url if Settings.key?(:avatar_storage_url)
 csp_policy[:img_src] << Settings.trace_image_storage_url if Settings.key?(:trace_image_storage_url)
index 0e73d2b02c8e7131341bca3b823d4924557c67d9..9ff8a653b7e69423fb2dff11e47dd62b1d9e381c 100644 (file)
@@ -138,3 +138,5 @@ smtp_tls_verify_mode: "none"
 smtp_authentication: null
 smtp_user_name: null
 smtp_password: null
+# Matomo settings for analytics
+#matomo: