Content-Security-Policy header (or a <meta http-equiv> policy), the browser
blocks the tracker unless the policy allows the gateway. Tested by the static example, whose server
sends the policy below with every page; the browser matrix runs all its pages under it and checks
that nothing is blocked.
What the tracker needs
Nothing else: the tracker needs no inline script, no
eval, no style, no image, no frame and no
worker. It uses WebCrypto in the page itself for the challenge.
The tested policy
The example builds its policy from the gateway origin:Notes
- Self-hosted
sdk.js(self-hosting.md):script-srcthen needs your own origin ('self') instead of the gateway, andconnect-srcstill needs the gateway. - Nonces and
'strict-dynamic'. With a nonce-based policy, give the tag your nonce attribute; with'strict-dynamic', host entries inscript-srcare ignored, so the nonce is required. These variants were not tested. - Page code that calls
umami.track()must itself be allowed by the policy. The example keeps it in a file of its own (page.js) so that no inline script is needed. - Integrity is separate. The
integrityattribute is checked whatever the policy says; a CSP does not replace it, and it does not replace a CSP.
What the browser tests check
The test page listens forsecuritypolicyviolation events, loads the home page with the policy
above, sends a pageview and both kinds of custom event, and requires that no violation was reported
and every event arrived, in Chromium, Firefox and WebKit (tests/e2e/specs/onboarding.spec.ts).