]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.12] Add Plausible for docs metrics (GH-119977) (#120194)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 7 Jun 2024 07:42:37 +0000 (09:42 +0200)
committerGitHub <noreply@github.com>
Fri, 7 Jun 2024 07:42:37 +0000 (10:42 +0300)
Co-authored-by: Hugo van Kemenade <1324225+hugovk@users.noreply.github.com>
Co-authored-by: Julien Palard <julien@palard.fr>
Doc/conf.py
Doc/tools/templates/layout.html

index e292bdd5003b9732e4e2456146c197ef139d42de..e38476a0b70506bf9927dfc244edd856d67e986e 100644 (file)
@@ -323,7 +323,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 e931147813ae03a8593bb119238f4257d8ddc126..394ebee5f9e139f82553d525880783925c3af1fd 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 %}