Skip to content

Commit

Permalink
docs: Add Matomo analytics and privacy message
Browse files Browse the repository at this point in the history
  • Loading branch information
cwhite911 committed Feb 21, 2025
1 parent 21933d1 commit c8d4254
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 2 deletions.
16 changes: 15 additions & 1 deletion man/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ DSTFILES := \
$(MDDIR)/source/grassdocs.css \
$(MDDIR)/scripts/hook_list_scripts.py \
$(MDDIR)/overrides/partials/footer.html \
$(MDDIR)/overrides/partials/actions.html
$(MDDIR)/overrides/partials/actions.html \
$(MDDIR)/overrides/partials/integrations/analytics/matomo.html \
$(MDDIR)/overrides/javascripts/consent.js

categories = \
d:display \
Expand Down Expand Up @@ -273,6 +275,18 @@ $(MDDIR)/overrides/partials/actions.html: mkdocs/overrides/partials/actions.html
$(MDDIR)/overrides/partials:
$(MKDIR) $@

$(MDDIR)/overrides/partials/integrations/analytics/matomo.html: mkdocs/overrides/partials/integrations/analytics/matomo.html | $(MDDIR)/overrides/partials/integrations/analytics
$(INSTALL_DATA) $< $@

$(MDDIR)/overrides/partials/integrations/analytics:
$(MKDIR) $@

$(MDDIR)/overrides/javascripts/consent.js: mkdocs/overrides/javascripts/consent.js | $(MDDIR)/overrides/javascripts
$(INSTALL_DATA) $< $@

$(MDDIR)/overrides/javascripts:
$(MKDIR) $@

build-mkdocs:
@cd $(MDDIR) ; SITE_NAME="GRASS GIS $(GRASS_VERSION_NUMBER) Reference Manual" \
COPYRIGHT="&copy; 2003-$(GRASS_VERSION_DATE) GRASS Development Team, GRASS GIS $(GRASS_VERSION_NUMBER) Reference Manual" \
Expand Down
17 changes: 17 additions & 0 deletions man/mkdocs/grassdocs.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
--gs-white-color--lighter: rgba(255, 255, 255, 0.322);
--gs-white-color--lightest: rgba(255, 255, 255, 0.071);
--gs-black-color: rgb(0, 0, 0); /* Black */
--gs-gray-color: rgb(135, 135, 135); /* Gray */
--gs-gray-color--light: rgba(135, 135, 135, 0.541);
--gs-gray-color--lighter: rgba(135, 135, 135, 0.322);
--gs-gray-color--lightest: rgba(135, 135, 135, 0.071);

--gs-primary-color: rgb(76, 176, 91); /* Dark green */
--gs-primary-color--light: rgba(76, 176, 91, 0.541);
Expand Down Expand Up @@ -170,3 +174,16 @@
.md-typeset table:not([class]) tbody tr:hover {
background-color: transparent;
}

/* Analytics consent styling */
#__consent > aside > form > p {
font-size: 0.7rem;
}

/* Sets the checkbox colors for analytics consent */
.md-typeset [type=checkbox]:checked+.task-list-indicator:before {
background-color: var(--gs-secondary-color);
}
.md-typeset .task-list-indicator:before {
background-color: var(--gs-gray-color--lighter);
}
37 changes: 37 additions & 0 deletions man/mkdocs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,39 @@ theme:
# Customization
extra:
homepage: ./index.html
analytics:
provider: matomo
url: https://2022.foss4g.org/matomo/
site_id: '2'
consent:
actions:
- accept
- manage

cookies:
analytics:
name: Matomo
checked: true
github:
name: GitHub
checked: true

title: Analytics Consent
description: >-
<strong>Matomo</strong><br>
This website uses the open source web analytics service
<a href="https://matomo.org/" target="_blank">Matomo</a>.
Matomo uses technologies that enable the recognition of
the user across pages for the analysis of user behaviour.
In our case no cookies are collected. The information collected by
Matomo about the use of this website is stored on our server.<br>
<strong>GitHub</strong><br>
This website uses the GitHub API to fetch
<a href="https://https://github.com/OSGeo/grass" target="_blank">OSGeo/grass</a>
and <a href="https://github.com/OSGeo/grass-addons" target="_blank">OSGeo/grass-addons</a> statistics.<br>
<br>
For more information, please read our
<a href="https://grass.osgeo.org/about/privacy/" target="_blank">privacy policy</a>.
# Hooks
hooks:
Expand All @@ -53,6 +86,10 @@ hooks:
extra_css:
- grassdocs.css

# Custom JavaScript
extra_javascript:
- javascripts/consent.js

# Plugins
plugins:
- search
Expand Down
17 changes: 17 additions & 0 deletions man/mkdocs/overrides/javascripts/consent.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
var consent = __md_get("__consent")
console.debug(consent);
if (consent && consent.analytics) {
/* The user accepted the cookie */
console.debug("User accepted Analytics");
_paq.push([ function() {
if (this.isUserOptedOut()) {
// ... change form to say user is currently opted out ...
console.debug("Switching form opt-out to opt-in");
_paq.push([ 'forgetUserOptOut' ]);
}
} ]);
} else {
/* The user rejected the cookie */
_paq.push([ 'optUserOut' ]); // Matomo opt-out
console.debug("User rejected Analytics");
}
2 changes: 1 addition & 1 deletion man/mkdocs/overrides/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
<!-- Further information -->
<div class="md-footer-meta md-typeset">
<center>
<a href="./index.html">Main index</a> | <a href="./topics.html">Topics index</a> | <a href="./keywords.html">Keywords index</a> | <a href="./graphical_index.html">Graphical index</a> | <a href="./full_index.html">Full index</a><br>
<a href="./index.html">Main index</a> | <a href="./topics.html">Topics index</a> | <a href="./keywords.html">Keywords index</a> | <a href="./graphical_index.html">Graphical index</a> | <a href="./full_index.html">Full index</a>| <a href="#__consent">Privacy Settings</a><br>
</center>
<div class="md-footer-meta__inner md-grid">
{% include "partials/copyright.html" %}
Expand Down
23 changes: 23 additions & 0 deletions man/mkdocs/overrides/partials/integrations/analytics/matomo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<script>
var u="{{ config.extra.analytics.url }}";
var siteId = "{{ config.extra.analytics.site_id }}";
var _paq = window._paq = window._paq || [];
// Call disableCookies before calling trackPageView
_paq.push(['disableCookies']);
_paq.push(['enableLinkTracking']);
_paq.push(['trackPageView']);
_paq.push(['enableHeartBeatTimer', 10]); // Page needs to be open for 10 seconds before tracking
(function() {
_paq.push(['setTrackerUrl', u+'matomo.php']);
_paq.push(['setSiteId', ['2']]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);
})();
/* Wait for page to load and application to mount */
document.addEventListener("DOMContentLoaded", function() {
location$.subscribe(function(url) {
/* Add custom page event tracking here */
_paq.push(['setDocumentTitle', document.title]);
})
})
</script>

0 comments on commit c8d4254

Please sign in to comment.