Module: VANotify::NotificationEmail

Defined in:
lib/va_notify/notification_email.rb,
lib/va_notify/notification_email/saved_claim.rb

Overview

module functions for sending a VaNotify notification email

Defined Under Namespace

Modules: Type Classes: FailureToSend, SavedClaim

Constant Summary collapse

STATSD =

statsd metric prefix

'api.va_notify.notification_email'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.monitor_deliver_success(tags:, context: nil) ⇒ Object

monitor delivery successful

Parameters:

  • tags (Array<String>)

    array of tags for StatsD; [“tag_name:tag_value”, …]

  • context (Hash) (defaults to: nil)

    additional information to send with the log



61
62
63
64
65
66
67
68
69
70
# File 'lib/va_notify/notification_email.rb', line 61

def monitor_deliver_success(tags:, context: nil)
  metric = "#{VANotify::NotificationEmail::STATSD}.deliver_success"
  payload = {
    statsd: metric,
    context:
  }

  StatsD.increment(metric, tags:)
  Rails.logger.info('VANotify::NotificationEmail deliver success!', **payload)
end

.monitor_duplicate_attempt(tags:, context: nil) ⇒ Object

monitor attempting a duplicate notification for the same item

Parameters:

  • tags (Array<String>)

    array of tags for StatsD; [“tag_name:tag_value”, …]

  • context (Hash) (defaults to: nil)

    additional information to send with the log



46
47
48
49
50
51
52
53
54
55
# File 'lib/va_notify/notification_email.rb', line 46

def monitor_duplicate_attempt(tags:, context: nil)
  metric = "#{VANotify::NotificationEmail::STATSD}.duplicate_attempt"
  payload = {
    statsd: metric,
    context:
  }

  StatsD.increment(metric, tags:)
  Rails.logger.warn('VANotify::NotificationEmail duplicate attempt', **payload)
end

.monitor_send_failure(error_message, tags:, context: nil) ⇒ Object

monitor send failure

Parameters:

  • error_message (String)

    the error message to be logged

  • tags (Array<String>)

    array of tags for StatsD; [“tag_name:tag_value”, …]

  • context (Hash) (defaults to: nil)

    additional information to send with the log



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/va_notify/notification_email.rb', line 30

def monitor_send_failure(error_message, tags:, context: nil)
  metric = "#{VANotify::NotificationEmail::STATSD}.send_failure"
  payload = {
    statsd: metric,
    error_message:,
    context:
  }

  StatsD.increment(metric, tags:)
  Rails.logger.error('VANotify::NotificationEmail send failure!', **payload)
end

Instance Method Details

#monitor_deliver_success(tags:, context: nil) ⇒ Object (private)

monitor delivery successful

Parameters:

  • tags (Array<String>)

    array of tags for StatsD; [“tag_name:tag_value”, …]

  • context (Hash) (defaults to: nil)

    additional information to send with the log



61
62
63
64
65
66
67
68
69
70
# File 'lib/va_notify/notification_email.rb', line 61

def monitor_deliver_success(tags:, context: nil)
  metric = "#{VANotify::NotificationEmail::STATSD}.deliver_success"
  payload = {
    statsd: metric,
    context:
  }

  StatsD.increment(metric, tags:)
  Rails.logger.info('VANotify::NotificationEmail deliver success!', **payload)
end

#monitor_duplicate_attempt(tags:, context: nil) ⇒ Object (private)

monitor attempting a duplicate notification for the same item

Parameters:

  • tags (Array<String>)

    array of tags for StatsD; [“tag_name:tag_value”, …]

  • context (Hash) (defaults to: nil)

    additional information to send with the log



46
47
48
49
50
51
52
53
54
55
# File 'lib/va_notify/notification_email.rb', line 46

def monitor_duplicate_attempt(tags:, context: nil)
  metric = "#{VANotify::NotificationEmail::STATSD}.duplicate_attempt"
  payload = {
    statsd: metric,
    context:
  }

  StatsD.increment(metric, tags:)
  Rails.logger.warn('VANotify::NotificationEmail duplicate attempt', **payload)
end

#monitor_send_failure(error_message, tags:, context: nil) ⇒ Object (private)

monitor send failure

Parameters:

  • error_message (String)

    the error message to be logged

  • tags (Array<String>)

    array of tags for StatsD; [“tag_name:tag_value”, …]

  • context (Hash) (defaults to: nil)

    additional information to send with the log



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/va_notify/notification_email.rb', line 30

def monitor_send_failure(error_message, tags:, context: nil)
  metric = "#{VANotify::NotificationEmail::STATSD}.send_failure"
  payload = {
    statsd: metric,
    error_message:,
    context:
  }

  StatsD.increment(metric, tags:)
  Rails.logger.error('VANotify::NotificationEmail send failure!', **payload)
end