MCPcopy Index your code
hub / github.com/getsentry/sentry-javascript / createEventEnvelope

Function createEventEnvelope

packages/core/src/envelope.ts:88–117  ·  view source on GitHub ↗
(
  event: Event,
  dsn?: DsnComponents,
  metadata?: SdkMetadata,
  tunnel?: string,
)

Source from the content-addressed store, hash-verified

86 * Create an Envelope from an event.
87 */
88export function createEventEnvelope(
89 event: Event,
90 dsn?: DsnComponents,
91 metadata?: SdkMetadata,
92 tunnel?: string,
93): EventEnvelope {
94 const sdkInfo = getSdkMetadataForEnvelopeHeader(metadata);
95
96 /*
97 Note: Due to TS, event.type may be `replay_event`, theoretically.
98 In practice, we never call `createEventEnvelope` with `replay_event` type,
99 and we'd have to adjust a looot of types to make this work properly.
100 We want to avoid casting this around, as that could lead to bugs (e.g. when we add another type)
101 So the safe choice is to really guard against the replay_event type here.
102 */
103 const eventType = event.type && event.type !== 'replay_event' ? event.type : 'event';
104
105 _enhanceEventWithSdkInfo(event, metadata?.sdk);
106
107 const envelopeHeaders = createEventEnvelopeHeaders(event, sdkInfo, tunnel, dsn);
108
109 // Prevent this data (which, if it exists, was used in earlier steps in the processing pipeline) from being sent to
110 // sentry. (Note: Our use of this property comes and goes with whatever we might be debugging, whatever hacks we may
111 // have temporarily added, etc. Even if we don't happen to be using it at some point in the future, let's not get rid
112 // of this `delete`, lest we miss putting it back in the next time the property is in use.)
113 delete event.sdkProcessingMetadata;
114
115 const eventItem: EventItem = [{ type: eventType }, event];
116 return createEnvelope<EventEnvelope>(envelopeHeaders, [eventItem]);
117}
118
119/**
120 * Create envelope from Span item.

Callers 5

envelope.test.tsFile · 0.90
sendEventFunction · 0.90
sendAnrEventFunction · 0.90
sendBlockEventFunction · 0.90

Calls 4

createEnvelopeFunction · 0.90
_enhanceEventWithSdkInfoFunction · 0.85

Tested by

no test coverage detected