diff --git a/app/__init__.py b/app/__init__.py index 61050e5..c561d47 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -169,6 +169,10 @@ def register_settings(app): 'USER_REQUIRE_INVITATION', app.config['USER_REQUIRE_INVITATION'] ) + app.config['ALLOW_ANALYTICS'] = os.getenv( + 'ALLOW_ANALYTICS', + app.config['ALLOW_ANALYTICS'] + ) app.config['SQLALCHEMY_ENGINE_OPTIONS'] = { "pool_pre_ping": True, "pool_size": 10, diff --git a/app/settings.py b/app/settings.py index 3ed103f..8e4a66a 100644 --- a/app/settings.py +++ b/app/settings.py @@ -4,6 +4,9 @@ APP_NAME = "Nexus Dashboard" APP_SYSTEM_ERROR_SUBJECT_LINE = APP_NAME + " system error" +# Send Analytics for Developers to better fix issues +ALLOW_ANALYTICS = False + # Flask settings CSRF_ENABLED = True diff --git a/app/templates/base.html.j2 b/app/templates/base.html.j2 index c0f418a..041dc0c 100644 --- a/app/templates/base.html.j2 +++ b/app/templates/base.html.j2 @@ -93,7 +93,27 @@ $(function () { $('[data-toggle="tooltip"]').tooltip() }) + {% if config.ALLOW_ANALYTICS %} + // Matomo JS analytics + var _paq = window._paq = window._paq || []; + /* tracker methods like "setCustomDimension" should be called before "trackPageView" */ + _paq.push(["setDocumentTitle", document.domain + "/" + document.title]); + _paq.push(['trackPageView']); + _paq.push(['enableLinkTracking']); + (function() { + var u="https://matomo.aronwk.com/"; + _paq.push(['setTrackerUrl', u+'matomo.php']); + _paq.push(['setSiteId', '3']); + 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); + })(); + {% endif %} + {% if config.ALLOW_ANALYTICS %} + + + {% endif %} + {% endblock %} diff --git a/app/templates/ldd/ldd.html.j2 b/app/templates/ldd/ldd.html.j2 index 302f17c..208b845 100644 --- a/app/templates/ldd/ldd.html.j2 +++ b/app/templates/ldd/ldd.html.j2 @@ -36,6 +36,29 @@ +{% if config.ALLOW_ANALYTICS %} + +{% endif %} + +{% if config.ALLOW_ANALYTICS %} + + +{% endif %} +