1
0
mirror of https://github.com/XFox111/my-website.git synced 2026-04-22 07:28:01 +03:00

fix: cookie consent tracking breaks when CDN caching is involved

This commit is contained in:
2024-10-24 16:20:34 +00:00
parent 5a4b67d83e
commit f2e985cfea
5 changed files with 25 additions and 21 deletions
+1 -9
View File
@@ -1,5 +1,4 @@
import { unstable_noStore } from "next/cache";
import { headers } from "next/headers";
/**
* Check if Clarity is enabled
@@ -15,15 +14,8 @@ export const analyticsEnabled = (): boolean =>
* Check if Clarity requires explicit consent
* @returns true if Clarity requires explicit consent
*/
export const requireExcplicitConsent = (): boolean =>
export const requireExplicitConsent = (): boolean =>
{
unstable_noStore();
return process.env.CLARITY_CONSENT === "1";
};
/**
* Check if Clarity is enabled and the browser didn't send a DNT signal
* @returns true if Clarity is enabled and the browser didn't send a DNT signal
*/
export const canLoadAnalytics = (): boolean =>
analyticsEnabled() && headers().get("Dnt") !== "1";