( options: ClientOptions, event: Event, hint: EventHint, scope?: Scope, client?: Client, isolationScope?: Scope, )
| 39 | * @hidden |
| 40 | */ |
| 41 | export function prepareEvent( |
| 42 | options: ClientOptions, |
| 43 | event: Event, |
| 44 | hint: EventHint, |
| 45 | scope?: Scope, |
| 46 | client?: Client, |
| 47 | isolationScope?: Scope, |
| 48 | ): PromiseLike<Event | null> { |
| 49 | const { normalizeDepth = 3, normalizeMaxBreadth = 1_000 } = options; |
| 50 | const prepared: Event = { |
| 51 | ...event, |
| 52 | event_id: event.event_id || hint.event_id || uuid4(), |
| 53 | timestamp: event.timestamp || dateTimestampInSeconds(), |
| 54 | }; |
| 55 | const integrations = hint.integrations || options.integrations.map(i => i.name); |
| 56 | |
| 57 | applyClientOptions(prepared, options); |
| 58 | applyIntegrationsMetadata(prepared, integrations); |
| 59 | |
| 60 | if (client) { |
| 61 | client.emit('applyFrameMetadata', event); |
| 62 | } |
| 63 | |
| 64 | // Only put debug IDs onto frames for error events. |
| 65 | if (event.type === undefined) { |
| 66 | applyDebugIds(prepared, options.stackParser); |
| 67 | } |
| 68 | |
| 69 | // If we have scope given to us, use it as the base for further modifications. |
| 70 | // This allows us to prevent unnecessary copying of data if `captureContext` is not provided. |
| 71 | const finalScope = getFinalScope(scope, hint.captureContext); |
| 72 | |
| 73 | if (hint.mechanism) { |
| 74 | addExceptionMechanism(prepared, hint.mechanism); |
| 75 | } |
| 76 | |
| 77 | const clientEventProcessors = client ? client.getEventProcessors() : []; |
| 78 | |
| 79 | // This should be the last thing called, since we want that |
| 80 | // {@link Scope.addEventProcessor} gets the finished prepared event. |
| 81 | // Merge scope data together |
| 82 | const data = getCombinedScopeData(isolationScope, finalScope); |
| 83 | |
| 84 | const attachments = [...(hint.attachments || []), ...data.attachments]; |
| 85 | if (attachments.length) { |
| 86 | hint.attachments = attachments; |
| 87 | } |
| 88 | |
| 89 | applyScopeDataToEvent(prepared, data); |
| 90 | |
| 91 | const eventProcessors = [ |
| 92 | ...clientEventProcessors, |
| 93 | // Run scope event processors _after_ all other processors |
| 94 | ...data.eventProcessors, |
| 95 | ]; |
| 96 | |
| 97 | // Skip event processors for internal exceptions to prevent recursion |
| 98 | // oxlint-disable-next-line typescript/prefer-optional-chain |
no test coverage detected