(message: string)
| 3 | const token = process.env.COMPANY_SLACK_BOT_TOKEN || ''; |
| 4 | // send notification to events-and-metrics channel |
| 5 | export const sendNotification = async (message: string) => { |
| 6 | if (skipNotification()) return; |
| 7 | if (!token) { |
| 8 | console.log('no token'); |
| 9 | return; |
| 10 | } |
| 11 | |
| 12 | const url = 'https://slack.com/api/chat.postMessage?'; |
| 13 | |
| 14 | const response = await request |
| 15 | .post( |
| 16 | url + |
| 17 | 'channel=events-and-metrics' + |
| 18 | `&text=${encodeURIComponent(message)}` |
| 19 | ) |
| 20 | .set('Authorization', 'Bearer ' + token); |
| 21 | |
| 22 | return response; |
| 23 | }; |
| 24 | |
| 25 | export function skipNotification() { |
| 26 | return process.env.SKIP_NOTIFICATION === 'true'; |
no test coverage detected