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
5 changes: 5 additions & 0 deletions app/controllers/frontend_log_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ class FrontendLogController < ApplicationController
# rubocop:enable Layout/LineLength

ALLOWED_EVENTS = %i[
idv_sdk_selfie_image_added
idv_sdk_selfie_image_capture_closed_without_photo
idv_sdk_selfie_image_capture_failed
idv_sdk_selfie_image_capture_opened
idv_selfie_image_file_uploaded
phone_input_country_changed
].freeze

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,11 @@ function AcuantCapture(
size: nextValue.size,
failedImageResubmission: hasFailed,
});
trackEvent(`IdV: ${name} image added`, analyticsPayload);

trackEvent(
name === 'selfie' ? 'idv_selfie_image_file_uploaded' : `IdV: ${name} image added`,
analyticsPayload,
);
}

onChangeAndResetError(nextValue, analyticsPayload);
Expand Down Expand Up @@ -498,13 +502,32 @@ function AcuantCapture(
}
}

function onSelfieCaptureOpen() {
trackEvent('idv_sdk_selfie_image_capture_opened');

setIsCapturingEnvironment(true);
}

function onSelfieCaptureClosed() {
trackEvent('idv_sdk_selfie_image_capture_closed_without_photo');

setIsCapturingEnvironment(false);
}

function onSelfieCaptureSuccess({ image }: { image: string }) {
trackEvent('idv_sdk_selfie_image_added', { attempt });

onChangeAndResetError(image);
onResetFailedCaptureAttempts();
setIsCapturingEnvironment(false);
}

function onSelfieCaptureFailure() {
function onSelfieCaptureFailure(error) {
trackEvent('idv_sdk_selfie_image_capture_failed', {
sdk_error_code: error.code,
sdk_error_message: error.message,
});

// Internally, Acuant sets a cookie to bail on guided capture if initialization had
// previously failed for any reason, including declined permission. Since the cookie
// never expires, and since we want to re-prompt even if the user had previously
Expand Down Expand Up @@ -653,8 +676,8 @@ function AcuantCapture(
<AcuantSelfieCamera
onImageCaptureSuccess={onSelfieCaptureSuccess}
onImageCaptureFailure={onSelfieCaptureFailure}
onImageCaptureOpen={() => setIsCapturingEnvironment(true)}
onImageCaptureClose={() => setIsCapturingEnvironment(false)}
onImageCaptureOpen={onSelfieCaptureOpen}
onImageCaptureClose={onSelfieCaptureClosed}
>
<AcuantSelfieCaptureCanvas
fullScreenRef={fullScreenRef}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ interface AcuantSelfieCameraContextProps {
/**
* Failure callback
*/
onImageCaptureFailure: any;
onImageCaptureFailure: (error: { code: number; message: string }) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

🚀

/**
* Capture open callback, tells the rest of the page
* when the fullscreen selfie capture page is open
Expand Down Expand Up @@ -100,7 +100,7 @@ function AcuantSelfieCamera({
onError: (error) => {
// Error occurred. Camera permission not granted will
// manifest here with 1 as error code. Unexpected errors will have 2 as error code.
onImageCaptureFailure({ error });
onImageCaptureFailure(error);
},
onPhotoTaken: () => {
// The photo has been taken and it's showing a preview with a button to accept or retake the image.
Expand Down
68 changes: 68 additions & 0 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2729,6 +2729,74 @@ def idv_request_letter_visited(
)
end

# @param [Integer] attempt number of attempts
# User captured and approved of their selfie
def idv_sdk_selfie_image_added(attempt:, **extra)
track_event(:idv_sdk_selfie_image_added, attempt: attempt, **extra)
end

# User closed the SDK for taking a selfie without submitting a photo
def idv_sdk_selfie_image_capture_closed_without_photo(**extra)
track_event(:idv_sdk_selfie_image_capture_closed_without_photo, **extra)
end

# @param [Integer] sdk_error_code SDK code for the error encountered
# @param [String] sdk_error_message SDK message for the error encountered
# User encountered an error with the SDK selfie process
# Error code 1: camera permission not granted
# Error code 2: unexpected errors
def idv_sdk_selfie_image_capture_failed(sdk_error_code:, sdk_error_message:, **extra)
track_event(
:idv_sdk_selfie_image_capture_failed,
sdk_error_code: sdk_error_code,
sdk_error_message: sdk_error_message,
**extra,
)
end

# User opened the SDK to take a selfie
def idv_sdk_selfie_image_capture_opened(**extra)
track_event(:idv_sdk_selfie_image_capture_opened, **extra)
end

# @param [Integer] attempt number of attempts
# @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
# @param [Integer] height height of image added in pixels
# @param [String] mimeType MIME type of image added
# @param [Integer] size size of image added in bytes
# @param [String] source
# @param [Integer] width width of image added in pixels
# User uploaded a selfie using the file picker
# rubocop:disable Naming/VariableName,Naming/MethodParameterName
def idv_selfie_image_file_uploaded(
attempt:,
failedImageResubmission:,
fingerprint:,
flow_path:,
height:,
mimeType:,
size:,
source:,
width:,
**_extra
)
track_event(
:idv_selfie_image_file_uploaded,
attempt: attempt,
failedImageResubmission: failedImageResubmission,
fingerprint: fingerprint,
flow_path: flow_path,
height: height,
mimeType: mimeType,
size: size,
source: source,
width: width,
)
end
# rubocop:enable Naming/VariableName,Naming/MethodParameterName

# Tracks when the user visits one of the the session error pages.
# @param [String] type
# @param [Integer,nil] attempts_remaining
Expand Down
Loading