{"id":15288765,"url":"https://github.com/aldesantis/hertz","last_synced_at":"2025-10-16T18:28:54.883Z","repository":{"id":52414950,"uuid":"56337634","full_name":"aldesantis/hertz","owner":"aldesantis","description":"A Ruby on Rails engine for transport-agnostic notification delivery, with read-tracking support.","archived":false,"fork":false,"pushed_at":"2021-04-29T21:00:23.000Z","size":143,"stargazers_count":12,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-07T20:42:52.435Z","etag":null,"topics":["notifications","rails","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aldesantis.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"MIT-LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-04-15T17:21:09.000Z","updated_at":"2021-04-06T19:42:32.000Z","dependencies_parsed_at":"2022-08-20T23:10:26.900Z","dependency_job_id":null,"html_url":"https://github.com/aldesantis/hertz","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/aldesantis/hertz","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldesantis%2Fhertz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldesantis%2Fhertz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldesantis%2Fhertz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldesantis%2Fhertz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aldesantis","download_url":"https://codeload.github.com/aldesantis/hertz/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aldesantis%2Fhertz/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018720,"owners_count":26086613,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["notifications","rails","ruby"],"created_at":"2024-09-30T15:53:07.667Z","updated_at":"2025-10-16T18:28:54.852Z","avatar_url":"https://github.com/aldesantis.png","language":"Ruby","readme":"# Hertz\n\n[![Build Status](https://travis-ci.org/aldesantis/hertz.svg?branch=master)](https://travis-ci.org/aldesantis/hertz)\n[![Coverage Status](https://coveralls.io/repos/github/aldesantis/hertz/badge.svg?branch=master)](https://coveralls.io/github/aldesantis/hertz?branch=master)\n[![Maintainability](https://api.codeclimate.com/v1/badges/84d43f19a0ec0bf62ede/maintainability)](https://codeclimate.com/github/aldesantis/hertz/maintainability)\n\nHertz is a Ruby on Rails engine for sending in-app notifications to your users.\n\n## Installation\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'hertz'\n```\n\nAnd then execute:\n\n```console\n$ bundle\n```\n\nOr install it yourself as:\n\n```console\n$ gem install hertz\n```\n\nThen, run the installer generator:\n\n```console\n$ rails g hertz:install\n$ rake db:migrate\n```\n\nFinally, add the following to the model that will receive the notifications (e.g. `User`):\n\n```ruby\nclass User \u003c ActiveRecord::Base\n  include Hertz::Notifiable\nend\n```\n\n## Usage\n\n### Using couriers\n\nCouriers are what Hertz uses to deliver notifications to your users. For instance, you might have a \ncourier for delivering notifications by SMS and another one for delivering them by email.\n\nCreating a new courier in Hertz is easy:\n\n```ruby\nmodule Hertz\n  class Sms\n    def self.deliver_notification(notification)\n      # ...\n    end\n  end\nend\n```\n\n### Creating new notification types\n\nIn Hertz, every notification is a model. If you want to create a new notification type, just create \na new model inheriting from `Hertz::Notification`:\n\n```ruby\nclass CommentNotification \u003c Hertz::Notification\nend\n```\nSince not all notifications might implement interfaces for all couriers, you have to manually\nspecify which couriers they implement via `deliver_by`:\n\n```ruby\nclass CommentNotification \u003c Hertz::Notification\n  deliver_by :sms, :email\nend\n```\n\nNotifications are not required to implement any couriers.\n\nYou can set common couriers (i.e. couriers that will be used for all notifications) by putting the\nfollowing into an \ninitializer:\n\n```ruby\nHertz.configure do |config|\n  config.common_couriers = [:sms, :email]\nend\n```\n\n### Attaching metadata to a notification\n\nYou can attach custom metadata to a notification, but make sure it can be cleanly stored in an\nhstore:\n\n```ruby\nnotification = CommentNotification.new(meta: { comment_id: comment.id })\nuser.notify(notification)\n```\n\nYou can then unserialize any data in the model:\n\n```ruby\nclass CommentNotification \u003c Hertz::Notification\n  def comment\n    Comment.find(meta['comment_id'])\n  end\nend\n```\n\nNote that you should always access your metadata with string keys, regardless of the type you use\nwhen attaching it.\n\n### Notifying users\n\nYou can use `#notify` for notifying a user:\n\n```ruby\nuser.notify(CommentNotification.new(meta: { comment_id: comment.id }))\n# or\nuser.notify(CommentNotification, comment_id: comment.id)\n```\n\nYou can access a user's notifications with `#notifications`:\n\n```ruby\ncurrent_user.notifications\ncurrent_user.notifications.read\ncurrent_user.notifications.unread\n```\n\nYou can also mark notifications as read/unread:\n\n```ruby\nnotification.mark_as_read\nnotification.mark_as_unread\n```\n\n### Tracking delivery status\n\nHertz provides an API couriers can use to mark the notification as delivered. This allows you to\nknow which couriers have successfully delivered your notifications and helps prevent double\ndeliveries:\n\n```ruby\nnotification.delivered_with?(:email) # =\u003e false\nnotification.mark_delivered_with(:email) # =\u003e Hertz::Delivery\nnotification.delivered_with?(:email) # =\u003e true\n```\n\nHertz does not enforce usage of the delivery status API in any way, so some couriers may not take\nadvantage of it.\n\n## Available couriers\n\n- [hertz-twilio](https://github.com/aldesantis/hertz-twilio): delivers notifications by SMS with the\n  Twilio API.\n- [hertz-email](https://github.com/aldesantis/hertz-email): delivers notifications by email with \n  ActionMailer.\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/aldesantis/hertz.\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faldesantis%2Fhertz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faldesantis%2Fhertz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faldesantis%2Fhertz/lists"}