Skip to content

Commit 9820343

Browse files
committed
fix: allow pre-populating event before processing
1 parent e9ef553 commit 9820343

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

src/v2/defaultEventProcessor.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,19 @@ export const defaultEventProcessor: EventProcessor = (
2323
? { ...detail, ...existingMetadata }
2424
: existingMetadata
2525

26+
const inputEvent = entry as InputEvent
27+
28+
inputEvent.metadata = metadata
29+
30+
if (!('operations' in entry) || typeof entry.operations !== 'object') {
31+
inputEvent.operations = {}
32+
}
33+
34+
if (typeof inputEvent.event === 'object') {
35+
// the event might have been prepopulated, in which case we don't want to overwrite it
36+
return inputEvent as Event
37+
}
38+
2639
let kind = entry.entryType
2740
let commonName = entry.name
2841
let status: EventStatus = 'ok'
@@ -66,11 +79,6 @@ export const defaultEventProcessor: EventProcessor = (
6679
}`
6780
}
6881

69-
const inputEvent = entry as InputEvent
70-
if (!('operations' in entry) || typeof entry.operations !== 'object') {
71-
inputEvent.operations = {}
72-
}
73-
inputEvent.metadata = metadata
7482
inputEvent.event = { commonName, kind, status }
7583

7684
return inputEvent as Event

0 commit comments

Comments
 (0)