Imison.Notifications.Channels.Slack (Imison v0.1.0)

Copy Markdown View Source

Posts each notification to a Slack channel through an incoming webhook.

Its stored setting is the incoming webhook's URL, which must start with https://hooks.slack.com/: %{"webhook_url" => "https://hooks.slack.com/services/..."}. The whole URL is the credential, so its field on the Notifications screen is a secret: never shown back, and never named in a failure. It isn't in the default channels; add it there to show its "Slack" panel.

Each notification is one {"text": ...} message in Slack's mrkdwn: a bold headline ("New error", "Came back" with when it came back, "Still happening" with when it was last seen), then *kind*: message, the location in backticks, the occurrence count and when it was first seen and, with the dashboard_url option, an "Open in Imison" link to the error. The daily digest is "Daily summary for <date> (UTC)" with the sections "New errors", "Came back" and "Most frequent", one line per listed error (kind, message, that day's count, location and its link) and "and N more" for the errors a section leaves out. The test message sent from the Notifications screen says that Slack delivery works.

The error's kind, message and location are cut to their first line and at most 300 characters (ending "…"), so a long exception message can't push the counts and the link out of Slack's view, and &, < and > in them are escaped as Slack asks, so an error message can't post a mention (<!channel>) or a link of its own.

Delivery goes through the same HTTP client as the webhook channel: a 2xx answer is a delivery, any other fails it with {:http_status, status}, and a connection that fails or times out fails it with the reason.