Skip to content

docs: Add Matomo analytics and privacy message #5173

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion man/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,12 @@ DSTFILES := \
$(MDDIR)/source/grass_icon.png \
$(MDDIR)/source/favicon.ico \
$(MDDIR)/source/grassdocs.css \
$(MDDIR)/source/tags.md \
$(MDDIR)/scripts/hook_list_scripts.py \
$(MDDIR)/overrides/partials/footer.html \
$(MDDIR)/overrides/partials/actions.html \
$(MDDIR)/source/tags.md
$(MDDIR)/overrides/partials/integrations/analytics/matomo.html \
$(MDDIR)/overrides/javascripts/consent.js

categories = \
d:display \
Expand Down Expand Up @@ -277,6 +279,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="{{ config.site_url }}index.html">Main index</a> | <a href="{{ config.site_url }}topics.html">Topics index</a> | <a href="{{ config.site_url }}keywords.html">Keywords index</a> | <a href="{{ config.site_url }}tags.html">Tags index</a> | <a href="{{ config.site_url }}graphical_index.html">Graphical index</a> | <a href="{{ config.site_url }}full_index.html">Full index</a><br>
<a href="{{ config.site_url }}index.html">Main index</a> | <a href="{{ config.site_url }}topics.html">Topics index</a> | <a href="{{ config.site_url }}keywords.html">Keywords index</a> | <a href="{{ config.site_url }}tags.html">Tags index</a> | <a href="{{ config.site_url }}graphical_index.html">Graphical index</a> | <a href="{{ config.site_url }}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>
Loading