Behind The Code Magazine #4

Page 37

ARTICLE

Michael KarĂŠn

Why use Slack for Errors? If your company is using Slack as a communication tool, then it makes sense to integrate it with your tooling. You can, for example, record your failing builds and deploys there. And why not then also log your errors there? Since you probably already have Slack open on your desktop and maybe on your phone as well, all these logs will be more available to people. Having Slack open on all devices makes it easier to notice when something bad is happening. Every solution can have its Slack channel for errors. You can also differentiate for different environments like test and production. Errors can also be customized as needed as we will see later in this article.

Webhook To be able to test our code we need to have a Slack channel where to send the errors. Before we start coding, we need an address where to send our errors. For this, we need a Slack app with a Webhook. This is the way we add tooling to our workspace. Incoming Webhooks are a simple way to post messages from apps into Slack. Creating an Incoming Webhook gives you a unique URL to which you send a JSON payload with the message text and some options. 1. Create a Slack app (if you don’t already have one). 2. Enable Incoming Webhooks from the settings page. 3. After the settings page refreshes, click Add New Webhook to Workspace. 4. Pick a channel that the app will post to, then click Authorize. 5. Use your Incoming Webhook URL to post a message to Slack.

ngVikings 2019

|

BEHIND THE CODE MAGAZINE

37


Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.