Skip to content
19 linesCodeBlameRaw

Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.

Analytics asks first in the EU, EEA, UK and Switzerland, and loads only when the page is idle1import assert from "node:assert/strict";
2import { test } from "node:test";
3
4import { asksFirst, choice, consentRequired } from "./analytics-consent.ts";
5
6test("visitors from the EU, EEA, UK and Switzerland are asked first", () => {
7 for (const country of ["DE", "fr", "IE", "NO", "IS", "GB", "CH"]) assert.equal(asksFirst(country), true, country);
8});
9
10test("others are not, nor is a visitor whose country is unknown", () => {
11 for (const country of ["US", "CA", "AU", "JP", "BR"]) assert.equal(asksFirst(country), false, country);
12 assert.equal(asksFirst(null), false);
13 assert.equal(asksFirst(""), false);
14});
15
16test("on the server nothing is chosen or required", () => {
17 assert.equal(choice(), null);
18 assert.equal(consentRequired(), false);
19});