diff --git a/modules/accredited_representative_portal/app/controllers/accredited_representative_portal/v0/intent_to_file_controller.rb b/modules/accredited_representative_portal/app/controllers/accredited_representative_portal/v0/intent_to_file_controller.rb index 778143eb64e..2ccd1e972d3 100644 --- a/modules/accredited_representative_portal/app/controllers/accredited_representative_portal/v0/intent_to_file_controller.rb +++ b/modules/accredited_representative_portal/app/controllers/accredited_representative_portal/v0/intent_to_file_controller.rb @@ -20,9 +20,6 @@ class IntentToFileController < ApplicationController SUCCESS_METRIC = 'ar.itf.submit.success' ERROR_METRIC = 'ar.itf.submit.error' - EMAIL_SUCCESS_METRIC = 'ar.itf.va_notify.confirmation_email.success' - EMAIL_ERROR_METRIC = 'ar.itf.va_notify.confirmation_email.error' - before_action :validate_file_type, only: %i[show create] before_action { authorize icn, policy_class: IntentToFilePolicy } @@ -167,11 +164,7 @@ def claimant_icn def send_confirmation_email(saved_claim) AccreditedRepresentativePortal::NotificationEmail.new(saved_claim.id).deliver(:itf_confirmation) - ar_monitoring.track_count(EMAIL_SUCCESS_METRIC, tags: default_tags) - Rails.logger.info('ARP ITF: Confirmation email sent successfully') rescue => e - ar_monitoring.track_count(EMAIL_ERROR_METRIC, tags: default_tags + - ["reason:#{e.class.name.demodulize.underscore}"]) Rails.logger.error("ARP ITF: Failed to send confirmation email - #{e.class}: #{e.message.truncate(100)}") end diff --git a/modules/accredited_representative_portal/spec/requests/accredited_representative_portal/v0/intent_to_file_spec.rb b/modules/accredited_representative_portal/spec/requests/accredited_representative_portal/v0/intent_to_file_spec.rb index a35983ba9e7..c02d89b5969 100644 --- a/modules/accredited_representative_portal/spec/requests/accredited_representative_portal/v0/intent_to_file_spec.rb +++ b/modules/accredited_representative_portal/spec/requests/accredited_representative_portal/v0/intent_to_file_spec.rb @@ -393,89 +393,6 @@ end end - context 'confirmation email monitoring' do - before do - allow(Flipper).to receive(:enabled?).with(:accredited_representative_portal_itf_confirmation_email) - .and_return(true) - end - - context 'when email sends successfully' do - before do - notification_double = double('notification') - allow(AccreditedRepresentativePortal::NotificationEmail) - .to receive(:new).and_return(notification_double) - allow(notification_double).to receive(:deliver).with(:itf_confirmation) - end - - it 'tracks the email success metric' do - VCR.use_cassette('lighthouse/benefits_claims/intent_to_file/create_compensation_200_response') do - post('/accredited_representative_portal/v0/intent_to_file', params:) - end - - expect(datadog_instance).to have_received(:track_count).with( - 'ar.itf.va_notify.confirmation_email.success', - tags: array_including('benefit_type:compensation') - ) - expect(datadog_instance).not_to have_received(:track_count).with( - 'ar.itf.va_notify.confirmation_email.error', - tags: anything - ) - end - end - - context 'when email sending fails' do - before do - allow(AccreditedRepresentativePortal::NotificationEmail) - .to receive(:new).and_raise(StandardError.new('email service down')) - end - - it 'tracks the email error metric with reason tag' do - VCR.use_cassette('lighthouse/benefits_claims/intent_to_file/create_compensation_200_response') do - post('/accredited_representative_portal/v0/intent_to_file', params:) - end - - expect(datadog_instance).to have_received(:track_count).with( - 'ar.itf.va_notify.confirmation_email.error', - tags: array_including('benefit_type:compensation', 'reason:standard_error') - ) - expect(datadog_instance).not_to have_received(:track_count).with( - 'ar.itf.va_notify.confirmation_email.success', - tags: anything - ) - end - - it 'still returns a successful ITF response' do - VCR.use_cassette('lighthouse/benefits_claims/intent_to_file/create_compensation_200_response') do - post('/accredited_representative_portal/v0/intent_to_file', params:) - end - - expect(response).to have_http_status(:created) - end - end - - context 'when confirmation email flag is disabled' do - before do - allow(Flipper).to receive(:enabled?).with(:accredited_representative_portal_itf_confirmation_email) - .and_return(false) - end - - it 'does not track any email metrics' do - VCR.use_cassette('lighthouse/benefits_claims/intent_to_file/create_compensation_200_response') do - post('/accredited_representative_portal/v0/intent_to_file', params:) - end - - expect(datadog_instance).not_to have_received(:track_count).with( - 'ar.itf.va_notify.confirmation_email.success', - tags: anything - ) - expect(datadog_instance).not_to have_received(:track_count).with( - 'ar.itf.va_notify.confirmation_email.error', - tags: anything - ) - end - end - end - context 'when poa_code lookup fails' do before do # only affect Datadog tags