]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Add Plausible for docs metrics (#119977)
authorHugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Fri, 7 Jun 2024 06:38:31 +0000 (00:38 -0600)
committerGitHub <noreply@github.com>
Fri, 7 Jun 2024 06:38:31 +0000 (00:38 -0600)
Co-authored-by: Julien Palard <julien@palard.fr>
Doc/conf.py
Doc/tools/templates/layout.html

index 47fb96fe1de4822fb8d571407555ffcb995fe499..8a14646801ebac5a63a112d242192fb2b4bffcdd 100644 (file)
@@ -339,7 +339,8 @@ repository_url = os.getenv("READTHEDOCS_GIT_CLONE_URL")
 html_context = {
     "is_deployment_preview": os.getenv("READTHEDOCS_VERSION_TYPE") == "external",
     "repository_url": repository_url.removesuffix(".git") if repository_url else None,
-    "pr_id": os.getenv("READTHEDOCS_VERSION")
+    "pr_id": os.getenv("READTHEDOCS_VERSION"),
+    "enable_analytics": os.getenv("PYTHON_DOCS_ENABLE_ANALYTICS"),
 }
 
 # This 'Last updated on:' timestamp is inserted at the bottom of every page.
index 3f88fc8e91faad4c55b63606897a344e0f63ab3f..b09fd21a8ddcc9f83282bb13377e9b61ff02ae4d 100644 (file)
@@ -26,6 +26,9 @@
 {% endblock %}
 
 {% block extrahead %}
+    {% if builder == "html" and enable_analytics %}
+      <script defer data-domain="docs.python.org" src="https://plausible.io/js/script.js"></script>
+    {% endif %}
     <link rel="canonical" href="https://docs.python.org/3/{{pagename}}.html" />
     {% if builder != "htmlhelp" %}
       {% if pagename == 'whatsnew/changelog' and not embedded %}