Class: EVSS::DisabilityCompensationForm::Form4142DocumentUploadFailureEmail

Inherits:
Job
  • Object
show all
Defined in:
app/sidekiq/evss/disability_compensation_form/form4142_document_upload_failure_email.rb

Constant Summary collapse

STATSD_METRIC_PREFIX =
'api.form_526.veteran_notifications.form4142_upload_failure_email'
ZSF_DD_TAG_FUNCTION =
'526_form_4142_upload_failure_email_sending'

Constants included from Sidekiq::Form526JobStatusTracker::JobTracker

Sidekiq::Form526JobStatusTracker::JobTracker::STATSD_KEY_PREFIX

Instance Method Summary collapse

Methods inherited from Job

#submission

Methods included from Sidekiq::Form526JobStatusTracker::JobTracker

#error_message, #job_success, #job_try, #klass, #log_error, #log_info, #metrics, #non_retryable_error_handler, #update_background_job_errors, #upsert_job_status, #with_tracking

Methods included from Sidekiq::Form526JobStatusTracker::BackupSubmission

#send_backup_submission_if_enabled

Methods included from SentryLogging

#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger, #set_sentry_metadata

Instance Method Details

#log_mailer_dispatch(form526_submission_id, email_response = {}) ⇒ Object (private)



115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'app/sidekiq/evss/disability_compensation_form/form4142_document_upload_failure_email.rb', line 115

def log_mailer_dispatch(form526_submission_id, email_response = {})
  log_info = { form526_submission_id:, timestamp: Time.now.utc }
  Rails.logger.info('Form4142DocumentUploadFailureEmail notification dispatched', log_info)

  cl = caller_locations.first
  call_location = Logging::CallLocation.new(ZSF_DD_TAG_FUNCTION, cl.path, cl.lineno)
  zsf_monitor.log_silent_failure_avoided(
    log_info.merge(email_confirmation_id: email_response&.id),
    Form526Submission.find(form526_submission_id).,
    call_location:
  )
  StatsD.increment("#{STATSD_METRIC_PREFIX}.success")
end

#mailer_template_idObject (private)



129
130
131
132
# File 'app/sidekiq/evss/disability_compensation_form/form4142_document_upload_failure_email.rb', line 129

def mailer_template_id
  Settings.vanotify.services
          .benefits_disability.template_id.form4142_upload_failure_notification_template_id
end

#perform(form526_submission_id) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'app/sidekiq/evss/disability_compensation_form/form4142_document_upload_failure_email.rb', line 77

def perform(form526_submission_id)
  form526_submission = Form526Submission.find(form526_submission_id)

  with_tracking('Form4142DocumentUploadFailureEmail', form526_submission.saved_claim_id, form526_submission_id) do
    notify_client = VaNotify::Service.new(Settings.vanotify.services.benefits_disability.api_key)

    email_address = form526_submission.veteran_email_address
    first_name = form526_submission.get_first_name
     = form526_submission.format_creation_time_for_mailers

    notify_response = notify_client.send_email(
      email_address:,
      template_id: mailer_template_id,
      personalisation: {
        first_name:,
        date_submitted:
      }
    )

    log_mailer_dispatch(form526_submission_id, notify_response)
  end
rescue => e
  retryable_error_handler(e)
end

#retryable_error_handler(error) ⇒ Object (private)



108
109
110
111
112
113
# File 'app/sidekiq/evss/disability_compensation_form/form4142_document_upload_failure_email.rb', line 108

def retryable_error_handler(error)
  # Needed to log the error properly in the Sidekiq::Form526JobStatusTracker::JobTracker,
  # which is included near the top of this job's inheritance tree in EVSS::DisabilityCompensationForm::JobStatus
  super(error)
  raise error
end

#zsf_monitorObject (private)



104
105
106
# File 'app/sidekiq/evss/disability_compensation_form/form4142_document_upload_failure_email.rb', line 104

def zsf_monitor
  @zsf_monitor ||= ZeroSilentFailures::Monitor.new(Form526Submission::ZSF_DD_TAG_SERVICE)
end