Skip to content

Commit

Permalink
Merge pull request #56 from yaal-coop/issue-54-matomo
Browse files Browse the repository at this point in the history
Intégration du code matomo
  • Loading branch information
klorydryk authored Feb 5, 2024
2 parents 2f3e2a6 + 59a9ff3 commit 66bc6dc
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 0 deletions.
3 changes: 3 additions & 0 deletions web.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,6 @@ REDIS_URL=broker:6379 # SHARED between worker and web services, used for backgr

# Feature flags
FILE_SHARING=on

MATOMO_URL=
MATOMO_SITE_ID=
10 changes: 10 additions & 0 deletions web/b3desk/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -976,3 +976,13 @@ def get_rie_network_ips(
Plus d’informations sur
https://docs.bigbluebutton.org/development/api/#create
"""

MATOMO_URL: Optional[str] = None
"""
URL de l’instance de Matomo vers laquelle envoyer des statistiques.
"""

MATOMO_SITE_ID: Optional[str] = None
"""
ID de l’instance B3Desk dans Matomo.
"""
15 changes: 15 additions & 0 deletions web/b3desk/templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,21 @@
<script type="text/javascript" nomodule href="dsfr-1.7/dsfr/dsfr.nomodule.min.js" ></script>
<!-- Scampi Modal en attendant la modale GouvFr-->
<script src="{{ url_for('static', filename='js/scampi-modal.js')}}"></script>
{% if config.get("MATOMO_SITE_ID") and config.get("MATOMO_URL") %}
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="{{ config.get("MATOMO_URL") }}";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', '{{ config.get("MATOMO_SITE_ID") }}']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
{% endif %}
{% block js %}{% endblock %}
</div>
</body>
Expand Down
15 changes: 15 additions & 0 deletions web/b3desk/templates/static-layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,21 @@
<script src="{{ url_for('static', filename='js/scampi-modal.js')}}"></script>
<!-- minified nc filepicker : from https://github.com/julien-nc/nextcloud-webdav-filepicker -->
<!-- <script src="{{ url_for('static', filename='js/filePickerWrapper.js')}}"></script> -->
{% if config.get("MATOMO_SITE_ID") and config.get("MATOMO_URL") %}
<script>
var _paq = window._paq = window._paq || [];
/* tracker methods like "setCustomDimension" should be called before "trackPageView" */
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="{{ config.get("MATOMO_URL") }}";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', 'config.get("MATOMO_SITE_ID")']);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
{% endif %}
{% block js %}{% endblock %}
</div>
</body>
Expand Down

0 comments on commit 66bc6dc

Please sign in to comment.