Switch analytics privacy controls to opt-out

This commit is contained in:
achraf
2026-06-07 16:57:48 +02:00
parent 796fa7bb4b
commit 25b9f36686
10 changed files with 102 additions and 176 deletions

View File

@@ -1,20 +1,16 @@
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 interface AnalyticsPreferenceValue {
enabled: boolean;
disableAnalytics: () => void;
enableAnalytics: () => void;
toggleAnalytics: () => void;
}
export const AnalyticsConsentContext =
createContext<AnalyticsConsentValue | null>(null);
createContext<AnalyticsPreferenceValue | null>(null);
export function useAnalyticsConsent(): AnalyticsConsentValue {
export function useAnalyticsConsent(): AnalyticsPreferenceValue {
const context = useContext(AnalyticsConsentContext);
if (!context) {
throw new Error(