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
1 change: 1 addition & 0 deletions app/controllers/frontend_log_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class FrontendLogController < ApplicationController
idv_sdk_selfie_image_capture_closed_without_photo
idv_sdk_selfie_image_capture_failed
idv_sdk_selfie_image_capture_opened
idv_sdk_selfie_image_re_taken
idv_selfie_image_added
idv_selfie_image_clicked
phone_input_country_changed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,6 @@ function AcuantCapture(
trackEvent('idv_selfie_image_added', {
captureAttempts,
selfie_attempts: selfieAttempts.current,
extra: { here: true },
});

onChangeAndResetError(image, analyticsPayload);
Expand Down Expand Up @@ -586,6 +585,13 @@ function AcuantCapture(
setIsCapturingEnvironment(false);
}

function onSelfieRetaken() {
trackEvent('idv_sdk_selfie_image_re_taken', {
captureAttempts,
selfie_attempts: selfieAttempts.current,
});
}

function onAcuantImageCaptureSuccess(nextCapture: AcuantSuccessResponse) {
const { image, dpi, moire, glare, sharpness, cardType } = nextCapture;

Expand Down Expand Up @@ -732,6 +738,7 @@ function AcuantCapture(
onImageCaptureClose={onSelfieCaptureClosed}
onImageCaptureFeedback={onImageCaptureFeedback}
onSelfieTaken={onSelfieTaken}
onSelfieRetaken={onSelfieRetaken}
>
<FullScreen
ref={fullScreenRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ interface AcuantSelfieCameraContextProps {
* Selfie taken, ready for accept or retake
*/
onSelfieTaken: () => void;
/**
* Selfie captured by user initiated retake
*/
onSelfieRetaken: () => void;
/**
* React children node
*/
Expand Down Expand Up @@ -84,6 +88,7 @@ function AcuantSelfieCamera({
onImageCaptureClose = () => {},
onImageCaptureFeedback = () => {},
onSelfieTaken = () => {},
onSelfieRetaken = () => {},
children,
}: AcuantSelfieCameraContextProps) {
const { isReady, setIsActive } = useContext(AcuantContext);
Expand Down Expand Up @@ -119,6 +124,7 @@ function AcuantSelfieCamera({
},
onPhotoRetake: () => {
// Triggered when retake button is tapped
onSelfieRetaken();
},
onCaptured: (base64Image) => {
// Triggered when accept button is tapped
Expand Down
19 changes: 19 additions & 0 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3280,6 +3280,25 @@ def idv_sdk_selfie_image_capture_opened(
**extra,
)
end

# 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 selfie captured by SDK
def idv_sdk_selfie_image_re_taken(
acuant_version:,
captureAttempts: nil,
selfie_attempts: nil,
**extra
)
track_event(
:idv_sdk_selfie_image_re_taken,
acuant_version: acuant_version,
captureAttempts: captureAttempts,
selfie_attempts: selfie_attempts,
**extra,
)
end
# rubocop:enable Naming/VariableName,Naming/MethodParameterName

# User took a selfie image with the SDK, or uploaded a selfie using the file picker
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1222,6 +1222,30 @@ describe('document-capture/components/acuant-capture', () => {
'idv_selfie_image_added',
sinon.match({
captureAttempts: sinon.match.number,
selfie_attempts: sinon.match.number,
}),
);
});

it('calls trackEvent from onSelfieRetake', () => {
// In real use the `start` method opens the Acuant SDK full screen selfie capture window.
// Because we can't do that in test (AcuantSDK does not allow), this doesn't attempt to load
// the SDK. Instead, it simply calls the callback that happens when a photo is captured.
// This allows us to test everything about that callback -except- the Acuant SDK parts.
initialize({
selfieStart: sinon.stub().callsFake((callbacks) => {
callbacks.onPhotoTaken();
callbacks.onPhotoRetake();
}),
});

expect(trackEvent).to.be.calledWith('idv_selfie_image_clicked');
expect(trackEvent).to.be.calledWith('IdV: Acuant SDK loaded');
expect(trackEvent).to.be.calledWith(
'idv_sdk_selfie_image_re_taken',
sinon.match({
captureAttempts: sinon.match.number,
selfie_attempts: sinon.match.number,
}),
);
});
Expand Down