Skip to content

Serve the web tracker from a versioned URL so it can be pinned with SRI #715

Backlog

Description

@govanalytics

Context

We load the web tracker from the collector's own endpoint (/d/wt.min.js on a first-party tracking domain, CNAME to d8a) instead of jsDelivr. For public-sector sites this is the preferred setup: first-party, no third-party CDN in the CSP.

The downside is that /d/wt.min.js has no version in the path. The file is embedded in the server binary (pkg/protocol/d8a/protocol.go, //go:embed static/wt.min.js), so it changes with every server release, without notice to the sites that load it.

Problem

  1. No Subresource Integrity possible. An integrity hash on /d/wt.min.js breaks tracking on every site as soon as the server is updated. So today we load it without SRI.
  2. No control over which tracker runs. A tracker change goes live on all sites at once, without a chance to test it first. Our implementation has a privacy layer around the tracker (URL and query parameter scrubbing); a change in tracker behaviour can bypass it without us noticing.
  3. The served file doesn't identify its version. The file served today reports _dtv = "dev-26-09", while the server runs a v1.5.x release, and the bytes don't match any published @d8a-tech/wt npm release. There are no ETag, Last-Modified or version headers either. So we can't tell which tracker version is live, or when it changed.

Proposal

Any of these would solve it, in order of preference:

  1. Versioned path next to the current one, for example /d/wt.1.5.4.min.js or /d/1.5.4/wt.min.js, kept available for at least a few releases after a new one ships. /d/wt.min.js stays as the "latest" alias.
  2. Release builds only: the embedded tracker is built from the tagged @d8a-tech/wt release, _dtv reports that release version, and the SHA-384 hash is listed in the release notes.
  3. Version header on /d/wt.min.js (for example X-D8a-Tracker-Version) plus an ETag, so changes can at least be detected and monitored.

Also helpful: a short note in the release notes whenever the embedded tracker changes behaviour.

Why it matters

With a versioned URL we can pin the tracker with SRI, test a new version before switching, and roll out per site. That is what government CSP and security reviews ask for.

Happy to test a build against our test kit (Playwright e2e, 46 checks) before release.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions