pounce/frontend/src/components/ReferralCapture.tsx
Yves Gugger bb7ce97330
Some checks failed
CI / Frontend Lint & Type Check (push) Has been cancelled
CI / Frontend Build (push) Has been cancelled
CI / Backend Lint (push) Has been cancelled
CI / Backend Tests (push) Has been cancelled
CI / Docker Build (push) Has been cancelled
CI / Security Scan (push) Has been cancelled
Deploy / Build & Push Images (push) Has been cancelled
Deploy / Deploy to Server (push) Has been cancelled
Deploy / Notify (push) Has been cancelled
Deploy: referral rewards antifraud + legal contact updates
2025-12-15 13:56:43 +01:00

32 lines
762 B
TypeScript

'use client'
import { useEffect } from 'react'
function readQueryRef(): string | null {
try {
const url = new URL(window.location.href)
return url.searchParams.get('ref')
} catch {
return null
}
}
function setReferralCookie(code: string) {
const normalized = code.trim().toLowerCase()
// Accept only our invite codes (12 hex chars) to avoid storing garbage.
if (!/^[0-9a-f]{12}$/.test(normalized)) return
const maxAgeSeconds = 60 * 60 * 24 * 30 // 30 days
document.cookie = `pounce_ref=${encodeURIComponent(normalized)}; Max-Age=${maxAgeSeconds}; Path=/; SameSite=Lax`
}
export default function ReferralCapture() {
useEffect(() => {
const ref = readQueryRef()
if (ref) setReferralCookie(ref)
}, [])
return null
}