Skip to content

Commit

Permalink
fix: simple analytics (#98)
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowCrimsonGator authored Jan 30, 2024
1 parent fc38136 commit a37c48d
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions src/components/CookieConsent/index.jsx
Original file line number Diff line number Diff line change
@@ -1,32 +1,29 @@
import React from "react";
import { useCookies } from "react-cookie";
import CookieBanner from "./CookieBanner";
import Head from '@docusaurus/Head';
import useIsBrowser from '@docusaurus/useIsBrowser';

const COOKIES_CONSENT_NAME = "cookie-consent-given";
const COOKIES_CONSENT_VALUE = 1;

export default function CookiesConsent() {
if (typeof window === "undefined") return null;
const isBrowser = useIsBrowser();
if(!isBrowser) return null
const [cookies, setCookie] = useCookies();
const [consentGiven, setIsConsentGiven] = React.useState(
cookies?.[COOKIES_CONSENT_NAME] === COOKIES_CONSENT_VALUE
);

return consentGiven ? (
<>
<Head>
<script
async
defer
src="https://scripts.simpleanalyticscdn.com/latest.js"
></script>
<noscript>
<img
src="https://queue.simpleanalyticscdn.com/noscript.gif"
alt=""
referrerPolicy="no-referrer-when-downgrade"
/>
</noscript>
</>
<noscript>{`<img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt="" referrerPolicy="no-referrer-when-downgrade" />`}</noscript>
</Head>
) : (
<CookieBanner
onClick={() => {
Expand Down

0 comments on commit a37c48d

Please sign in to comment.