Files
classroomio/apps/dashboard/src/lib/components/Buttons/Logout/index.svelte
T

20 lines
681 B
Svelte
Raw Normal View History

2023-10-30 06:04:53 +00:00
<script lang="ts">
import posthog from 'posthog-js';
import { goto } from '$app/navigation';
import PrimaryButton from '$lib/components/PrimaryButton/index.svelte';
import { VARIANTS } from '$lib/components/PrimaryButton/constants';
import { supabase } from '$lib/utils/functions/supabase';
import { capturePosthogEvent } from '$lib/utils/services/posthog';
async function logout() {
const { error } = await supabase.auth.signOut();
console.error('Error logging out: ', error);
capturePosthogEvent('user_logged_out');
posthog.reset();
goto('/login');
}
</script>
<PrimaryButton variant={VARIANTS.OUTLINED} label="Log out" onClick={logout} />