mirror of
https://github.com/supabase/supabase.git
synced 2026-10-11 20:35:07 +03:00
send sign_in telemetry event
This commit is contained in:
1 parent
9c4d82c021
commit
b49968d977
2 files changed
+20
-2
No files matched your search
@@ -3,7 +3,7 @@ import { useRouter } from 'next/router'
|
||||
import { useTelemetryProps } from 'common'
|
||||
import { useProfileCreateMutation } from 'data/profile/profile-create-mutation'
|
||||
import { useProfileQuery } from 'data/profile/profile-query'
|
||||
import telemetry from 'lib/telemetry'
|
||||
import Telemetry from 'lib/telemetry'
|
||||
|
||||
/**
|
||||
* Fetches the user's profile, creating one if it does not exist
|
||||
@@ -14,7 +14,7 @@ function useProfile() {
|
||||
|
||||
const { mutate: createProfile, isLoading: isCreating } = useProfileCreateMutation({
|
||||
onSuccess() {
|
||||
telemetry.sendEvent(
|
||||
Telemetry.sendEvent(
|
||||
{ category: 'conversion', action: 'sign_up', label: '' },
|
||||
telemetryProps,
|
||||
router
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { useRouter } from 'next/router'
|
||||
import { PropsWithChildren, useCallback, useEffect } from 'react'
|
||||
|
||||
import {
|
||||
@@ -17,6 +18,7 @@ export const AuthContext = AuthContextInternal
|
||||
|
||||
export const AuthProvider = ({ children }: PropsWithChildren<{}>) => {
|
||||
const { ui, app } = useStore()
|
||||
const router = useRouter()
|
||||
const telemetryProps = useTelemetryProps()
|
||||
|
||||
// Check for unverified GitHub users after a GitHub sign in
|
||||
@@ -36,6 +38,22 @@ export const AuthProvider = ({ children }: PropsWithChildren<{}>) => {
|
||||
handleEmailVerificationError()
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
const {
|
||||
data: { subscription },
|
||||
} = gotrueClient.onAuthStateChange((event) => {
|
||||
if (event === 'SIGNED_IN') {
|
||||
Telemetry.sendEvent(
|
||||
{ category: 'conversion', action: 'sign_in', label: '' },
|
||||
telemetryProps,
|
||||
router
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
return subscription.unsubscribe
|
||||
}, [])
|
||||
|
||||
// Track telemetry for the current user
|
||||
useProfileQuery({
|
||||
onSuccess(profile) {
|
||||
|
||||
Reference in new issue
Block a user