From c06428986ec43fa3fd1a0bec90585315d9ccfc35 Mon Sep 17 00:00:00 2001 From: Nathalie Kuoch Date: Thu, 23 Dec 2021 15:38:56 +0100 Subject: [PATCH 1/3] Add onfido logs --- src/components/Onfido/BaseOnfidoWeb.js | 23 ++++++++++++++++--- src/pages/EnablePayments/OnfidoStep.js | 4 +--- .../ReimbursementAccount/RequestorStep.js | 4 +--- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/components/Onfido/BaseOnfidoWeb.js b/src/components/Onfido/BaseOnfidoWeb.js index 63ae8e679d12..f7ced8812db7 100644 --- a/src/components/Onfido/BaseOnfidoWeb.js +++ b/src/components/Onfido/BaseOnfidoWeb.js @@ -1,3 +1,4 @@ +import _ from 'underscore'; import './index.css'; import lodashGet from 'lodash/get'; import React from 'react'; @@ -9,6 +10,7 @@ import variables from '../../styles/variables'; import colors from '../../styles/colors'; import fontWeightBold from '../../styles/fontWeight/bold'; import fontFamily from '../../styles/fontFamily'; +import Log from '../../libs/Log'; const propTypes = { ...withLocalizePropTypes, @@ -83,13 +85,28 @@ class Onfido extends React.Component { ], smsNumberCountryCode: CONST.ONFIDO.SMS_NUMBER_COUNTRY_CODE.US, showCountrySelection: false, - onComplete: this.props.onSuccess, + onComplete: (data) => { + if (_.isEmpty(data)) { + Log.warn('Onfido completed with no data'); + } + this.props.onSuccess(data); + }, onError: (error) => { const errorMessage = lodashGet(error, 'message', CONST.ERROR.UNKNOWN_ERROR); + Log.hmmm('Onfido error', {errorType: error.type, errorMessage}); this.props.onError(errorMessage); }, - onUserExit: this.props.onUserExit, - onModalRequestClose: () => {}, + onUserExit: (userExitCode) => { + Log.hmmm('Onfido user exits the flow', {userExitCode}); + this.props.onUserExit(userExitCode); + }, + onModalRequestClose: () => { + Log.hmmm('Onfido user closed the modal'); + }, + }); + + window.addEventListener('userAnalyticsEvent', (event) => { + Log.hmmm('Receiving Onfido analytic event', event.detail); }); } diff --git a/src/pages/EnablePayments/OnfidoStep.js b/src/pages/EnablePayments/OnfidoStep.js index e39dad6a1ff1..baa85d3e3a59 100644 --- a/src/pages/EnablePayments/OnfidoStep.js +++ b/src/pages/EnablePayments/OnfidoStep.js @@ -15,7 +15,6 @@ import TextLink from '../../components/TextLink'; import withLocalize, {withLocalizePropTypes} from '../../components/withLocalize'; import compose from '../../libs/compose'; import Text from '../../components/Text'; -import Log from '../../libs/Log'; import Growl from '../../libs/Growl'; const propTypes = { @@ -70,8 +69,7 @@ class OnfidoStep extends React.Component { this.canShowOnfido() ? ( { - Log.hmmm('Onfido error in OnfidoStep', {error}); + onError={() => { Growl.error(this.props.translate('onfidoStep.genericError'), 10000); }} onUserExit={() => { diff --git a/src/pages/ReimbursementAccount/RequestorStep.js b/src/pages/ReimbursementAccount/RequestorStep.js index 13555bab55a6..9232795b9cd0 100644 --- a/src/pages/ReimbursementAccount/RequestorStep.js +++ b/src/pages/ReimbursementAccount/RequestorStep.js @@ -19,7 +19,6 @@ import Onfido from '../../components/Onfido'; import compose from '../../libs/compose'; import ONYXKEYS from '../../ONYXKEYS'; import * as ReimbursementAccountUtils from '../../libs/ReimbursementAccountUtils'; -import Log from '../../libs/Log'; import Growl from '../../libs/Growl'; import reimbursementAccountPropTypes from './reimbursementAccountPropTypes'; import ReimbursementAccountForm from './ReimbursementAccountForm'; @@ -162,9 +161,8 @@ class RequestorStep extends React.Component { // We're taking the user back to the company step. They will need to come back to the requestor step to make the Onfido flow appear again. BankAccounts.goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.COMPANY); }} - onError={(error) => { + onError={() => { // In case of any unexpected error we log it to the server, show a growl, and return the user back to the company step so they can try again. - Log.hmmm('Onfido error in RequestorStep', {error}); Growl.error(this.props.translate('onfidoStep.genericError'), 10000); BankAccounts.goToWithdrawalAccountSetupStep(CONST.BANK_ACCOUNT.STEP.COMPANY); }} From aeeefb581a8456460d7efab3af469d0a9200752f Mon Sep 17 00:00:00 2001 From: Nathalie Kuoch Date: Fri, 24 Dec 2021 09:29:35 +0100 Subject: [PATCH 2/3] Keep error logs on Native --- src/components/Onfido/BaseOnfidoWeb.js | 3 ++- src/components/Onfido/index.native.js | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/Onfido/BaseOnfidoWeb.js b/src/components/Onfido/BaseOnfidoWeb.js index f7ced8812db7..b1114f911abd 100644 --- a/src/components/Onfido/BaseOnfidoWeb.js +++ b/src/components/Onfido/BaseOnfidoWeb.js @@ -93,7 +93,8 @@ class Onfido extends React.Component { }, onError: (error) => { const errorMessage = lodashGet(error, 'message', CONST.ERROR.UNKNOWN_ERROR); - Log.hmmm('Onfido error', {errorType: error.type, errorMessage}); + const errorType = lodashGet(error, 'type'); + Log.hmmm('Onfido error', {errorType, errorMessage}); this.props.onError(errorMessage); }, onUserExit: (userExitCode) => { diff --git a/src/components/Onfido/index.native.js b/src/components/Onfido/index.native.js index a84098c70f50..a982cd871563 100644 --- a/src/components/Onfido/index.native.js +++ b/src/components/Onfido/index.native.js @@ -10,6 +10,7 @@ import { import onfidoPropTypes from './onfidoPropTypes'; import CONST from '../../CONST'; import withLocalize, {withLocalizePropTypes} from '../withLocalize'; +import Log from "../../libs/Log"; const propTypes = { ...withLocalizePropTypes, @@ -34,6 +35,8 @@ class Onfido extends React.Component { .then(this.props.onSuccess) .catch((error) => { const errorMessage = lodashGet(error, 'message', CONST.ERROR.UNKNOWN_ERROR); + const errorType = lodashGet(error, 'type'); + Log.hmmm('Onfido error on native', {errorType, errorMessage}); // If the user cancels the Onfido flow we won't log this error as it's normal. In the React Native SDK the user exiting the flow will trigger this error which we can use as // our "user exited the flow" callback. On web, this event has it's own callback passed as a config so we don't need to bother with this there. From 79bb2999947aff55c918415c9dcf6f401ae6e82c Mon Sep 17 00:00:00 2001 From: Nathalie Kuoch Date: Fri, 24 Dec 2021 10:00:10 +0100 Subject: [PATCH 3/3] fix js style --- src/components/Onfido/index.native.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Onfido/index.native.js b/src/components/Onfido/index.native.js index a982cd871563..2915ca1edb88 100644 --- a/src/components/Onfido/index.native.js +++ b/src/components/Onfido/index.native.js @@ -10,7 +10,7 @@ import { import onfidoPropTypes from './onfidoPropTypes'; import CONST from '../../CONST'; import withLocalize, {withLocalizePropTypes} from '../withLocalize'; -import Log from "../../libs/Log"; +import Log from '../../libs/Log'; const propTypes = { ...withLocalizePropTypes,