From 2f6f27c4fb50cbefc2aef00d589fc3629a0e091a Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Wed, 3 Jan 2024 00:11:04 -0600 Subject: [PATCH] Add some more logging (#2402) * Add a few logs * Report unknown create account errors separately * Downgrade to warn * Nvm --- src/state/session/index.tsx | 12 ++++-------- src/view/com/auth/create/state.ts | 8 +++++++- src/view/com/auth/login/LoginForm.tsx | 6 +++++- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/state/session/index.tsx b/src/state/session/index.tsx index aa8c94eb..a452d6aa 100644 --- a/src/state/session/index.tsx +++ b/src/state/session/index.tsx @@ -181,14 +181,10 @@ export function Provider({children}: React.PropsWithChildren<{}>) { const createAccount = React.useCallback( async ({service, email, password, handle, inviteCode}: any) => { - logger.debug( - `session: creating account`, - { - service, - handle, - }, - logger.DebugContext.session, - ) + logger.info(`session: creating account`, { + service, + handle, + }) track('Try Create Account') const agent = new BskyAgent({service}) diff --git a/src/view/com/auth/create/state.ts b/src/view/com/auth/create/state.ts index a77d2a44..62a8495b 100644 --- a/src/view/com/auth/create/state.ts +++ b/src/view/com/auth/create/state.ts @@ -136,7 +136,13 @@ export async function submit({ msg`Invite code not accepted. Check that you input it correctly and try again.`, ) } - logger.error('Failed to create account', {error: e}) + + if ([400, 429].includes(e.status)) { + logger.warn('Failed to create account', {error: e}) + } else { + logger.error(`Failed to create account (${e.status} status)`, {error: e}) + } + uiDispatch({type: 'set-processing', value: false}) uiDispatch({type: 'set-error', value: cleanError(errMsg)}) throw e diff --git a/src/view/com/auth/login/LoginForm.tsx b/src/view/com/auth/login/LoginForm.tsx index 727a0e94..98c5eb37 100644 --- a/src/view/com/auth/login/LoginForm.tsx +++ b/src/view/com/auth/login/LoginForm.tsx @@ -107,17 +107,21 @@ export const LoginForm = ({ }) } catch (e: any) { const errMsg = e.toString() - logger.warn('Failed to login', {error: e}) setIsProcessing(false) if (errMsg.includes('Authentication Required')) { + logger.info('Failed to login due to invalid credentials', { + error: errMsg, + }) setError(_(msg`Invalid username or password`)) } else if (isNetworkError(e)) { + logger.warn('Failed to login due to network error', {error: errMsg}) setError( _( msg`Unable to contact your service. Please check your Internet connection.`, ), ) } else { + logger.warn('Failed to login', {error: errMsg}) setError(cleanError(errMsg)) } }