Initial Commit

This commit is contained in:
2026-05-27 23:47:53 +01:00
parent fbc70f96e6
commit 9b28db724f
18103 changed files with 1600554 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import type {
AnalyticsEvent,
ConsentPolicy,
} from "../types/analytics.types.js";
/**
* Permits every event. Default policy when none is supplied to the
* tracker.
*/
export class AllowAllPolicy implements ConsentPolicy {
public isAllowed(_event: AnalyticsEvent): boolean {
return true;
}
}
/**
* Honours the host's `Do Not Track` signal. Blocks every event when
* `navigator.doNotTrack === "1"`, otherwise permits every event. Reads
* the navigator lazily inside `isAllowed` so the policy is constructable
* in SSR / Node contexts where `navigator` does not exist.
*/
export class DoNotTrackPolicy implements ConsentPolicy {
public isAllowed(_event: AnalyticsEvent): boolean {
if (typeof navigator === "undefined") {
return true;
}
return navigator.doNotTrack !== "1";
}
}