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 #120074

Closed
hugovk opened this issue Jun 4, 2024 · 11 comments
Closed

Add Plausible for docs metrics #120074

hugovk opened this issue Jun 4, 2024 · 11 comments
Labels
docs Documentation in the Doc dir

Comments

@hugovk
Copy link
Member

hugovk commented Jun 4, 2024

We're going to continue using Plausible for https://docs.python.org stats. We'll start with a trial again (because it's now hosted under a PSF account), and after that the Steering Council said it can be covered by their budget.

(Here's data from the trial last July: https://github.com/hugovk/plausible-stats)

During the trial, @JulienPalard suggested in #107136 that the loading of the JavaScript snippet should be:

implemented on docsbuild-scripts, or at least be made optional (using an environment flag?) and disabled by default so we could enable it in docsbuild-script.

I think an env var sounds the best option. That way we can define both it in docsbuild-script and also Read the Docs, which will enable a smoother migration (re: python/docs-community#5).

Here's what the plain JS snippet looks like in the template: #119977

@JulienPalard What sort of changes do we need to #119977 and https://github.com/python/docsbuild-scripts to put it behind an env var?

@hugovk hugovk added the docs Documentation in the Doc dir label Jun 4, 2024
@JacobCoffee
Copy link
Member

Where is the plausible dashboard hosted? Their cloud or do we self host? Would it be cheaper to self-host? (sorry if all of this has been discussed, I use plausible in my homelab so im just curious)

@hugovk
Copy link
Member Author

hugovk commented Jun 5, 2024

It's hosted in their cloud. The PSF prefers hosted services for this kind of thing rather than increasing the burden on their limited infra staff. Paying the experts to maintain is more cost-effective and a more efficient use of PSF resources.

Once it's up and running, I'd like to make the read-only dashboard open to all. It will have info like the screenshots at https://discuss.python.org/t/docs-metrics-trial-with-plausible/28896/4 and will be useful for our translators and documenters.

@JulienPalard
Copy link
Member

To enable plausible using an environment variable I proposed a simple patch in your PR @hugovk, and I don't think we should touch docsbuild scripts which could be used to local builds too (like by translators, html previous, and so on).

I think the environment variable should be added to the build cron directly on docs.python.org, so via https://github.com/python/psf-salt/.

@hugovk
Copy link
Member Author

hugovk commented Jun 6, 2024

To enable plausible using an environment variable I proposed a simple patch in your PR @hugovk, ...

Thanks, added to the PR.

... and I don't think we should touch docsbuild scripts which could be used to local builds too (like by translators, html previous, and so on).

I think the environment variable should be added to the build cron directly on docs.python.org, so via python/psf-salt.

Yep, okay. Do you know what changes are needed for psf-salt and could you propose a PR, or point me in the right direction?

@JulienPalard
Copy link
Member

Yep, okay. Do you know what changes are needed for psf-salt and could you propose a PR, or point me in the right direction?

Hum, I'm very not a salt user, @ewdurbin could you help us? We'll need a PYTHON_DOCS_ENABLE_ANALYTICS environment variable set during the docsbuild cron.

@ewdurbin
Copy link
Member

ewdurbin commented Jun 6, 2024

Two options, given that docbuild-scripts is more or less unique to the docs.python.org deployment consider setting it there, or adding a section like https://github.com/python/psf-salt/blob/fb015e69842594575efdc8d855d0edcb8b1a44ac/salt/docs/init.sls#L69-L73 for the docsbuild user's cron.

@JulienPalard
Copy link
Member

I'd prefer it on the psf-salt side than on docsbuild-script, I don't think I'm alone (OK let's write "I hope I'm not alone") to use docsbuild-script on my machine for some tests.

@ewdurbin
Copy link
Member

ewdurbin commented Jun 6, 2024

Great! Then a quick PR to add something like:

docsbuild-analytics:
  cron.env_present:
    - user: docsbuild
    - name: PYTHON_DOCS_ENABLE_ANALYTICS
    - value: 1

to the state for docs should be all that's needed.

@hugovk
Copy link
Member Author

hugovk commented Jun 7, 2024

Thanks, please see PR python/psf-salt#357.

@ewdurbin
Copy link
Member

ewdurbin commented Jun 7, 2024

docsbuild server has been updated with the env var for cron tasks.

@hugovk
Copy link
Member Author

hugovk commented Jun 16, 2024

The snippet has been deployed to the 3.12, 3.13 and main for a week now, here's the public dashboard: https://plausible.io/docs.python.org/

Thanks all!

@hugovk hugovk closed this as completed Jun 16, 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
Projects
None yet
Development

No branches or pull requests

4 participants