Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/components/Onfido/BaseOnfidoWeb.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _ from 'underscore';
import './index.css';
import lodashGet from 'lodash/get';
import React from 'react';
Expand All @@ -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,
Expand Down Expand Up @@ -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);
});
}

Expand Down
3 changes: 3 additions & 0 deletions src/components/Onfido/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
Expand Down
4 changes: 1 addition & 3 deletions src/pages/EnablePayments/OnfidoStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -70,8 +69,7 @@ class OnfidoStep extends React.Component {
this.canShowOnfido() ? (
<Onfido
sdkToken={this.props.walletOnfidoData.sdkToken}
onError={(error) => {
Log.hmmm('Onfido error in OnfidoStep', {error});
onError={() => {
Comment thread
marcaaron marked this conversation as resolved.
Growl.error(this.props.translate('onfidoStep.genericError'), 10000);
}}
onUserExit={() => {
Expand Down
4 changes: 1 addition & 3 deletions src/pages/ReimbursementAccount/RequestorStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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);
}}
Expand Down