Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Feat/privacy settings (#17896)

Francesco Sansalvadorea9abe79d5613
diff --git a/apps/docs/components/Navigation/Footer.tsx b/apps/docs/components/Navigation/Footer.tsx
index ebcd7204c62..b18b0880b74 100644
--- a/apps/docs/components/Navigation/Footer.tsx
+++ b/apps/docs/components/Navigation/Footer.tsx
@@ -8,7 +8,7 @@ const Footer = () => (
<div className="mt-16">
<ul className="flex flex-col gap-2">
{primaryLinks.map(({ url, featherIcon: Icon, icon, text, ctaLabel }) => (
- <li key={url} className="flex items-center gap-1 text-xs text-scale-900">
+ <li key={url} className="flex items-center gap-1 text-xs text-lighter">
{icon && (
<svg
width="16"
@@ -37,18 +37,24 @@ const Footer = () => (
))}
</ul>
</div>
- <hr className="border-scale-400 my-6"></hr>
+ <hr className="border-border my-6"></hr>
<div className="flex gap-4 items-center justify-between">
<div className="flex flex-col lg:flex-row gap-3 ">
<Link href="https://supabase.com/">
- <a className="text-xs text-scale-900">&copy; Supabase Inc</a>
+ <a className="text-xs text-lighter">&copy; Supabase Inc</a>
</Link>
- <span className="text-xs text-scale-900">—</span>
- {secondaryLinks.map((item) => (
- <Link href={item.url} key={item.url}>
- <a className="text-xs text-scale-800 hover:underline">{item.title}</a>
- </Link>
- ))}
+ <span className="text-xs text-lighter">—</span>
+ {secondaryLinks.map(({ component: Component, ...item }) =>
+ item.url ? (
+ <Link href={item.url} key={item.url}>
+ <a className="text-xs text-lighter hover:underline">{item.title}</a>
+ </Link>
+ ) : (
+ Component && (
+ <Component className="text-xs text-lighter hover:underline">{item.title}</Component>
+ )
+ )
+ )}
</div>
<div className="flex items-center gap-2">
<Button type="text" asChild>
diff --git a/apps/docs/data/footer.ts b/apps/docs/data/footer.ts
index 05004527be4..1ce0b5b161d 100644
--- a/apps/docs/data/footer.ts
+++ b/apps/docs/data/footer.ts
@@ -1,4 +1,4 @@
-import { IconCheckCircle, IconLifeBuoy } from '~/../../packages/ui'
+import { IconCheckCircle, IconLifeBuoy, PrivacySettings } from '~/../../packages/ui'
export const primaryLinks = [
{
@@ -29,4 +29,5 @@ export const secondaryLinks = [
},
{ title: 'Open Source', url: 'https://supabase.com/open-source' },
{ title: 'SupaSquad', url: 'https://supabase.com/supasquad' },
+ { title: 'Privacy Settings', component: PrivacySettings },
]
diff --git a/apps/www/components/Footer/index.tsx b/apps/www/components/Footer/index.tsx
index 20669551d73..1e36be4625d 100644
--- a/apps/www/components/Footer/index.tsx
+++ b/apps/www/components/Footer/index.tsx
@@ -1,15 +1,15 @@
-import FooterLinks from 'data/Footer.json'
-import SectionContainer from '../Layouts/SectionContainer'
import Link from 'next/link'
import { useTheme } from 'next-themes'
-import { Badge, IconChevronRight, TextLink } from 'ui'
+import { Badge } from 'ui'
import Image from 'next/image'
-import * as supabaseLogoWordmarkDark from 'common/assets/images/supabase-logo-wordmark--dark.png'
-import * as supabaseLogoWordmarkLight from 'common/assets/images/supabase-logo-wordmark--light.png'
import { useRouter } from 'next/router'
-import { Fragment } from 'react'
import ThemeToggle from '@ui/components/ThemeProvider/ThemeToggle'
import { CheckIcon } from '@heroicons/react/outline'
+import SectionContainer from '../Layouts/SectionContainer'
+
+import footerData from 'data/Footer'
+import * as supabaseLogoWordmarkDark from 'common/assets/images/supabase-logo-wordmark--dark.png'
+import * as supabaseLogoWordmarkLight from 'common/assets/images/supabase-logo-wordmark--light.png'
interface Props {
className?: string
@@ -23,7 +23,7 @@ const Footer = (props: Props) => {
return (
<footer
- className={['border-scale-500 dark:border-scale-600 border-t', props.className].join(' ')}
+ className={['border-border border-t', props.className].join(' ')}
aria-labelledby="footerHeading"
>
<h2 id="footerHeading" className="sr-only">
@@ -72,7 +72,7 @@ const Footer = (props: Props) => {
<div className="flex space-x-5">
<a
href="https://twitter.com/supabase"
- className="text-scale-900 hover:text-scale-1200 transition"
+ className="text-lighter hover:text-foreground transition"
>
<span className="sr-only">Twitter</span>
<svg className="h-6 w-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
@@ -82,7 +82,7 @@ const Footer = (props: Props) => {
<a
href="https://github.com/supabase"
- className="text-scale-900 hover:text-scale-1200 transition"
+ className="text-lighter hover:text-foreground transition"
>
<span className="sr-only">GitHub</span>
<svg className="h-6 w-6" fill="currentColor" viewBox="0 0 24 24" aria-hidden="true">
@@ -96,7 +96,7 @@ const Footer = (props: Props) => {
<a
href="https://discord.supabase.com/"
- className="text-scale-900 hover:text-scale-1200 transition"
+ className="text-lighter hover:text-foreground transition"
>
<span className="sr-only">Discord</span>
<svg className="h-6 w-6" fill="currentColor" viewBox="0 0 71 55" aria-hidden="true">
@@ -110,7 +110,7 @@ const Footer = (props: Props) => {
<a
href="https://youtube.com/c/supabase"
- className="text-scale-900 hover:text-scale-1200 transition"
+ className="text-lighter hover:text-foreground transition"
>
<span className="sr-only">Youtube</span>
<svg
@@ -126,39 +126,43 @@ const Footer = (props: Props) => {
</div>
<div className="mt-12 grid grid-cols-1 gap-8 xl:col-span-2 xl:mt-0">
<div className="grid grid-cols-2 gap-8 md:grid-cols-4">
- {FooterLinks.map((segment) => {
+ {footerData.map((segment) => {
return (
<div key={`footer_${segment.title}`}>
- <h6 className="text-scale-1200 overwrite text-base">{segment.title}</h6>
+ <h6 className="text-foreground overwrite text-base">{segment.title}</h6>
<ul className="mt-4 space-y-2">
- {segment.links.map((link, idx) => {
+ {segment.links.map(({ component: Component, ...link }, idx) => {
const children = (
- <a
- // only add href key if link is external
- {...(link.url.startsWith('https') && { href: link.url })}
+ <div
className={`text-sm transition-colors ${
- link.url
- ? 'text-scale-1100 hover:text-scale-1200 '
- : 'text-scale-900 hover:text-scale-900'
+ link.url || Component
+ ? 'text-lighter hover:text-foreground'
+ : 'text-muted hover:text-lighter'
} `}
>
{link.text}
- {!link.url && (
+ {!link.url && !Component && (
<div className="ml-2 inline text-xs xl:ml-0 xl:block 2xl:ml-2 2xl:inline">
<Badge color="scale" size="small">
Coming soon
</Badge>
</div>
)}
- </a>
+ </div>
)
return (
<li key={`${segment.title}_link_${idx}`}>
- {link.url.startsWith('https') ? (
- <Fragment>{children}</Fragment>
+ {link.url ? (
+ link.url.startsWith('https') ? (
+ <a href={link.url}>{children}</a>
+ ) : (
+ <Link href={link.url}>
+ <a>{children}</a>
+ </Link>
+ )
) : (
- <Link href={link.url}>{children}</Link>
+ Component && <Component>{children}</Component>
)}
</li>
)
@@ -170,7 +174,7 @@ const Footer = (props: Props) => {
</div>
</div>
</div>
- <div className="border-scale-500 dark:border-scale-600 mt-32 flex justify-between border-t pt-8">
+ <div className="border-border mt-32 flex justify-between border-t pt-8">
<small className="small">&copy; Supabase Inc</small>
<ThemeToggle forceDark={isLaunchWeekPage} />
</div>
diff --git a/apps/www/data/Footer.json b/apps/www/data/Footer.json
deleted file mode 100644
index f05fe79ce6c..00000000000
--- a/apps/www/data/Footer.json
+++ /dev/null
@@ -1,170 +0,0 @@
-[
- {
- "title": "Product",
- "links": [
- {
- "text": "Database",
- "url": "/database"
- },
- {
- "text": "Auth",
- "url": "/auth"
- },
- {
- "text": "Functions",
- "url": "/edge-functions"
- },
- {
- "text": "Realtime",
- "url": "/realtime"
- },
- {
- "text": "Storage",
- "url": "/storage"
- },
- {
- "text": "Vector",
- "url": "/vector"
- },
- {
- "text": "Pricing",
- "url": "/pricing"
- },
- {
- "text": "Launch Week 8",
- "url": "/launch-week"
- }
- ]
- },
- {
- "title": "Resources",
- "links": [
- {
- "text": "Support",
- "url": "/support"
- },
- {
- "text": "System Status",
- "url": "https://status.supabase.com/"
- },
- {
- "text": "Become a Partner",
- "url": "/partners"
- },
- {
- "text": "Integrations",
- "url": "/partners/integrations"
- },
- {
- "text": "Experts",
- "url": "/partners/experts"
- },
- {
- "text": "Brand Assets / Logos",
- "url": "/brand-assets"
- },
- {
- "text": "Security and Compliance",
- "url": "/security"
- },
- {
- "text": "DPA",
- "url": "/legal/dpa"
- },
- {
- "text": "SOC2",
- "url": "https://forms.supabase.com/soc2"
- },
- {
- "text": "HIPAA",
- "url": "https://forms.supabase.com/hipaa"
- }
- ]
- },
- {
- "title": "Developers",
- "links": [
- {
- "text": "Documentation",
- "url": "/docs"
- },
- {
- "text": "Changelog",
- "url": "/changelog"
- },
- {
- "text": "Contributing",
- "url": "/docs/handbook/contributing"
- },
- {
- "text": "Open Source",
- "url": "/open-source"
- },
- {
- "text": "SupaSquad",
- "url": "/supasquad"
- },
- {
- "text": "DevTo",
- "url": "https://dev.to/supabase"
- },
- {
- "text": "RSS",
- "url": "/rss.xml"
- }
- ]
- },
- {
- "title": "Company",
- "links": [
- {
- "text": "Blog",
- "url": "/blog"
- },
- {
- "text": "Customer Stories",
- "url": "/customers"
- },
- {
- "text": "Careers",
- "url": "/careers"
- },
- {
- "text": "Company",
- "url": "/company"
- },
- {
- "text": "Terms of Service",
- "url": "/terms"
- },
- {
- "text": "Privacy Policy",
- "url": "/privacy"
- },
- {
- "text": "Acceptable Use Policy",
- "url": "/aup"
- },
- {
- "text": "Support Policy",
- "url": "/support-policy"
- },
- {
- "text": "Service Level Agreement",
- "url": "/sla"
- },
- {
- "text": "Humans.txt",
- "url": "/humans.txt"
- },
- {
- "text": "Lawyers.txt",
- "url": "/lawyers.txt"
- },
- {
- "text": "Security.txt",
- "url": "/.well-known/security.txt"
- }
- ]
- }
-]
diff --git a/apps/www/data/Footer.ts b/apps/www/data/Footer.ts
new file mode 100644
index 00000000000..aa707c4d691
--- /dev/null
+++ b/apps/www/data/Footer.ts
@@ -0,0 +1,178 @@
+import { PrivacySettings } from 'ui'
+
+const footerData = [
+ {
+ title: 'Product',
+ links: [
+ {
+ text: 'Database',
+ url: '/database',
+ },
+ {
+ text: 'Auth',
+ url: '/auth',
+ },
+ {
+ text: 'Functions',
+ url: '/edge-functions',
+ },
+ {
+ text: 'Realtime',
+ url: '/realtime',
+ },
+ {
+ text: 'Storage',
+ url: '/storage',
+ },
+ {
+ text: 'Vector',
+ url: '/vector',
+ },
+ {
+ text: 'Pricing',
+ url: '/pricing',
+ },
+ {
+ text: 'Launch Week 8',
+ url: '/launch-week',
+ },
+ ],
+ },
+ {
+ title: 'Resources',
+ links: [
+ {
+ text: 'Support',
+ url: '/support',
+ },
+ {
+ text: 'System Status',
+ url: 'https://status.supabase.com/',
+ },
+ {
+ text: 'Become a Partner',
+ url: '/partners',
+ },
+ {
+ text: 'Integrations',
+ url: '/partners/integrations',
+ },
+ {
+ text: 'Experts',
+ url: '/partners/experts',
+ },
+ {
+ text: 'Brand Assets / Logos',
+ url: '/brand-assets',
+ },
+ {
+ text: 'Security and Compliance',
+ url: '/security',
+ },
+ {
+ text: 'DPA',
+ url: '/legal/dpa',
+ },
+ {
+ text: 'SOC2',
+ url: 'https://forms.supabase.com/soc2',
+ },
+ {
+ text: 'HIPAA',
+ url: 'https://forms.supabase.com/hipaa',
+ },
+ ],
+ },
+ {
+ title: 'Developers',
+ links: [
+ {
+ text: 'Documentation',
+ url: '/docs',
+ },
+ {
+ text: 'Changelog',
+ url: '/changelog',
+ },
+ {
+ text: 'Contributing',
+ url: '/docs/handbook/contributing',
+ },
+ {
+ text: 'Open Source',
+ url: '/open-source',
+ },
+ {
+ text: 'SupaSquad',
+ url: '/supasquad',
+ },
+ {
+ text: 'DevTo',
+ url: 'https://dev.to/supabase',
+ },
+ {
+ text: 'RSS',
+ url: '/rss.xml',
+ },
+ ],
+ },
+ {
+ title: 'Company',
+ links: [
+ {
+ text: 'Blog',
+ url: '/blog',
+ },
+ {
+ text: 'Customer Stories',
+ url: '/customers',
+ },
+ {
+ text: 'Careers',
+ url: '/careers',
+ },
+ {
+ text: 'Company',
+ url: '/company',
+ },
+ {
+ text: 'Terms of Service',
+ url: '/terms',
+ },
+ {
+ text: 'Privacy Policy',
+ url: '/privacy',
+ },
+ {
+ text: 'Privacy Settings',
+ component: PrivacySettings,
+ },
+ {
+ text: 'Acceptable Use Policy',
+ url: '/aup',
+ },
+ {
+ text: 'Support Policy',
+ url: '/support-policy',
+ },
+ {
+ text: 'Service Level Agreement',
+ url: '/sla',
+ },
+ {
+ text: 'Humans.txt',
+ url: '/humans.txt',
+ },
+ {
+ text: 'Lawyers.txt',
+ url: '/lawyers.txt',
+ },
+ {
+ text: 'Security.txt',
+ url: '/.well-known/security.txt',
+ },
+ ],
+ },
+]
+
+export default footerData
diff --git a/apps/www/pages/privacy.mdx b/apps/www/pages/privacy.mdx
index b5582b43041..1ce9ed1c558 100644
--- a/apps/www/pages/privacy.mdx
+++ b/apps/www/pages/privacy.mdx
@@ -1,5 +1,6 @@
import Layout from '../layouts/Layout'
import SectionContainer from '../components/Layouts/SectionContainer'
+import { PrivacySettings } from 'ui'
export const meta = {
title: 'Privacy Policy | Supabase',
@@ -331,9 +332,9 @@ If you would like to find out more about cookies and other similar technologies,
Please note that deleting or blocking cookies may not be effective for all types of tracking technologies, such as Local Storage Objects (LSOs) like HTML5.
-**Cookiesless analytics**
+#### **Cookiesless analytics**
-We also use cookieless technologies to collect information to assess how our Service is used. When you access a website or service on the internet, your device and your browser send certain information to the provider of that website or service in order to access that website or service. We collect, aggregate and analyze this information to identify errors in and improvements to Service. We will only do so, however, only if you give us your consent to do so.
+We also use cookieless technologies to collect information to assess how our Service is used. When you access a website or service on the internet, your device and your browser send certain information to the provider of that website or service in order to access that website or service. We collect, aggregate and analyze this information to identify errors in and improvements to Service. We will only do so, however, only if you give us your consent to do so. <PrivacySettings className="underline">Manage preferences</PrivacySettings>
</SectionContainer>
diff --git a/apps/www/public/customers-rss.xml b/apps/www/public/customers-rss.xml
index 16c589f11af..f79e5232876 100644
--- a/apps/www/public/customers-rss.xml
+++ b/apps/www/public/customers-rss.xml
@@ -5,7 +5,7 @@
<link>https://supabase.com</link>
<description>Latest news from Supabase</description>
<language>en</language>
- <lastBuildDate>Thu, 05 Oct 2023 04:00:00 GMT</lastBuildDate>
+ <lastBuildDate>Thu, 05 Oct 2023 22:00:00 GMT</lastBuildDate>
<atom:link href="https://supabase.com/rss.xml" rel="self" type="application/rss+xml"/>
<item>
<guid>https://supabase.com/customers/pebblely</guid>
@@ -19,70 +19,70 @@
<title>Bootstrapped founder builds an AI app with Supabase and scales to $1M in 5 months</title>
<link>https://supabase.com/customers/chatbase</link>
<description>How Yasser leveraged Supabase to build Chatbase and became one of the most successful single-founder AI products.</description>
- <pubDate>Thu, 05 Oct 2023 04:00:00 GMT</pubDate>
+ <pubDate>Thu, 05 Oct 2023 22:00:00 GMT</pubDate>
</item>
<item>
<guid>https://supabase.com/customers/quivr</guid>
<title>Quivr launch 5,000 Vector databases on Supabase.</title>
<link>https://supabase.com/customers/quivr</link>
<description>Learn how one of the most popular Generative AI projects uses Supabase as their Vector Store.</description>
- <pubDate>Wed, 04 Oct 2023 04:00:00 GMT</pubDate>
+ <pubDate>Wed, 04 Oct 2023 22:00:00 GMT</pubDate>
</item>
<item>
<guid>https://supabase.com/customers/berriai</guid>
<title>Berri AI boosts productivity by migrating from AWS RDS to Supabase Vector</title>
<link>https://supabase.com/customers/berriai</link>
<description>Learn how Berri AI overcame challenges with self-hosting their vector database on AWS RDS and successfully migrated to Supabase.</description>
- <pubDate>Mon, 05 Jun 2023 04:00:00 GMT</pubDate>
+ <pubDate>Mon, 05 Jun 2023 22:00:00 GMT</pubDate>
</item>
<item>
<guid>https://supabase.com/customers/markprompt</guid>
<title>Markprompt and Supabase - GDPR-compliant AI chatbots for docs and websites.</title>
<link>https://supabase.com/customers/markprompt</link>
<description>AI-powered chatbot platform, Markprompt, empowers developers to deliver efficient and GDPR-compliant prompt experiences on top of their content, by leveraging Supabase&apos;s secure and privacy-focused vector database and authentication solutions.</description>
- <pubDate>Tue, 16 May 2023 04:00:00 GMT</pubDate>
+ <pubDate>Tue, 16 May 2023 22:00:00 GMT</pubDate>
</item>
<item>
<guid>https://supabase.com/customers/mendableai</guid>
<title>Mendable switches from Pinecone to Supabase Vector for PostgreSQL vector embeddings.</title>
<link>https://supabase.com/customers/mendableai</link>
<description>How Mendable boosts efficiency and accuracy of chat powered search for documentation using Supabase Vector.</description>
- <pubDate>Thu, 04 May 2023 04:00:00 GMT</pubDate>
+ <pubDate>Thu, 04 May 2023 22:00:00 GMT</pubDate>
</item>
<item>
<guid>https://supabase.com/customers/happyteams</guid>
<title>HappyTeams unlocks better performance and reduces cost with Supabase.</title>
<link>https://supabase.com/customers/happyteams</link>
<description>How a bootstrapped startup migrated from Heroku to Supabase in 30 minutes and never looked back.</description>
- <pubDate>Wed, 15 Feb 2023 05:00:00 GMT</pubDate>
+ <pubDate>Wed, 15 Feb 2023 23:00:00 GMT</pubDate>
</item>
<item>
<guid>https://supabase.com/customers/xendit</guid>
<title>Xendit use Supabase and create a full solution shipped to production in less than one week.</title>
<link>https://supabase.com/customers/xendit</link>
<description>As a payment processor, Xendit are responsible for verifying that all transactions are legal.</description>
- <pubDate>Mon, 13 Feb 2023 05:00:00 GMT</pubDate>
+ <pubDate>Mon, 13 Feb 2023 23:00:00 GMT</pubDate>
</item>
<item>
<guid>https://supabase.com/customers/replenysh</guid>
<title>Replenysh uses Supabase to implement OTP in less than 24 hours.</title>
<link>https://supabase.com/customers/replenysh</link>
<description>With Supabase, Replenysh gets a slick auth experience, reduces DevOps overhead, and continues to scale with Postgres.</description>
- <pubDate>Mon, 13 Feb 2023 05:00:00 GMT</pubDate>
+ <pubDate>Mon, 13 Feb 2023 23:00:00 GMT</pubDate>
</item>
<item>
<guid>https://supabase.com/customers/mobbin</guid>
<title>How Mobbin migrated 200,000 users from Firebase for a better authentication experience.</title>
<link>https://supabase.com/customers/mobbin</link>
<description>Mobbin helps over 200,000 creators globally search and view the latest design patterns from well-known apps.</description>
- <pubDate>Mon, 13 Feb 2023 05:00:00 GMT</pubDate>
+ <pubDate>Mon, 13 Feb 2023 23:00:00 GMT</pubDate>
</item>
<item>
<guid>https://supabase.com/customers/epsilon3</guid>
<title>Epsilon3 digitize paper-based procedures in the space industry using telemetry data, simplifying testing and operations.</title>
<link>https://supabase.com/customers/epsilon3</link>
<description>Epsilon3 uses Supabase to help teams execute secure and reliable operations in an industry where project spend runs into the billions.</description>
- <pubDate>Mon, 13 Feb 2023 05:00:00 GMT</pubDate>
+ <pubDate>Mon, 13 Feb 2023 23:00:00 GMT</pubDate>
</item>
</channel>
diff --git a/packages/common/constants/index.ts b/packages/common/constants/index.ts
index dc0b46c78ab..b1b0b3c29be 100644
--- a/packages/common/constants/index.ts
+++ b/packages/common/constants/index.ts
@@ -1 +1,2 @@
export * from './client-libraries'
+export * from './local-storage'
diff --git a/packages/common/constants/local-storage.ts b/packages/common/constants/local-storage.ts
new file mode 100644
index 00000000000..fcd9162b4e8
--- /dev/null
+++ b/packages/common/constants/local-storage.ts
@@ -0,0 +1,3 @@
+export const LOCAL_STORAGE_KEYS = {
+ TELEMETRY_CONSENT: 'supabase-consent',
+}
diff --git a/packages/common/fetchWrappers.tsx b/packages/common/fetchWrappers.tsx
new file mode 100644
index 00000000000..0313e49565f
--- /dev/null
+++ b/packages/common/fetchWrappers.tsx
@@ -0,0 +1,18 @@
+interface DataProps {
+ [prop: string]: any
+}
+
+export const post = (url: string, data: DataProps, options = {}) => {
+ return fetch(url, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ Accept: 'application/json',
+ },
+ referrerPolicy: 'no-referrer-when-downgrade',
+ body: JSON.stringify(data),
+ ...options,
+ }).catch((error) => {
+ console.error('Error at fetchWrapper - post:', error)
+ })
+}
diff --git a/packages/common/helpers.ts b/packages/common/helpers.ts
index 5b8e307dfce..80554ea6f00 100644
--- a/packages/common/helpers.ts
+++ b/packages/common/helpers.ts
@@ -9,3 +9,5 @@ export const detectBrowser = () => {
return 'Safari'
}
}
+
+export const isBrowser = typeof window !== 'undefined'
diff --git a/packages/common/hooks/index.ts b/packages/common/hooks/index.ts
index c5f3b270c5a..24160bac261 100644
--- a/packages/common/hooks/index.ts
+++ b/packages/common/hooks/index.ts
@@ -1,5 +1,6 @@
export * from './useBreakpoint'
export * from './useConsent'
+export * from './useConsentValue'
export * from './useDebounce'
export * from './useParams'
export * from './useTelemetryProps'
diff --git a/packages/common/hooks/useBreakpoint.tsx b/packages/common/hooks/useBreakpoint.tsx
index 8e967f9e0e6..6704d7917f9 100644
--- a/packages/common/hooks/useBreakpoint.tsx
+++ b/packages/common/hooks/useBreakpoint.tsx
@@ -1,7 +1,6 @@
import { useEffect, useState } from 'react'
import { useWindowSize } from 'react-use'
-
-export const isBrowser = typeof window !== 'undefined'
+import { isBrowser } from '../helpers'
export function useBreakpoint(breakpoint = 768) {
if (!isBrowser) return
diff --git a/packages/common/hooks/useConsent.tsx b/packages/common/hooks/useConsent.tsx
index 399ae569f71..4ad16cbe7e2 100644
--- a/packages/common/hooks/useConsent.tsx
+++ b/packages/common/hooks/useConsent.tsx
@@ -1,13 +1,17 @@
import { useEffect, useRef, useState } from 'react'
import { toast } from 'react-hot-toast'
import ConsentToast from 'ui/src/components/ConsentToast'
+import { handlePageTelemetry } from '../telemetry'
+import { useTelemetryProps } from './useTelemetryProps'
+import { LOCAL_STORAGE_KEYS } from '../constants'
// Use with PortalToast from 'ui/src/layout/PortalToast'
export const useConsent = () => {
+ const { TELEMETRY_CONSENT } = LOCAL_STORAGE_KEYS
const consentToastId = useRef<string>()
const isClient = typeof window !== 'undefined'
if (!isClient) return {}
- const TELEMETRY_CONSENT = 'supabase-consent'
+ const telemetryProps = useTelemetryProps()
const [consentValue, setConsentValue] = useState<string | null>(
localStorage?.getItem(TELEMETRY_CONSENT)
)
@@ -18,8 +22,19 @@ export const useConsent = () => {
localStorage.setItem(TELEMETRY_CONSENT, value)
if (consentToastId.current) toast.dismiss(consentToastId.current)
+ if (value === 'true')
+ handlePageTelemetry(process.env.NEXT_PUBLIC_API_URL!, location.pathname, telemetryProps)
}
+ useEffect(() => {
+ const handleSetLocalStorage = () => {
+ if (localStorage?.getItem(TELEMETRY_CONSENT)) toast.dismiss(consentToastId.current)
+ }
+
+ window.addEventListener('storage', handleSetLocalStorage)
+ return window.removeEventListener('storage', () => null)
+ }, [])
+
useEffect(() => {
if (isClient && consentValue === null) {
consentToastId.current = toast(
diff --git a/packages/common/hooks/useConsentValue.tsx b/packages/common/hooks/useConsentValue.tsx
new file mode 100644
index 00000000000..4357cd8c49b
--- /dev/null
+++ b/packages/common/hooks/useConsentValue.tsx
@@ -0,0 +1,27 @@
+import { useState } from 'react'
+import { isBrowser } from '../helpers'
+import { handlePageTelemetry } from '../telemetry'
+import { useTelemetryProps } from './useTelemetryProps'
+
+export const useConsentValue = (KEY_NAME: string) => {
+ if (!isBrowser) return {}
+
+ const telemetryProps = useTelemetryProps()
+ const [consentValue, setConsentValue] = useState<string | null>(localStorage?.getItem(KEY_NAME))
+
+ const handleConsent = (value: 'true' | 'false') => {
+ if (!isBrowser) return
+ setConsentValue(value)
+ localStorage.setItem(KEY_NAME, value)
+ window.dispatchEvent(new Event('storage'))
+ if (value === 'true')
+ handlePageTelemetry(process.env.NEXT_PUBLIC_API_URL!, location.pathname, telemetryProps)
+ }
+
+ return {
+ consentValue,
+ setConsentValue,
+ hasAccepted: consentValue === 'true',
+ handleConsent,
+ }
+}
diff --git a/packages/common/hooks/useTelemetryProps.ts b/packages/common/hooks/useTelemetryProps.ts
index 73e63cd5e4f..5a0b1f9c399 100644
--- a/packages/common/hooks/useTelemetryProps.ts
+++ b/packages/common/hooks/useTelemetryProps.ts
@@ -1,6 +1,5 @@
import { useRouter } from 'next/router'
-
-const isBrowser = typeof window !== 'undefined'
+import { isBrowser } from '../helpers'
export function useTelemetryProps() {
const { locale } = useRouter()
diff --git a/packages/common/index.tsx b/packages/common/index.tsx
index 56de36023d9..9711f61a95d 100644
--- a/packages/common/index.tsx
+++ b/packages/common/index.tsx
@@ -1,10 +1,12 @@
import SidebarLayout from './layouts/SidebarLayout'
export * from './Providers'
+export * from './constants'
export * from './helpers'
export * from './hooks'
export * from './gotrue'
export * from './auth'
+export * from './telemetry'
export const Layouts = {
SidebarLayout,
diff --git a/packages/common/telemetry.ts b/packages/common/telemetry.ts
new file mode 100644
index 00000000000..eb536b448d6
--- /dev/null
+++ b/packages/common/telemetry.ts
@@ -0,0 +1,13 @@
+import { post } from './fetchWrappers'
+
+export function handlePageTelemetry(API_URL: string, route: string, telemetryProps: any) {
+ return post(`${API_URL}/telemetry/page`, {
+ referrer: document.referrer,
+ title: document.title,
+ route,
+ ga: {
+ screen_resolution: telemetryProps?.screenResolution,
+ language: telemetryProps?.language,
+ },
+ })
+}
diff --git a/packages/ui/index.tsx b/packages/ui/index.tsx
index 6cd7da46997..16a795ab9f6 100644
--- a/packages/ui/index.tsx
+++ b/packages/ui/index.tsx
@@ -39,8 +39,9 @@ export * from './src/components/Modal'
export * from './src/components/SidePanel'
export * from './src/components/ConsentToast'
export * from './src/components/ContextMenu'
-export * from './src/components/Popover'
export * from './src/components/ExpandableVideo'
+export * from './src/components/PrivacySettings'
+export * from './src/components/Popover'
export * from './src/layout/PortalToast'
// UTILITIES
diff --git a/packages/ui/src/components/PrivacySettings/PrivacySettings.tsx b/packages/ui/src/components/PrivacySettings/PrivacySettings.tsx
new file mode 100644
index 00000000000..663115ea7b4
--- /dev/null
+++ b/packages/ui/src/components/PrivacySettings/PrivacySettings.tsx
@@ -0,0 +1,89 @@
+import { PropsWithChildren, useEffect, useState } from 'react'
+import Link from 'next/link'
+import { Modal, Toggle } from 'ui'
+import { useConsentValue, LOCAL_STORAGE_KEYS } from 'common'
+
+const PrivacySettings = ({ children, ...props }: PropsWithChildren<{ className?: string }>) => {
+ const [isOpen, setIsOpen] = useState(false)
+ const { hasAccepted, handleConsent } = useConsentValue(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT)
+ const [telemetryValue, setTelemetryValue] = useState(hasAccepted)
+
+ // Every time the modal opens, sync state with localStorage
+ useEffect(() => {
+ setTelemetryValue(localStorage?.getItem(LOCAL_STORAGE_KEYS.TELEMETRY_CONSENT) === 'true')
+ }, [isOpen])
+
+ const handleConfirmPreferences = () => {
+ handleConsent && handleConsent(telemetryValue ? 'true' : 'false')
+ setIsOpen(false)
+ }
+
+ const handleCancel = () => {
+ setTelemetryValue(hasAccepted)
+ setIsOpen(false)
+ }
+
+ return (
+ <>
+ <button {...props} onClick={() => setIsOpen(true)}>
+ {children}
+ </button>
+
+ <Modal
+ closable
+ visible={isOpen}
+ alignFooter="right"
+ onCancel={handleCancel}
+ onConfirm={handleConfirmPreferences}
+ header="Privacy Settings"
+ onInteractOutside={(e) => {
+ // Only hide menu when clicking outside, not focusing outside
+ // Prevents Firefox dropdown issue that immediately closes menu after opening
+ if (e.type === 'dismissableLayer.pointerDownOutside') {
+ setIsOpen(!isOpen)
+ }
+ }}
+ className="max-w-[calc(100vw-4rem)]"
+ size="medium"
+ >
+ <div className="pt-6 pb-3 space-y-4">
+ <Modal.Content>
+ <Toggle
+ checked={true}
+ disabled
+ onChange={() => null}
+ label="Strictly necessary cookies"
+ descriptionText={
+ <>
+ These cookies are necessary for Supabase to function.{' '}
+ <Link href="https://supabase.com/privacy#4-how-we-use-cookies-and-other-tracking-technology-to-collect-information">
+ <a className="underline">Learn more</a>
+ </Link>
+ </>
+ }
+ />
+ </Modal.Content>
+ <Modal.Separator />
+ <Modal.Content>
+ <Toggle
+ checked={telemetryValue}
+ onChange={() => setTelemetryValue((prev) => !prev)}
+ label="Telemetry"
+ descriptionText={
+ <>
+ By opting in to sending telemetry data, Supabase can improve the overall user
+ experience.{' '}
+ <Link href="https://supabase.com/privacy#cookieless-analytics">
+ <a className="underline">Learn more</a>
+ </Link>
+ </>
+ }
+ />
+ </Modal.Content>
+ </div>
+ </Modal>
+ </>
+ )
+}
+
+export default PrivacySettings
diff --git a/packages/ui/src/components/PrivacySettings/index.ts b/packages/ui/src/components/PrivacySettings/index.ts
new file mode 100644
index 00000000000..3ca1b366740
--- /dev/null
+++ b/packages/ui/src/components/PrivacySettings/index.ts
@@ -0,0 +1 @@
+export { default as PrivacySettings } from './PrivacySettings'