@@ -6,8 +6,9 @@ import {useEventState} from "../../../../state/Event/useEventState.ts";
66import { useVisitIntentState } from "../../../../state/Intent/useVisitIntentState.ts" ;
77import { useAddToCart } from "../../../../hooks/domain/useAddToCart.tsx" ;
88import { useDashboardState } from "../../../../state/Dashboard/useDashboardState.ts" ;
9- import { getCloudflareSiteKey } from "../../../../security/turnstileService.ts" ;
109import { Turnstile } from "../../../../security/Turnstile.tsx" ;
10+ import { useSystemState } from "../../../../state/System/useSystemState.ts" ;
11+ import { activity } from "../../../../../activity" ;
1112
1213interface AddToCartProps {
1314 onRequireAuth : ( ) => void
@@ -19,7 +20,7 @@ export function AddToCart({onRequireAuth}: AddToCartProps) {
1920 const { visitIntent } = useVisitIntentState ( ) ;
2021 const { addToCart, loadingAddToCart, errorAddToCart } = useAddToCart ( ) ;
2122 const { increaseVersionNumber, setLastBookedEventId } = useDashboardState ( ) ;
22- const turnstileEnabled = Boolean ( getCloudflareSiteKey ( ) ) ;
23+ const { cloudflareKey , isTurnstileEnabled } = useSystemState ( )
2324 const [ verifiedAt , setVerifiedAt ] = useState < number | null > ( null ) ;
2425 const [ awaitingSecurity , setAwaitingSecurity ] = useState ( false ) ;
2526 const [ turnstileToken , setTurnstileToken ] = useState < string | null > ( null ) ;
@@ -29,6 +30,13 @@ export function AddToCart({onRequireAuth}: AddToCartProps) {
2930 verifiedAt &&
3031 Date . now ( ) - verifiedAt < 1000 * 90 ; // 90s safety window
3132
33+ activity ( 'add-to-cart' , 'Add To Cart Data' , {
34+ cloudflareKey,
35+ turnstileToken,
36+ turnstileEnabled : isTurnstileEnabled ( ) ,
37+ isHumanVerified
38+ } ) ;
39+
3240 const refreshDashboard = ( ) => {
3341 increaseVersionNumber ( )
3442 if ( eventState . activeEventId ) setLastBookedEventId ( eventState . activeEventId )
@@ -126,9 +134,9 @@ export function AddToCart({onRequireAuth}: AddToCartProps) {
126134 >
127135 Book{ loadingAddToCart && 'ing' } appointment+-
128136 </ button >
129- { turnstileEnabled && (
137+ { isTurnstileEnabled ( ) && (
130138 < Turnstile
131- siteKey = { getCloudflareSiteKey ( ) }
139+ siteKey = { cloudflareKey }
132140 containerId = "booking-turnstile"
133141 />
134142 ) }
0 commit comments