diff --git a/app/controllers/idv/phone_controller.rb b/app/controllers/idv/phone_controller.rb index 6f8c4a5aaf1..fdb6d6d5d83 100644 --- a/app/controllers/idv/phone_controller.rb +++ b/app/controllers/idv/phone_controller.rb @@ -31,7 +31,7 @@ def new def create result = idv_form.submit(step_params) - analytics.track_event(Analytics::IDV_PHONE_CONFIRMATION_FORM, result.to_h) + analytics.idv_phone_confirmation_form_submitted(**result.to_h) flash[:error] = result.first_error_message if !result.success? return render :new, locals: { gpo_letter_available: gpo_letter_available } if !result.success? submit_proofing_attempt @@ -117,9 +117,8 @@ def failure_url(reason) def async_state_done(async_state) form_result = step.async_state_done(async_state) - analytics.track_event( - Analytics::IDV_PHONE_CONFIRMATION_VENDOR, - form_result.to_h.merge( + analytics.idv_phone_confirmation_vendor_submitted( + **form_result.to_h.merge( pii_like_keypaths: [ [:errors, :phone], [:context, :stages, :address], diff --git a/app/services/analytics.rb b/app/services/analytics.rb index 9c6fc1485cc..1b9f4f58438 100644 --- a/app/services/analytics.rb +++ b/app/services/analytics.rb @@ -148,8 +148,6 @@ def session_started_at IDV_INTRO_VISIT = 'IdV: intro visited' IDV_JURISDICTION_VISIT = 'IdV: jurisdiction visited' IDV_JURISDICTION_FORM = 'IdV: jurisdiction form submitted' - IDV_PHONE_CONFIRMATION_FORM = 'IdV: phone confirmation form' - IDV_PHONE_CONFIRMATION_VENDOR = 'IdV: phone confirmation vendor' IDV_PHONE_CONFIRMATION_OTP_RATE_LIMIT_ATTEMPTS = 'Idv: Phone OTP attempts rate limited' IDV_PHONE_CONFIRMATION_OTP_RATE_LIMIT_LOCKED_OUT = 'Idv: Phone OTP rate limited user' IDV_PHONE_CONFIRMATION_OTP_RATE_LIMIT_SENDS = 'Idv: Phone OTP sends rate limited' diff --git a/app/services/analytics_events.rb b/app/services/analytics_events.rb index 29ad24d1dac..a4383ce7829 100644 --- a/app/services/analytics_events.rb +++ b/app/services/analytics_events.rb @@ -530,6 +530,40 @@ def idv_personal_key_confirm_visited(*) track_event('IdV: personal key confirm visited') end + # @identity.idp.event_name IdV: phone confirmation form + # @param [Boolean] success + # @param [Hash] errors + # The user submitted their phone on the phone confirmation page + def idv_phone_confirmation_form_submitted( + success:, + errors:, + **extra + ) + track_event( + 'IdV: phone confirmation form', + success: success, + errors: errors, + **extra, + ) + end + + # @identity.idp.event_name IdV: phone confirmation vendor + # @param [Boolean] success + # @param [Hash] errors + # The vendor finished the process of confirming the users phone + def idv_phone_confirmation_vendor_submitted( + success:, + errors:, + **extra + ) + track_event( + 'IdV: phone confirmation vendor', + success: success, + errors: errors, + **extra, + ) + end + # @identity.idp.event_name IdV: phone confirmation otp submitted # @param [Boolean] success # @param [Hash] errors diff --git a/spec/controllers/idv/phone_controller_spec.rb b/spec/controllers/idv/phone_controller_spec.rb index b21227a32cf..c27e6121573 100644 --- a/spec/controllers/idv/phone_controller_spec.rb +++ b/spec/controllers/idv/phone_controller_spec.rb @@ -174,7 +174,7 @@ } expect(@analytics).to have_received(:track_event).with( - Analytics::IDV_PHONE_CONFIRMATION_FORM, result + 'IdV: phone confirmation form', result ) expect(subject.idv_session.vendor_phone_confirmation).to be_falsy end @@ -204,7 +204,7 @@ } expect(@analytics).to have_received(:track_event).with( - Analytics::IDV_PHONE_CONFIRMATION_FORM, result + 'IdV: phone confirmation form', result ) end @@ -313,10 +313,10 @@ } expect(@analytics).to receive(:track_event).ordered.with( - Analytics::IDV_PHONE_CONFIRMATION_FORM, hash_including(:success) + 'IdV: phone confirmation form', hash_including(:success) ) expect(@analytics).to receive(:track_event).ordered.with( - Analytics::IDV_PHONE_CONFIRMATION_VENDOR, result + 'IdV: phone confirmation vendor', result ) put :create, params: { idv_phone_form: { phone: good_phone } } @@ -365,13 +365,13 @@ } expect(@analytics).to receive(:track_event).ordered.with( - Analytics::IDV_PHONE_CONFIRMATION_FORM, hash_including(:success) + 'IdV: phone confirmation form', hash_including(:success) ) put :create, params: { idv_phone_form: { phone: bad_phone } } expect(@analytics).to receive(:track_event).ordered.with( - Analytics::IDV_PHONE_CONFIRMATION_VENDOR, result + 'IdV: phone confirmation vendor', result ) expect(response).to redirect_to idv_phone_path