diff --git a/app/javascript/packages/document-capture/components/acuant-camera.tsx b/app/javascript/packages/document-capture/components/acuant-camera.tsx index 352e256f44f..cbdc2243d43 100644 --- a/app/javascript/packages/document-capture/components/acuant-camera.tsx +++ b/app/javascript/packages/document-capture/components/acuant-camera.tsx @@ -202,7 +202,7 @@ interface AcuantDetectedResult { } /** - * @see https://github.com/Acuant/JavascriptWebSDKV11/tree/11.4.3/SimpleHTMLApp#acuantcamera + * @see https://github.com/Acuant/JavascriptWebSDKV11/tree/11.8.1#image-from-acuantcameraui-and-acuantcamera */ export interface AcuantSuccessResponse { /** @@ -212,7 +212,7 @@ export interface AcuantSuccessResponse { /** * Document type */ - cardType: AcuantDocumentType; + cardtype: AcuantDocumentType; /** * Detected image glare */ diff --git a/app/javascript/packages/document-capture/components/acuant-capture.tsx b/app/javascript/packages/document-capture/components/acuant-capture.tsx index 1e4078cc2be..dcc7540660b 100644 --- a/app/javascript/packages/document-capture/components/acuant-capture.tsx +++ b/app/javascript/packages/document-capture/components/acuant-capture.tsx @@ -61,7 +61,7 @@ interface ImageAnalyticsPayload { } interface AcuantImageAnalyticsPayload extends ImageAnalyticsPayload { - documentType: AcuantDocumentTypeLabel; + documentType: AcuantDocumentTypeLabel | string; dpi: number; moire: number; glare: number; @@ -135,14 +135,16 @@ export const isAcuantCameraAccessFailure = (error: AcuantCaptureFailureError): e * Returns a human-readable document label corresponding to the given document type constant. * */ -function getDocumentTypeLabel(documentType: AcuantDocumentType): AcuantDocumentTypeLabel { +function getDocumentTypeLabel(documentType: AcuantDocumentType): AcuantDocumentTypeLabel | string { switch (documentType) { + case 0: + return 'none'; case 1: return 'id'; case 2: return 'passport'; default: - return 'none'; + return `An error in document type returned: ${documentType}`; } } @@ -433,7 +435,7 @@ function AcuantCapture( } function onAcuantImageCaptureSuccess(nextCapture: AcuantSuccessResponse) { - const { image, cardType, dpi, moire, glare, sharpness } = nextCapture; + const { image, cardtype, dpi, moire, glare, sharpness } = nextCapture; const isAssessedAsGlare = glare < glareThreshold; const isAssessedAsBlurry = sharpness < sharpnessThreshold; const { width, height, data } = image; @@ -454,7 +456,7 @@ function AcuantCapture( height, mimeType: 'image/jpeg', // Acuant Web SDK currently encodes all images as JPEG source: 'acuant', - documentType: getDocumentTypeLabel(cardType), + documentType: getDocumentTypeLabel(cardtype), dpi, moire, glare, diff --git a/spec/javascript/packages/document-capture/components/acuant-capture-spec.jsx b/spec/javascript/packages/document-capture/components/acuant-capture-spec.jsx index 6457e126011..96bf37f3063 100644 --- a/spec/javascript/packages/document-capture/components/acuant-capture-spec.jsx +++ b/spec/javascript/packages/document-capture/components/acuant-capture-spec.jsx @@ -20,7 +20,7 @@ const ACUANT_CAPTURE_SUCCESS_RESULT = { width: 1748, height: 1104, }, - cardType: 1, + cardtype: 1, dpi: 519, moire: 99, moireraw: 99, @@ -756,6 +756,41 @@ describe('document-capture/components/acuant-capture', () => { }); }); + it('logs a human readable error when the document type errs', async () => { + const trackEvent = sinon.spy(); + const incorrectCardType = 5; + const { findByText, getByText } = render( + + + + + + + , + ); + + initialize({ + start: sinon.stub().callsFake(async (callbacks) => { + await Promise.resolve(); + callbacks.onCaptured(); + await Promise.resolve(); + callbacks.onCropped({ ...ACUANT_CAPTURE_SUCCESS_RESULT, cardtype: incorrectCardType }); + }), + }); + + const button = getByText('doc_auth.buttons.take_picture'); + fireEvent.click(button); + + await findByText('doc_auth.info.image_loading'); + + expect(trackEvent).to.have.been.calledWith( + 'IdV: test image added', + sinon.match({ + documentType: `An error in document type returned: ${incorrectCardType}`, + }), + ); + }); + it('triggers forced upload', () => { const { getByText } = render(