diff --git a/src/components/Onfido/BaseOnfidoWeb.js b/src/components/Onfido/BaseOnfidoWeb.js index 63ae8e679d12..b1114f911abd 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,29 @@ 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); + const errorType = lodashGet(error, 'type'); + Log.hmmm('Onfido error', {errorType, 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/components/Onfido/index.native.js b/src/components/Onfido/index.native.js index a84098c70f50..2915ca1edb88 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. 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); }}