Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data collection privacy opt-in/out #470

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
21 changes: 0 additions & 21 deletions website/assets/js/analytics.js → website/_includes/analytics.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,3 @@
function setCookie(name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + (days*24*60*60*1000));
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
}

function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}

function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
Expand Down
9 changes: 0 additions & 9 deletions website/_includes/clearbit.html

This file was deleted.

7 changes: 7 additions & 0 deletions website/_includes/clearbit.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
(function (d, u, h, s) {
h = d.getElementsByTagName("head")[0];
s = d.createElement("script");
s.async = 1;
s.src = u + new Date().getTime();
h.appendChild(s);
})(document, "https://grow.clearbitjs.com/api/pixel.js?v=");
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
<script src="https://cdn.jsdelivr.net/npm/@growthbook/growthbook/dist/bundles/index.js"></script>
<script>
var script = document.createElement("script")
script.id = "growthbookScript"
script.src = "https://cdn.jsdelivr.net/npm/@growthbook/growthbook/dist/bundles/index.js"
document.head.appendChild(script)

var script = document.querySelector("#growthbookScript");
script.addEventListener("load", function () {
// Uncomment for testing
//var earthlyID = uuidv4();
// var earthlyID = uuidv4();
var earthlyID = getAnalyticCookie();

// Create a GrowthBook instance
Expand Down Expand Up @@ -43,4 +48,4 @@
}*/
});
});
</script>
});
19 changes: 13 additions & 6 deletions website/_includes/head.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,19 @@
<script defer src="/assets/js/tabs.js"></script>
<script defer src="/assets/js/star-cta.js"></script>
<script defer src="/assets/js/button.js"></script>
<script src="/assets/js/analytics.js"></script>
<script src="/assets/js/utils.js"></script>

{% if jekyll.environment == "production" %}
{%- include segment.html -%}
<!-- {%- include growthbook.html -%} -->
{%- include clearbit.html -%}
{% endif %}
{%- include intercom.html -%}

</head>
<script>
var privacyPolicyCookie = getCookie("privacyPolicy");
if (privacyPolicyCookie == "true") {
{% include analytics.js %}
{% include clearbit.js %}
// {% include growthbook.js %}
{% include segment.js %}
}
</script>
{% endif %}
</head>
12 changes: 12 additions & 0 deletions website/_includes/intercom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!-- intercom start-->
<script>
window.intercomSettings = {
app_id: "e1503j4y"
};
</script>

<script>
// We pre-filled your app ID in the widget URL: 'https://widget.intercom.io/widget/e1503j4y'
(function(){var w=window;var ic=w.Intercom;if(typeof ic==="function"){ic('reattach_activator');ic('update',w.intercomSettings);}else{var d=document;var i=function(){i.c(arguments);};i.q=[];i.c=function(args){i.q.push(args);};w.Intercom=i;var l=function(){var s=d.createElement('script');s.type='text/javascript';s.async=true;s.src='https://widget.intercom.io/widget/e1503j4y';var x=d.getElementsByTagName('script')[0];x.parentNode.insertBefore(s,x);};if(w.attachEvent){w.attachEvent('onload',l);}else{w.addEventListener('load',l,false);}}})();
</script>
<!-- intercom end-->
43 changes: 43 additions & 0 deletions website/_includes/privacy-policy-box.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<div
id="privacy-policy-box"
class="bg-[#2c2b2b] border border-[#979797] fixed bottom-4 left-4 right-4 hidden max-w-xl px-9 py-8 rounded-[20px] z-50"
>
<p class="leading-7 sm:ml-3.5 text-white tracking-tight">
We care about your data, and we’d like to use cookies to make your
experience better.
<a class="underline" href="/privacy-policy">Privacy policy</a>
</p>

<div class="flex sm:ml-1.5 mt-9">
<button
class="w-[166px] bg-[#2d7e5d] cursor-pointer py-2 rounded-lg text-center text-lg text-white"
onclick="handleClick(true)"
>
Okay!
</button>

<button
class="w-[166px] border border-[#979797] cursor-pointer ml-4 py-2 rounded-lg text-center text-lg text-white"
onclick="handleClick(false)"
>
No, thanks
</button>
</div>
</div>

<script>
$(document).ready(function () {
var privacyPolicyCookie = getCookie("privacyPolicy");
if (privacyPolicyCookie != "true") {
$("#privacy-policy-box").removeClass("hidden");
}
});

function handleClick(accepted) {
$("#privacy-policy-box").addClass("hidden");
if (accepted) {
setCookie("privacyPolicy", accepted, 365);
location.reload();
}
}
</script>
6 changes: 0 additions & 6 deletions website/_includes/segment.html

This file was deleted.

4 changes: 4 additions & 0 deletions website/_includes/segment.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions website/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</main>

{% include home/v2/footer.html %}
{% include privacy-policy-box.html %}
</body>

</html>
2 changes: 1 addition & 1 deletion website/assets/css/index.46bb9c26.css

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions website/assets/js/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function getCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(";");
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == " ") c = c.substring(1, c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
}
return null;
}

function setCookie(name, value, days) {
var expires = "";
if (days) {
var date = new Date();
date.setTime(date.getTime() + days * 24 * 60 * 60 * 1000);
expires = "; expires=" + date.toUTCString();
}
document.cookie = name + "=" + (value || "") + expires + "; path=/";
}