Skip to content
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

Add Plausible for docs metrics #119977

Merged
merged 4 commits into from
Jun 7, 2024
Merged

Add Plausible for docs metrics #119977

merged 4 commits into from
Jun 7, 2024

Conversation

hugovk
Copy link
Member

@hugovk hugovk commented Jun 3, 2024

We're going to continue using Plausible for stats. The account is ready, let's merge this so we can begin collecting stats, and then look into one of the options suggested at #107136.


📚 Documentation preview 📚: https://cpython-previews--119977.org.readthedocs.build/

@hugovk hugovk added docs Documentation in the Doc dir needs backport to 3.12 bug and security fixes needs backport to 3.13 bugs and security fixes labels Jun 3, 2024
@JulienPalard
Copy link
Member

Something like this could prevent plausible to land on HTML builds distributed out of docs.python.org (like linux distribs):

--- a/Doc/conf.py
+++ b/Doc/conf.py
@@ -339,7 +339,8 @@
 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.
--- a/Doc/tools/templates/layout.html
+++ b/Doc/tools/templates/layout.html
@@ -26,7 +26,7 @@
 {% endblock %}
 
 {% block extrahead %}
-    {% if builder == "html" %}
+    {% 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" />

@hugovk
Copy link
Member Author

hugovk commented Jun 6, 2024

Thanks for the diff! I've added that to the PR, and verified locally the snippet only shows in the HTML when building with the env var set.

@hugovk
Copy link
Member Author

hugovk commented Jun 7, 2024

Merging to give a chance to be deployed. It won't be active until the env var is set by python/psf-salt#357.

@hugovk hugovk merged commit 5c11556 into python:main Jun 7, 2024
25 checks passed
@hugovk hugovk deleted the add-plausible branch June 7, 2024 06:38
@miss-islington-app
Copy link

Thanks @hugovk for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13.
🐍🍒⛏🤖 I'm not a witch! I'm not a witch!

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 7, 2024
(cherry picked from commit 5c11556)

Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Julien Palard <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Jun 7, 2024

GH-120193 is a backport of this pull request to the 3.13 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.13 bugs and security fixes label Jun 7, 2024
miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Jun 7, 2024
(cherry picked from commit 5c11556)

Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Julien Palard <[email protected]>
@bedevere-app
Copy link

bedevere-app bot commented Jun 7, 2024

GH-120194 is a backport of this pull request to the 3.12 branch.

@bedevere-app bedevere-app bot removed the needs backport to 3.12 bug and security fixes label Jun 7, 2024
hugovk added a commit that referenced this pull request Jun 7, 2024
Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Julien Palard <[email protected]>
hugovk added a commit that referenced this pull request Jun 7, 2024
Co-authored-by: Hugo van Kemenade <[email protected]>
Co-authored-by: Julien Palard <[email protected]>
noahbkim pushed a commit to hudson-trading/cpython that referenced this pull request Jul 11, 2024
estyxx pushed a commit to estyxx/cpython that referenced this pull request Jul 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation in the Doc dir skip issue skip news
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants