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
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,7 @@ function AcuantCapture(
const { isMobile } = useContext(DeviceContext);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested this out manually and it mostly worked as expected! However I did see one extra selfie attempt - so if I took 2 pictures, it recorded 3.

const { t, formatHTML } = useI18n();
const [captureAttempts, incrementCaptureAttempts] = useCounter(1);
const selfieAttempts = useRef(0);
const [acuantFailureCookie, setAcuantFailureCookie, refreshAcuantFailureCookie] =
useCookie('AcuantCameraHasFailed');
const [imageCaptureText, setImageCaptureText] = useState('');
Expand Down Expand Up @@ -393,6 +394,7 @@ function AcuantCapture(
const enhancedPayload = {
...payload,
captureAttempts,
selfie_attempts: selfieAttempts.current,
acuantCaptureMode: payload.source === 'upload' ? null : acuantCaptureMode,
liveness_checking_required: isSelfieCaptureEnabled,
};
Expand Down Expand Up @@ -517,14 +519,20 @@ function AcuantCapture(
}

function onSelfieCaptureOpen() {
trackEvent('idv_sdk_selfie_image_capture_opened', { captureAttempts });
trackEvent('idv_sdk_selfie_image_capture_opened', {
captureAttempts,
selfie_attempts: selfieAttempts.current,
});

setImageCaptureText('');
setIsCapturingEnvironment(true);
}

function onSelfieCaptureClosed() {
trackEvent('idv_sdk_selfie_image_capture_closed_without_photo', { captureAttempts });
trackEvent('idv_sdk_selfie_image_capture_closed_without_photo', {
captureAttempts,
selfie_attempts: selfieAttempts.current,
});

setImageCaptureText('');
setIsCapturingEnvironment(false);
Expand All @@ -538,7 +546,11 @@ function AcuantCapture(
failedImageResubmission: false,
});

trackEvent('idv_selfie_image_added', { captureAttempts });
trackEvent('idv_selfie_image_added', {
captureAttempts,
selfie_attempts: selfieAttempts.current,
extra: { here: true },
});

onChangeAndResetError(image, analyticsPayload);
onResetFailedCaptureAttempts();
Expand All @@ -550,6 +562,7 @@ function AcuantCapture(
sdk_error_code: error.code,
sdk_error_message: error.message,
captureAttempts,
selfie_attempts: selfieAttempts.current,
});

// Internally, Acuant sets a cookie to bail on guided capture if initialization had
Expand Down Expand Up @@ -611,6 +624,7 @@ function AcuantCapture(
fingerprint: null,
failedImageResubmission: false,
liveness_checking_required: false,
selfie_attempts: selfieAttempts.current,
});

trackEvent(
Expand Down Expand Up @@ -683,6 +697,10 @@ function AcuantCapture(
setImageCaptureText(text);
}

function onSelfieTaken() {
selfieAttempts.current += 1;
}

return (
<div className={[className, 'document-capture-acuant-capture'].filter(Boolean).join(' ')}>
{isCapturingEnvironment && !selfieCapture && (
Expand All @@ -709,6 +727,7 @@ function AcuantCapture(
onImageCaptureOpen={onSelfieCaptureOpen}
onImageCaptureClose={onSelfieCaptureClosed}
onImageCaptureFeedback={onImageCaptureFeedback}
onSelfieTaken={onSelfieTaken}
>
<FullScreen
ref={fullScreenRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ interface AcuantSelfieCameraContextProps {
* why the acuant sdk cannot capture a selfie.
*/
onImageCaptureFeedback: (text: string) => void;
/**
* Selfie taken, ready for accept or retake
*/
onSelfieTaken: () => void;
/**
* React children node
*/
Expand Down Expand Up @@ -79,6 +83,7 @@ function AcuantSelfieCamera({
onImageCaptureOpen = () => {},
onImageCaptureClose = () => {},
onImageCaptureFeedback = () => {},
onSelfieTaken = () => {},
children,
}: AcuantSelfieCameraContextProps) {
const { isReady, setIsActive } = useContext(AcuantContext);
Expand Down Expand Up @@ -110,6 +115,7 @@ function AcuantSelfieCamera({
},
onPhotoTaken: () => {
// The photo has been taken and it's showing a preview with a button to accept or retake the image.
onSelfieTaken();
},
onPhotoRetake: () => {
// Triggered when retake button is tapped
Expand Down
13 changes: 12 additions & 1 deletion app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3208,13 +3208,15 @@ def idv_sdk_error_before_init(
# @param [String] acuant_version
# @param [Integer] captureAttempts number of attempts to capture / upload an image
# (previously called "attempt")
# @param [Integer] selfie_attempts number of times SDK captured selfie, user may decide to retake
# rubocop:disable Naming/VariableName,Naming/MethodParameterName
def idv_sdk_selfie_image_capture_closed_without_photo(acuant_version:, captureAttempts: nil,
**extra)
selfie_attempts: nil, **extra)
track_event(
:idv_sdk_selfie_image_capture_closed_without_photo,
acuant_version: acuant_version,
captureAttempts: captureAttempts,
selfie_attempts: selfie_attempts,
**extra,
)
end
Expand All @@ -3228,12 +3230,14 @@ def idv_sdk_selfie_image_capture_closed_without_photo(acuant_version:, captureAt
# @param [String] sdk_error_message SDK message for the error encountered
# @param [Integer] captureAttempts number of attempts to capture / upload an image
# (previously called "attempt")
# @param [Integer] selfie_attempts number of times SDK captured selfie, user may decide to retake
# rubocop:disable Naming/VariableName,Naming/MethodParameterName
def idv_sdk_selfie_image_capture_failed(
acuant_version:,
sdk_error_code:,
sdk_error_message:,
captureAttempts: nil,
selfie_attempts: nil,
**extra
)
track_event(
Expand All @@ -3242,6 +3246,7 @@ def idv_sdk_selfie_image_capture_failed(
sdk_error_code: sdk_error_code,
sdk_error_message: sdk_error_message,
captureAttempts: captureAttempts,
selfie_attempts: selfie_attempts,
**extra,
)
end
Expand All @@ -3250,16 +3255,19 @@ def idv_sdk_selfie_image_capture_failed(
# User opened the SDK to take a selfie
# @param [String] acuant_version
# @param [Integer] captureAttempts number of attempts to capture / upload an image
# @param [Integer] selfie_attempts number of times SDK captured selfie, user may decide to retake
# rubocop:disable Naming/VariableName,Naming/MethodParameterName
def idv_sdk_selfie_image_capture_opened(
acuant_version:,
captureAttempts: nil,
selfie_attempts: nil,
**extra
)
track_event(
:idv_sdk_selfie_image_capture_opened,
acuant_version: acuant_version,
captureAttempts: captureAttempts,
selfie_attempts: selfie_attempts,
**extra,
)
end
Expand All @@ -3269,6 +3277,7 @@ def idv_sdk_selfie_image_capture_opened(
# @param [String] acuant_version
# @param [Integer] captureAttempts number of attempts to capture / upload an image
# (previously called "attempt")
# @param [Integer] selfie_attempts number of times SDK captured selfie, user may decide to retake
# @param [Integer] failedImageResubmission
# @param [String] fingerprint fingerprint of the image added
# @param [String] flow_path whether the user is in the hybrid or standard flow
Expand All @@ -3282,6 +3291,7 @@ def idv_sdk_selfie_image_capture_opened(
def idv_selfie_image_added(
acuant_version:,
captureAttempts:,
selfie_attempts:,
failedImageResubmission:,
fingerprint:,
flow_path:,
Expand All @@ -3297,6 +3307,7 @@ def idv_selfie_image_added(
:idv_selfie_image_added,
acuant_version: acuant_version,
captureAttempts: captureAttempts,
selfie_attempts: selfie_attempts,
failedImageResubmission: failedImageResubmission,
fingerprint: fingerprint,
flow_path: flow_path,
Expand Down
2 changes: 1 addition & 1 deletion spec/features/idv/analytics_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@
success: true, errors: {}, flow_path: 'standard', step: 'document_capture', redo_document_capture: nil, skip_hybrid_handoff: nil, acuant_sdk_upgrade_ab_test_bucket: :default, lexisnexis_instant_verify_workflow_ab_test_bucket: :default, analytics_id: 'Doc Auth', irs_reproofing: false, selfie_check_required: boolean, liveness_checking_required: true
},
:idv_selfie_image_added => {
acuant_version: kind_of(String), captureAttempts: 1, failedImageResubmission: nil, fingerprint: 'aIzxkX_iMtoxFOURZr55qkshs53emQKUOr7VfTf6G1Q', flow_path: 'standard', height: 38, mimeType: 'image/png', size: 3694, source: 'upload', width: 284, liveness_checking_required: boolean
acuant_version: kind_of(String), captureAttempts: 1, failedImageResubmission: nil, fingerprint: 'aIzxkX_iMtoxFOURZr55qkshs53emQKUOr7VfTf6G1Q', flow_path: 'standard', height: 38, mimeType: 'image/png', size: 3694, source: 'upload', width: 284, liveness_checking_required: boolean, selfie_attempts: 0
},
'IdV: doc auth ssn visited' => {
flow_path: 'standard', step: 'ssn', acuant_sdk_upgrade_ab_test_bucket: :default, lexisnexis_instant_verify_workflow_ab_test_bucket: :default, skip_hybrid_handoff: anything, analytics_id: 'Doc Auth', irs_reproofing: false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,7 @@ describe('document-capture/components/acuant-capture', () => {
sharpness: 100,
width: 1748,
captureAttempts: sinon.match.number,
selfie_attempts: sinon.match.number,
size: sinon.match.number,
acuantCaptureMode: 'AUTO',
fingerprint: null,
Expand Down Expand Up @@ -873,6 +874,7 @@ describe('document-capture/components/acuant-capture', () => {
sharpness: 49,
width: 1748,
captureAttempts: sinon.match.number,
selfie_attempts: sinon.match.number,
size: sinon.match.number,
acuantCaptureMode: sinon.match.string,
fingerprint: null,
Expand Down Expand Up @@ -986,6 +988,7 @@ describe('document-capture/components/acuant-capture', () => {
sharpness: 49,
width: 1748,
captureAttempts: sinon.match.number,
selfie_attempts: sinon.match.number,
size: sinon.match.number,
acuantCaptureMode: sinon.match.string,
fingerprint: null,
Expand Down