Skip to content

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

chore: add signin method to tracking (#33757)

Pamela Chiafc6c8b52133f
diff --git a/apps/studio/components/interfaces/SignIn/SignInForm.tsx b/apps/studio/components/interfaces/SignIn/SignInForm.tsx
index 8e8e29f5c4a..c1135ab07d2 100644
--- a/apps/studio/components/interfaces/SignIn/SignInForm.tsx
+++ b/apps/studio/components/interfaces/SignIn/SignInForm.tsx
@@ -62,7 +62,10 @@ const SignInForm = () => {
}
toast.success(`Signed in successfully!`, { id: toastId })
- sendEvent({ action: TelemetryActions.SIGN_IN, properties: { category: 'account' } })
+ sendEvent({
+ action: TelemetryActions.SIGN_IN,
+ properties: { category: 'account', method: 'email' },
+ })
addLoginEvent({})
await queryClient.resetQueries()
diff --git a/apps/studio/components/interfaces/SignIn/SignInSSOForm.tsx b/apps/studio/components/interfaces/SignIn/SignInSSOForm.tsx
index 436b5f4c149..a5078f42836 100644
--- a/apps/studio/components/interfaces/SignIn/SignInSSOForm.tsx
+++ b/apps/studio/components/interfaces/SignIn/SignInSSOForm.tsx
@@ -37,7 +37,7 @@ const SignInSSOForm = () => {
process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview'
? location.origin
: process.env.NEXT_PUBLIC_SITE_URL
- }${BASE_PATH}/sign-in-mfa`
+ }${BASE_PATH}/sign-in-mfa?method=sso`
)
const { data, error } = await auth.signInWithSSO({
diff --git a/apps/studio/components/interfaces/SignIn/SignInWithGitHub.tsx b/apps/studio/components/interfaces/SignIn/SignInWithGitHub.tsx
index 23ac466283c..cd47cc3afbc 100644
--- a/apps/studio/components/interfaces/SignIn/SignInWithGitHub.tsx
+++ b/apps/studio/components/interfaces/SignIn/SignInWithGitHub.tsx
@@ -24,7 +24,7 @@ const SignInWithGitHub = () => {
process.env.NEXT_PUBLIC_VERCEL_ENV === 'preview'
? location.origin
: process.env.NEXT_PUBLIC_SITE_URL
- }${BASE_PATH}/sign-in-mfa`
+ }${BASE_PATH}/sign-in-mfa?method=github`
)
const { error } = await auth.signInWithOAuth({
diff --git a/apps/studio/pages/sign-in-mfa.tsx b/apps/studio/pages/sign-in-mfa.tsx
index 9060fb3a981..7be3a948707 100644
--- a/apps/studio/pages/sign-in-mfa.tsx
+++ b/apps/studio/pages/sign-in-mfa.tsx
@@ -3,18 +3,25 @@ import { useRouter } from 'next/router'
import { useEffect, useState } from 'react'
import { toast } from 'sonner'
+import { useParams } from 'common'
import { TelemetryActions } from 'common/telemetry-constants'
import SignInMfaForm from 'components/interfaces/SignIn/SignInMfaForm'
import SignInLayout from 'components/layouts/SignInLayout/SignInLayout'
import { Loading } from 'components/ui/Loading'
import { useAddLoginEvent } from 'data/misc/audit-login-mutation'
import { useSendEventMutation } from 'data/telemetry/send-event-mutation'
+import useLatest from 'hooks/misc/useLatest'
import { auth, buildPathWithParams, getAccessToken, getReturnToPath } from 'lib/gotrue'
import type { NextPageWithLayout } from 'types'
const SignInMfaPage: NextPageWithLayout = () => {
const router = useRouter()
const queryClient = useQueryClient()
+ const {
+ // current methods for mfa are github and sso
+ method: signInMethod = 'unknown',
+ } = useParams()
+ const signInMethodRef = useLatest(signInMethod)
const { mutate: sendEvent } = useSendEventMutation()
const { mutate: addLoginEvent } = useAddLoginEvent()
@@ -46,7 +53,13 @@ const SignInMfaPage: NextPageWithLayout = () => {
}
if (data.currentLevel === data.nextLevel) {
- sendEvent({ action: TelemetryActions.SIGN_IN, properties: { category: 'account' } })
+ sendEvent({
+ action: TelemetryActions.SIGN_IN,
+ properties: {
+ category: 'account',
+ method: signInMethodRef.current,
+ },
+ })
addLoginEvent({})
await queryClient.resetQueries()
diff --git a/packages/common/telemetry-constants.ts b/packages/common/telemetry-constants.ts
index ece1f7686fa..f85df320c22 100644
--- a/packages/common/telemetry-constants.ts
+++ b/packages/common/telemetry-constants.ts
@@ -103,6 +103,10 @@ export interface SignInEvent {
action: TelemetryActions.SIGN_IN
properties: {
category: 'account'
+ /**
+ * The method used to sign in, e.g. email, github, sso
+ */
+ method: string
}
}