@prunellejs/analytics 0.7.4 → 0.8.0
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.
- package/llms.txt +1 -1
- package/package.json +2 -2
- package/src/providers.ts +3 -1
package/llms.txt
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
|
|
12
12
|
Register in `prunelle.config.ts` `plugins`:
|
|
13
13
|
|
|
14
|
-
- `provider`: `plausible({ domain, host? })`, `umami({ websiteId, host })`, `matomo({ url, siteId, tokenAuth? })`, or `custom({ sendPageview, sendEvent?, sendVital?, requiresConsent? })`. `plausible()` defaults to `requiresConsent: true` for `plausible.io` and `false` for a self-hosted host; `umami()` and `matomo()` default to `true` unless their host is the app's own (the `site` host, a subdomain of it, or loopback), and `custom()` to `true`. `requiresConsent: false` is the explicit waiver, for a tool that meets the CNIL conditions (publisher alone, anonymous, no cross-site tracking). Providers receive a User-Agent cut to major versions and 160 characters.
|
|
14
|
+
- `provider`: `plausible({ domain, host? })`, `umami({ websiteId, host })`, `matomo({ url, siteId, tokenAuth? })`, or `custom({ sendPageview, sendEvent?, sendVital?, requiresConsent? })`. `plausible()` defaults to `requiresConsent: true` for `plausible.io` and `false` for a self-hosted host; `umami()` and `matomo()` default to `true` unless their host is the app's own (the `site` host, a subdomain of it, or loopback), and `custom()` to `true`. `requiresConsent: false` is the explicit waiver, for a tool that meets the CNIL conditions (publisher alone, anonymous, no cross-site tracking). Providers receive a User-Agent cut to major versions and 160 characters. Without `sendIp`, `plausible()` appends `pru-visitor/<16 hex of the daily visitorId>` to it, so Plausible (which hashes IP, user agent and domain) counts visitors apart without an IP; no country then.
|
|
15
15
|
- Counts both dynamic and prerendered HTML GET 2xx page views via `api.use(mw, { scope: 'all' })` with **0 B client JS** (never sets `clientEntry`). Automatically skips non-GET, non-2xx/non-HTML, `/_pru/` assets, `/auth` and `/auth/*` paths, bots, and prefetch requests (`Purpose: prefetch`, as `@prunellejs/spa` sends, and the browsers' own headers). Strips query strings and fragments from `url` and `referrer` by default (pass `includeQueryParams: ['utm_source', ...]` to allowlist specific query params).
|
|
16
16
|
- `secret`: optional hash salt (defaults to `process.env.ANALYTICS_SECRET` or a random ephemeral per-process 32-byte secret). Visitor ID is `SHA-256(YYYY-MM-DD, secret, ip, userAgent, hostname)` — daily-rotating, no cookies, no persistent storage.
|
|
17
17
|
- `sendIp`: default `false`. Raw client IP is NEVER forwarded to providers unless `sendIp: true`.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prunellejs/analytics",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "CNIL-compliant server-side first-party audience measurement, custom events, and optional Web Vitals plugin for Prunelle",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -22,6 +22,6 @@
|
|
|
22
22
|
"directory": "packages/plugin-analytics"
|
|
23
23
|
},
|
|
24
24
|
"peerDependencies": {
|
|
25
|
-
"prunelle": "^0.
|
|
25
|
+
"prunelle": "^0.8.0"
|
|
26
26
|
}
|
|
27
27
|
}
|
package/src/providers.ts
CHANGED
|
@@ -105,9 +105,11 @@ export function plausible(options: PlausibleOptions): AnalyticsProvider {
|
|
|
105
105
|
item: AnalyticsPageview | AnalyticsEvent,
|
|
106
106
|
props?: AnalyticsEvent['props'],
|
|
107
107
|
): Promise<void> => {
|
|
108
|
+
const userAgent = item.userAgent ?? DEFAULT_USER_AGENT
|
|
108
109
|
const headers: Record<string, string> = {
|
|
109
110
|
'content-type': 'application/json',
|
|
110
|
-
|
|
111
|
+
// Plausible hashes IP + user agent + domain, and without an IP every visitor reaches it from this server. The daily-rotating visitor id, already no more than a hash, keeps them apart.
|
|
112
|
+
'user-agent': item.ip === undefined ? `${userAgent} pru-visitor/${item.visitorId.slice(0, 16)}` : userAgent,
|
|
111
113
|
'x-visitor-id': item.visitorId,
|
|
112
114
|
}
|
|
113
115
|
if (item.ip !== undefined)
|