Files
supabase/apps/studio/components/interfaces/Account/Preferences/AnalyticsSettings.tsx
T

42 lines
1.3 KiB
TypeScript

import { Toggle } from 'ui'
import { toast } from 'sonner'
import { useConsentState } from 'common'
import Panel from 'components/ui/Panel'
import { useSendResetMutation } from 'data/telemetry/send-reset-mutation'
export const AnalyticsSettings = () => {
const { hasAccepted, acceptAll, denyAll, categories } = useConsentState()
const hasLoaded = categories !== null
const { mutate: sendReset } = useSendResetMutation()
const onToggleOptIn = () => {
if (!hasLoaded) {
toast.error(
"We couldn't load the privacy settings due to an ad blocker or network error. Please disable any ad blockers and try again. If the problem persists, please contact support."
)
return
}
if (hasAccepted) {
denyAll()
sendReset()
} else {
acceptAll()
}
}
return (
<Panel title={<h5 key="panel-title">Analytics and Marketing</h5>}>
<Panel.Content>
<Toggle
checked={hasAccepted}
onChange={onToggleOptIn}
label="Send telemetry data from Supabase services"
descriptionText="By opting in to sharing telemetry data, Supabase can analyze usage patterns to enhance user experience and use it for marketing and advertising purposes"
/>
</Panel.Content>
</Panel>
)
}