SmartNotify
Ruby Gem designed for sending various types of notifications via a common configurable interface.
Overview
The gem makes use of two components, modules, and templates.
Modules are defined within this gem, and provide various forms of generic notification functionality. The modules are created to be reusable. A module could be responsible for sending emails, posting Slack notifications, making a REST call to an external API, whatever.
Templates on the other hand, consume a specific module, in conjunction with template specific configuration, creating very specific use cases. These use cases could be team specific, allowing different consumers to tweak who, and how notifications are distributed.
Why
There was a need to easily send SLA incident emails to the correct person on support, as well as to a MS Teams channel. A module was created rotation_emailer
which could send emails, based on a given email template, and support rotation csv file. With that in place, a template was created incident_start_email
which defines where the specific email template, and support rotation csv file is located for this particular instance. This is awesome, because a new team or solution could create a template, changing only the support rotation csv location, and get the same functionality for next to no setup cost.
Usage
Add gem 'smartnotify'
to your Gemfile. Latest version can be found internally at gems.hax
require 'smartnotify'
# ... your logic ...
smartnotify = SmartNotify.new
smartnotify.run(template, json, [debug], [dryrun])
- template - [String] The id of the template to use. The templates are configured externally in PHPerfImp/smartnotify-config
- json - [String] The JSON key/value pairs to be used as input to the selected template. Each template defines what keys must be provided.
- debug - [Boolean] (optional, defaults false) Enables debug logging within SmartNotify.
- dryrun - [Boolean] (optional, defaults false) Enables debug logging within SmartNotify, and disables sending any notifications for testing purposes.
Example
smartnotify = SmartNotify.new
smartnotify.run('incident_start_email', "{\"mnemonic\": \"sbmcin\", \"cerner_mnemonic\": \"UNVR_NY\", \"link\": \"https://jira2.cerner.com/browse/PERFIMPDEV-1349\", \"title\": \"Readmission SLA Exceeded\", \"message\": \"Readmission SLA exceeded, please check the JIRA for more information.\"}")
Modules
The following are the currently available modules that can be consumed. Follow the link to get more information on intended usage, and configuration.
Releasing New Version
Clone the gem locally.
git clone https://github.cerner.com/PHPerfImp/smartnotify.git cd smartnotify bundle install
Make your change.
Update smartnotify.gemspec gem version.
Build the gem locally
gem build smartnotify
Upload created
smartnotify-x.x.x.gem
internally to gems.hax