Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.
/ slack-report Public archive

Publish a structured report to Slack

License

Notifications You must be signed in to change notification settings

delightroom/slack-report

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ Deprecated

No longer maintained/used by the team.


Slack Report

XO code style license

Why Slack Report?

Slack is the most popular collaboration tool. However, when it comes to message formatting, Slack provides very limited features. This makes it difficult to share monitored metrics or analyzed statistics in a structured format.

Slack Report gives you a better way to do this by making use of message attachments. Especially, the API based on Builder Pattern allows you to write clean and easy-to-read code.

Installation

You can install Slack Report through npm:

npm install slack-report --save

Usage Example

Builder

You can set up the report by using method chain. You should call title and metric methods at least once. Other fields are optional. Don't forget to call the build method at the end of the chain. You can find an example here.

const ReportBuilder = require('slack-report');

const report = new ReportBuilder()
  .title('Daily User Report')
  .titleLink('https://fabric.io')
  .description('This is a sample report made by Slack Report.')
  .metric(dau, {
    title: 'DAU',
    description: 'This is a sample table.',
    timestamp: Date.now(),
    author: 'Delightroom'
  })
  .build();

Preview

Before publishing it to Slack, you can preview the message . The preview method prints out an url. Just copy and paste the link to your browser.

report.preview();

Publish

In order to publish the report, you need to call the publish method with slack webhook url, which starts with https://hooks.slack.com/services. The method returns axios object so I would recommend use await operator. For the detailed info about slack webhook, please refer to this document.

const slackWebhookUrl = 'https://api.slack.com/incoming-webhooks/...';
await report.publish(slackWehookUrl);

License

This project is licensed under the MIT License - see the LICENSE file for details

About

Publish a structured report to Slack

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published