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

refactor: moved analytics checks to a separate file

This commit is contained in:
2024-08-21 00:18:17 +00:00
parent 272049c71a
commit d7500e861c
4 changed files with 20 additions and 3 deletions
+14
View File
@@ -0,0 +1,14 @@
import { headers } from "next/headers";
/**
* Check if Clarity is enabled
* @returns true if Clarity is enabled
*/
export const analyticsEnabled = (): boolean => !!process.env.CLARITY_ID;
/**
* 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";