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

Function createSessionEnvelope

packages/core/src/envelope.ts:66–83  ·  view source on GitHub ↗
(
  session: Session | SessionAggregates,
  dsn?: DsnComponents,
  metadata?: SdkMetadata,
  tunnel?: string,
)

Source from the content-addressed store, hash-verified

64
65/** Creates an envelope from a Session */
66export function createSessionEnvelope(
67 session: Session | SessionAggregates,
68 dsn?: DsnComponents,
69 metadata?: SdkMetadata,
70 tunnel?: string,
71): SessionEnvelope {
72 const sdkInfo = getSdkMetadataForEnvelopeHeader(metadata);
73 const envelopeHeaders = {
74 sent_at: new Date(safeDateNow()).toISOString(),
75 ...(sdkInfo && { sdk: sdkInfo }),
76 ...(!!tunnel && dsn && { dsn: dsnToString(dsn) }),
77 };
78
79 const envelopeItem: SessionItem =
80 'aggregates' in session ? [{ type: 'sessions' }, session] : [{ type: 'session' }, session.toJSON()];
81
82 return createEnvelope<SessionEnvelope>(envelopeHeaders, [envelopeItem]);
83}
84
85/**
86 * Create an Envelope from an event.

Callers 4

sendSessionFunction · 0.90
sendAbnormalSessionFunction · 0.90
sendAbnormalSessionFunction · 0.90

Calls 5

safeDateNowFunction · 0.90
dsnToStringFunction · 0.90
createEnvelopeFunction · 0.90
toJSONMethod · 0.65

Tested by

no test coverage detected