diff --git a/apps/mobile/src/core/auth/useAuth.ts b/apps/mobile/src/core/auth/useAuth.ts index 03ec583..91e3a58 100644 --- a/apps/mobile/src/core/auth/useAuth.ts +++ b/apps/mobile/src/core/auth/useAuth.ts @@ -2,12 +2,14 @@ import { INSERT_KUZER, Kuzer } from '@kuzpot/core'; import { useInsertMutation } from '@kuzpot/react-native'; import { useAuthenticationStatus, useSignInAnonymous, useUserData } from '@nhost/react'; import { useCallback, useEffect, useState } from 'react'; +import * as Sentry from 'sentry-expo'; import { useRegisterDevice } from './useRegisterDevice'; let isInit = false; export function useAuth() { + Sentry.Native.captureMessage('useAuth'); const { register } = useRegisterDevice(); const { isAuthenticated, isLoading: authLoading } = useAuthenticationStatus(); @@ -19,14 +21,18 @@ export function useAuth() { const initUser = useCallback( async (userId: string) => { + Sentry.Native.setUser({ id: userId, role: 'anonymous' }); try { await mutateUser({ id: userId, status: 'online', }); await register(userId); + Sentry.Native.captureMessage(`User ${userId} registered`); setIsLoading(false); } catch (err) { + Sentry.Native.captureException(err, { extra: { userId } }); + console.error('nhost err', err); setIsLoading(false); } }, @@ -34,6 +40,9 @@ export function useAuth() { ); useEffect(() => { + Sentry.Native.captureMessage( + `useAuth in useEffect: ${JSON.stringify({ authLoading, isAuthenticated, isInit }, null, 2)}}` + ); if (!authLoading && !isAuthenticated && !isInit) { signInAnonymous() .then((user) => { @@ -42,6 +51,7 @@ export function useAuth() { } }) .catch((err) => { + Sentry.Native.captureException(err); console.error('nhost err', err); setIsLoading(false); }); diff --git a/apps/mobile/src/main.tsx b/apps/mobile/src/main.tsx index 3e7fb22..91d9e38 100644 --- a/apps/mobile/src/main.tsx +++ b/apps/mobile/src/main.tsx @@ -65,8 +65,10 @@ export default function Main() { clientStorageType: 'react-native', }); setIsReady(true); + + Sentry.Native.captureMessage('Secure storage initialized'); }) - .catch((err) => console.log('err', err)); + .catch((err) => Sentry.Native.captureException(err)); } }, []);