Skip to content

Commit

Permalink
Merge branch 'staging'
Browse files Browse the repository at this point in the history
  • Loading branch information
spwoodcock committed May 29, 2024
2 parents 5baf617 + 760d115 commit 12daf63
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 27 deletions.
29 changes: 29 additions & 0 deletions src/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,35 @@
<link rel="icon" href="/favicon.ico" sizes="48x48" />
<link rel="icon" href="/favicon.svg" sizes="any" type="image/svg+xml" />
<link rel="apple-touch-icon" href="/apple-touch-icon-180x180.png" />

<!-- Matomo -->
<script type="text/javascript">
if (window.location.hostname === 'fmtm.hotosm.org') {
console.log('Adding Matomo tracking to fmtm.hotosm.org');

var _paq = (window._paq = window._paq || []);
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['requireConsent']);
_paq.push(['setDomains', ['fmtm.hotosm.org']]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']); // Tracks downloads
_paq.push(['trackVisibleContentImpressions']); // Tracks content blocks
(function () {
var u = '//matomo.hotosm.org/';
_paq.push(['setTrackerUrl', u + 'matomo.php']);
_paq.push(['setSiteId', '28']);
var d = document,
g = d.createElement('script'),
s = d.getElementsByTagName('script')[0];
g.async = true;
g.src = u + 'matomo.js';
s.parentNode.insertBefore(g, s);
})();
} else {
console.log('Matomo tracking disabled: Not on fmtm.hotosm.org domain.');
}
</script>
<!-- End Matomo Code -->
</head>

<body>
Expand Down
27 changes: 0 additions & 27 deletions src/frontend/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,33 +74,6 @@ axios.interceptors.request.use(
});
})();

(function matomoTrackingInit() {
// Immediately invoked function to enable Matomo tracking
if (import.meta.env.MODE === 'development' || window.location.hostname !== 'fmtm.hotosm.org') {
return;
}
console.log('Adding Matomo');

var _paq = (window._paq = window._paq || []);
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['requireConsent']);
_paq.push(['setDomains', ['fmtm.hotosm.org']]);
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']); // Tracks downloads
_paq.push(['trackVisibleContentImpressions']); // Tracks content blocks
(function () {
var u = '//matomo.hotosm.org/';
_paq.push(['setTrackerUrl', u + 'matomo.php']);
_paq.push(['setSiteId', environment.matomoTrackingId]);
var d = document,
g = d.createElement('script'),
s = d.getElementsByTagName('script')[0];
g.async = true;
g.src = u + 'matomo.js';
s.parentNode.insertBefore(g, s);
})();
})();

// React 17 setup
ReactDOM.render(<App />, document.getElementById('app'));

Expand Down

0 comments on commit 12daf63

Please sign in to comment.