diff --git a/modules/accredited_representative_portal/app/services/accredited_representative_portal/power_of_attorney_request_service/create.rb b/modules/accredited_representative_portal/app/services/accredited_representative_portal/power_of_attorney_request_service/create.rb index 11016c35b60..541b46d78fd 100644 --- a/modules/accredited_representative_portal/app/services/accredited_representative_portal/power_of_attorney_request_service/create.rb +++ b/modules/accredited_representative_portal/app/services/accredited_representative_portal/power_of_attorney_request_service/create.rb @@ -65,9 +65,13 @@ def create_poa_request end request.save! - Monitoring.new.track_count('ar.poa.request.count') end + pathway = @registration_number.present? ? 'rep_first' : 'org_first' + + Monitoring.new.track_count('ar.poa.request.count') + Monitoring.new.track_count("ar.poa.request.pathway.#{pathway}") + request end end diff --git a/modules/accredited_representative_portal/spec/services/accredited_representative_portal/power_of_attorney_request_service/create_spec.rb b/modules/accredited_representative_portal/spec/services/accredited_representative_portal/power_of_attorney_request_service/create_spec.rb index 537d6d1b4fa..d53d9ac0b3b 100644 --- a/modules/accredited_representative_portal/spec/services/accredited_representative_portal/power_of_attorney_request_service/create_spec.rb +++ b/modules/accredited_representative_portal/spec/services/accredited_representative_portal/power_of_attorney_request_service/create_spec.rb @@ -65,6 +65,17 @@ let(:poa_code) { organization.poa } let(:representative) { create(:representative, representative_id: '86753') } let(:registration_number) { representative.representative_id } + let(:monitoring) do + instance_double( + AccreditedRepresentativePortal::Monitoring, + track_count: true + ) + end + + before do + allow(monitoring).to receive(:trace).and_yield(nil) + allow(AccreditedRepresentativePortal::Monitoring).to receive(:new).and_return(monitoring) + end it 'creates a new AccreditedRepresentativePortal::PowerOfAttorneyRequest' do expect { subject.call }.to change(AccreditedRepresentativePortal::PowerOfAttorneyRequest, :count).by(1) @@ -98,6 +109,18 @@ expect(result[:request].power_of_attorney_holder_type).to eq('veteran_service_organization') end + it 'tracks the overall request count' do + subject.call + + expect(monitoring).to have_received(:track_count).with('ar.poa.request.count') + end + + it 'tracks the rep_first pathway count when registration_number is present' do + subject.call + + expect(monitoring).to have_received(:track_count).with('ar.poa.request.pathway.rep_first') + end + context 'unresolved PowerOfAttorneyRequests' do context 'when there are unresolved requests' do let!(:poa_request1) { create(:power_of_attorney_request, claimant:) } @@ -156,6 +179,12 @@ expect(result[:request].accredited_individual).to be_nil end + + it 'tracks the org_first pathway count' do + subject.call + + expect(monitoring).to have_received(:track_count).with('ar.poa.request.pathway.org_first') + end end context 'when there are errors' do