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
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading