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
9 changes: 6 additions & 3 deletions app/controllers/users/two_factor_authentication_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -224,19 +224,22 @@ def track_events(otp_delivery_preference:)
if UserSessionContext.reauthentication_context?(context)
irs_attempts_api_tracker.mfa_login_phone_otp_sent(
reauthentication: true,
phone_number: parsed_phone.e164,
success: @telephony_result.success?,
phone_number: parsed_phone.e164,
otp_delivery_method: otp_delivery_preference,
)
elsif UserSessionContext.authentication_context?(context)
irs_attempts_api_tracker.mfa_login_phone_otp_sent(
reauthentication: false,
phone_number: parsed_phone.e164,
success: @telephony_result.success?,
phone_number: parsed_phone.e164,
otp_delivery_method: otp_delivery_preference,
)
elsif UserSessionContext.confirmation_context?(context)
irs_attempts_api_tracker.mfa_enroll_phone_otp_sent(
phone_number: parsed_phone.e164,
success: @telephony_result.success?,
phone_number: parsed_phone.e164,
otp_delivery_method: otp_delivery_preference,
)
end
end
Expand Down
22 changes: 13 additions & 9 deletions app/services/irs_attempts_api/tracker_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ def idv_personal_key_generated(success:)

# @param [Boolean] success
# @param [String] phone_number
# @param [String] otp_delivery_method
# @param [String] otp_delivery_method - Either SMS or Voice
# @param [Hash<Key, Array<String>>] failure_reason
# Track when OTP is sent and what method chosen during idv flow.
def idv_phone_confirmation_otp_sent(success:, phone_number:,
Expand Down Expand Up @@ -426,15 +426,17 @@ def mfa_enroll_options_selected(success:, mfa_device_types:)
)
end

# @param [String] phone_number - The user's phone_number used for multi-factor authentication
# @param [Boolean] success - True if the OTP Verification was sent
# @param [String] phone_number - The user's phone_number used for multi-factor authentication
# @param [String] otp_delivery_method - Either SMS or Voice
# Relevant only when the user is enrolling a phone as their MFA.
# The user has been sent an OTP by login.gov over SMS during the MFA enrollment process.
def mfa_enroll_phone_otp_sent(phone_number:, success:)
# The user has been sent an OTP and by SMS or Voice during the MFA enrollment process.
def mfa_enroll_phone_otp_sent(success:, phone_number:, otp_delivery_method:)
track_event(
:mfa_enroll_phone_otp_sent,
phone_number: phone_number,
success: success,
phone_number: phone_number,
otp_delivery_method: otp_delivery_method,
)
end

Expand Down Expand Up @@ -521,15 +523,17 @@ def mfa_login_backup_code(success:)
end

# @param [Boolean] reauthentication - True if the user was already logged in
# @param [String] phone_number - The user's phone_number used for multi-factor authentication
# @param [Boolean] success - True if the OTP Verification was sent
# During a login attempt, an OTP code has been sent via SMS.
def mfa_login_phone_otp_sent(reauthentication:, phone_number:, success:)
# @param [String] phone_number - The user's phone_number used for multi-factor authentication
# @param [String] otp_delivery_method - Either SMS or Voice
# During a login attempt, an OTP code has been sent via SMS or Voice.
def mfa_login_phone_otp_sent(reauthentication:, success:, phone_number:, otp_delivery_method:)
track_event(
:mfa_login_phone_otp_sent,
reauthentication: reauthentication,
phone_number: phone_number,
success: success,
phone_number: phone_number,
otp_delivery_method: otp_delivery_method,
)
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,12 @@ def index
it 'tracks the verification attempt event' do
stub_attempts_tracker
expect(@irs_attempts_api_tracker).to receive(:mfa_login_phone_otp_sent).
with(phone_number: '+12025551212', reauthentication: false, success: true)
with(
phone_number: '+12025551212',
reauthentication: false,
success: true,
otp_delivery_method: 'sms',
)

get :send_code, params: { otp_delivery_selection_form:
{ otp_delivery_preference: 'sms' } }
Expand All @@ -338,7 +343,12 @@ def index
subject.user_session[:context] = 'reauthentication'

expect(@irs_attempts_api_tracker).to receive(:mfa_login_phone_otp_sent).
with(phone_number: '+12025551212', reauthentication: true, success: true)
with(
phone_number: '+12025551212',
reauthentication: true,
success: true,
otp_delivery_method: 'sms',
)

get :send_code, params: { otp_delivery_selection_form:
{ otp_delivery_preference: 'sms' } }
Expand Down Expand Up @@ -532,7 +542,7 @@ def index

stub_attempts_tracker
expect(@irs_attempts_api_tracker).to receive(:mfa_enroll_phone_otp_sent).
with({ phone_number: '+12025551213', success: true })
with({ phone_number: '+12025551213', success: true, otp_delivery_method: 'sms' })

get :send_code, params: { otp_delivery_selection_form: { otp_delivery_preference: 'sms' } }
end
Expand Down