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
4 changes: 4 additions & 0 deletions app/controllers/users/passwords_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ def update
result = @update_user_password_form.submit(user_params)

analytics.password_changed(**result.to_h)
irs_attempts_api_tracker.logged_in_password_change(
success: result.success?,
failure_reason: result.to_h[:error_details],
)

if result.success?
handle_valid_password
Expand Down
82 changes: 46 additions & 36 deletions app/services/irs_attempts_api/tracker_events.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ def forgot_password_new_password_submitted(success:, failure_reason: nil)
)
end

# The user has exceeded the rate limit during idv document upload
def idv_document_upload_rate_limited
track_event(
:idv_document_upload_rate_limited,
)
end

# @param [Boolean] success
# @param [String] document_state
# @param [String] document_number
Expand Down Expand Up @@ -139,42 +146,6 @@ def idv_document_upload_submitted(
)
end

# Tracks when the user submits their idv phone number
# @param [String] phone_number
# param [Boolean] success
# @param [Hash<Symbol,Array<Symbol>>] failure_reason
def idv_phone_submitted(phone_number:, success:, failure_reason: nil)
track_event(
:idv_phone_submitted,
phone_number: phone_number,
success: success,
failure_reason: failure_reason,
)
end

# Tracks Idv phone OTP sent rate limits
def idv_phone_otp_sent_rate_limited
track_event(
:idv_phone_otp_sent_rate_limited,
)
end

# The user has exceeded the rate limit during idv document upload
def idv_document_upload_rate_limited
track_event(
:idv_document_upload_rate_limited,
)
end

# Tracks when the user submits a password for identity proofing
# @param [Boolean] success
def idv_password_entered(success:)
track_event(
:idv_password_entered,
success: success,
)
end

# param [Boolean] Success
# param [Hash<Key, Array<String>>] failure_reason displays GPO submission failed
# GPO verification submitted from Letter sent to verify address
Expand Down Expand Up @@ -204,6 +175,15 @@ def idv_letter_requested(success:, resend:)
)
end

# Tracks when the user submits a password for identity proofing
# @param [Boolean] success
def idv_password_entered(success:)
track_event(
:idv_password_entered,
success: success,
)
end

# @param [Boolean] success
# Personal Key got generated for user
def idv_personal_key_generated(success:)
Expand Down Expand Up @@ -236,6 +216,13 @@ def idv_phone_confirmation_otp_sent_rate_limited
)
end

# Tracks Idv phone OTP sent rate limits
def idv_phone_otp_sent_rate_limited
track_event(
:idv_phone_otp_sent_rate_limited,
)
end

# Tracks when a user submits OTP code sent to their phone
# @param [String] phone_number
# param [Boolean] success
Expand All @@ -258,6 +245,19 @@ def idv_phone_otp_submitted_rate_limited(phone:)
)
end

# Tracks when the user submits their idv phone number
# @param [String] phone_number
# param [Boolean] success
# @param [Hash<Symbol,Array<Symbol>>] failure_reason
def idv_phone_submitted(phone_number:, success:, failure_reason: nil)
track_event(
:idv_phone_submitted,
phone_number: phone_number,
success: success,
failure_reason: failure_reason,
)
end

# @param [Boolean] success
# @param [String] phone_number
# The phone number that the link was sent to during the IDV process
Expand Down Expand Up @@ -340,6 +340,16 @@ def idv_verification_submitted(
)
end

# @param [Boolean] success True if the password was successfully changed
# A logged-in user has attempted to change their password
def logged_in_password_change(success:, failure_reason: nil)
track_event(
:logged_in_password_change,
success: success,
failure_reason: failure_reason,
)
end

# @param [String] email
# A login attempt was rejected due to too many incorrect attempts
def login_rate_limited(email)
Expand Down
13 changes: 13 additions & 0 deletions spec/controllers/users/passwords_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,17 @@
it 'redirects to profile and sends a password change email' do
stub_sign_in
stub_analytics
stub_attempts_tracker
allow(@analytics).to receive(:track_event)
allow(@irs_attempts_api_tracker).to receive(:track_event)

params = { password: 'salty new password' }
patch :update, params: { update_user_password_form: params }

expect(@analytics).to have_received(:track_event).
with('Password Changed', success: true, errors: {})
expect(@irs_attempts_api_tracker).to have_received(:track_event).
with(:logged_in_password_change, failure_reason: nil, success: true)
expect(response).to redirect_to account_url
expect(flash[:info]).to eq t('notices.password_changed')
expect(flash[:personal_key]).to be_nil
Expand Down Expand Up @@ -77,7 +81,9 @@
stub_sign_in

stub_analytics
stub_attempts_tracker
allow(@analytics).to receive(:track_event)
allow(@irs_attempts_api_tracker).to receive(:track_event)

params = { password: 'new' }
patch :update, params: { update_user_password_form: params }
Expand All @@ -92,6 +98,13 @@
},
error_details: { password: [:too_short] },
)
expect(@irs_attempts_api_tracker).to have_received(:track_event).with(
:logged_in_password_change,
success: false,
failure_reason: {
password: [:too_short],
},
)
expect(response).to render_template(:edit)
end

Expand Down