API Reference Chime v#0.1.0-dev

Copy Markdown View Source

Modules

Chime is notifications for Phoenix: something happens in the app, and Chime tells the people it concerns, in the app's feed (the bell), by email and by the app's own channels, as each person wants.

The feed and the preferences as JSON, for a frontend that Phoenix does not render: React, Vue, Svelte, a mobile app. Mounted with Chime.Router.chime_api/2

Who may see Chime's admin (Chime.Router.Admin): the app writes one module, from its own admins.

A way to tell a person, besides the feed and email: Telegram, SMS, Slack, Discord, the app's own push. The app writes a module and names it in the config's :channels

Discord: a message by a channel's webhook.

The :email channel: the notifier's Chime.Notifier.email/3, sent with the app's mailer (:mailer in Chime.Config).

The :push channel: a notification on a person's devices, browsers by Web Push, Apple's by APNs, Android's by FCM, with the services of the config's :push (see the Push guide).

Slack: a message to a person, or to a channel of the team's.

Microsoft Teams: an Adaptive Card by a channel's workflow webhook (or an incoming webhook).

SMS by Twilio: a text to the person's phone.

A webhook: the notification as JSON, signed, posted to an address of the app's or the person's.

The bell, the feed and the preferences in the app's LiveViews, from @chime (Chime.Live)

The options of Chime, given to its child in the app's supervision tree, after the repo, the PubSub and Oban

A notification by a channel other than the feed, and what became of it: the log Chime.Explain reads.

A person's device, for the :push channel

The digests: one email of the notifications of a day or a week, for the people who chose "daily" or "weekly" for a category's email (Chime.Preferences).

Something that happened, once, whoever it notifies: a call of Chime.notify/3. Its notifications point to it.

Why a person got a notification, or did not: the log of what Chime decided, with the reason of each decision.

A person's feed: their notifications, the newest first, and what they did with them. Chime has the functions; the JSON API and Chime.Live are over them.

Links that open a notification from an email or a channel, and read it in the feed: the same notification is read everywhere.

The feed in the app's LiveViews: an on_mount hook that gives each LiveView of a live_session the @chime assign, for the components of Chime.Components.

The @chime assign

A notification on its way to a person by a channel, as Chime.Channel.deliver/2 gets it

Chime's words, in the app's languages, by the app's own Gettext. Chime ships English, and a template of its words; the app translates them as it translates its own.

The tables of Chime, in a migration of the app.

What a person was told of an event: an item of their feed, and what the other channels' deliveries hang from.

A kind of notification of the app: who it goes to, by which channels, and what it says in each. Chime has none of its own; the app writes one module for each kind it has.

What each person wants to hear about: a setting for each category of Chime.Config and each channel.

A person who gets notifications, as the app's Chime.Resolver says

How Chime knows the people of the app. The app writes one module, from the users it already has, and gives it to Chime's config

Mounts Chime in the app's router.

The admin, mounted with chime_admin/2 (imported with Chime.Router): a person's notifications and their log, the events, the deliveries that failed and a way to send them again.

The addresses of the emails' links, mounted with chime_mail/2 (imported with Chime.Router) at the config's :mail_url: to unsubscribe (Chime.Unsubscribe), and to open a notification, which reads it (Chime.Links).

Helpers for the app's tests of its notifications, with no Oban to run and no clock to wait for.

Signed tokens of a person, for the JSON API (Chime.API) where the app's own session or token does not reach: an EventSource cannot send an authorization header, and a page on another origin has no cookie of the app's.

The links to unsubscribe of the emails, mounted with Chime.Router.chime_mail/2 at the config's :mail_url

Mix Tasks

Generates the migration of Chime's tables in the app's repo: the one that installs them, or, after an upgrade of Chime, the one that brings them to its latest version.

Generates a pair of VAPID keys, for :web of the :push option of Chime.Config