diff --git a/www/assets/js/main.js b/www/assets/js/main.js index bb5290d..8478a51 100644 --- a/www/assets/js/main.js +++ b/www/assets/js/main.js @@ -97,6 +97,14 @@ $(document).keyup(function (e) { router.on("routeChange", function (newRoute) { console.log("Info", "Navigating to ", newRoute.path); + if (getStorage("analytics") !== "false") { + try { + _paq.push(['setCustomUrl', newRoute.path]); + _paq.push(['trackPageView']); + } catch (ex) { + console.error(ex); + } + } }); function setAppTheme(theme) { @@ -176,6 +184,27 @@ var setup = (inStorage("accountnumber") && inStorage("accountkey")) || inStorage app.init(); +if (getStorage("analytics") !== "false") { + try { + var _paq = window._paq = window._paq || []; + _paq.push(['enableLinkTracking']); + (function () { + var u = "https://analytics.netsyms.net/"; + _paq.push(['setTrackerUrl', u + 'matomo.php']); + _paq.push(['setSiteId', '40']); + 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); + })(); + } catch (ex) { + // skip + } +} else { + console.log("Analytics code not loaded at user request."); +} + + if (setup) { router.navigate("/home"); } else { diff --git a/www/assets/js/settings.js b/www/assets/js/settings.js index c23e8cb..c688efa 100644 --- a/www/assets/js/settings.js +++ b/www/assets/js/settings.js @@ -33,6 +33,11 @@ $('.item-content[data-setting=hideaccountnag] .toggle input').on("change", funct setStorage("hideaccountnag", checked); }); +$('.item-content[data-setting=analytics] .toggle input').on("change", function () { + var checked = $(this).prop('checked'); + setStorage("analytics", checked ? "true" : "false"); +}); + function resetAccountPrompt() { app.dialog.confirm("Are you sure you want to log out?", function () { removeFromStorage("accountnumber"); diff --git a/www/pages/welcome.html b/www/pages/welcome.html index e57e42b..b3bd352 100644 --- a/www/pages/welcome.html +++ b/www/pages/welcome.html @@ -25,9 +25,9 @@
Privacy Info: This app doesn't track you or sell your data. We only know - what you actually tell us, and we only use that data to provide and - improve the services we offer you. +
Privacy Info: This app doesn't sell your data. We do collect a small amount + of analytics to help improve the app. You can opt out in the + app settings.