Skip to content

Commit

Permalink
refactor: protection provider
Browse files Browse the repository at this point in the history
  • Loading branch information
janndriessen committed Oct 17, 2023
1 parent 12f56e6 commit af6b5a2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/lib/providers/Protection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const useProtection = () => useContext(ProtectionContext)
export const ProtectionProvider = (props: { children: any }) => {
const [isProtectable, setIsProtectable] = useState<boolean>()

const checkIfProtectable = useCallback(async () => {
const checkIfProtectable = async () => {
const API_KEY =
process.env.NEXT_PUBLIC_IP_LOOKUP_KEY ?? 'vN8S4cMfz4KPoq5eLx3X'
fetch('https://extreme-ip-lookup.com/json/?key=' + API_KEY)
Expand All @@ -31,13 +31,16 @@ export const ProtectionProvider = (props: { children: any }) => {
error
)
})
}, [])
}

useEffect(() => {
checkIfProtectable()
logEvent('US_IP_CHECK', { USA_IP: isProtectable })
}, [])

useEffect(() => {
logEvent('US_IP_CHECK', { USA_IP: isProtectable })
}, [isProtectable])

return (
<ProtectionContext.Provider
value={{
Expand Down

0 comments on commit af6b5a2

Please sign in to comment.