-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
13b150b
commit 1ce2d73
Showing
30 changed files
with
286 additions
and
553 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import Link from '@docusaurus/Link'; | ||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; | ||
import Cookies from 'js-cookie'; | ||
import { usePostHog } from 'posthog-js/react'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
export default function CookieConsent() { | ||
const { | ||
siteConfig: { | ||
customFields: { isDev, isProd, posthogProjectApiKey }, | ||
}, | ||
} = useDocusaurusContext(); | ||
const posthog = usePostHog(); | ||
const [showConsent, setShowConsent] = useState(false); | ||
|
||
useEffect(() => { | ||
if (posthog.has_opted_in_capturing()) { | ||
setShowConsent(false); | ||
} else { | ||
setShowConsent(Cookies.get('cookie_consent') !== 'false'); | ||
} | ||
|
||
if ( | ||
posthog.has_opted_in_capturing() || | ||
Cookies.get('cookie_consent') !== 'false' | ||
) { | ||
Cookies.remove('cookie_consent', { | ||
domain: isProd ? '.fix.security' : undefined, | ||
secure: !isDev, | ||
}); | ||
} | ||
}, [isDev, isProd, posthog]); | ||
|
||
if (!posthogProjectApiKey || !showConsent) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div | ||
style={{ | ||
pointerEvents: 'none', | ||
position: 'fixed', | ||
left: '0px', | ||
right: '0px', | ||
bottom: '0px', | ||
padding: '0 1.5rem 1.5rem', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
pointerEvents: 'auto', | ||
marginLeft: 'auto', | ||
maxWidth: '36rem', | ||
borderRadius: '0.75rem', | ||
backgroundColor: 'white', | ||
padding: '1.5rem', | ||
boxShadow: '0 0 0 1px var(--ifm-color-secondary)', | ||
}} | ||
> | ||
<p | ||
style={{ | ||
fontSize: '1rem', | ||
lineHeight: '1.5rem', | ||
}} | ||
> | ||
We use cookies and other tracking technologies to analyze site usage | ||
and assist in marketing efforts. For details, see our{' '} | ||
<Link href="https://fix.security/cookie-policy">cookie policy</Link>. | ||
</p> | ||
<div | ||
style={{ | ||
marginTop: '1rem', | ||
display: 'flex', | ||
alignItems: 'center', | ||
columnGap: '1.25rem', | ||
}} | ||
> | ||
<button | ||
className="button button--primary" | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
setShowConsent(false); | ||
posthog.opt_in_capturing({ enable_persistence: true }); | ||
}} | ||
> | ||
Accept | ||
</button> | ||
<button | ||
className="button button--primary button--outline" | ||
onClick={(e) => { | ||
e.preventDefault(); | ||
setShowConsent(false); | ||
Cookies.set('cookie_consent', 'false', { | ||
expires: isProd ? 30 : undefined, | ||
domain: isProd ? '.fix.security' : undefined, | ||
secure: !isDev, | ||
}); | ||
posthog.opt_out_capturing(); | ||
}} | ||
> | ||
Reject | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { useLocation } from '@docusaurus/router'; | ||
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'; | ||
import { usePostHog } from 'posthog-js/react'; | ||
import { useEffect } from 'react'; | ||
|
||
export default function PosthogPageView() { | ||
const { | ||
siteConfig: { | ||
customFields: { posthogProjectApiKey }, | ||
}, | ||
} = useDocusaurusContext(); | ||
const { pathname, search } = useLocation(); | ||
const posthog = usePostHog(); | ||
|
||
useEffect(() => { | ||
if (posthogProjectApiKey && pathname) { | ||
const url = `${window.origin}${pathname}${search}`; | ||
|
||
posthog.capture('$pageview', { | ||
$current_url: url, | ||
}); | ||
} | ||
}, [posthogProjectApiKey, pathname, search, posthog]); | ||
|
||
return null; | ||
} |
This file was deleted.
Oops, something went wrong.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.