Merge pull request #4 from DarkflameUniverse/analytics

Analytics Reporting to Matomo
This commit is contained in:
Aaron Kimbrell 2022-01-18 20:11:28 -06:00 committed by GitHub
commit 7f7b854b8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 58 additions and 0 deletions

View File

@ -6,6 +6,12 @@
<img src="app/static/logo/logo.png" alt="Sublime's custom image"/>
</p>
## Features
* Analytics
* Provide reporting to Developers to help better solve issues
* Disabled by default. Set `ALLOW_ANALYTICS` to true to enable
# Deployment
## Docker
@ -46,6 +52,7 @@ docker run -d \
* USER_ENABLE_CONFIRM_EMAIL (Default: True)
* USER_ENABLE_INVITE_USER (Default: False)
* USER_REQUIRE_INVITATION (Default: False)
* ALLOW_ANALYTICS (Default: False)
* REQUIRE_PLAY_KEY (Default: True)
* MAIL_SERVER (Default: smtp.gmail.com)
* MAIL_PORT (Default: 587)
@ -62,6 +69,7 @@ Don't, use Docker /s
TODO: Make manual deployment easier to configure
# Development
Please use [Editor Config](https://editorconfig.org/)

View File

@ -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,

View File

@ -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

View File

@ -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 %}
</script>
{% if config.ALLOW_ANALYTICS %}
<!-- Matomo no js analytics -->
<noscript><p><img src="https://matomo.aronwk.com/matomo.php?idsite=3&amp;rec=1" style="border:0;" alt="" /></p></noscript>
{% endif %}
{% endblock %}
</body>

View File

@ -36,6 +36,29 @@
<script type="text/javascript" src="{{ url_for('static', filename='lddviewer/base64-binary.js') }}"></script>
{% if config.ALLOW_ANALYTICS %}
<script>
// 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);
})();
</script>
{% endif %}
{% if config.ALLOW_ANALYTICS %}
<!-- Matomo no js analytics -->
<noscript><p><img src="https://matomo.aronwk.com/matomo.php?idsite=3&amp;rec=1" style="border:0;" alt="" /></p></noscript>
{% endif %}
<script type='module'>
import {MTLLoader} from 'https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/jsm/loaders/MTLLoader.js'
import {OBJLoader} from 'https://cdn.jsdelivr.net/gh/mrdoob/three.js/examples/jsm/loaders/OBJLoader.js'