Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
c7864d8
Note the places for addition
charleyf Feb 26, 2024
3293150
Add FE logging and fix existing tests
charleyf Feb 26, 2024
b027ec7
changelog: Internal, In-Person Proofing, Add FE logging for liveness_…
charleyf Feb 26, 2024
d5d1dff
test commit
charleyf Feb 26, 2024
8320a0f
Merge branch 'main' into charley/lg-12160-logs-add-fe
charleyf Feb 26, 2024
02ae174
Add to FE logs
charleyf Feb 27, 2024
772c8f3
Add additional FE events
charleyf Feb 27, 2024
a9da90f
Remove unnessecary change - liveness_checking_required is already inc…
charleyf Feb 28, 2024
1455f33
Add `liveness_checking_required` to more FE events
charleyf Feb 28, 2024
34f21f1
Add new value to tests
charleyf Feb 28, 2024
75cb337
Merge branch 'main' into charley/lg-12160-logs-add-fe
charleyf Feb 28, 2024
396f50b
Fix missing argument
charleyf Feb 28, 2024
105cf15
Merge branch 'main' into charley/lg-12160-logs-add-fe
charleyf Feb 28, 2024
c73d7a0
Remove duplicate param doc
charleyf Feb 29, 2024
4c6710e
Merge branch 'main' into charley/lg-12160-logs-add-fe
charleyf Feb 29, 2024
7c8654e
Lint fixes
charleyf Feb 29, 2024
aa76de9
Merge branch 'main' into charley/lg-12160-logs-add-fe
charleyf Feb 29, 2024
9ad3d3e
Merge branch 'main' into charley/lg-12160-logs-add-fe
charleyf Feb 29, 2024
7b968ee
Merge branch 'main' into charley/lg-12160-logs-add-fe
charleyf Mar 8, 2024
26f8af4
Use the new SelfieCaptureContext
charleyf Mar 8, 2024
bd90f48
Update events to include "image added" events
charleyf Mar 8, 2024
9a79f9c
Document events to fix lint problem
charleyf Mar 8, 2024
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 @@ -22,6 +22,7 @@ import AcuantCaptureCanvas from './acuant-capture-canvas';
import AcuantContext, { AcuantCaptureMode } from '../context/acuant';
import AnalyticsContext from '../context/analytics';
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 locally with both selfie on and off. I saw mostly what's expected (and always the correct value), with a few caveats:

  1. I didn't see the image added events have the liveness_checking_required field (image clicked ones did have it though). I didn't see it in front, back, or selfie added events.
  2. I had trouble triggering the following events and so didn't test them:
    Frontend: IdV: barcode warning continue clicked
    Frontend: IdV: barcode warning retake photos clicked
    Frontend: IdV: Image capture failed
    
  3. I did see some additional events not listed in the PR with the field:
IdV: doc auth document_capture visited
IdV: doc auth image upload form submitted
IdV: doc auth image upload vendor submitted
IdV: doc auth image upload vendor pii validation
IdV: doc auth document_capture submitted
IdV: failed doc image resubmitted

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

  1. I forgot to add them to the analytics 😅 fixed.
  2. 🤷 Seems reasonable to me. I'm comfortable merging with just automated tests for these.
  3. Those are coming for free since I added to the getAddAttemptAnalyticsPayload. I think it's good to have the new property more places.

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.

Thanks for fixing #1! The rest makes sense to me.

import DeviceContext from '../context/device';
import SelfieCaptureContext from '../context/selfie-capture';
import FailedCaptureAttemptsContext from '../context/failed-capture-attempts';
import FileInput from './file-input';
import UploadContext from '../context/upload';
Expand Down Expand Up @@ -320,6 +321,7 @@ function AcuantCapture(
} = useContext(AcuantContext);
const { isMockClient } = useContext(UploadContext);
const { trackEvent } = useContext(AnalyticsContext);
const { isSelfieCaptureEnabled } = useContext(SelfieCaptureContext);
const fullScreenRef = useRef<FullScreenRefHandle>(null);
const inputRef = useRef<HTMLInputElement>(null);
const isForceUploading = useRef(false);
Expand Down Expand Up @@ -382,6 +384,7 @@ function AcuantCapture(
...payload,
captureAttempts,
acuantCaptureMode: payload.source === 'upload' ? null : acuantCaptureMode,
liveness_checking_required: isSelfieCaptureEnabled,
};
incrementCaptureAttempts();
return enhancedPayload;
Expand Down Expand Up @@ -424,7 +427,11 @@ function AcuantCapture(
return <T extends (...args: any[]) => any>(fn: T) =>
(...args: Parameters<T>) => {
if (!isSuppressingClickLogging.current) {
trackEvent(`IdV: ${name} image clicked`, { source, ...metadata });
trackEvent(`IdV: ${name} image clicked`, {
source,
...metadata,
liveness_checking_required: isSelfieCaptureEnabled,
});
}

return fn(...args);
Expand Down Expand Up @@ -591,6 +598,7 @@ function AcuantCapture(
size: getDecodedBase64ByteSize(nextCapture.image.data),
fingerprint: null,
failedImageResubmission: false,
liveness_checking_required: false,
});

trackEvent(
Expand Down Expand Up @@ -655,6 +663,7 @@ function AcuantCapture(
field: name,
acuantCaptureMode,
error: getNormalizedAcuantCaptureFailureMessage(error, code),
liveness_checking_required: isSelfieCaptureEnabled,
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Button, StatusPage } from '@18f/identity-components';
import { t } from '@18f/identity-i18n';
import { trackEvent } from '@18f/identity-analytics';
import { useContext } from 'react';
import { removeUnloadProtection } from '@18f/identity-url';
import type { PII } from '../services/upload';
import DocumentCaptureTroubleshootingOptions from './document-capture-troubleshooting-options';
import SelfieCaptureContext from '../context/selfie-capture';

interface BarcodeAttentionWarningProps {
/**
Expand All @@ -18,15 +20,20 @@ interface BarcodeAttentionWarningProps {
}

function BarcodeAttentionWarning({ onDismiss, pii }: BarcodeAttentionWarningProps) {
const { isSelfieCaptureEnabled } = useContext(SelfieCaptureContext);
function skipAttention() {
trackEvent('IdV: barcode warning continue clicked');
trackEvent('IdV: barcode warning continue clicked', {
liveness_checking_required: isSelfieCaptureEnabled,
});
removeUnloadProtection();
const form = document.querySelector<HTMLFormElement>('.js-document-capture-form');
form?.submit();
}

function handleDismiss() {
trackEvent('IdV: barcode warning retake photos clicked');
trackEvent('IdV: barcode warning retake photos clicked', {
liveness_checking_required: isSelfieCaptureEnabled,
});
onDismiss();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import DocumentCaptureTroubleshootingOptions from './document-capture-troublesho
import UnknownError from './unknown-error';
import { InPersonContext } from '../context';
import AnalyticsContext from '../context/analytics';
import SelfieCaptureContext from '../context/selfie-capture';

interface DocumentCaptureWarningProps {
isFailedDocType: boolean;
Expand Down Expand Up @@ -77,6 +78,7 @@ function DocumentCaptureWarning({
}: DocumentCaptureWarningProps) {
const { t } = useI18n();
const { inPersonURL } = useContext(InPersonContext);
const { isSelfieCaptureEnabled } = useContext(SelfieCaptureContext);
const { trackEvent } = useContext(AnalyticsContext);

const nonIppOrFailedResult = !inPersonURL || isFailedResult;
Expand Down Expand Up @@ -109,6 +111,7 @@ function DocumentCaptureWarning({
heading,
subheading: subheadingText,
error_message_displayed: errorMessageDisplayed,
liveness_checking_required: isSelfieCaptureEnabled,
});
}, []);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type { PII } from '../services/upload';
import AnalyticsContext from '../context/analytics';
import BarcodeAttentionWarning from './barcode-attention-warning';
import FailedCaptureAttemptsContext from '../context/failed-capture-attempts';
import SelfieCaptureContext from '../context/selfie-capture';
import DocumentCaptureWarning from './document-capture-warning';
import DocumentCaptureReviewIssues from './document-capture-review-issues';

Expand Down Expand Up @@ -64,6 +65,7 @@ function ReviewIssuesStep({
failedImageFingerprints = { front: [], back: [] },
}: ReviewIssuesStepProps) {
const { trackEvent } = useContext(AnalyticsContext);
const { isSelfieCaptureEnabled } = useContext(SelfieCaptureContext);
const [hasDismissed, setHasDismissed] = useState(remainingSubmitAttempts === Infinity);
const { onPageTransition, changeStepCanComplete } = useContext(FormStepsContext);
const [skipWarning, setSkipWarning] = useState(false);
Expand Down Expand Up @@ -100,7 +102,9 @@ function ReviewIssuesStep({
}, []);

function onWarningPageDismissed() {
trackEvent('IdV: Capture troubleshooting dismissed');
trackEvent('IdV: Capture troubleshooting dismissed', {
liveness_checking_required: isSelfieCaptureEnabled,
});

setHasDismissed(true);
}
Expand Down
4 changes: 4 additions & 0 deletions app/javascript/packages/document-capture/context/acuant.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import type { ReactNode } from 'react';
import useObjectMemo from '@18f/identity-react-hooks/use-object-memo';
import AnalyticsContext from './analytics';
import DeviceContext from './device';
import SelfieCaptureContext from './selfie-capture';

/**
* Global declarations
Expand Down Expand Up @@ -221,6 +222,7 @@ function AcuantContextProvider({
}: AcuantContextProviderProps) {
const { isMobile } = useContext(DeviceContext);
const { trackEvent } = useContext(AnalyticsContext);
const { isSelfieCaptureEnabled } = useContext(SelfieCaptureContext);
// Only mobile devices should load the Acuant SDK. Consider immediately ready otherwise.
const [isReady, setIsReady] = useState(!isMobile);
const [isAcuantLoaded, setIsAcuantLoaded] = useState(false);
Expand Down Expand Up @@ -275,6 +277,7 @@ function AcuantContextProvider({
trackEvent('IdV: Acuant SDK loaded', {
success: true,
isCameraSupported: nextIsCameraSupported,
liveness_checking_required: isSelfieCaptureEnabled,
});

setIsCameraSupported(nextIsCameraSupported);
Expand All @@ -287,6 +290,7 @@ function AcuantContextProvider({
success: false,
code,
description,
liveness_checking_required: isSelfieCaptureEnabled,
});

setIsError(true);
Expand Down
32 changes: 30 additions & 2 deletions app/services/analytics_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -612,6 +612,7 @@ def fraud_review_rejected(
# @param [Boolean] isCameraSupported
# @param [Boolean] success
# @param [Boolean] use_alternate_sdk
# @param [Boolean] liveness_checking_required
# The Acuant SDK was loaded
# rubocop:disable Naming/VariableName,Naming/MethodParameterName
def idv_acuant_sdk_loaded(
Expand All @@ -621,6 +622,7 @@ def idv_acuant_sdk_loaded(
isCameraSupported:,
success:,
use_alternate_sdk:,
liveness_checking_required:,
**_extra
)
track_event(
Expand All @@ -631,6 +633,7 @@ def idv_acuant_sdk_loaded(
isCameraSupported: isCameraSupported,
success: success,
use_alternate_sdk: use_alternate_sdk,
liveness_checking_required: liveness_checking_required,
)
end
# rubocop:enable Naming/VariableName,Naming/MethodParameterName
Expand Down Expand Up @@ -689,6 +692,7 @@ def idv_address_visit
# @param [Integer] size size of image added in bytes
# @param [String] source
# @param [Boolean] use_alternate_sdk
# @param [String] liveness_checking_required Whether or not the selfie is required
# @param [Integer] width width of image added in pixels
# Back image was added in document capture
# rubocop:disable Naming/VariableName,Naming/MethodParameterName
Expand Down Expand Up @@ -716,6 +720,7 @@ def idv_back_image_added(
size:,
source:,
use_alternate_sdk:,
liveness_checking_required:,
width:,
**_extra
)
Expand Down Expand Up @@ -744,6 +749,7 @@ def idv_back_image_added(
size: size,
source: source,
use_alternate_sdk: use_alternate_sdk,
liveness_checking_required: liveness_checking_required,
width: width,
)
end
Expand All @@ -754,13 +760,15 @@ def idv_back_image_added(
# @param [Boolean] isDrop
# @param [Boolean] source
# @param [Boolean] use_alternate_sdk
# @param [String] liveness_checking_required Whether or not the selfie is required
def idv_back_image_clicked(
acuant_sdk_upgrade_a_b_testing_enabled:,
acuant_version:,
flow_path:,
isDrop:,
source:,
use_alternate_sdk:,
liveness_checking_required:,
**_extra
)
track_event(
Expand All @@ -771,19 +779,24 @@ def idv_back_image_clicked(
isDrop: isDrop,
source: source,
use_alternate_sdk: use_alternate_sdk,
liveness_checking_required: liveness_checking_required,
)
end
# rubocop:enable Naming/VariableName,Naming/MethodParameterName

def idv_barcode_warning_continue_clicked(**_extra)
# @param [String] liveness_checking_required Whether or not the selfie is required
def idv_barcode_warning_continue_clicked(liveness_checking_required:, **_extra)
track_event(
'Frontend: IdV: barcode warning continue clicked',
liveness_checking_required: liveness_checking_required,
)
end

def idv_barcode_warning_retake_photos_clicked(**_extra)
# @param [String] liveness_checking_required Whether or not the selfie is required
def idv_barcode_warning_retake_photos_clicked(liveness_checking_required:, **_extra)
track_event(
'Frontend: IdV: barcode warning retake photos clicked',
liveness_checking_required: liveness_checking_required,
)
end

Expand Down Expand Up @@ -835,11 +848,13 @@ def idv_cancellation_visited(
# @param [String] acuant_version
# @param [String] flow_path whether the user is in the hybrid or standard flow
# @param [String] use_alternate_sdk
# @param [Boolean] liveness_checking_required
def idv_capture_troubleshooting_dismissed(
acuant_sdk_upgrade_a_b_testing_enabled:,
acuant_version:,
flow_path:,
use_alternate_sdk:,
liveness_checking_required:,
**_extra
)
track_event(
Expand All @@ -848,6 +863,7 @@ def idv_capture_troubleshooting_dismissed(
acuant_version: acuant_version,
flow_path: flow_path,
use_alternate_sdk: use_alternate_sdk,
liveness_checking_required: liveness_checking_required,
)
end

Expand Down Expand Up @@ -1347,6 +1363,7 @@ def idv_forgot_password_confirmed(proofing_components: nil, **extra)
# @param [Integer] size size of image added in bytes
# @param [String] source
# @param [Boolean] use_alternate_sdk
# @param [String] liveness_checking_required Whether or not the selfie is required
# @param [Integer] width width of image added in pixels
# Front image was added in document capture
# rubocop:disable Naming/VariableName,Naming/MethodParameterName
Expand Down Expand Up @@ -1374,6 +1391,7 @@ def idv_front_image_added(
size:,
source:,
use_alternate_sdk:,
liveness_checking_required:,
width:,
**_extra
)
Expand Down Expand Up @@ -1402,6 +1420,7 @@ def idv_front_image_added(
size: size,
source: source,
use_alternate_sdk: use_alternate_sdk,
liveness_checking_required: liveness_checking_required,
width: width,
)
end
Expand All @@ -1412,13 +1431,15 @@ def idv_front_image_added(
# @param [Boolean] isDrop
# @param [String] source
# @param [String] use_alternate_sdk
# @param [Boolean] liveness_checking_required
def idv_front_image_clicked(
acuant_sdk_upgrade_a_b_testing_enabled:,
acuant_version:,
flow_path:,
isDrop:,
source:,
use_alternate_sdk:,
liveness_checking_required: nil,
**_extra
)
track_event(
Expand All @@ -1429,6 +1450,7 @@ def idv_front_image_clicked(
isDrop: isDrop,
source: source,
use_alternate_sdk: use_alternate_sdk,
liveness_checking_required: liveness_checking_required,
)
end
# rubocop:enable Naming/VariableName,Naming/MethodParameterName
Expand Down Expand Up @@ -2897,6 +2919,7 @@ def idv_sdk_selfie_image_capture_opened(captureAttempts: nil, **extra)
# @param [String] mimeType MIME type of image added
# @param [Integer] size size of image added in bytes
# @param [String] source
# @param [String] liveness_checking_required Whether or not the selfie is required
# @param [Integer] width width of image added in pixels
# rubocop:disable Naming/VariableName,Naming/MethodParameterName
def idv_selfie_image_added(
Expand All @@ -2908,6 +2931,7 @@ def idv_selfie_image_added(
mimeType:,
size:,
source:,
liveness_checking_required:,
width:,
**_extra
)
Expand All @@ -2921,6 +2945,7 @@ def idv_selfie_image_added(
mimeType: mimeType,
size: size,
source: source,
liveness_checking_required: liveness_checking_required,
width: width,
)
end
Expand Down Expand Up @@ -3094,6 +3119,7 @@ def idv_warning_action_triggered(
# @param [Integer] remaining_submit_attempts (previously called "remaining_attempts")
# @param [String] subheading
# @param [Boolean] use_alternate_sdk
# @param [Boolean] liveness_checking_required
def idv_warning_shown(
acuant_sdk_upgrade_a_b_testing_enabled:,
acuant_version:,
Expand All @@ -3104,6 +3130,7 @@ def idv_warning_shown(
remaining_submit_attempts:,
subheading:,
use_alternate_sdk:,
liveness_checking_required:,
**_extra
)
track_event(
Expand All @@ -3117,6 +3144,7 @@ def idv_warning_shown(
remaining_submit_attempts: remaining_submit_attempts,
subheading: subheading,
use_alternate_sdk: use_alternate_sdk,
liveness_checking_required: liveness_checking_required,
)
end

Expand Down
Loading