chore(misc): normalize logs (#242)

This commit is contained in:
Jef LeCompte
2020-09-23 14:20:06 -04:00
committed by GitHub
parent 8466f9f398
commit 7c50e2b5aa
21 changed files with 239 additions and 183 deletions
+14 -11
View File
@@ -1,19 +1,22 @@
import {Link, Store} from '../store/model';
import {Logger, Print} from '../logger';
import {Config} from '../config';
import {Link} from '../store/model';
import {Logger} from '../logger';
import PushBullet from 'pushbullet';
const pushBulletApiKey = Config.notifications.pushBulletApiKey;
export function sendPushBulletNotification(cartUrl: string, link: Link) {
export function sendPushBulletNotification(link: Link, store: Store) {
const pusher = new PushBullet(pushBulletApiKey);
const title = `🚨 ${link.brand} ${link.model} ${link.series} 👀`;
pusher.note({}, title, cartUrl, (err: Error, result: string) => {
if (err) {
Logger.error(err);
} else {
Logger.info(`↗ pushbullet notification sent: ${result}`);
}
});
pusher.note(
{},
Print.inStock(link, store),
link.cartUrl ? link.cartUrl : link.url,
(error: Error) => {
if (error) {
Logger.error('✖ couldn\'t send pushbullet message', error);
} else {
Logger.info('✔ pushbullet message sent');
}
});
}