Skip to main content

Module analytics

Module analytics 

Source
Expand description

First-party proxies for Plausible and the Sentry browser SDK.

Both vendors’ own origins are on blocklists, and a blocked request is a visitor you never counted or an error you never saw. Serving their scripts and receiving their payloads from this origin makes the traffic same-origin, which is what Plausible themselves recommend.

Nothing here interprets a payload — see [proxy] for why that matters.

Structs§

AnalyticsConfig
Which Plausible site events belong to.
SentryDsn
A parsed Sentry DSN.
SentryDsnParseError
Why a DSN could not be understood.

Constants§

CLIENT_IP_HEADERS
Headers consulted for the client’s real address, most trusted first. The socket address is the fallback: always present, but behind a proxy it is the proxy.
ENV_ANALYTICS_ID
The environment variable holding the Plausible script id.
ENV_SENTRY_BROWSER_DSN
The environment variable holding the browser Sentry DSN.
PLAUSIBLE_HOST
Plausible’s script host.
SENTRY_CDN_HOST
Sentry’s loader-script CDN.

Functions§

relay_envelope
Relays a Sentry envelope verbatim.
relay_event
Forwards a Plausible event, carrying the real visitor IP.
relay_script
Fetches an upstream script and returns it with the upstream’s own headers.
resolve_true_client_ip_address
Resolves the client’s address, preferring proxy headers over the socket.