File tree Expand file tree Collapse file tree 2 files changed +8
-11
lines changed
Expand file tree Collapse file tree 2 files changed +8
-11
lines changed Original file line number Diff line number Diff line change 1- import { v4 } from 'uuid' ;
21import type { handlerType , errorHandlerType } from './EventPattern' ;
32import type { TelemetryConfig } from './Telemetry' ;
43import { EventPattern } from './EventPattern' ;
@@ -35,12 +34,10 @@ export class ExpressBridge {
3534 }
3635
3736 public async process ( incomingEvent : EventType ) : Promise < void > {
38- console . log ( 'Handling incoming event: ' , incomingEvent ) ;
3937 try {
4038 // if telemetry is defined, set uuid and call beacon
4139 console . log ( 'Telemetry enabled: ' , ! ! process . env . EB_TELEMETRY ) ;
4240 if ( process . env . EB_TELEMETRY && this . options . telemetry ) {
43- console . log ( 'Telemetry enabled, setting trace tag on event.' ) ;
4441 this . telemetry = new Telemetry ( this . options . telemetry ) ;
4542 this . telemetry . tagEvent ( incomingEvent ) ;
4643 }
@@ -54,8 +51,6 @@ export class ExpressBridge {
5451
5552 const matchedPatterns = this . match ( incomingEvent ) ;
5653
57- console . log ( 'Patterns matched: ' , matchedPatterns ) ;
58-
5954 if ( matchedPatterns . length > 0 ) {
6055 await this . telemetry ?. beacon ( 'EB-MATCH' , {
6156 description : 'Patterns matched for event. Calling assigned handlers.' ,
Original file line number Diff line number Diff line change @@ -35,22 +35,24 @@ export class Telemetry {
3535 const { body, detail, Records } = event ;
3636 let payload = body ?? detail ?? Records ;
3737
38- console . log ( 'Tagging payload: ' , payload ) ;
39-
40- const tag = v4 ( ) ;
38+ let tag = v4 ( ) ;
4139 if ( Array . isArray ( payload ) ) {
4240 for ( const record of payload ) {
43- record . eb_event_id = record . eb_event_id || tag ;
41+ tag = record . eb_event_id || tag ;
42+ record . eb_event_id = tag ;
4443 }
4544 } else if ( payload ) {
4645 payload = typeof payload === 'string' ? JSON . parse ( payload ) : payload ;
47- payload . eb_event_id = payload . eb_event_id || tag ;
46+ tag = payload . eb_event_id || tag ;
47+ payload . eb_event_id = tag ;
4848 event [ body ? 'body' : 'detail' ] = payload ;
4949 } else {
50- event . eb_event_id = event . eb_event_id || tag ;
50+ tag = event . eb_event_id || tag ;
51+ event . eb_event_id = tag ;
5152 }
5253
5354 this . eb_event_id = tag ;
55+
5456 return tag ;
5557 }
5658}
You can’t perform that action at this time.
0 commit comments