Imison.Notifications.Message (Imison v0.1.0)

Copy Markdown View Source

The channel-neutral content of one notification, handed to a channel's Imison.Notifications.Channel.deliver/3.

trigger is what the notification is about (:new for an error seen for the first time, :regression for a resolved error that came back, :still_happening for the reminder, at most once an hour, about an unresolved error that keeps happening, :digest for the daily digest, :test for the test message sent from the notifications screen; the digest and the test message are about no single error, so their error fields are nil); regressed_at is when the error last came back, nil if it never did; url is the link to the error's detail page on the dashboard, nil when the dashboard_url option isn't set.

summary is set only for the daily digest (and nil for every other message): the UTC date it covers, url, the dashboard's error list (nil without dashboard_url), and three sections: the errors first seen that day (new, oldest first), the errors that came back that day (came_back) and the errors that occurred most that day (most_frequent, most first). Each section is %{lines: [...], total: n}: lines holds at most 20 errors (5 for most_frequent) and total counts every error in the section that day (for most_frequent, every error that occurred), so a channel can say how many it left out. Each line has the error's error_id, kind, message, location, its occurrence count on that day and its url (nil without dashboard_url). Muted errors are listed too.

Summary

Types

summary()

@type summary() :: %{
  date: Date.t(),
  url: String.t() | nil,
  new: summary_section(),
  came_back: summary_section(),
  most_frequent: summary_section()
}

summary_line()

@type summary_line() :: %{
  error_id: pos_integer(),
  kind: String.t(),
  message: String.t(),
  location: String.t() | nil,
  count: non_neg_integer(),
  url: String.t() | nil
}

summary_section()

@type summary_section() :: %{lines: [summary_line()], total: non_neg_integer()}

t()

@type t() :: %Imison.Notifications.Message{
  error_id: pos_integer() | nil,
  first_seen_at: DateTime.t() | nil,
  kind: String.t() | nil,
  last_seen_at: DateTime.t() | nil,
  location: String.t() | nil,
  message: String.t() | nil,
  occurrence_count: pos_integer() | nil,
  regressed_at: DateTime.t() | nil,
  summary: summary() | nil,
  trigger: trigger(),
  url: String.t() | nil
}

trigger()

@type trigger() :: :new | :regression | :still_happening | :digest | :test