splent-feature-analytics 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- splent_feature_analytics-0.2.0.dist-info/METADATA +112 -0
- splent_feature_analytics-0.2.0.dist-info/RECORD +14 -0
- splent_feature_analytics-0.2.0.dist-info/WHEEL +5 -0
- splent_feature_analytics-0.2.0.dist-info/licenses/COPYING +674 -0
- splent_feature_analytics-0.2.0.dist-info/licenses/COPYING.LESSER +165 -0
- splent_feature_analytics-0.2.0.dist-info/top_level.txt +1 -0
- splent_io/splent_feature_analytics/__init__.py +33 -0
- splent_io/splent_feature_analytics/assets/js/matomo.js +44 -0
- splent_io/splent_feature_analytics/config.py +12 -0
- splent_io/splent_feature_analytics/hooks.py +12 -0
- splent_io/splent_feature_analytics/tracking.py +244 -0
- splent_io/splent_feature_analytics/translations/es/LC_MESSAGES/messages.mo +0 -0
- splent_io/splent_feature_analytics/translations/es/LC_MESSAGES/messages.po +44 -0
- splent_io/splent_feature_analytics/translations/messages.pot +41 -0
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: splent_feature_analytics
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
License-Expression: LGPL-3.0-or-later
|
|
5
|
+
Requires-Python: >=3.13
|
|
6
|
+
Description-Content-Type: text/markdown
|
|
7
|
+
License-File: COPYING
|
|
8
|
+
License-File: COPYING.LESSER
|
|
9
|
+
Requires-Dist: splent_framework>=1.30.0
|
|
10
|
+
Dynamic: license-file
|
|
11
|
+
|
|
12
|
+
# splent_feature_analytics
|
|
13
|
+
|
|
14
|
+
Visit counts for a SPLENT product without cookies, so without a consent
|
|
15
|
+
banner (decision D11): [Plausible](https://plausible.io) or
|
|
16
|
+
[Matomo](https://matomo.org), cloud or self-hosted. Optional in the line
|
|
17
|
+
and off by default: until the deployment gives the script and the site,
|
|
18
|
+
nothing is loaded.
|
|
19
|
+
|
|
20
|
+
## What a page gets
|
|
21
|
+
|
|
22
|
+
The tag goes at the end of every page of both shells, in the
|
|
23
|
+
`layout.scripts` slot, with the request's Content-Security-Policy nonce
|
|
24
|
+
(`csp_nonce()`), so a policy that names the nonce allows it and no inline
|
|
25
|
+
script is needed.
|
|
26
|
+
|
|
27
|
+
- **plausible**: the provider's script, with the site's domain:
|
|
28
|
+
```html
|
|
29
|
+
<script defer data-domain="uvlhub.io" src="https://plausible.io/js/script.js" nonce="…"></script>
|
|
30
|
+
```
|
|
31
|
+
Plausible sets no cookie and keeps no query string but the campaign
|
|
32
|
+
tags.
|
|
33
|
+
- **matomo**: this feature's own `assets/js/matomo.js`, which reads the
|
|
34
|
+
server and the site from its data attributes, tells Matomo to set no
|
|
35
|
+
cookie (`disableCookies`) and to record the page and the referrer
|
|
36
|
+
without their query strings, and then loads `matomo.js` from the Matomo
|
|
37
|
+
server with the same nonce. The tracker is `matomo.php` next to it.
|
|
38
|
+
|
|
39
|
+
## What is never counted
|
|
40
|
+
|
|
41
|
+
- **The excluded paths**, `ANALYTICS_EXCLUDED_PATHS`, and everything under
|
|
42
|
+
them, segment by segment (`/api` excludes `/api/v1/datasets`, not
|
|
43
|
+
`/apidocs`). By default: the administration, the account pages, signing
|
|
44
|
+
in, up and out, the reset and confirmation links, the developer pages,
|
|
45
|
+
the API, the ORCID and GitHub returns, and the acceptance of the legal
|
|
46
|
+
texts.
|
|
47
|
+
- **The pages of a signed-in account**, unless `ANALYTICS_SIGNED_IN`:
|
|
48
|
+
their addresses are about the account.
|
|
49
|
+
- **Every page that holds a token** (ID-14), whatever its path: a reset or
|
|
50
|
+
confirmation link, the page that shows a new API token, the return from
|
|
51
|
+
a provider. Those go through auth's `keep_token_private`, which sends
|
|
52
|
+
`Referrer-Policy: no-referrer`; a response that sends no Referer to
|
|
53
|
+
anybody has the tag taken out before it leaves. The page carries no
|
|
54
|
+
script of another site, and its address reaches no counter, even one
|
|
55
|
+
served from the site's own domain.
|
|
56
|
+
|
|
57
|
+
## The Content-Security-Policy
|
|
58
|
+
|
|
59
|
+
A product that sends one (`SPLENT_CONTENT_SECURITY_POLICY`) names the
|
|
60
|
+
provider's host in `script-src` and `connect-src` (and `img-src` for
|
|
61
|
+
Matomo's fallback), or uses the nonce with `'strict-dynamic'`. The feature
|
|
62
|
+
says at start when the policy would block the script.
|
|
63
|
+
|
|
64
|
+
With splent_feature_legal, the provider is listed in the privacy notice as
|
|
65
|
+
a third party, with its host; no cookie is declared, since none is set.
|
|
66
|
+
|
|
67
|
+
## Settings
|
|
68
|
+
|
|
69
|
+
Each is a typed parameter in `[tool.splent.config_schema]`, so
|
|
70
|
+
`product:validate` checks a product's value against it. The two of `deploy`
|
|
71
|
+
bind are left to each deployment's `.env`; the rest are decided when the
|
|
72
|
+
product is derived.
|
|
73
|
+
|
|
74
|
+
| Variable | Type | Bind | Default | |
|
|
75
|
+
|---|---|---|---|---|
|
|
76
|
+
| `ANALYTICS_PROVIDER` | enum | derivation | `plausible` | `plausible` or `matomo` |
|
|
77
|
+
| `ANALYTICS_SCRIPT_URL` | url | deploy | | Plausible's `script.js`, or the address of `matomo.js` on the Matomo server. Empty loads nothing |
|
|
78
|
+
| `ANALYTICS_SITE_ID` | str | deploy | | The domain registered in Plausible, or the site's number in Matomo. Matches `[A-Za-z0-9.:_-]{1,253}` |
|
|
79
|
+
| `ANALYTICS_EXCLUDED_PATHS` | list | derivation | the sensitive routes | Paths never counted, with everything under them. Each matches `/.*` |
|
|
80
|
+
| `ANALYTICS_SIGNED_IN` | bool | derivation | `false` | Whether the pages of a signed-in account are counted |
|
|
81
|
+
|
|
82
|
+
The default `ANALYTICS_EXCLUDED_PATHS` is `/admin`, `/account`, `/login`,
|
|
83
|
+
`/logout`, `/signup`, `/reset`, `/confirmemail`, `/confirm_email_change`,
|
|
84
|
+
`/confirm_user`, `/developer`, `/api`, `/orcid`, `/github` and
|
|
85
|
+
`/legal/accept`. A product that sets it replaces the list, so it keeps these
|
|
86
|
+
and adds its own.
|
|
87
|
+
|
|
88
|
+
At start the feature refuses a Matomo site that is not a number, and in
|
|
89
|
+
production a script over plain http, or a script without a site (or the
|
|
90
|
+
reverse); elsewhere the last is a warning and nothing is loaded.
|
|
91
|
+
|
|
92
|
+
## Enable it in a product
|
|
93
|
+
|
|
94
|
+
1. Select `analytics`, an optional feature of `plataforma` in
|
|
95
|
+
openhubs_spl, and pin it. It requires no other feature.
|
|
96
|
+
2. Choose the provider in the product's `[tool.splent.config]` if it is not
|
|
97
|
+
Plausible, and add any path of the product's own that must not be
|
|
98
|
+
counted to `ANALYTICS_EXCLUDED_PATHS`.
|
|
99
|
+
3. In the deployment's `.env`:
|
|
100
|
+
```
|
|
101
|
+
ANALYTICS_SCRIPT_URL=https://plausible.io/js/script.js
|
|
102
|
+
ANALYTICS_SITE_ID=uvlhub.io
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Develop
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
splent feature:test analytics --neutral
|
|
109
|
+
splent feature:contract analytics --write
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
No test calls Plausible or Matomo: they check the tag the pages carry.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
splent_feature_analytics-0.2.0.dist-info/licenses/COPYING,sha256=jOtLnuWt7d5Hsx6XXB2QxzrSe2sWWh3NgMfFRetluQM,35147
|
|
2
|
+
splent_feature_analytics-0.2.0.dist-info/licenses/COPYING.LESSER,sha256=2n6rt7r999OuXp8iOqW9we7ORaxWncIbOwN1ILRGR2g,7651
|
|
3
|
+
splent_io/splent_feature_analytics/__init__.py,sha256=w-6mJVR2qFPSlHZ_jXfe7NFkShYShLbXtypgB-XOrJk,990
|
|
4
|
+
splent_io/splent_feature_analytics/config.py,sha256=2JzcrPU14Oz0d2M1xfOj5IU-IF1lFcbzSC2xe-HG0cA,448
|
|
5
|
+
splent_io/splent_feature_analytics/hooks.py,sha256=MQRbD9RB3mJRS8X5YNiFSJRUWC-SqYZFosXn_-Zy45g,394
|
|
6
|
+
splent_io/splent_feature_analytics/tracking.py,sha256=riKtZFRTBLPY7e_Q6KAGNcC4TNJILp7PL3XrrhHtdyA,9336
|
|
7
|
+
splent_io/splent_feature_analytics/assets/js/matomo.js,sha256=W4vDd9-vD5lC18vXT9bpG5V2RKcJ0BxomnD7qLwH35U,1563
|
|
8
|
+
splent_io/splent_feature_analytics/translations/messages.pot,sha256=hevR6VcU_tO95rjjqT4de-htqGJeNrxTS7diRnW0MBo,1277
|
|
9
|
+
splent_io/splent_feature_analytics/translations/es/LC_MESSAGES/messages.mo,sha256=mUdD0Nl73T2wUWZ2ty2ejkecSGAeFzZIh3W4Ij0AQWo,1095
|
|
10
|
+
splent_io/splent_feature_analytics/translations/es/LC_MESSAGES/messages.po,sha256=uh3vPirV9AfaQN5jmVspM6FxP0vdxkyNap0LzE3FBVo,1613
|
|
11
|
+
splent_feature_analytics-0.2.0.dist-info/METADATA,sha256=JVHp_a0mQkt9xadFrxRE1J2hmF4iKlLU6bHX18SNqw4,5000
|
|
12
|
+
splent_feature_analytics-0.2.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
13
|
+
splent_feature_analytics-0.2.0.dist-info/top_level.txt,sha256=nksrfdr_edPhGPUsCqz08kyNRLBkNc2sInZYzmbZ4TA,10
|
|
14
|
+
splent_feature_analytics-0.2.0.dist-info/RECORD,,
|