Add consent-first analytics privacy controls

This commit is contained in:
achraf
2026-06-07 16:11:21 +02:00
parent aa44f6c105
commit 0b2d38ee5e
15 changed files with 492 additions and 24 deletions

View File

@@ -0,0 +1,25 @@
import { createContext, useContext } from "react";
export type ConsentChoice = "pending" | "granted" | "denied";
export interface AnalyticsConsentValue {
choice: ConsentChoice;
isSettingsOpen: boolean;
accept: () => void;
reject: () => void;
openSettings: () => void;
closeSettings: () => void;
}
export const AnalyticsConsentContext =
createContext<AnalyticsConsentValue | null>(null);
export function useAnalyticsConsent(): AnalyticsConsentValue {
const context = useContext(AnalyticsConsentContext);
if (!context) {
throw new Error(
"useAnalyticsConsent must be used inside AnalyticsConsentProvider."
);
}
return context;
}