1
1
require ( 'dotenv' ) . config ( ) ;
2
2
3
3
const Utils = require ( './utils' ) ;
4
+ const HawkCatcher = require ( '@hawk.so/nodejs' ) . default ;
4
5
5
6
const { Octokit } = require ( '@octokit/core' ) ;
6
7
const parseGithubUrl = require ( 'parse-github-url' ) ;
@@ -9,6 +10,8 @@ const axios = require('axios').default;
9
10
const CronJob = require ( 'cron' ) . CronJob ;
10
11
11
12
const TOKEN = process . env . TOKEN ;
13
+ const HAWK_TOKEN = process . env . HAWK_TOKEN ;
14
+
12
15
const COLUMN_NODE_ID_TO_DO = process . env . COLUMN_NODE_ID_TO_DO ;
13
16
const COLUMN_NODE_ID_PR = process . env . COLUMN_NODE_ID_PR ;
14
17
const NOTIFIER_URL = process . env . NOTIFIER_URL ;
@@ -40,6 +43,16 @@ const CARDS_QUERY = require('./queries/cards');
40
43
const ISSUE_QUERY = require ( './queries/issue' ) ;
41
44
const PR_QUERY = require ( './queries/pr' ) ;
42
45
46
+ /**
47
+ * Initialize HawkCatcher.
48
+ */
49
+ HawkCatcher . init ( {
50
+ token : HAWK_TOKEN ,
51
+ context : {
52
+ myOwnDebugInfo : '1234' ,
53
+ } ,
54
+ } ) ;
55
+
43
56
/**
44
57
* Sends POST request to telegram bot
45
58
*
@@ -76,7 +89,7 @@ function checkForParsableGithubLink(message) {
76
89
return [ true , owner , name , type , id ] ;
77
90
}
78
91
79
- return [ false ] ;
92
+ return [ false ] ;
80
93
}
81
94
82
95
/**
@@ -355,7 +368,7 @@ async function parseQuery(members, response) {
355
368
} )
356
369
) ;
357
370
358
- let cardDataWithoutMembers = [ ...parsedCardData ] ;
371
+ let cardDataWithoutMembers = [ ...parsedCardData ] ;
359
372
360
373
for ( let i = 0 ; i < members . length ; i ++ ) {
361
374
cardDataWithoutMembers = cardDataWithoutMembers . map ( ( x ) =>
@@ -482,56 +495,60 @@ function parseMeetingMessage(mentionList) {
482
495
* Call the Github GraphQL API, parse its response to message and add that message as cron job.
483
496
*/
484
497
async function main ( ) {
485
- const toDoJob = new CronJob (
486
- TO_DO_TIME ,
487
- async ( ) => {
488
- notify (
489
- await notifyMessage ( "📌 Sprint's backlog" , COLUMN_NODE_ID_TO_DO , true )
490
- )
491
- . then ( ( ) => console . log ( 'Tasks Job Completed.' ) )
492
- . catch ( console . error ) ;
493
- } ,
494
- null ,
495
- true ,
496
- 'Europe/Moscow'
497
- ) ;
498
+ try {
499
+ const toDoJob = new CronJob (
500
+ TO_DO_TIME ,
501
+ async ( ) => {
502
+ notify (
503
+ await notifyMessage ( "📌 Sprint's backlog" , COLUMN_NODE_ID_TO_DO , true )
504
+ )
505
+ . then ( ( ) => console . log ( 'Tasks Job Completed.' ) )
506
+ . catch ( HawkCatcher . send ) ;
507
+ } ,
508
+ null ,
509
+ true ,
510
+ 'Europe/Moscow'
511
+ ) ;
498
512
499
- const prJob = new CronJob (
500
- PR_TIME ,
501
- async ( ) => {
502
- notify (
503
- await notifyMessage ( '👀 Pull requests for review' , COLUMN_NODE_ID_PR )
504
- )
505
- . then ( ( ) => console . log ( 'PR Job Completed.' ) )
506
- . catch ( console . error ) ;
507
- } ,
508
- null ,
509
- true ,
510
- 'Europe/Moscow'
511
- ) ;
512
- const meetingJob = new CronJob (
513
- MEETING_TIME ,
514
- ( ) => {
515
- notify ( parseMeetingMessage ( MEETING_MENTION ) )
516
- . then ( ( ) => console . log ( 'Meeting Job Completed.' ) )
517
- . catch ( console . error ) ;
518
- } ,
519
- null ,
520
- true ,
521
- 'Europe/Moscow'
522
- ) ;
513
+ const prJob = new CronJob (
514
+ PR_TIME ,
515
+ async ( ) => {
516
+ notify (
517
+ await notifyMessage ( '👀 Pull requests for review' , COLUMN_NODE_ID_PR )
518
+ )
519
+ . then ( ( ) => console . log ( 'PR Job Completed.' ) )
520
+ . catch ( HawkCatcher . send ) ;
521
+ } ,
522
+ null ,
523
+ true ,
524
+ 'Europe/Moscow'
525
+ ) ;
526
+ const meetingJob = new CronJob (
527
+ MEETING_TIME ,
528
+ ( ) => {
529
+ notify ( parseMeetingMessage ( MEETING_MENTION ) )
530
+ . then ( ( ) => console . log ( 'Meeting Job Completed.' ) )
531
+ . catch ( HawkCatcher . send ) ;
532
+ } ,
533
+ null ,
534
+ true ,
535
+ 'Europe/Moscow'
536
+ ) ;
523
537
524
- toDoJob . start ( ) ;
525
- console . log ( 'To do list Notifier started' ) ;
526
- console . log ( 'Will notify at:' + TO_DO_TIME ) ;
538
+ toDoJob . start ( ) ;
539
+ console . log ( 'To do list Notifier started' ) ;
540
+ console . log ( 'Will notify at:' + TO_DO_TIME ) ;
527
541
528
- prJob . start ( ) ;
529
- console . log ( 'PR review list Notifier started' ) ;
530
- console . log ( 'Will notify at:' + PR_TIME ) ;
542
+ prJob . start ( ) ;
543
+ console . log ( 'PR review list Notifier started' ) ;
544
+ console . log ( 'Will notify at:' + PR_TIME ) ;
531
545
532
- meetingJob . start ( ) ;
533
- console . log ( 'Meeting notifier started' ) ;
534
- console . log ( 'Will notify at:' + MEETING_TIME ) ;
546
+ meetingJob . start ( ) ;
547
+ console . log ( 'Meeting notifier started' ) ;
548
+ console . log ( 'Will notify at:' + MEETING_TIME ) ;
549
+ } catch ( e ) {
550
+ HawkCatcher . send ( e ) ;
551
+ }
535
552
}
536
553
537
554
main ( ) ;
0 commit comments