File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed
Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change 1+ const exported = { } ;
2+ const common = require ( '../../../api/utils/common.js' ) ;
3+ const log = common . log ( 'alerts:ingestor' ) ;
4+ const plugins = require ( '../../pluginManager.js' ) ;
5+ const commonLib = require ( "./parts/common-lib.js" ) ;
6+
7+
8+ ( function ( ) {
9+ const TRIGGER_BY_EVENT = Object . keys ( commonLib . TRIGGERED_BY_EVENT ) . map ( name => ( {
10+ module : require ( "./alertModules/" + name + ".js" ) ,
11+ name
12+ } ) ) ;
13+
14+ plugins . register ( "/sdk/process_request" , async function ( ob ) {
15+ const events = ob . params ?. qstring ?. events ;
16+ const app = ob . app ;
17+
18+ if ( ! events || ! app ) {
19+ return ;
20+ }
21+
22+ for ( let { module, name } of TRIGGER_BY_EVENT ) {
23+ if ( name !== "crashes" ) {
24+ try {
25+ await module . triggerByEvent ( { events, app } ) ;
26+ }
27+ catch ( err ) {
28+ log . e ( "Alert module '" + name + "' couldn't be triggered by event" , err ) ;
29+ }
30+ }
31+ }
32+ } ) ;
33+
34+ } ( exported ) ) ;
35+
36+ module . exports = exported ;
You can’t perform that action at this time.
0 commit comments