diff --git a/frontend/src/core/components/AppProviders.tsx b/frontend/src/core/components/AppProviders.tsx
index 88093d84b7..e65388ada7 100644
--- a/frontend/src/core/components/AppProviders.tsx
+++ b/frontend/src/core/components/AppProviders.tsx
@@ -17,7 +17,6 @@ import { TourOrchestrationProvider } from "@app/contexts/TourOrchestrationContex
import { AdminTourOrchestrationProvider } from "@app/contexts/AdminTourOrchestrationContext";
import { PageEditorProvider } from "@app/contexts/PageEditorContext";
import { BannerProvider } from "@app/contexts/BannerContext";
-import { CookieConsentProvider } from "@app/contexts/CookieConsentContext";
import ErrorBoundary from "@app/components/shared/ErrorBoundary";
import { useScarfTracking } from "@app/hooks/useScarfTracking";
import { useAppInitialization } from "@app/hooks/useAppInitialization";
@@ -83,12 +82,11 @@ export function AppProviders({ children, appConfigRetryOptions, appConfigProvide
retryOptions={appConfigRetryOptions}
{...appConfigProviderProps}
>
-
-
-
-
-
-
+
+
+
+
+
@@ -114,7 +112,6 @@ export function AppProviders({ children, appConfigRetryOptions, appConfigProvide
-
diff --git a/frontend/src/core/components/onboarding/hooks/useOnboardingFlow.ts b/frontend/src/core/components/onboarding/hooks/useOnboardingFlow.ts
index b2b97b2a33..139e2b58a4 100644
--- a/frontend/src/core/components/onboarding/hooks/useOnboardingFlow.ts
+++ b/frontend/src/core/components/onboarding/hooks/useOnboardingFlow.ts
@@ -1,7 +1,6 @@
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { usePreferences } from '@app/contexts/PreferencesContext';
import { useAppConfig } from '@app/contexts/AppConfigContext';
-import { useCookieConsentContext } from '@app/contexts/CookieConsentContext';
import { useOnboarding } from '@app/contexts/OnboardingContext';
import type { LicenseNotice } from '@app/types/types';
import { useNavigate, useLocation } from 'react-router-dom';
@@ -39,7 +38,6 @@ interface ServerLicenseModalHandlers {
export function useOnboardingFlow() {
const { preferences, updatePreference } = usePreferences();
const { config, loading: configLoading } = useAppConfig();
- const { showCookieConsent, isReady: isCookieConsentReady } = useCookieConsentContext();
const { completeTour, tourType, isOpen } = useOnboarding();
const location = useLocation();
@@ -71,7 +69,6 @@ export function useOnboardingFlow() {
isOverLimit: false,
requiresLicense: false,
});
- const [cookieBannerPending, setCookieBannerPending] = useState(false);
const [serverLicenseIntent, setServerLicenseIntent] = useState<'idle' | 'pending' | 'deferred'>('idle');
const [serverLicenseSource, setServerLicenseSource] = useState<'config' | 'self-reported' | null>(null);
const [isServerLicenseOpen, setIsServerLicenseOpen] = useState(false);
@@ -97,29 +94,6 @@ export function useOnboardingFlow() {
setToolPromptCompleted(true);
}, []);
- const maybeShowCookieBanner = useCallback(() => {
- if (preferences.hasSeenCookieBanner) {
- return;
- }
-
- if (!isCookieConsentReady || isServerLicenseOpen || serverLicenseIntent !== 'idle' || !toolPromptCompleted) {
- setCookieBannerPending(true);
- return;
- }
-
- setCookieBannerPending(false);
- showCookieConsent();
- updatePreference('hasSeenCookieBanner', true);
- }, [
- isCookieConsentReady,
- isServerLicenseOpen,
- preferences.hasSeenCookieBanner,
- serverLicenseIntent,
- showCookieConsent,
- toolPromptCompleted,
- updatePreference,
- ]);
-
const requestServerLicense = useCallback(
({
deferUntilTourComplete = false,
@@ -191,25 +165,6 @@ export function useOnboardingFlow() {
};
}, [requestServerLicense]);
- useEffect(() => {
- if (
- cookieBannerPending &&
- isCookieConsentReady &&
- serverLicenseIntent === 'idle' &&
- !isServerLicenseOpen &&
- toolPromptCompleted
- ) {
- maybeShowCookieBanner();
- }
- }, [
- cookieBannerPending,
- isCookieConsentReady,
- isServerLicenseOpen,
- serverLicenseIntent,
- toolPromptCompleted,
- maybeShowCookieBanner,
- ]);
-
useEffect(() => {
const isEligibleAdmin =
isAdminUser || serverLicenseSource === 'self-reported' || licenseNotice.requiresLicense;
@@ -269,8 +224,7 @@ export function useOnboardingFlow() {
setHasShownServerLicense(true);
setServerLicenseIntent('idle');
setServerLicenseSource(null);
- maybeShowCookieBanner();
- }, [maybeShowCookieBanner]);
+ }, []);
useEffect(() => {
if (onboardingSessionMarkedRef.current) {
@@ -309,11 +263,9 @@ export function useOnboardingFlow() {
setServerLicenseSource((prev) => prev ?? (isAdminUser ? 'config' : 'self-reported'));
setServerLicenseIntent((prev) => (prev === 'pending' ? prev : 'pending'));
}
- maybeShowCookieBanner();
}, [
completeTour,
isAdminUser,
- maybeShowCookieBanner,
serverLicenseIntent,
serverLicenseSource,
tourType,
diff --git a/frontend/src/core/components/shared/Footer.tsx b/frontend/src/core/components/shared/Footer.tsx
index 07b5213baf..52ee4165b6 100644
--- a/frontend/src/core/components/shared/Footer.tsx
+++ b/frontend/src/core/components/shared/Footer.tsx
@@ -1,6 +1,6 @@
import { Flex } from '@mantine/core';
import { useTranslation } from 'react-i18next';
-import { useCookieConsentContext } from '@app/contexts/CookieConsentContext';
+import { useCookieConsent } from '@app/hooks/useCookieConsent';
interface FooterProps {
privacyPolicy?: string;
@@ -20,7 +20,7 @@ export default function Footer({
analyticsEnabled = false
}: FooterProps) {
const { t } = useTranslation();
- const { showCookiePreferences } = useCookieConsentContext();
+ const { showCookiePreferences } = useCookieConsent({ analyticsEnabled });
// Helper to check if a value is valid (not null/undefined/empty string)
const isValidLink = (link?: string) => link && link.trim().length > 0;
diff --git a/frontend/src/core/contexts/CookieConsentContext.tsx b/frontend/src/core/contexts/CookieConsentContext.tsx
deleted file mode 100644
index 530f99a2a3..0000000000
--- a/frontend/src/core/contexts/CookieConsentContext.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import React, { createContext, useContext, useMemo } from 'react';
-import { useCookieConsent } from '@app/hooks/useCookieConsent';
-import { useAppConfig } from '@app/contexts/AppConfigContext';
-
-interface CookieConsentContextValue {
- isReady: boolean;
- showCookieConsent: () => void;
- showCookiePreferences: () => void;
- hasResponded: boolean;
-}
-
-const CookieConsentContext = createContext(undefined);
-
-export const CookieConsentProvider: React.FC<{ children: React.ReactNode }> = ({ children }) => {
- const { config } = useAppConfig();
- const analyticsEnabled = config ? config.enableAnalytics !== false : false;
- const {
- showCookieConsent,
- showCookiePreferences,
- isInitialized,
- hasResponded,
- } = useCookieConsent({ analyticsEnabled });
-
- const value = useMemo(() => ({
- isReady: analyticsEnabled && isInitialized,
- showCookieConsent,
- showCookiePreferences,
- hasResponded,
- }), [analyticsEnabled, hasResponded, isInitialized, showCookieConsent, showCookiePreferences]);
-
- return (
-
- {children}
-
- );
-};
-
-export const useCookieConsentContext = (): CookieConsentContextValue => {
- const context = useContext(CookieConsentContext);
- if (!context) {
- throw new Error('useCookieConsentContext must be used within a CookieConsentProvider');
- }
- return context;
-};
-
diff --git a/frontend/src/core/hooks/useCookieConsent.ts b/frontend/src/core/hooks/useCookieConsent.ts
index 881215a34e..29eb6d550f 100644
--- a/frontend/src/core/hooks/useCookieConsent.ts
+++ b/frontend/src/core/hooks/useCookieConsent.ts
@@ -241,11 +241,17 @@ export const useCookieConsent = ({
};
}, [analyticsEnabled, config?.enablePosthog, config?.enableScarf, t]);
- const showCookiePreferences = () => {
+ const showCookieConsent = useCallback(() => {
+ if (isInitialized && window.CookieConsent) {
+ window.CookieConsent?.show();
+ }
+ }, [isInitialized]);
+
+ const showCookiePreferences = useCallback(() => {
if (isInitialized && window.CookieConsent) {
window.CookieConsent?.show(true);
}
- };
+ }, [isInitialized]);
const isServiceAccepted = useCallback((service: string, category: string): boolean => {
if (typeof window === 'undefined' || !window.CookieConsent) {
@@ -255,7 +261,9 @@ export const useCookieConsent = ({
}, []);
return {
+ showCookieConsent,
showCookiePreferences,
- isServiceAccepted
+ isServiceAccepted,
+ isInitialized,
};
};
diff --git a/frontend/src/core/pages/HomePage.tsx b/frontend/src/core/pages/HomePage.tsx
index e03f46ee2d..04174d29a0 100644
--- a/frontend/src/core/pages/HomePage.tsx
+++ b/frontend/src/core/pages/HomePage.tsx
@@ -9,7 +9,6 @@ import { useIsMobile } from "@app/hooks/useIsMobile";
import { useAppConfig } from "@app/contexts/AppConfigContext";
import { useLogoPath } from "@app/hooks/useLogoPath";
import { useLogoAssets } from '@app/hooks/useLogoAssets';
-import { useCookieConsentContext } from "@app/contexts/CookieConsentContext";
import { useFileContext } from "@app/contexts/file/fileHooks";
import { useNavigationActions } from "@app/contexts/NavigationContext";
import { useViewer } from "@app/contexts/ViewerContext";
@@ -49,7 +48,6 @@ export default function HomePage() {
const { openFilesModal } = useFilesModalContext();
const { colorScheme } = useMantineColorScheme();
const { config } = useAppConfig();
- const { hasResponded: cookieConsentResponded } = useCookieConsentContext();
const isMobile = useIsMobile();
const sliderRef = useRef(null);
const [activeMobileView, setActiveMobileView] = useState("tools");
@@ -64,10 +62,10 @@ export default function HomePage() {
// Show admin analytics choice modal if analytics settings not configured
useEffect(() => {
- if (config && config.enableAnalytics === null && cookieConsentResponded) {
+ if (config && config.enableAnalytics === null) {
setShowAnalyticsModal(true);
}
- }, [config, cookieConsentResponded]);
+ }, [config]);
// Auto-switch to viewer when going from 0 to 1 file
useEffect(() => {
diff --git a/frontend/src/proprietary/components/shared/UpgradeBanner.tsx b/frontend/src/proprietary/components/shared/UpgradeBanner.tsx
index 4b325106b0..c71546d3ac 100644
--- a/frontend/src/proprietary/components/shared/UpgradeBanner.tsx
+++ b/frontend/src/proprietary/components/shared/UpgradeBanner.tsx
@@ -1,7 +1,6 @@
import React, { useState, useEffect, useCallback } from 'react';
import { useTranslation } from 'react-i18next';
import { useNavigate } from 'react-router-dom';
-import { useCookieConsentContext } from '@app/contexts/CookieConsentContext';
import { useOnboarding } from '@app/contexts/OnboardingContext';
import { useCheckout } from '@app/contexts/CheckoutContext';
import { InfoBanner } from '@app/components/shared/InfoBanner';
@@ -22,7 +21,6 @@ const WEEK_IN_MS = 7 * 24 * 60 * 60 * 1000;
const UpgradeBanner: React.FC = () => {
const { t } = useTranslation();
const navigate = useNavigate();
- const { hasResponded: cookieChoiceMade } = useCookieConsentContext();
const { isOpen: tourOpen } = useOnboarding();
const { openCheckout } = useCheckout();
const {
@@ -159,7 +157,6 @@ const UpgradeBanner: React.FC = () => {
shouldShowFriendlyBase &&
!licenseLoading &&
effectiveTotalUsersLoaded &&
- cookieChoiceMade &&
!tourOpen &&
!sessionBlocked,
);
@@ -168,7 +165,6 @@ const UpgradeBanner: React.FC = () => {
: Boolean(
shouldShowUrgentBase &&
!licenseLoading &&
- cookieChoiceMade &&
!tourOpen &&
!sessionBlocked,
);