const Monitor = require('ping-monitor');
// how to get channels
const Mailer = require('@ping-monitor/email');
const Slakey = require('@ping-monitor/slack');
const TwiT = require('@ping-monitor/twitter');
const SMS = require('@ping-monitor/sms');
// channel example
class Channel {
constructor(options) {
/***
do something with the options
e.g.
const transporter = require("nodemailer").createTransport(options);
this.transporter = transporter;
this.transporter then becomes accessible within your methods
***/
}
up(res, state) {
// send up notification
}
down(res, state) {
// send down notification
}
stop(res, state) {
// send stopped notification
}
error(error, res) {
// send error notification
}
timeout(error, res) {
// send timeout notification
}
}
let email = new Mailer({
host: process.env.MAILER_HOST,
port: process.env.MAILER_PORT,
secure: false,
auth: {
user: process.env.MAILER_USER,
pass: process.env.MAILER_PASS,
},
})
let slack = new Slakey({
token: process.env.SLACK_TOKEN;
})
const myMonitor = new Monitor({
website: 'https://ragingflame.co.za',
title: 'Raging Flame',
interval: 10
});
// option 1
myMonitor.addChannel(email)
myMonitor.addChannel(slack)
// option 2
myMonitor.addSubscriber(email)
myMonitor.addSubscriber(slack)
// option 3
myMonitor.subscribe(email)
myMonitor.subscribe(slack)
Last active
January 29, 2023 08:27
-
-
Save qawemlilo/f650d06035d77c74d5b850167122a3fb to your computer and use it in GitHub Desktop.
Ideas on how to integrate notification channels with ping-monitor
@kailashvele Thanks for your feedback.
- Yes I agree, we need more options to make if fully customisable.
- The slack snippet was just an example, will have to look at how the api package works.
- Yes, will explore how to provide those options.
- This was just an example. We could integrate something like Vonage.
I will create a new branch to run some experiments to see what's possible. Will tag you on it.
@qawemlilo Sure I will take a look at it
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@qawemlilo At quick glance, I have the following questions that we may have to answer:
But as an approach for providing an option for notification in the library, we can go with what you have made. Also, option 1 for addChannel sounds better and clear to use, rather I was thinking to make it addNotificationChannel as the name.
Let me know about your views and if we have to discuss on this then we can get on a call as well, if you are available for that.