The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
Add sign in event for email password login (#31395)
Joshen Lim1aa371a9d7ec
diff --git a/apps/studio/components/interfaces/SignIn/SignInForm.tsx b/apps/studio/components/interfaces/SignIn/SignInForm.tsxindex 1b72d45fa83..2d202b7ee90 100644--- a/apps/studio/components/interfaces/SignIn/SignInForm.tsx+++ b/apps/studio/components/interfaces/SignIn/SignInForm.tsx@@ -9,9 +9,11 @@ import { toast } from 'sonner'import { object, string } from 'yup'import { getMfaAuthenticatorAssuranceLevel } from 'data/profile/mfa-authenticator-assurance-level-query'+import { useSendEventMutation } from 'data/telemetry/send-event-mutation'+import { useLastSignIn } from 'hooks/misc/useLastSignIn'+import { TelemetryActions } from 'lib/constants/telemetry'import { auth, buildPathWithParams, getReturnToPath } from 'lib/gotrue'import { Button, Form, Input } from 'ui'-import { useLastSignIn } from 'hooks/misc/useLastSignIn'import { LastSignInWrapper } from './LastSignInWrapper'const signInSchema = object({@@ -22,11 +24,13 @@ const signInSchema = object({const SignInForm = () => {const router = useRouter()const queryClient = useQueryClient()- const [lastSignIn, setLastSignIn] = useLastSignIn()+ const [_, setLastSignIn] = useLastSignIn()const [captchaToken, setCaptchaToken] = useState<string | null>(null)const captchaRef = useRef<HCaptcha>(null)+ const { mutate: sendEvent } = useSendEventMutation()+const onSignIn = async ({ email, password }: { email: string; password: string }) => {const toastId = toast.loading('Signing in...')@@ -56,6 +60,7 @@ const SignInForm = () => {}toast.success(`Signed in successfully!`, { id: toastId })+ sendEvent({ action: TelemetryActions.SIGN_IN, properties: { category: 'account' } })await queryClient.resetQueries()const returnTo = getReturnToPath()// since we're already on the /sign-in page, prevent redirect loopsdiff --git a/apps/studio/components/interfaces/SignIn/SignInSSOForm.tsx b/apps/studio/components/interfaces/SignIn/SignInSSOForm.tsxindex 5a31e6baf26..93b2e16951a 100644--- a/apps/studio/components/interfaces/SignIn/SignInSSOForm.tsx+++ b/apps/studio/components/interfaces/SignIn/SignInSSOForm.tsx@@ -5,10 +5,12 @@ import { useRef, useState } from 'react'import { toast } from 'sonner'import { object, string } from 'yup'+import { useSendEventMutation } from 'data/telemetry/send-event-mutation'+import { useLastSignIn } from 'hooks/misc/useLastSignIn'import { BASE_PATH } from 'lib/constants'+import { TelemetryActions } from 'lib/constants/telemetry'import { auth, buildPathWithParams } from 'lib/gotrue'import { Button, Form, Input } from 'ui'-import { useLastSignIn } from 'hooks/misc/useLastSignIn'const WHITELIST_ERRORS = ['No SSO provider assigned for this domain']@@ -16,10 +18,14 @@ const SignInSSOForm = () => {const queryClient = useQueryClient()const captchaRef = useRef<HCaptcha>(null)const [captchaToken, setCaptchaToken] = useState<string | null>(null)- const [lastSignInUsed, setLastSignInUsed] = useLastSignIn()+ const [_, setLastSignInUsed] = useLastSignIn()+const signInSchema = object({email: string().email('Must be a valid email').required('Email is required'),})++ const { mutate: sendEvent } = useSendEventMutation()+const onSignIn = async ({ email }: { email: string }) => {const toastId = toast.loading('Signing in...')@@ -47,6 +53,7 @@ const SignInSSOForm = () => {})if (!error) {+ sendEvent({ action: TelemetryActions.SIGN_IN, properties: { category: 'account' } })await queryClient.resetQueries()setLastSignInUsed('sso')if (data) {